Exemplo n.º 1
0
        private void but_StaffUpdate_Click(object sender, EventArgs e)
        {
            string Message = string.Empty;

            if (!isValidateUpdateStaff(out Message))
            {
                MessageBox.Show(Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                StaffUpdateModel        _staffUpdateInfo    = new StaffUpdateModel();
                List <StaffUpdateModel> _lstStaffUpdateInfo = new List <StaffUpdateModel>();
                for (int i = 0; i < gridView_StaffInfo.SelectedRowsCount; i++)
                {
                    int handle = Convert.ToInt32(gridView_StaffInfo.GetRowHandle(gridView_StaffInfo.GetSelectedRows()[i]));
                    _staffUpdateInfo.StaffCode = gridView_StaffInfo.GetRowCellValue(handle, "StaffCode") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffCode").ToString()) : 0;

                    _staffUpdateInfo.StaffName = gridView_StaffInfo.GetRowCellValue(handle, "StaffName") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffName").ToString() : "";

                    _staffUpdateInfo.StaffGender = gridView_StaffInfo.GetRowCellValue(handle, "StaffGender") != null?Convert.ToBoolean(gridView_StaffInfo.GetRowCellValue(handle, "StaffGender").ToString()) : false;

                    _staffUpdateInfo.StaffBirthday = gridView_StaffInfo.GetRowCellValue(handle, "StaffBirthday") != null?Convert.ToDateTime(gridView_StaffInfo.GetRowCellValue(handle, "StaffBirthday").ToString()) : DateTime.Now;

                    _staffUpdateInfo.StaffEmail = gridView_StaffInfo.GetRowCellValue(handle, "StaffEmail") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffEmail").ToString() : "";

                    _staffUpdateInfo.StaffPhoneNumber = gridView_StaffInfo.GetRowCellValue(handle, "StaffPhoneNumber") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffPhoneNumber").ToString() : "";

                    _staffUpdateInfo.StaffAddress = gridView_StaffInfo.GetRowCellValue(handle, "StaffAddress") != null?gridView_StaffInfo.GetRowCellValue(handle, "StaffAddress").ToString() : "";

                    _staffUpdateInfo.StaffJobtitle = gridView_StaffInfo.GetRowCellValue(handle, "StaffJobtitle") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffJobtitle").ToString()) : 0;

                    _staffUpdateInfo.StaffPaymentStore = gridView_StaffInfo.GetRowCellValue(handle, "StaffPaymentStore") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffPaymentStore").ToString()) : 0;

                    _staffUpdateInfo.StaffPermission = gridView_StaffInfo.GetRowCellValue(handle, "StaffPermission") != null?Convert.ToInt32(gridView_StaffInfo.GetRowCellValue(handle, "StaffPermission").ToString()) : 0;

                    _lstStaffUpdateInfo.Add(_staffUpdateInfo);
                }
                NhanVienBus _nhaVienBUS   = new NhanVienBus();
                string      updateMessage = string.Empty;
                if (!_nhaVienBUS.UpdateStaff(_lstStaffUpdateInfo, out updateMessage))
                {
                    MessageBox.Show(updateMessage, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(updateMessage, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Search();
                }
            }
        }