Ejemplo n.º 1
0
        private void cboThang_SelectedIndexChanged(object sender, EventArgs e)
        {
            RefreshView();
            int thang    = int.Parse(cboThang.Text);
            int nam      = LopBLL.GetNamHoc(thang, KeyHandle.GetKeyFromCombobox(cboNamHoc.SelectedItem.ToString()));
            int dieuKien = HocPhiBLL.CoTheCapNhatHocPhi(thang, nam, DateTime.Now);

            cboChiPhi.Enabled        = false;
            txtSoTien.Enabled        = false;
            btnThemChiPhi.Enabled    = false;
            btnCapNhatChiPhi.Enabled = false;
            btnXoa.Enabled           = false;
            btnApDungHocPhi.Enabled  = false;
            if (dieuKien == -1)
            {
                lbMessage.Text = "Đã quá hạn áp dụng học phí";
            }
            else if (dieuKien == 1)
            {
                lbMessage.Text = "Chưa tới thời gian áp dụng học phí";
            }
            else
            {
                lbMessage.Text           = "";
                cboChiPhi.Enabled        = true;
                txtSoTien.Enabled        = true;
                btnThemChiPhi.Enabled    = true;
                btnCapNhatChiPhi.Enabled = true;
                btnXoa.Enabled           = true;
                btnApDungHocPhi.Enabled  = true;
            }

            CapNhatTienNoThangTruoc();
        }
Ejemplo n.º 2
0
        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");
            }
        }