Пример #1
0
        private void btnLapBienLai_Click(object sender, EventArgs e)
        {
            if (txtTenTre.Text == "")
            {
                MessageBox.Show("Phải chọn một trẻ để lập biên lai.");
                return;
            }
            if (txtNguoiDongTien.Text == "")
            {
                MessageBox.Show("Tên người đóng tiền không được bỏ trống.");
                return;
            }
            if (txtNguoiThuTien.Text == "")
            {
                MessageBox.Show("Tên người thu tiền không được bỏ trống");
                return;
            }
            if (txtSoTienDong.Text == "")
            {
                MessageBox.Show("Số tiền đóng không được bỏ trống.");
                return;
            }
            if (decimal.Parse(txtSoTienDong.Text) <= 0)
            {
                MessageBox.Show("Số tiền đóng phải lớn hơn 0.");
                return;
            }

            try
            {
                BienLaiThuHocPhi bienLai = new BienLaiThuHocPhi();
                bienLai.MaBienLai   = HocPhiBLL.GenerateMaBienLai();
                bienLai.MaTre       = maTre;
                bienLai.NguoiDong   = txtNguoiDongTien.Text;
                bienLai.NguoiThu    = txtNguoiThuTien.Text;
                bienLai.NgayThu     = DateTime.Now;
                bienLai.SoTienThu   = decimal.Parse(txtSoTienDong.Text);
                bienLai.SoTienConNo = decimal.Parse(txtSoTienConNo.Text);
                bienLai.GhiChu      = txtGhiChu.Text;

                HocPhiBLL.ThemBienLai(bienLai, maHocPhi);
                MessageBox.Show("Thêm biên lai thành công!");

                LoadDataGirdView();
                cboThang.Text = DateTime.Now.Month.ToString();
                LoadListThongTinDongHocPhi();
                txtNguoiDongTien.Clear();
                txtSoTienDong.Clear();
                txtGhiChu.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi.");
            }
        }
Пример #2
0
        public static void ThemBienLai(BienLaiThuHocPhi bienLai)
        {
            DataAccessHelper.GetInstance().Open();
            SqlCommand cmd = DataAccessHelper.GetInstance().Command("ThemBienLai");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MaBienLai", bienLai.MaBienLai);
            cmd.Parameters.AddWithValue("@MaTre", bienLai.MaTre);
            cmd.Parameters.AddWithValue("@NguoiDong", bienLai.NguoiDong);
            cmd.Parameters.AddWithValue("@NguoiThu", bienLai.NguoiThu);
            cmd.Parameters.AddWithValue("@NgayThu", bienLai.NgayThu);
            cmd.Parameters.AddWithValue("@SoTienThu", bienLai.SoTienThu);
            cmd.Parameters.AddWithValue("@SoTienConNo", bienLai.SoTienConNo);
            cmd.Parameters.AddWithValue("@GhiChu", bienLai.GhiChu);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataAccessHelper.GetInstance().SetDataTable(new DataTable());
            da.Fill(DataAccessHelper.GetInstance().GetDataTable());
            DataAccessHelper.GetInstance().Close();
        }
Пример #3
0
        private void btnXoaBienLai_Click(object sender, EventArgs e)
        {
            if (dgvBienLai.SelectedRows.Count < 1)
            {
                MessageBox.Show("Phải chọn một biên lai.");
                return;
            }
            if (!HocPhiBLL.CoTheHuyBienLai((DateTime)dgvBienLai.SelectedRows[0].Cells["NgayThu"].Value, DateTime.Now))
            {
                MessageBox.Show("Không thể hủy biên lai này. Biên lai chỉ được hủy trong ngày tạo.");
                return;
            }
            try
            {
                DialogResult result = MessageBox.Show("Bạn có chắc sẽ hủy biên lai đã chọn?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
                if (result == DialogResult.Yes)
                {
                    BienLaiThuHocPhi bienLai = new BienLaiThuHocPhi();
                    bienLai.MaBienLai   = dgvBienLai.SelectedRows[0].Cells["MaBienLai"].Value.ToString();
                    bienLai.MaTre       = dgvBienLai.SelectedRows[0].Cells["MaTre"].Value.ToString();
                    bienLai.NguoiDong   = dgvBienLai.SelectedRows[0].Cells["NguoiDong"].Value.ToString();
                    bienLai.NguoiThu    = dgvBienLai.SelectedRows[0].Cells["NguoiThu"].Value.ToString();
                    bienLai.NgayThu     = (DateTime)dgvBienLai.SelectedRows[0].Cells["NgayThu"].Value;
                    bienLai.SoTienThu   = decimal.Parse(dgvBienLai.SelectedRows[0].Cells["SoTienThu"].Value.ToString());
                    bienLai.SoTienConNo = decimal.Parse(dgvBienLai.SelectedRows[0].Cells["SoTienConNo"].Value.ToString());
                    bienLai.GhiChu      = dgvBienLai.SelectedRows[0].Cells["GhiChu"].Value.ToString();
                    HocPhiBLL.HuyBienLai(bienLai, maHocPhi);
                    MessageBox.Show("Đã hủy biên lai!");

                    LoadListThongTinDongHocPhi();
                    LoadDataGirdView();
                    ClearAllField();
                }
            } catch (Exception ex)
            {
                MessageBox.Show("Đã xảy ra lỗi: " + ex.Message);
            }
        }