private void button_2_Click(object sender, EventArgs e) { if (dgBillMx.CurrentRowIndex >= 0) { DBCgBill bill = (DBCgBill)cgBillBindingSource.Current; StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendFormat("是否删除【{0}】{1}", new string[] { bill.Barcode, bill.PluName }); if (MessageBox.Show(strBuilder.ToString(), "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { string msg; if (!CgBillDAL.DeleteBill(bill, out msg)) { MessageBox.Show("删除失败:" + msg); } else { cgBill.RemoveAt(cgBill.FindIndex(a => a.ID == bill.ID)); cgBillBindingSource.ResetBindings(true); } } } }
private void button_4_Click(object sender, EventArgs e) { cgPlu = null; this.DialogResult = DialogResult.OK; }
/// <summary> /// 删除明细 /// </summary> /// <param name="bill">明细</param> /// <param name="msg">返回的消息</param> /// <returns>是否成功</returns> public static bool DeleteBill(DBCgBill bill, out string msg) { int i; return(DBTool.Delete(bill, out i, out msg)); }
private void button_1_Click(object sender, EventArgs e) { decimal packCount = 0, SGLCount = 0; try { packCount = decimal.Parse(tbPackCount.Text); SGLCount = decimal.Parse(tbSglCount.Text); if (packCount + SGLCount == 0) { MessageBox.Show("请输入采购数量"); if (cbxPackSpec.Enabled) { tbPackCount.Focus(); tbPackCount.SelectAll(); } else { tbSglCount.Focus(); tbSglCount.SelectAll(); } return; } } catch { MessageBox.Show("数量输入非法"); if (cbxPackSpec.Enabled) { tbPackCount.Focus(); tbPackCount.SelectAll(); } else { tbSglCount.Focus(); tbSglCount.SelectAll(); } return; } ShowWait("正在保存...请稍候..."); DBCgBill cgBill = new DBCgBill(); cgBill.Barcode = PubGlobal.Cur_TRFQueryKc[0].BARCODE; cgBill.ID = Guid.NewGuid(); cgBill.Unit = PubGlobal.Cur_TRFQueryKc[0].UNIT; cgBill.PackCount = packCount; cgBill.LrUser = PubGlobal.User.USERNAME; cgBill.LrDate = DateTime.Now; cgBill.SerialNo = ++PubGlobal.CgSerialNo; if (cbxPackSpec.SelectedItem != null) { cgBill.PackQty = decimal.Parse(((Model.TransModel.TPacket)(cbxPackSpec.SelectedItem)).PACKQTY); cgBill.PackUnit = ((Model.TransModel.TPacket)(cbxPackSpec.SelectedItem)).PACKUNIT; } else { cgBill.PackQty = 0; cgBill.PackUnit = string.Empty; } cgBill.PluID = PubGlobal.Cur_TRFQueryKc[0].PLUID; cgBill.PluCode = PubGlobal.Cur_TRFQueryKc[0].PLUCODE; cgBill.PluName = PubGlobal.Cur_TRFQueryKc[0].PLUNAME; cgBill.SGLCount = SGLCount; cgBill.CgCount = cgBill.PackQty * cgBill.PackCount + cgBill.SGLCount; int i; string msg; if (!DAL.CgBillDAL.Insert(cgBill, out i, out msg)) { HideWait(); MessageBox.Show(msg); } else { HideWait(); PubGlobal.Cur_TRFQueryKc[0].Packets = null; PubGlobal.Cur_TRFQueryKc = null; this.DialogResult = DialogResult.OK; } }