Example #1
0
        public int GetBill(int id)
        {
            if (ConnectionState.Closed == Getcon().State)
            {
                Getcon().Open();
            }
            string     query = "select * from dbo.Bill where idTable = " + id + " and status = 0";
            SqlCommand cmd   = new SqlCommand(query, Getcon());

            try
            {
                SqlDataReader rd = cmd.ExecuteReader();
                dt.Load(rd);
                if (dt.Rows.Count > 0)
                {
                    BEL_HOADON bill = new BEL_HOADON(dt.Rows[0]);
                    return(bill.MaHD);
                }
                return(-1);
            }
            catch (Exception err)
            {
                throw;
            }
            finally
            {
                Getcon().Close();
            }
        }
Example #2
0
        public List <BEL_HOADON> DuLieuHoaDon()
        {
            List <BEL_HOADON> listHoaDon = new List <BEL_HOADON>();
            DataTable         dt         = new DataTable();
            string            truyvan    = "select IDHD,IDNV,IDKH,CONVERT(varchar, Ngaylap, 103) as Ngaylap,GioLap,CAST(TongTien as int) as TongTien from HOADON";

            dt = this.Read(truyvan);
            foreach (DataRow item in dt.Rows)
            {
                BEL_HOADON nhanvien = new BEL_HOADON(item);
                listHoaDon.Add(nhanvien);
            }
            return(listHoaDon);
        }
Example #3
0
        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);
            }
        }
Example #4
0
 public bool ThemHD(BEL_HOADON hd)
 {
     return(dal_hd.ThemHD(hd));
 }
Example #5
0
        public bool ThemHD(BEL_HOADON hd)
        {
            string truyvan = "insert into HOADON(IDNV,IDKH,Ngaylap,GioLap,TongTien) values(" + hd.IDNV + "," + hd.IDKH + ",'" + hd.NGAYLAP + "','" + hd.GIOLAP + "'," + hd.TONGTIEN + ")";

            return(this.Change(truyvan));
        }