コード例 #1
0
 public frmStaffGroups()
 {
     InitializeComponent();
     //Load
     Load += (sender, e) =>
     {
         BindingGridView();
     };
     //Add button click
     ucActionButton.AddButtonClick += (sender, e) =>
     {
         frmStaffGroup frm = new frmStaffGroup();
         frm.OnSaved += t =>
         {
             var staffGroup = (StaffGroup)t;
             unitOfWork.StaffGroupService.Create(staffGroup);
             unitOfWork.Save();
             //reload gridview
             BindingGridView();
             frm.Close();
         };
         frm.ShowDialog();
     };
     //Edit button click
     ucActionButton.EditButtonClick += (sender, e) =>
     {
         frmStaffGroup frm = new frmStaffGroup();
         frm.staffGroup = unitOfWork.StaffGroupService.Find(staffGroupId);
         frm.OnSaved   += t =>
         {
             var staffGroup = (StaffGroup)t;
             unitOfWork.StaffGroupService.Update(staffGroup);
             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 nhân viên này # : " + staffGroupId, "Thông báo", MessageBoxButtons.OKCancel);
         if (messageBox == DialogResult.OK)
         {
             unitOfWork.StaffGroupService.Delete(staffGroupId);
             unitOfWork.Save();
             //reload gridview
             BindingGridView();
         }
     };
 }
コード例 #2
0
ファイル: frmStaff.cs プロジェクト: kent27791/SaleManager
 public frmStaff()
 {
     InitializeComponent();
     //Load
     Load += (sender, e) =>
     {
         if (staff == null)
         {
             staff = new Staff();
         }
         LoadStaffGroup();
     };
     //Save button click
     ucActionResultButton.SaveButtonClick += (sender, e) =>
     {
         if (dxValidationProvider.Validate())
         {
             OnSaved(staff);
         }
     };
     //Cancel button click
     ucActionResultButton.CancelButtonClick += (sender, e) =>
     {
         this.Close();
     };
     //Add staff group button click
     btnStaffGroupAdd.Click += (sender, e) =>
     {
         frmStaffGroup frm = new frmStaffGroup();
         frm.OnSaved += t =>
         {
             var staffGroup = (StaffGroup)t;
             unitOfWork.StaffGroupService.Create(staffGroup);
             unitOfWork.Save();
             //reload combobox
             LoadStaffGroup();
             frm.Close();
         };
         frm.ShowDialog();
     };
 }