private void btn_TinhLuong_Click(object sender, EventArgs e) { if (lsb_DanhSach.Items.Count > 0 && mtx_Thang.MaskCompleted) { string thangnam = mtx_Thang.Text; try { int nam = Convert.ToInt16(thangnam.Substring(3, 4)); int thang = Convert.ToInt16(thangnam.Substring(0, 2)); DateTime tu_ngay = new DateTime(nam, thang, 1); DateTime den_ngay = new DateTime(nam, thang, DateTime.DaysInMonth(nam, thang)); if (rdb_NV.Checked) { dtLuong = oTinhLuong.TinhLuongByListNV(lstMaNV, tu_ngay, den_ngay, Convert.ToInt32(nam.ToString() + thang.ToString("D2"))); dtPhuCap = oTinhLuong.TinhPhuCapByListNV(lstMaNV, tu_ngay, den_ngay, Convert.ToInt32(nam.ToString() + thang.ToString("D2"))); } else if (rdb_DonVi.Checked) { dtLuong = oTinhLuong.TinhLuongByListDV(lstDV_ID, tu_ngay, den_ngay, Convert.ToInt32(nam.ToString() + thang.ToString("D2"))); dtPhuCap = oTinhLuong.TinhPhuCapByListDV(lstDV_ID, tu_ngay, den_ngay, Convert.ToInt32(nam.ToString() + thang.ToString("D2"))); } dtgv_Luong.DataSource = null; dtgv_PhuCap.DataSource = null; AddLuongFormatCol(); dtgv_Luong.DataSource = dtLuong; dtgv_PhuCap.DataSource = dtPhuCap; SetupDTGV_Luong(); SetupDTGV_PhuCap(); } catch (Exception ex) { MessageBox.Show("Có lỗi xảy ra!\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Xin vui lòng chọn nhân viên / đơn vị và tháng cần tính lương. ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }