public UpdateBatForm(batchInfo model) { InitializeComponent(); this.batModel = model; siloNoCB.DataSource = SelectListModel.SiloNumList().Keys.ToList(); gradeCB.DataSource = SelectListModel.GradeList(); }
private void matSaveBTN_Click(object sender, EventArgs e) { if (batModel == null) { MessageBox.Show("界面数据获取异常,请重新打开编辑界面!"); this.Close(); return; } #region 更新对象组装 batModel.workLine = workLineCB.Text.Trim(); batModel.characteristics = txt_characteristics.Text.Trim(); batModel.siloNo = siloNoCB.Text.Trim(); batModel.grade = gradeCB.Text.Trim().ToUpper(); batModel.productDate = dtp_productDate.Value; batModel.ntbWeight = Convert.ToDecimal(nbtWeightCB.SelectedValue); batModel.modifyDate = DateTime.Now; batModel.modifyUser = UserBLL.userInfo.UserID; #endregion BatchInfoBLL batbll = new BatchInfoBLL(); var rv = batbll.UpdateBatInfo(batModel); MessageBox.Show(rv.Msg); this.DialogResult = DialogResult.OK; this.batModel = null; this.Close(); }
private void BatSaveBtn_Click(object sender, EventArgs e) { DateTime now = DateTime.Now; string user = UserBLL.userInfo.UserName; #region 组装批次信息 batchInfo bat = new batchInfo(); if (this.AddBatNoTabControl.SelectedTab.Text.Equals("新建批次")) { bat.batchNo = txt_batchNo.Text.Trim(); bat.material = materialTB.Text.Trim(); bat.workLine = workLineCB.Text.Trim(); bat.characteristics = txt_characteristics.Text.Trim(); bat.productDate = dtp_productDate.Value; bat.siloNo = txt_siloNo.Text.Trim(); bat.ntbWeight = nbtWeightCB.SelectedValue != null?Convert.ToDecimal(nbtWeightCB.SelectedValue) : 0; bat.grade = gradeCB.Text.Trim(); } else { bat.batchNo = txt_bNo.Text.Trim(); bat.material = matTb.Text.Trim(); bat.workLine = wkLineCB.Text.Trim(); bat.characteristics = txt_characteristicsByChange.Text.Trim(); bat.productDate = dtp_pdDate.Value; bat.siloNo = txt_siloNum.Text.Trim(); bat.ntbWeight = txt_nbt.SelectedValue != null?Convert.ToDecimal(txt_nbt.SelectedValue) : 0; bat.grade = txt_grade.Text.Trim(); } bat.createDate = now; bat.createUser = user; bat.modifyDate = now; bat.modifyUser = user; #endregion string Msg = string.Empty; if (!SaveValidate(this.AddBatNoTabControl.SelectedTab.Text, ref Msg)) { MessageBox.Show(Msg); return; } var result = batbll.AddBatInfo(bat); MessageBox.Show(result.Msg); if (this.AddBatNoTabControl.SelectedTab.Text.Equals("新建批次")) { string cno = (Convert.ToInt32(txt_batchNo.Text.Substring(txt_batchNo.Text.Length - 1)) + 1).ToString(); txt_batchNo.Text = txt_batchNo.Text.Substring(0, txt_batchNo.Text.Length - 1) + cno; } else { string cno = (Convert.ToInt32(txt_bNo.Text.Substring(txt_bNo.Text.Length - 1)) + 1).ToString(); txt_bNo.Text = txt_bNo.Text.Substring(0, txt_bNo.Text.Length - 1) + cno; } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void batch_del_Click(object sender, EventArgs e) { if (batchInfoDG.SelectedRows.Count <= 0) { MessageBox.Show("至少选中一行数据"); return; } if (MessageBox.Show("确认删除" + batchInfoDG.SelectedRows.Count + "条物料记录?", "此删除不可恢复", MessageBoxButtons.YesNo) == DialogResult.Yes) { List <string> list = new List <string>(); foreach (DataGridViewRow item in batchInfoDG.SelectedRows) { batchInfo batModel = (batchInfo)item.DataBoundItem; list.Add(batModel.batchNo); } var rv = batInfobll.DelBatInfo(list.ToArray()); MessageBox.Show(rv.Msg); } Search(sender); }