Exemplo n.º 1
0
        public ChiTietHoaDonBan GetOneCTHDN(string id)
        {
            DataTable        dt = db.GetData("SELECT * FROM chiTietHoaDonBan WHERE maHoaDonBan='" + id + "'");
            ChiTietHoaDonBan l  = new ChiTietHoaDonBan();

            l.maHoaDonBan = int.Parse(dt.Rows[0][0].ToString());
            l.maSp        = dt.Rows[0][1].ToString();
            l.soLuong     = int.Parse(dt.Rows[0][2].ToString());
            l.giaBan      = int.Parse(dt.Rows[0][3].ToString());
            return(l);
        }
Exemplo n.º 2
0
        public List <ChiTietHoaDonBan> GetAllCTHDN()
        {
            DataTable dt = db.GetData("SELECT * FROM chiTietHoaDonBan");
            List <ChiTietHoaDonBan> li = new List <ChiTietHoaDonBan>();

            foreach (DataRow dr in dt.Rows)
            {
                ChiTietHoaDonBan l = new ChiTietHoaDonBan();
                l.maHoaDonBan = int.Parse(dr[0].ToString());
                l.maSp        = dr[1].ToString();
                l.soLuong     = int.Parse(dr[2].ToString());
                l.giaBan      = int.Parse(dr[3].ToString());
                li.Add(l);
            }
            return(li);
        }
Exemplo n.º 3
0
        public List <ChiTietHoaDonBan> Thongke(string ngay, string thang, string nam)
        {
            DataTable dt = db.GetData("SELECT HD.ngayBan, CT.maSp, SP.tenSP, CT.giaBan, CT.soLuong FROM HoaDonBan HD INNER JOIN chiTietHoaDonBan CT INNER JOIN DienThoai SP ON SP.maSp = CT.maSp ON HD.maHoaDonBan = CT.maHoaDonBan WHERE DAY(HD.ngayBan) = '" + ngay + "' AND MONTH(HD.ngayBan) = '" + thang + "' AND YEAR(HD.ngayBan) = '" + nam + "'");
            List <ChiTietHoaDonBan> li = new List <ChiTietHoaDonBan>();

            foreach (DataRow dr in dt.Rows)
            {
                ChiTietHoaDonBan l = new ChiTietHoaDonBan();
                l.ngayBan = dr[0].ToString();
                l.maSp    = dr[1].ToString();
                l.tenSp   = dr[2].ToString();
                l.giaBan  = int.Parse(dr[3].ToString());
                l.soLuong = int.Parse(dr[4].ToString());
                li.Add(l);
            }
            return(li);
        }
Exemplo n.º 4
0
        public List <ChiTietHoaDonBan> GetListChiTiet(string id)
        {
            DataTable dt = db.GetData("SELECT CT.*, DT.tenSp, DT.hinhAnh FROM chiTietHoaDonBan CT INNER JOIN DienThoai DT ON CT.maSp = DT.maSp WHERE maHoaDonBan = '" + id + "'");
            List <ChiTietHoaDonBan> li = new List <ChiTietHoaDonBan>();

            foreach (DataRow dr in dt.Rows)
            {
                ChiTietHoaDonBan l = new ChiTietHoaDonBan();
                l.maHoaDonBan = int.Parse(dr[0].ToString());
                l.maSp        = dr[1].ToString();
                l.soLuong     = int.Parse(dr[2].ToString());
                l.giaBan      = int.Parse(dr[3].ToString());

                l.tenSp   = dr[4].ToString();
                l.hinhAnh = dr[5].ToString();
                li.Add(l);
            }
            return(li);
        }
Exemplo n.º 5
0
        public void themCTHDN(ChiTietHoaDonBan x)
        {
            string sql = "INSERT INTO chiTietHoaDonBan VALUES('" + x.maHoaDonBan + "','" + x.maSp + "','" + x.soLuong + "', '" + x.giaBan + "')";

            db.WriteData(sql);
        }