private void btnTaoBangChamCong_Click(object sender, EventArgs e) { _Thang = Convert.ToInt32(cboThang.SelectedIndex) + 1; _Nam = Convert.ToInt32(nudNam.Value); frmPhongBan frm_PhongBan = new frmPhongBan(this); frm_PhongBan.ShowDialog(); clsChamCong_BUS BUS = new clsChamCong_BUS(); dgvChamCong.DataSource = BUS.LayTenBangChamCong(); }
private void ucChamCong_Load(object sender, EventArgs e) { this.Dock = DockStyle.Fill; dgvChamCong.AutoGenerateColumns = false; clsChamCong_BUS BUSCC = new clsChamCong_BUS(); dgvChamCong.DataSource = BUSCC.LayBangChamCong(); clsPhongBan_BUS BUSPB = new clsPhongBan_BUS(); lsPB = BUSPB.LayDanhSachPhongBan(); }
private void ucTienLuong_Load(object sender, EventArgs e) { this.Dock = DockStyle.Fill; dgvChamCong.AutoGenerateColumns = false; cboThang.SelectedIndex = 0; nudNam.Minimum = 1; nudNam.Maximum = 9999; nudNam.Value = DateTime.Now.Year; clsChamCong_BUS BUS = new clsChamCong_BUS(); dgvChamCong.DataSource = BUS.LayTenBangChamCong(); }
private void btnDongY_Click(object sender, EventArgs e) { clsChamCong_BUS BUSCC = new clsChamCong_BUS(); clsNhanVien_BUS BUSNV = new clsNhanVien_BUS(); clsChiTietChamCong_BUS BUSCTCC = new clsChiTietChamCong_BUS(); clsChamCong_DTO ChamCong = new clsChamCong_DTO(); List <clsNhanVien_DTO> lsNhanVien = new List <clsNhanVien_DTO>(); DataGridViewRow r = dgvPhongBan.CurrentRow; ChamCong.MaCC = "CC" + (BUSCC.LaySoLuong() + 1).ToString(); ChamCong.Thang = ucTL.Thang; ChamCong.Nam = ucTL.Nam; ChamCong.Phong = r.Cells[0].Value.ToString(); //Thêm dữ liệu vào CHAMCONG if (BUSCC.KiemTraPhongChamCong(ChamCong.Thang, ChamCong.Nam, ChamCong.Phong) == false) { BUSCC.ThemBangChamCong(ChamCong); DataGridView dgvChamCong = ucTL.Controls.Find("dgvChamCong", true).FirstOrDefault() as DataGridView; dgvChamCong.DataSource = BUSCC.LayBangChamCong(); // Lấy phòng ban vừa được chọn để chấm công clsPhongBan_DTO PB = new clsPhongBan_DTO(); PB.MAPB = ChamCong.Phong; List <clsPhongBan_DTO> lsPB = new List <clsPhongBan_DTO>(); lsPB.Add(PB); //Lấy danh sách nhân viên theo phòng ban lsNhanVien = BUSNV.LayDanhSachNhanVienCC(lsPB); for (int i = 0; i < lsNhanVien.Count; i++) { clsChiTietChamCong_DTO ChiTietCC = new clsChiTietChamCong_DTO(); ChiTietCC.MaCC = ChamCong.MaCC; ChiTietCC.MaNV = lsNhanVien[i].MaNV; BUSCTCC.ThemChiTietChamCong(ChiTietCC); this.Close(); } clsNhatKy_BUS BUSNK = new clsNhatKy_BUS(); BUSNK.ThemNhatKy(Program.NhanVien_Login.TaiKhoan, DateTime.Now, string.Format("{0} đã tạo bảng chấm công {1}", Program.NhanVien_Login.TaiKhoan, ChamCong.MaCC)); } else { MessageBox.Show(string.Format("Đã chấm công cho phòng {0} tháng {1} năm {2}", r.Cells[1].Value.ToString(), ChamCong.Thang, ChamCong.Nam)); } }
private void btnLuu_Click(object sender, EventArgs e) { List <clsChamCong_DTO> lsChamCong = new List <clsChamCong_DTO>(); for (int i = 0; i < dgvBangChamCong.Rows.Count; i++) { clsChamCong_DTO ChamCong = new clsChamCong_DTO(); ChamCong.MaNV = dgvBangChamCong.Rows[i].Cells["colMaNV"].Value.ToString(); ChamCong.Thang = ucTL.Thang; ChamCong.Nam = ucTL.Nam; ChamCong.D1 = dgvBangChamCong.Rows[i].Cells["col1"].Value.ToString(); ChamCong.D2 = dgvBangChamCong.Rows[i].Cells["col2"].Value.ToString(); ChamCong.D3 = dgvBangChamCong.Rows[i].Cells["col3"].Value.ToString(); ChamCong.D4 = dgvBangChamCong.Rows[i].Cells["col4"].Value.ToString(); ChamCong.D5 = dgvBangChamCong.Rows[i].Cells["col5"].Value.ToString(); ChamCong.D6 = dgvBangChamCong.Rows[i].Cells["col6"].Value.ToString(); ChamCong.D7 = dgvBangChamCong.Rows[i].Cells["col7"].Value.ToString(); ChamCong.D8 = dgvBangChamCong.Rows[i].Cells["col8"].Value.ToString(); ChamCong.D9 = dgvBangChamCong.Rows[i].Cells["col9"].Value.ToString(); ChamCong.D10 = dgvBangChamCong.Rows[i].Cells["col10"].Value.ToString(); ChamCong.D11 = dgvBangChamCong.Rows[i].Cells["col11"].Value.ToString(); ChamCong.D12 = dgvBangChamCong.Rows[i].Cells["col12"].Value.ToString(); ChamCong.D13 = dgvBangChamCong.Rows[i].Cells["col13"].Value.ToString(); ChamCong.D14 = dgvBangChamCong.Rows[i].Cells["col14"].Value.ToString(); ChamCong.D15 = dgvBangChamCong.Rows[i].Cells["col15"].Value.ToString(); ChamCong.D16 = dgvBangChamCong.Rows[i].Cells["col16"].Value.ToString(); ChamCong.D17 = dgvBangChamCong.Rows[i].Cells["col17"].Value.ToString(); ChamCong.D18 = dgvBangChamCong.Rows[i].Cells["col18"].Value.ToString(); ChamCong.D19 = dgvBangChamCong.Rows[i].Cells["col19"].Value.ToString(); ChamCong.D20 = dgvBangChamCong.Rows[i].Cells["col20"].Value.ToString(); ChamCong.D21 = dgvBangChamCong.Rows[i].Cells["col21"].Value.ToString(); ChamCong.D22 = dgvBangChamCong.Rows[i].Cells["col22"].Value.ToString(); ChamCong.D23 = dgvBangChamCong.Rows[i].Cells["col23"].Value.ToString(); ChamCong.D24 = dgvBangChamCong.Rows[i].Cells["col24"].Value.ToString(); ChamCong.D25 = dgvBangChamCong.Rows[i].Cells["col25"].Value.ToString(); ChamCong.D26 = dgvBangChamCong.Rows[i].Cells["col26"].Value.ToString(); ChamCong.D27 = dgvBangChamCong.Rows[i].Cells["col27"].Value.ToString(); if (DateTime.DaysInMonth(ucTL.Nam, ucTL.Thang) == 28) { ChamCong.D28 = dgvBangChamCong.Rows[i].Cells["col28"].Value.ToString(); } else if (DateTime.DaysInMonth(ucTL.Nam, ucTL.Thang) == 29) { ChamCong.D28 = dgvBangChamCong.Rows[i].Cells["col28"].Value.ToString(); ChamCong.D29 = dgvBangChamCong.Rows[i].Cells["col29"].Value.ToString(); } else if (DateTime.DaysInMonth(ucTL.Nam, ucTL.Thang) == 30) { ChamCong.D28 = dgvBangChamCong.Rows[i].Cells["col28"].Value.ToString(); ChamCong.D29 = dgvBangChamCong.Rows[i].Cells["col29"].Value.ToString(); ChamCong.D30 = dgvBangChamCong.Rows[i].Cells["col30"].Value.ToString(); } else if (DateTime.DaysInMonth(ucTL.Nam, ucTL.Thang) == 31) { ChamCong.D28 = dgvBangChamCong.Rows[i].Cells["col28"].Value.ToString(); ChamCong.D29 = dgvBangChamCong.Rows[i].Cells["col29"].Value.ToString(); ChamCong.D30 = dgvBangChamCong.Rows[i].Cells["col30"].Value.ToString(); ChamCong.D30 = dgvBangChamCong.Rows[i].Cells["col31"].Value.ToString(); } ChamCong.Thang = ucTL.Thang; ChamCong.Nam = ucTL.Nam; lsChamCong.Add(ChamCong); } clsChamCong_BUS BUS = new clsChamCong_BUS(); if (BUS.ThemBangChamCong(DateTime.DaysInMonth(ucTL.Nam, ucTL.Thang), lsChamCong)) { MessageBox.Show("Đã lưu dữ liệu chấm công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _btnLuu = true; this.Hide(); frm_PhongBan.Close(); } else { MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }