private void dgrdGioKDQD_SelectionChanged(object sender, EventArgs e) { // mỗi lần chọn 1 row thì load dữ liệu vào các group thêm xóa sửa if (dgrdGioKDQD.SelectedRows.Count == 0) // trường hợp này xảy ra sau khi gán dataSource tức load lần đầu hay reload //reset từng group { chkGioVao.Checked = false; chkGioRaa.Checked = false; MyUtility.ClearControlText(tbCa_Them, tbGioCu_Suaa, tbCa_Suaa, tbGioCu_Xoaa, tbGioCuu_ChuyenDoi); tbCa_Them.Tag = null; tbCa_Suaa.Tag = null; //không row nào được chọn thì disable button, ko cho thực hiện thao tác MyUtility.EnableDisableControl(false, btnThem, btnXoaa, btnSuaa, btnChuyenDoi, btnChonCa_Them, btnChonCa_Suaa); return; } //chuyển từ dataGridViewRow sang DataRowView sang DataRow var row = (DataRowView)(dgrdGioKDQD.SelectedRows[0]).DataBoundItem; var CIO = (row["cCheckInOut"] != DBNull.Value) ? (cCheckInOut)row["cCheckInOut"] : null; //2. lấy dữ liệu và load group var ngayCong = (row["cNgayCong"] != DBNull.Value) ? (cNgayCong)row["cNgayCong"] : null; var chk = (row["cCheck"] != DBNull.Value) ? (cCheck)row["cCheck"] : null; LoadGroup_Them(ngayCong.Ngay, CIO); LoadGroup_Suaa(ngayCong, CIO, chk); LoadGroup_Xoaa(chk); }
private void dgrdDSThuChiThangTungNV_SelectionChanged(object sender, EventArgs e) { if (dgrdDSThuChiThangTungNV.SelectedRows.Count == 0) { return; } DataRowView selectedRow = (DataRowView)(dgrdDSThuChiThangTungNV.SelectedRows[0]).DataBoundItem; if (selectedRow == null) { return; } dgrdDSNV.ClearSelection(); // chọn thu chi --> tức muốn cập nhật xóa --> enable cập nhật xóa; disable thêm MyUtility.EnableDisableControl(true, btnCapNhat, btnXoa); MyUtility.EnableDisableControl(false, btnThem); tbTenNV.Text = selectedRow["UserFullName"].ToString(); tbMaNV.Text = selectedRow["UserFullCode"].ToString(); lbUserEnrollNumber.Tag = selectedRow["UserEnrollNumber"]; lbUserEnrollNumber.Text = ((int)selectedRow["UserEnrollNumber"]).ToString(); numTamUng.Value = Convert.ToDecimal(selectedRow["TamUng"]); numLuongdieuchinh.Value = Convert.ToDecimal(selectedRow["LuongDieuChinh"]); numThuchiKhac.Value = Convert.ToDecimal(selectedRow["ThuChiKhac"]); tbMucDongBHXH.Text = ((float)selectedRow["MucDongBHXH"]).ToString("00.00"); }
private void LoadGroup_Them(DateTime ngay, cCheckInOut CIO) { MyUtility.EnableDisableControl(true, btnChonCa_Them, btnThem); //vì thêm giờ ko cần xác định giờ cũ, chỉ insert data nên mặc định cho phép enable MyUtility.ClearControlText(tbCa_Them, tbGhichu_Them); tbCa_Them.Tag = (CIO == null || CIO.HaveINOUT < 0) ? null : CIO.ThuocCa; tbCa_Them.Text = (CIO == null || CIO.HaveINOUT < 0) ? string.Empty : CIO.ThuocCa.Code; chkGioVao.Checked = (CIO != null && CIO.HaveINOUT == -2); chkGioRaa.Checked = (CIO != null && CIO.HaveINOUT == -1); dtpVao_Them.Value = new DateTime(ngay.Year, ngay.Month, ngay.Day, 0, 0, 1); dtpRaa_Them.Value = new DateTime(ngay.Year, ngay.Month, ngay.Day, 0, 0, 1); cbLyDo_Them.SelectedIndex = 0; }
private void LoadGroup_Xoaa(cCheck check) { if (check == null) // check null thì reset group { MyUtility.ClearControlText(tbGioCuu_ChuyenDoi, tbGioCu_Xoaa, tbGhiChu_Xoaa); cbLyDo_Xoaa.SelectedIndex = 0; MyUtility.EnableDisableControl(false, btnChuyenDoi, btnXoaa); } else // check ko null { tbGioCu_Xoaa.Text = tbGioCuu_ChuyenDoi.Text = ((check.MachineNo % 2 == 1) ? "Vào" : "Ra") + " " + check.Time.ToString("H:mm ddd d/M", Application.CurrentCulture); cbLyDo_Xoaa.SelectedIndex = 0; tbGhiChu_Xoaa.Text = string.Empty; MyUtility.EnableDisableControl(true, btnChuyenDoi, btnXoaa); } }
private void LoadGroup_Suaa(cNgayCong ngayCong, cCheckInOut cio, cCheck check) { if (check == null) { MyUtility.ClearControlText(tbGioCu_Suaa, tbCa_Suaa, tbGhiChu_Suaa); tbCa_Suaa.Tag = null; MyUtility.EnableDisableControl(false, btnChonCa_Suaa, btnSuaa); // ko tồn tại giờ cũ nên ko cho sửa, chuyển đổi cbLyDo_Suaa.SelectedIndex = 0; } else { // xem xét check là CIO_V hay CIO_A, CIO_A cho sửa, CIO_V ko cho sửa, trong CIO_A coi có phải là check đệm giữa ca ko tbGioCu_Suaa.Text = ((check.MachineNo % 2 == 1) ? "Vào" : "Ra") + " " + check.Time.ToString("H:mm ddd d/M"); dtpGioMoi_Sua.Value = new DateTime(check.Time.Year, check.Time.Month, check.Time.Day, check.Time.Hour, check.Time.Minute, check.Time.Second); tbCa_Suaa.Tag = (cio == null || cio.HaveINOUT < 0) ? null : cio.ThuocCa; tbCa_Suaa.Text = (cio == null || cio.HaveINOUT < 0) ? string.Empty : cio.ThuocCa.Code; cbLyDo_Suaa.SelectedIndex = 0; tbGhiChu_Suaa.Text = string.Empty; //tồn tại giờ cũ nên cho phép sửa MyUtility.EnableDisableControl(true, btnChonCa_Suaa, btnSuaa); } }
private void radQuarter_CheckedChanged(object sender, EventArgs e) { MyUtility.EnableDisableControl(radQuarter.Checked, dtpQuyNam, numQuy); MyUtility.EnableDisableControl(!radQuarter.Checked, dtpNgayBD, dtpNgayKT, dtpThang); }
private void dgrdTongHop_SelectionChanged(object sender, EventArgs e) { MyUtility.EnableDisableControl((dgrdDSGioVaoRa.SelectedRows.Count != 0), new Control[] { btnThem, btnSuaa, btnXoaGioVao, btnXoaGioRaa }); }
private void frmThemNV_Load(object sender, EventArgs e) { dtpNgayVaoLam.Value = DateTime.Today; #region load chức vụ cbChucVu.DataSource = DAO5.LoadDataSourceChucVu(true); cbChucVu.ValueMember = "IDChucVu"; cbChucVu.DisplayMember = "ChucVu"; #endregion #region load phòng ban cbPhongBan.DataSource = DAO5.LoadDataSourcePhongBan(true); cbPhongBan.ValueMember = "ID"; cbPhongBan.DisplayMember = "Description"; #endregion #region load lịch trình làm việc var tableLichTrinh = SqlDataAccessHelper.ExecuteQueryString("select * from Schedule"); cbLichTrinh.DataSource = tableLichTrinh; cbLichTrinh.ValueMember = "SchID"; cbLichTrinh.DisplayMember = "SchName"; #endregion if (mode == 1) // chế độ thêm mới, cho phép thực hiện phần công nhật { MyUtility.EnableDisableControl(true, tbMaCC, checkLamCongnhat, checkNVChinhThuc, dtpNgayBDCongnhat, dtpNgayKTCongnhat); } else if (mode == 0) // chế độ cập nhật ko cho phép thực hiện phần công nhật { MyUtility.EnableDisableControl(false, tbMaCC, checkLamCongnhat, checkNVChinhThuc, dtpNgayBDCongnhat, dtpNgayKTCongnhat); tbMaNV.Text = RowView["UserFullCode"].ToString(); tbHoTenNV.Text = RowView["UserFullName"].ToString(); radNam.Checked = (RowView["UserSex"].ToString().ToLower() == "nam"); radNuu.Checked = !radNam.Checked; tbMaCC.Text = ((int)RowView["UserEnrollNumber"]).ToString("0000"); tbUserEnrollName.Text = RowView["UserEnrollName"].ToString(); tbMaTheTu.Text = (RowView["UserCardNo"] != DBNull.Value) ? RowView["UserCardNo"].ToString() : "0000000000"; dtpNgayVaoLam.Value = (RowView["UserHireDay"] != DBNull.Value) ? (DateTime)RowView["UserHireDay"] : DateTime.MinValue; if (RowView["IDChucVu"] == DBNull.Value || (int)RowView["IDChucVu"] == 0) { cbChucVu.SelectedIndex = 0; } else { cbChucVu.SelectedValue = (int)RowView["IDChucVu"]; } if (RowView["MaPhong"] == DBNull.Value || (int)RowView["MaPhong"] == 0) { cbPhongBan.SelectedIndex = 0; } else { cbPhongBan.SelectedValue = (int)RowView["MaPhong"]; } if (RowView["SchID"] == DBNull.Value || (int)RowView["SchID"] == 0) { cbLichTrinh.SelectedIndex = 0; } else { cbLichTrinh.SelectedValue = (int)RowView["SchID"]; } tbHSLCB.Text = (RowView["HeSoLuongCB"] != DBNull.Value) ? ((float)RowView["HeSoLuongCB"]).ToString("0.00") : "000"; tbHSLCV.Text = (RowView["HeSoLuongSP"] != DBNull.Value) ? ((float)RowView["HeSoLuongSP"]).ToString("0.00") : "000"; tbHSBHXHCongThem.Text = (RowView["HSBHCongThem"] != DBNull.Value) ? ((float)RowView["HSBHCongThem"]).ToString("0.00") : "000"; checkUserEnabled.Checked = (RowView["UserEnabled"] != DBNull.Value && (bool)RowView["UserEnabled"]); } }
private void dgrdGioCoLamThem_SelectionChanged(object sender, EventArgs e) { if (dgrdGioCoLamThem.SelectedRows.Count == 0) { #region reset layout MyUtility.ClearControlText(tbTTTenNV, tbTTGioVao, tbTTGioRaa, tbTTThuocCa, tbTTGioLam, tbTTTongGio, tbTTTreSom, tbTTOLaiThem, tbTTLamThem, tbXNCa, tbXNGioLam, tbXNTre, tbXNSom, tbXN_OLaiThem); MyUtility.CheckedCheckBox(false, checkTTChoPhepTre, checkTTChoPhepSom, checkTTTinhPC50, checkXNChoPhepTre, checkXNChoPhepSom, checkXNLamThem, checkXNTinhPC50, checkTTVaoTreTinhCV, checkTTRaaSomTinhCV, checkXNVaoTreTinhCV, checkXNRaaSomTinhCV);//ver 4.0.0.4 //numPhutTinhLamThem.Value = 0; maskPhutTinhLamThem.Text = "00:00"; //ver 4.0.0.4 maskPhutTinhLamThem.Tag = TimeSpan.Zero; //ver 4.0.0.4 #endregion MyUtility.EnableDisableControl(false, btnXacNhan, btnDoiCa, // ngoài reset layout thì disable nút xác nhận, nút sửa để tránh ấn nhầm gây lỗi checkXNChoPhepTre, checkXNChoPhepSom, checkXNLamThem, checkXNTinhPC50, numPhutTinhLamThem, maskPhutTinhLamThem, checkXNVaoTreTinhCV, checkXNRaaSomTinhCV); //ver 4.0.0.4 } else if (dgrdGioCoLamThem.SelectedRows.Count == 1) { MyUtility.EnableDisableControl(true, btnXacNhan, btnDoiCa, checkXNChoPhepTre, checkXNChoPhepSom, checkXNTinhPC50, checkXNLamThem, numPhutTinhLamThem, maskPhutTinhLamThem, checkXNVaoTreTinhCV, checkXNRaaSomTinhCV); //ver 4.0.0.4 var dataRowView = dgrdGioCoLamThem.SelectedRows[0].DataBoundItem as DataRowView; var nhanvien = dataRowView["cUserInfo"] as cUserInfo; var CIO = dataRowView["cCheckInOut"] as cCheckInOut; var ngaycong = dataRowView["cNgayCong"] as cNgayCong; #region fill phần thông tin CIO //DateTime ngaydangchon = CIO.ThuocNgayCong; tbTTTenNV.Text = nhanvien.TenNV; tbTTGioVao.Text = (CIO.Vao != null) ? CIO.Vao.Time.ToString("H:mm d/M") : string.Empty; tbTTGioRaa.Text = (CIO.Raa != null) ? CIO.Raa.Time.ToString("H:mm d/M") : string.Empty; tbTTThuocCa.Text = CIO.CIOCodeFull(); tbTTGioLam.Text = (CIO.HaveINOUT == 0) ? CIO.TG.GioLamViec5.ToString(@"h\gmm\p") : string.Empty; tbTTTongGio.Text = (CIO.HaveINOUT == 0) ? CIO.TG.GioThucTe5.ToString(@"h\gmm\p") : string.Empty; tbTTTreSom.Text = (CIO.HaveINOUT == 0) ? (CIO.TG.VaoTre + CIO.TG.RaaSom).ToString(@"h\gmm\p") : string.Empty; tbTTOLaiThem.Text = (CIO.HaveINOUT == 0) ? CIO.TG.OLai.ToString(@"h\gmm\p") : string.Empty; tbTTLamThem.Text = (CIO.DaXN) ? CIO.TG.SoPhutLamThem5.ToString(@"h\gmm\p") : string.Empty; checkTTChoPhepTre.Checked = CIO.DuyetChoPhepVaoTre; checkTTChoPhepSom.Checked = CIO.DuyetChoPhepRaSom; checkTTTinhPC50.Checked = ngaycong.TinhPC50; checkTTVaoTreTinhCV.Checked = CIO.VaoTreTinhCV; //ver 4.0.0.4 checkTTRaaSomTinhCV.Checked = CIO.RaaSomTinhCV; //ver 4.0.0.4 #endregion #region fill phần xác nhận CIO tbXNCa.Text = CIO.CIOCodeFull(); tbXNCa.Tag = (CIO.HaveINOUT == 0) ? CIO.ThuocCa : null; tbXNGioLam.Text = (CIO.HaveINOUT == 0) ? CIO.TG.GioLamViec5.ToString(@"h\gmm\p") : string.Empty; tbXNTre.Text = (CIO.HaveINOUT == 0) ? CIO.TG.VaoTre.ToString(@"h\gmm\p") : string.Empty; tbXNSom.Text = (CIO.HaveINOUT == 0) ? CIO.TG.RaaSom.ToString(@"h\gmm\p") : string.Empty; tbXN_OLaiThem.Text = (CIO.HaveINOUT == 0) ? CIO.TG.OLai.ToString(@"h\gmm\p") : string.Empty; //numPhutTinhLamThem.Maximum = (CIO.HaveINOUT == 0) ? Convert.ToInt32(CIO.TG.OLai.TotalMinutes) : 0; //numPhutTinhLamThem.Value = (CIO.HaveINOUT == 0) ? (Convert.ToInt32(CIO.TG.OLai.TotalMinutes) / 10) * 10 : 0; maskPhutTinhLamThem.Tag = (CIO.TG.OLai == null) ? TimeSpan.Zero : CIO.TG.OLai; //ver 4.0.0.4 maskPhutTinhLamThem.Text = (CIO.TG.OLai == null) ? "00:00" : CIO.TG.OLai.ToString(@"hh\:mm"); //ver 4.0.0.4 checkXNChoPhepTre.Checked = CIO.DuyetChoPhepVaoTre; checkXNChoPhepSom.Checked = CIO.DuyetChoPhepRaSom; checkXNLamThem.Checked = false; checkXNTinhPC50.Checked = false; checkXNVaoTreTinhCV.Checked = CIO.VaoTreTinhCV; //ver 4.0.0.4 checkXNRaaSomTinhCV.Checked = CIO.RaaSomTinhCV; //ver 4.0.0.4 tbXNGhiChu.Text = string.Empty; #endregion } else // chế độ xác nhận hàng loạt { MyUtility.EnableDisableControl(true, btnXacNhan, btnDoiCa, checkXNChoPhepTre, checkXNChoPhepSom, checkXNTinhPC50, checkXNLamThem, numPhutTinhLamThem, maskPhutTinhLamThem, checkXNVaoTreTinhCV, checkXNRaaSomTinhCV); //ver 4.0.0.4 var dataRowView = dgrdGioCoLamThem.SelectedRows[0].DataBoundItem as DataRowView; var nhanvien = dataRowView["cUserInfo"] as cUserInfo; var CIO = dataRowView["cCheckInOut"] as cCheckInOut; var ngaycong = dataRowView["cNgayCong"] as cNgayCong; #region fill thông tin CIO tbTTTenNV.Text = nhanvien.TenNV; tbTTGioVao.Text = (CIO.Vao != null) ? CIO.Vao.Time.ToString("H:mm d/M") : string.Empty; tbTTGioRaa.Text = (CIO.Raa != null) ? CIO.Raa.Time.ToString("H:mm d/M") : string.Empty; tbTTThuocCa.Text = CIO.CIOCodeFull(); tbTTGioLam.Text = (CIO.HaveINOUT == 0) ? CIO.TG.GioLamViec5.ToString(@"h\gmm\p") : string.Empty; tbTTTongGio.Text = (CIO.HaveINOUT == 0) ? CIO.TG.GioThucTe5.ToString(@"h\gmm\p") : string.Empty; tbTTTreSom.Text = (CIO.HaveINOUT == 0) ? (CIO.TG.VaoTre + CIO.TG.RaaSom).ToString(@"h\gmm\p") : string.Empty; tbTTOLaiThem.Text = (CIO.HaveINOUT == 0) ? CIO.TG.OLai.ToString(@"h\gmm\p") : string.Empty; tbTTLamThem.Text = (CIO.DaXN) ? CIO.TG.SoPhutLamThem5.ToString(@"h\gmm\p") : string.Empty; checkTTChoPhepTre.Checked = CIO.DuyetChoPhepVaoTre; checkTTChoPhepSom.Checked = CIO.DuyetChoPhepRaSom; checkTTTinhPC50.Checked = ngaycong.TinhPC50; checkTTVaoTreTinhCV.Checked = CIO.VaoTreTinhCV; //ver 4.0.0.4 checkTTRaaSomTinhCV.Checked = CIO.RaaSomTinhCV; //ver 4.0.0.4 #endregion #region fill phần xác nhận CIO var listCIO = (from DataGridViewRow dataGridViewRow in dgrdGioCoLamThem.SelectedRows let row = (DataRowView)dataGridViewRow.DataBoundItem select(cCheckInOut) row["cCheckInOut"]).ToList(); var distinctShift = (from cio in listCIO where cio.HaveINOUT == 0 select cio.ThuocCa).Distinct().ToList(); var distinctList_KR = listCIO.Where(item => item.HaveINOUT == -1).ToList(); var distinctList_KV = listCIO.Where(item => item.HaveINOUT == -2).ToList(); // phần ca làm việc if (distinctShift.Count == 1) { tbXNCa.Tag = distinctShift[0]; tbXNCa.Text = distinctShift[0].Code; } else { tbXNCa.Tag = null; tbXNCa.Text = string.Empty; } // phần giờ làm, ra trễ, về sớm, ở lại cần xn MyUtility.ClearControlText(tbXNGioLam, tbXNTre, tbXNSom, tbXN_OLaiThem); //numPhutTinhLamThem.Value = 0; //numPhutTinhLamThem.Maximum = 840; maskPhutTinhLamThem.Text = "00:00"; //ver 4.0.0.4 maskPhutTinhLamThem.Tag = XL2._16gio; //ver 4.0.0.4 MyUtility.CheckedCheckBox(false, checkXNChoPhepTre, checkXNChoPhepSom, checkXNLamThem, checkXNTinhPC50, checkXNVaoTreTinhCV, checkXNRaaSomTinhCV);//ver 4.0.0.4 tbXNGhiChu.Text = string.Empty; #endregion } }