Exemple #1
0
        public bool payTuition(HocPhiDTO hp, int payTime)
        {
            if (payTime == 1 && hp.Pay1 != 0)
            {
                hp.Date1 = DateTime.Now;
            }
            else if (payTime == 1 && hp.Pay1 == 0)
            {
                hp.Date1 = null;
            }
            else if (payTime == 2 && hp.Pay2 != 0)
            {
                hp.Date2 = DateTime.Now;
            }
            else if (payTime == 2 && hp.Pay2 == 0)
            {
                hp.Date2 = null;
            }
            hp.Complete = hp.Pay1 + hp.Pay2;

            if (hp.Complete > hp.Tuition)
            {
                Console.WriteLine("com > hp");
                return(false);
            }
            Console.WriteLine("com <= hp");
            return(HocPhiDAL.Instance.payTuition(hp, payTime));
        }
        public void addHV_LH(List <HocVienLopHocDTO> lstHVLH, LopHocDTO currentLopHoc, string maHV)
        {
            string maLop = currentLopHoc.id_LH;

            if (maLop != null && maHV != null && maLop.Trim() != "" && maHV.Trim() != "")
            {
                if (findHocVienInDSHV(lstHVLH, maHV) == null && lstHVLH.Count < currentLopHoc.sucChua)
                {
                    HocVienLopHocDTO hvlh = new HocVienLopHocDTO();
                    HocPhiDTO        hp   = new HocPhiDTO();
                    hp.ClassId     = maLop;
                    hp.StudentId   = maHV;
                    hvlh.StudentId = maHV;
                    hvlh.ClassId   = maLop;

                    hocVienLopHocDAL.insertHV_LH(hvlh);
                    HocPhiBLL.Instance.insertHocVien(hp);
                }
                else if (lstHVLH.Count >= currentLopHoc.sucChua)
                {
                    hienThongBao("Lớp học đã đầy!");
                }
                else
                {
                    hienThongBao("Học viên này đã có trong lớp!");
                }
            }
            else
            {
                hienThongBao("Bạn chưa chọn học viên nào!");
            }
        }
