private void DateTimePicker1_ValueChanged(object sender, EventArgs e) { lstChamCong = ChamCongBUL.LoadBangChamCongTheoNgay(dateTimePicker1.Value.Day, dateTimePicker1.Value.Month, dateTimePicker1.Value.Year); ReloadDataGridView(); for (int i = 0; i < dgvChamCong.Rows.Count; i++) { dgvChamCong.Rows[i].Cells["TrangThai"].Value = lstChamCong[i].MaTrangThai; dgvChamCong.Rows[i].Cells["TangCa"].Value = lstChamCong[i].SoGioTangCa; } }
private void BtnCapNhat_Click(object sender, EventArgs e) { List <CHAMCONG> lstChamCong = new List <CHAMCONG>(); DateTime dt = dateTimePicker1.Value; for (int i = 0; i < dgvChamCong.Rows.Count; i++) { lstChamCong.Add(new CHAMCONG() { MaNV = Convert.ToInt32(dgvChamCong.Rows[i].Cells["MaNV"].Value), ThoiGian = dt, MaTrangThai = Convert.ToInt32(dgvChamCong.Rows[i].Cells["TrangThai"].Value), SoGioTangCa = Convert.ToInt32(dgvChamCong.Rows[i].Cells["TangCa"].Value), }); } if (ChamCongBUL.ChamCongNhanVien(lstChamCong)) { MessageBox.Show("Chấm công thành công"); } else { MessageBox.Show("Chấm công thất bại"); } }