private void btnApDungHocPhi_Click(object sender, EventArgs e) { if (dgvTre.SelectedRows.Count == 0) { MessageBox.Show("Phải chọn ít nhất một trẻ để áp dụng học phí."); return; } try { for (int i = 0; i < dgvTre.SelectedRows.Count; i++) { if (TreBLL.KiemTraTreThoiHoc(dgvTre.SelectedRows[i].Cells["MaTre"].Value.ToString(), KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString()))) { message += dgvTre.SelectedRows[i].Cells["HoTenTre"].Value.ToString() + "\n"; continue; } HocPhi hocPhi = new HocPhi(); hocPhi.MaHocPhi = dgvTre.SelectedRows[i].Cells["MaHocPhi"].Value.ToString(); hocPhi.MaTre = dgvTre.SelectedRows[i].Cells["MaTre"].Value.ToString(); hocPhi.Thang = int.Parse(dgvTre.SelectedRows[i].Cells["Thang"].Value.ToString()); hocPhi.Nam = int.Parse(dgvTre.SelectedRows[i].Cells["Nam"].Value.ToString()); hocPhi.HocPhiThangNay = HocPhiBLL.TinhHocPhiThangNay(hocPhi, listChiTietHocPhi); hocPhi.TienNoThangTruoc = HocPhiBLL.LayTienNoHocPhiThangTruoc(hocPhi); hocPhi.TongTienHocPhi = hocPhi.HocPhiThangNay + hocPhi.TienNoThangTruoc; hocPhi.SoTienDaDong = decimal.Parse(dgvTre.SelectedRows[i].Cells["SoTienDaDong"].Value.ToString()); hocPhi.SoTienConNo = hocPhi.TongTienHocPhi - hocPhi.SoTienDaDong; HocPhiBLL.CapNhatHocPhi(hocPhi, listChiTietHocPhi); } if (message == "") { MessageBox.Show("Áp dụng học phí thanh công!"); } else { MessageBox.Show("Trẻ: \n" + message + "đã thôi học nên không được xét học phí."); message = ""; } } catch (Exception ex) { MessageBox.Show("Đã có lỗi xảy ra."); } RefreshView(); }
void CapNhatTienNoThangTruoc() { try { int thang = int.Parse(cboThang.Text); int nam = LopBLL.GetNamHoc(thang, KeyHandle.GetKeyFromCombobox(cboNamHoc.SelectedItem.ToString())); int dieuKien = HocPhiBLL.CoTheCapNhatHocPhi(thang, nam, DateTime.Now); List <HocPhi> list = new List <HocPhi>(); if (cboLop.SelectedItem == null || cboThang.SelectedItem == null || cboNamHoc.SelectedItem == null) { list = HocPhiBLL.GetListHocPhiTheoThang("", 0, 0); } else { list = HocPhiBLL.GetListHocPhiTheoThang( KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString()), int.Parse(cboThang.Text), LopBLL.GetNamHoc(int.Parse(cboThang.Text), KeyHandle.GetKeyFromCombobox(cboNamHoc.SelectedItem.ToString()))); } if (dieuKien == 0) { foreach (HocPhi hocPhi in list) { hocPhi.TienNoThangTruoc = HocPhiBLL.LayTienNoHocPhiThangTruoc(hocPhi); hocPhi.TongTienHocPhi = hocPhi.HocPhiThangNay + hocPhi.TienNoThangTruoc; hocPhi.SoTienConNo = hocPhi.TongTienHocPhi - hocPhi.SoTienDaDong; HocPhiBLL.CapNhatHocPhiVoiTienNoThangTruoc(hocPhi); } LoadDataGridViewTre(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Thông báo"); } }