Ejemplo n.º 1
0
        private void btXacNhan_Click_1(object sender, EventArgs e)
        {
            if (txtEmail.Text == "" || nUDSoTienThu.Text == "")
            {
                MessageBox.Show("Bạn phải nhập hết dữ liệu");
            }
            else
            {
                string lastID = ID.GetLastID("PhieuThuTien", "MaPhieuThuTien");
                string newID  = ID.NextID(lastID, "PT");

                int tien   = Convert.ToInt32(nUDSoTienThu.Text);
                int tienno = objpt.GetNoDaiLi(cbTenDaiLi.SelectedValue.ToString());

                if (tien > tienno)
                {
                    MessageBox.Show("Số tiền nợ đại lý nợ: " + tienno + " bé hơn tiền thu!", "SỐ TIỀN NỢ KHÔNG VƯỢC HƠN SỐ TIỀN THU");
                }
                else
                {
                    DateTime ngay        = dateTT.Value;
                    PhieuThu Pt          = new PhieuThu(newID, cbTenDaiLi.SelectedValue.ToString(), ngay, tien, txtEmail.Text);
                    int      tiennodatra = tienno - tien;
                    objpt.ThayDoiTienNo(tiennodatra, cbTenDaiLi.SelectedValue.ToString());
                    if (objpt.ThemPhieuThu(Pt))
                    {
                        MessageBox.Show("Thêm phiếu thu thành công");
                    }
                    else
                    {
                        MessageBox.Show("Có lỗi trong quá trình thêm");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public bool ThemPhieuThu(PhieuThu pt)
        {
            string SQLstring = "insert into PhieuThuTien(MaPhieuThuTien,MaDaiLi,NgayThuTien,SoTienThu,Email)" +
                               "values ('" + pt.MaPhieuThuTien + "', '" + pt.MaDaiLi + "','" + pt.NgayThuTien + "','" + pt.SoTienThu + "','" + pt.email + "')";

            if (objDL.AddData(SQLstring))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }