public List <BEL_CHITIETHOADON> DuLieuCTHoaDon() { List <BEL_CHITIETHOADON> listCTHoaDon = new List <BEL_CHITIETHOADON>(); DataTable dt = new DataTable(); string truyvan = "select IDHD,IDSP,Soluong,CAST(ThanhTien as int) as ThanhTien from CHITIETHOADON"; dt = this.Read(truyvan); foreach (DataRow item in dt.Rows) { BEL_CHITIETHOADON cthd = new BEL_CHITIETHOADON(item); listCTHoaDon.Add(cthd); } return(listCTHoaDon); }
private void btnThanhToan_Click(object sender, EventArgs e) { if (this.listSanPhamDatHang.Count < 1) { MessageBox.Show("Vui lòng chọn sản phẩm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { BEL_HOADON bel_hd = new BEL_HOADON(); BAL_HOADON bAL_HOADON = new BAL_HOADON(); bel_hd.IDNV = this.bel_nv.IDNV; bel_hd.IDKH = this.bel_kh.IDKH; bel_hd.NGAYLAP = DateTime.Now.ToShortDateString(); bel_hd.GIOLAP = labTime.Text; bel_hd.TONGTIEN = ThanhTien(this.listSanPhamDatHang); bAL_HOADON.ThemHD(bel_hd); bel_hd.IDHD = bAL_HOADON.LayIDHD().ToString(); for (int i = 0; i < this.listSanPhamDatHang.Count; i++) { BEL_CHITIETHOADON bel_cthd = new BEL_CHITIETHOADON(this.listSanPhamDatHang[i]); bel_cthd.IDHD = bel_hd.IDHD; bAL_HOADON.ThemChiTietHoaDon(bel_cthd); } //--- this.listSanPhamDatHang.Clear(); txtTenKH.Text = ""; txtThanhTien.Text = ""; HienThiDatHang(lvBill, this.listSanPhamDatHang); MessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public bool ThemChiTietHoaDon(BEL_CHITIETHOADON cthd) { return(dal_hd.ThemChiTietHoaDon(cthd)); }
public bool ThemChiTietHoaDon(BEL_CHITIETHOADON cthd) { string truyvan = "insert into CHITIETHOADON values(" + cthd.IDHD + "," + cthd.IDSP + "," + cthd.SOLUONG + "," + cthd.ThanhTien + ")"; return(this.Change(truyvan)); }