private void EditForm(string formText, string btnCommand) { SUPP_M001_PurPlan temp = this.sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; PurPlanEditForm edit = new PurPlanEditForm(temp); edit.Text = formText; edit.Tag = btnCommand; if (edit.ShowDialog() != DialogResult.OK) { sUPPM001PurPlanBindingSource.CancelEdit(); } }
public override void OnBtnCommand(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // MessageBox.Show(e.Item.Caption); //新增 if (e.Item.Caption == BtnCommandEnum.Add) { sUPPM001PurPlanBindingSource.AddNew(); SUPP_M001_PurPlan temp = this.sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; temp.TxDt = DateTime.Now.Date; EditForm("采购计划新增", BtnCommandEnum.Add); } else if (e.Item.Caption == BtnCommandEnum.Edit) { SUPP_M001_PurPlan temp = sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; if (temp == null) { throw new AppException("请先选择要修改的数据"); } EditForm("采购计划修改", BtnCommandEnum.Edit); } else if (e.Item.Caption == BtnCommandEnum.Delete) { if (ERPHelper.Instance.MessageDel()) { SUPP_M001_PurPlan temp = sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; purPlanService.DelPurAndDetail(temp.Id); sUPPM001PurPlanBindingSource.RemoveCurrent(); gridView1_FocusedRowChanged(null, null); } } else if (e.Item.Caption == BtnCommandEnum.Watch) { SUPP_M001_PurPlan temp = sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; if (temp == null) { throw new AppException("请先选择要查看的数据"); } EditForm("采购计划查看", BtnCommandEnum.Watch); } else if (e.Item.Caption == BtnCommandEnum.Refresh) { InitData(); } else if (e.Item.Caption == BtnCommandEnum.SuppSet) { SUPP_M001_PurPlan temp = this.sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; PurPlanEditForm frm = new PurPlanEditForm(temp); frm.Text = "采购安排"; frm.Tag = BtnCommandEnum.Add; if (frm.ShowDialog() == DialogResult.OK) { InitData(); } } else if (e.Item.Caption == "审核") { SUPP_M001_PurPlan temp = sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; if (temp == null) { throw new AppException("请先选择要审核的数据"); } if (ERPHelper.Instance.MessageIf("确定审核通过吗")) { temp.Status = "已审核"; purPlanService.Update(temp); } } else if (e.Item.Caption == "取消审核") { SUPP_M001_PurPlan temp = sUPPM001PurPlanBindingSource.Current as SUPP_M001_PurPlan; if (temp == null) { throw new AppException("请先选择要审核的数据"); } if (ERPHelper.Instance.MessageIf("确定审核通过吗")) { temp.Status = ""; purPlanService.Update(temp); } } }