//新增信息 private void btnAdd_Click(object sender, EventArgs e) { try { //添加一行数据,对相应数据进行填充 DataRow newrow = dsM.Tables[0].NewRow(); newrow["InPut_Time"] = DateTime.Now; newrow["Check_Date"] = DateTime.Now; newrow["ShiftID"] = "2"; newrow["Operator"] = Adapter.Session.User; dsM.Tables[0].Rows.Add(newrow); bsM.MoveFirst();// while (((System.Data.DataRowView)(bsM.Current)).Row != newrow && bsM.Position != dsM.Tables[0].Rows.Count - 1) { bsM.MoveNext(); } LanceMakeMagShowFrm MakeFrm = new LanceMakeMagShowFrm(); MakeFrm.ShowDialogEx(Adapter.Session, bsM.Position, strSortM, ref dsM); //dsM.Tables[0].Rows[bsM.Position]["makeid"] = MakeFrm.makeid; //dsM.AcceptChanges(); //GC.Collect(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//修改信息 private void dvM_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex >= 0 && dsM.Tables[0].Rows.Count > 0) { bsM.Position = e.RowIndex; LanceMakeMagShowFrm MakeFrm = new LanceMakeMagShowFrm(); MakeFrm.ShowDialogEx(Adapter.Session, bsM.Position, strSortM, ref dsM); GC.Collect(); } }