Ejemplo n.º 1
0
 public frmUnits()
 {
     InitializeComponent();
     //Load
     Load += (sender, e) =>
     {
         BindingGridView();
     };
     //Add button click
     ucActionButton.AddButtonClick += (sender, e) =>
     {
         frmUnit frm = new frmUnit();
         frm.OnSaved += t =>
         {
             var unit = (Unit)t;
             unitOfWork.UnitService.Create(unit);
             unitOfWork.Save();
             //reload gridview
             BindingGridView();
             frm.Close();
         };
         frm.ShowDialog();
     };
     //Edit button click
     ucActionButton.EditButtonClick += (sender, e) =>
     {
         frmUnit frm = new frmUnit();
         frm.unit     = unitOfWork.UnitService.Find(unitId);
         frm.OnSaved += t =>
         {
             var unit = (Unit)t;
             unitOfWork.UnitService.Update(unit);
             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 đơn vị tính này này # : " + unitId, "Thông báo", MessageBoxButtons.OKCancel);
         if (messageBox == DialogResult.OK)
         {
             unitOfWork.UnitService.Delete(unitId);
             unitOfWork.Save();
             //reload gridview
             BindingGridView();
         }
     };
     //Search
     ucActionButton.SearchTextChanged += (sender, e) =>
     {
         var term = ((TextEdit)sender).Text;
         gvUnit.ApplyFindFilter(term);
     };
 }
Ejemplo n.º 2
0
        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();
            };
        }