Exemple #3
0
        public bool payTuition(HocPhiDTO hp, int payTime)
        {
            conn.Open();
            string     sql = "";
            SqlCommand cmd = null;

            if (payTime == 1)
            {
                sql = "update hocphi set nop_lan_1 = @nop1, ngay_nop_lan_1 = @date1, hoanthanh = @ht where id_HV = @idhv and id_LH = @idlh";
                cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("nop1", hp.Pay1);
                if (hp.Date1 != null)
                {
                    cmd.Parameters.AddWithValue("date1", hp.Date1);
                }
                else
                {
                    cmd.Parameters.AddWithValue("date1", DBNull.Value);
                }
            }
            else if (payTime == 2)
            {
                sql = "update hocphi set nop_lan_2 = @nop2, ngay_nop_lan_2 = @date2, hoanthanh = @ht where id_HV = @idhv and id_LH = @idlh";
                cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("nop2", hp.Pay2);

                if (hp.Date2 != null)
                {
                    cmd.Parameters.AddWithValue("date2", hp.Date2);
                }
                else
                {
                    cmd.Parameters.AddWithValue("date2", DBNull.Value);
                }
            }
            if (sql != "")
            {
                cmd.Parameters.AddWithValue("ht", hp.Complete);
                cmd.Parameters.AddWithValue("idhv", hp.StudentId);
                cmd.Parameters.AddWithValue("idlh", hp.ClassId);
                int rowEffect = cmd.ExecuteNonQuery();
                conn.Close();
                if (rowEffect > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                conn.Close();
                return(false);
            }
        }
Exemple #4
0
        // This method handling việc nhập học phí cho tất cả học viên cùng lúc
        private void Bt_xacNhanHP_Click(object sender, EventArgs e)
        {
            string lanNop = cb_lanNop.Text;
            int    PayTime;

            if (lanNop == "Lần 1")
            {
                PayTime = 1;
            }
            else if (lanNop == "Lần 2")
            {
                PayTime = 2;
            }
            else
            {
                PayTime = 0;
            }

            int i = 0;

            foreach (DataGridViewRow r in dgv_HocPhi.Rows)
            {
                if (PayTime == 1)
                {
                    // this code used to ngăn không cho xóa lần nộp 1 khi lần nộp 2 đã có dữ liệu.
                    // Vì phải có lần 1 mới có lần 2 chứ. -))
                    if (r.Cells["nop1"].Value.ToString() == "" && r.Cells["nop2"].Value.ToString() != "")
                    {
                        continue;
                    }
                }

                // Chỉ thay đổi các row có điều chỉnh ở cột nộp 1 || cột nộp 2
                if (r.Cells["nop1"].Value != null && r.Cells["nop1"].Value.ToString() != string.Empty || r.Cells["nop2"].Value != null && r.Cells["nop2"].Value.ToString() != string.Empty)
                {
                    HocPhiDTO hp = getHPfromGridRowIndex(i);
                    HocPhiBLL.Instance.payTuition(hp, PayTime);
                }
                ++i;
            }

            // Sau khi nhập xong. Reset lại sự hiển thị của các button, hiện thị lại grid, thống kê,..
            reloadButton();
            hienThiGrid();
            ChangeCollumnColorActive();
            cellVisiable();
            loadTextBoxThongKe();
        }
Exemple #5
0
        public bool insertHocVien(HocPhiDTO hp)
        {
            conn.Open();
            string     sql = "insert into hocphi (id_HV, id_LH) values (@idhv, @idlh)";
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("idhv", hp.StudentId);
            cmd.Parameters.AddWithValue("idlh", hp.ClassId);

            int rowEffect = cmd.ExecuteNonQuery();

            conn.Close();
            if (rowEffect == 0)
            {
                return(false);
            }
            return(true);
        }
Exemple #6
0
        //This method return HocPhiDTO object in active row
        private HocPhiDTO getHPfromGridRowIndex(int index)
        {
            HocPhiDTO hp = new HocPhiDTO();

            hp.StudentId   = dgv_HocPhi.Rows[index].Cells["id_HV"].Value.ToString();
            hp.StudentName = dgv_HocPhi.Rows[index].Cells["ten_HV"].Value.ToString();
            hp.ClassId     = cb_listClass.SelectedValue.ToString();
            hp.ClassName   = cb_listClass.Text;
            hp.Tuition     = double.Parse(tb_hocphi.Text);
            try
            {
                hp.Pay1 = double.Parse(dgv_HocPhi.Rows[index].Cells["nop1"].Value.ToString());
            }
            catch { }
            try
            {
                hp.Pay2 = double.Parse(dgv_HocPhi.Rows[index].Cells["nop2"].Value.ToString());
            }
            catch { }

            try
            {
                hp.Complete = double.Parse(dgv_HocPhi.Rows[index].Cells["complete"].Value.ToString());
            }
            catch { }

            try
            {
                hp.Date1 = DateTime.Parse(dgv_HocPhi.Rows[index].Cells["date1"].Value.ToString());
            }
            catch { }
            try
            {
                hp.Date2 = DateTime.Parse(dgv_HocPhi.Rows[index].Cells["date2"].Value.ToString());
            }
            catch { }
            return(hp);
        }
Exemple #7
0
        public static List <HocPhiDTO> LoadHocPhi(string x_strMaSinhVien)
        {
            SqlDataReader objReader = HocPhiDAL.LoadHocPhi(x_strMaSinhVien);

            if (objReader == null)
            {
                return(null);
            }

            List <HocPhiDTO> lstHocPhi = new List <HocPhiDTO>();
            HocPhiDTO        objHocPhi;

            while (objReader.Read())
            {
                objHocPhi              = new HocPhiDTO();
                objHocPhi.NienKhoa     = objReader[0].ToString();
                objHocPhi.HocKy        = int.Parse(objReader[1].ToString());
                objHocPhi.HocPhi       = int.Parse(objReader[2].ToString());
                objHocPhi.SoTienDaDong = int.Parse(objReader[3].ToString());
                lstHocPhi.Add(objHocPhi);
            }
            return(lstHocPhi);
        }
Exemple #8
0
 public bool insertHocVien(HocPhiDTO hp)
 {
     return(HocPhiDAL.Instance.insertHocVien(hp));
 }