public frmProduce() { InitializeComponent(); //Load Load += (sender, e) => { if (produce == null) { produce = new Produce(); } //load combobox LoadUnit(); LoadProduceGroup(); }; //Save button click ucActionResultButton.SaveButtonClick += (sender, e) => { if (dxValidationProvider.Validate()) { OnSaved(produce); } }; //Cancel button click ucActionResultButton.CancelButtonClick += (sender, e) => { this.Close(); }; //Unit add button click btnUnitAdd.Click += (sender, e) => { frmUnit frm = new frmUnit(); frm.OnSaved += t => { unitOfWork.UnitService.Create(t as Unit); unitOfWork.Save(); //reload combobox LoadUnit(); frm.Close(); }; frm.ShowDialog(); }; //Produce group add button click btnProduceGroupAdd.Click += (sender, e) => { frmProduceGroup frm = new frmProduceGroup(); frm.OnSaved += t => { unitOfWork.ProduceGroupService.Create(t as ProduceGroup); unitOfWork.Save(); //reload comboxbox LoadProduceGroup(); frm.Close(); }; frm.ShowDialog(); }; }
public frmProduceGroups() { InitializeComponent(); //Load Load += (sender, e) => { BindingGridView(); }; //Add button click ucActionButton.AddButtonClick += (sender, e) => { frmProduceGroup frm = new frmProduceGroup(); frm.OnSaved += t => { var produceGroup = (ProduceGroup)t; unitOfWork.ProduceGroupService.Create(produceGroup); unitOfWork.Save(); //reload gridview BindingGridView(); frm.Close(); }; frm.ShowDialog(); }; //Edit button click ucActionButton.EditButtonClick += (sender, e) => { frmProduceGroup frm = new frmProduceGroup(); //send data frm.produceGroup = unitOfWork.ProduceGroupService.Find(produceGroupId); frm.OnSaved += t => { var produceGroup = (ProduceGroup)t; unitOfWork.ProduceGroupService.Update(produceGroup); unitOfWork.Save(); //reload gridview BindingGridView(); frm.Close(); }; frm.ShowDialog(); }; //Delete button click ucActionButton.DeleteButtonClick += (sender, e) => { var messageBox = MessageBox.Show("Bạn chắc chắn muốn xóa nhóm sản phẩm này # : " + produceGroupId, "Thông báo", MessageBoxButtons.OKCancel); if (messageBox == DialogResult.OK) { unitOfWork.ProduceGroupService.Delete(produceGroupId); unitOfWork.Save(); //reload gridview BindingGridView(); } }; }