如何从列表框更新数据集

时间:2018-04-12 11:42:01

标签: c# sql dataset

我正在努力为我的工作场所制作一个简单的资产管理系统。

我希望用户能够自行检查多个资产。

为此,他们会将所需资产的SM编号键入文本框,单击按钮,然后将数字传输到列表框。

然后当他们添加了所需的所有SM编号时,他们可以通过单击另一个按钮来检查它们。

如何搜索和更新数据集以执行此操作。 这是我到目前为止所做的,但我仍然坚持查询。

我想搜索SM号码,如果某行的SM column包含SM号码,我想将CheckedOut列更新为{ {1}}和trueCheckedOutTo

enter image description here

logged in user

我不知道如何更新它,或者我正在做的事情是否有效。

1 个答案:

答案 0 :(得分:0)

自己想一想:

 //Check checkin/out state and set to opiset
            if (dataGridView1.Rows[numberRow].Cells[5].Value.Equals(true))
            {
                dataGridView1.Rows[numberRow].Cells[5].Value = false;
                newHistoryRow["Action"] = "Checkout";
                sIMSDataSet.Tables["History"].Rows.Add(newHistoryRow);
                historyTableAdapter.Update(sIMSDataSet);
            }
            else
            {
                dataGridView1.Rows[numberRow].Cells[5].Value = true;
                newHistoryRow["Action"] = "Checkin";
                sIMSDataSet.Tables["History"].Rows.Add(newHistoryRow);
                historyTableAdapter.Update(sIMSDataSet);
            }
            //check if username cell is empty, if is empty add username if is full remove username
            if (String.IsNullOrEmpty(dataGridView1.Rows[numberRow].Cells[4].Value as string))
            {
                dataGridView1.Rows[numberRow].Cells[4].Value = username;
            }
            else
            {
                dataGridView1.Rows[numberRow].Cells[4].Value = "";
            }
相关问题