Example #1
0
        void CapNhatCongNo()
        {
            if (this.txtSoTienTraHomNay.Text == string.Empty)
            {
                MessageBox.Show("Bạn chưa nhập tiền trả nợ !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Convert.ToDecimal(this.txtSoTienTraHomNay.Text) > cn.TIENCONNO)
            {
                MessageBox.Show("Số tiền trả đang lớn hơn số tiền còn nợ trong hóa đơn !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtSoTienTraHomNay.Focus();
                return;
            }
            if (cn.TIENCONNO == Convert.ToDecimal(this.txtSoTienTraHomNay.Text))
            {
                CongNoBUS.CapNhatCongNo(new CONGNO
                {
                    MACONGNO  = cn.MACONGNO,
                    MAKH      = this.dgvCongNo.CurrentRow.Cells["MAKHCongNo"].Value.ToString(),
                    MAHD      = cn.MAHD,
                    TONGTIEN  = cn.TONGTIEN,
                    TIENCONNO = 0M,
                    NGAYTRA   = cn.NGAYTRA.Value.Date,
                    NV_LAPCN  = cn.NV_LAPCN,
                    NGAYLAP   = cn.NGAYLAP.Value.Date,
                    TRANGTHAI = false
                });
                //CongNoBUS.XoaCongNo(cn.MACONGNO);
            }
            else
            {
                CongNoBUS.CapNhatCongNo(new CONGNO
                {
                    MACONGNO  = cn.MACONGNO,
                    MAKH      = this.dgvCongNo.CurrentRow.Cells["MAKHCongNo"].Value.ToString(),
                    MAHD      = cn.MAHD,
                    TONGTIEN  = cn.TONGTIEN,
                    TIENCONNO = Convert.ToDecimal(cn.TIENCONNO) - Convert.ToDecimal(this.txtSoTienTraHomNay.Text),
                    NGAYTRA   = cn.NGAYTRA.Value.Date,
                    NV_LAPCN  = cn.NV_LAPCN,
                    NGAYLAP   = cn.NGAYLAP.Value.Date,
                    TRANGTHAI = true
                });
            }
            LichSuTraNoBUS.TaoLichSuTraNo(new LICHSUTRANO
            {
                MACONGNO        = cn.MACONGNO,
                NGAYTRA_THEODOI = DateTime.Now.Date,
                TIENTRA_THEODOI = Convert.ToDecimal(this.txtSoTienTraHomNay.Text),
                TRANGTHAI       = true,
            });
            MessageBox.Show("Thanh toán thành công !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            LoadDSCN();
            Reset();
            string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã cập nhật thông tin của mã công nợ " + cn.MACONGNO;

            LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG
            {
                NGAYTAO       = DateTime.Now.Date,
                NV_THAOTAC    = this.manv,
                VITRI_THAOTAC = this.vitrithaotac,
                GHICHU        = lsth
            });
        }