Esempio n. 1
0
        public List <ChiTietHoaDon> getAll()
        {
            String    query = "select MaHoaDon,MaSach,SoLuongMua from ChiTietHoaDon";
            DataTable dt    = this.dp.ExecuteQuery(query);

            List <ChiTietHoaDon> lstChiTietHoaDon = new List <ChiTietHoaDon>();

            foreach (DataRow dr in dt.Rows)
            {
                ChiTietHoaDon chiTietHoaDon = new ChiTietHoaDon();
                chiTietHoaDon.MaHoaDon   = (int)dr["MaHoaDon"];
                chiTietHoaDon.MaSach     = (int)dr["MaSach"];
                chiTietHoaDon.SoLuongMua = (int)dr["SoLuongMua"];

                lstChiTietHoaDon.Add(chiTietHoaDon);
            }
            return(lstChiTietHoaDon);
        }
Esempio n. 2
0
        public static List <ChiTietHoaDon> LoadCTHoaDon(int id)
        {
            QLCHXeEntity db     = new QLCHXeEntity();
            var          result = (
                from c in db.ChiTietHoaDons
                join x in db.Xes on c.MaSanPham equals x.MaXe
                join km in db.KhuyenMais on c.MaKhuyenMai equals km.MaKhuyenMai
                where c.MaHoaDon == id
                select new
            {
                MaHoaDon = c.MaHoaDon,
                MaSanPham = c.MaSanPham,
                TenXe = x.TenXe,
                DonGia = c.DonGia,
                SoLuong = c.SoLuong,
                MaKhuyenMai = c.MaKhuyenMai,
                GiamGia = c.GiamGia,
                ThanhTien = c.ThanhTien,
                NoiDung = km.NoiDung
            }).ToList();
            List <ChiTietHoaDon> listReturn = new List <ChiTietHoaDon>();

            foreach (var item in result)
            {
                ChiTietHoaDon cthoadon_list = new ChiTietHoaDon();



                cthoadon_list.MaHoaDon    = item.MaHoaDon;
                cthoadon_list.MaSanPham   = item.MaSanPham;
                cthoadon_list.TenXe       = item.TenXe;
                cthoadon_list.DonGia      = item.DonGia;
                cthoadon_list.SoLuong     = item.SoLuong;
                cthoadon_list.MaKhuyenMai = item.MaKhuyenMai;
                cthoadon_list.GiamGia     = item.GiamGia;
                cthoadon_list.ThanhTien   = item.ThanhTien;


                listReturn.Add(cthoadon_list);
            }

            return(listReturn);
        }
Esempio n. 3
0
        public List <ChiTietHoaDon> getByMaHoaDon(int MaHoaDon)
        {
            String query = "select MaHoaDon,MaSach,SoLuongMua from ChiTietHoaDon where MaHoaDon = @MaHoaDon";

            List <SqlParameter> sqlParameters = new List <SqlParameter>();
            SqlParameter        param         = new SqlParameter("MaHoaDon", MaHoaDon);

            sqlParameters.Add(param);
            DataTable            dt = this.dp.ExecuteQuery(query, sqlParameters);
            List <ChiTietHoaDon> lstChiTietHoaDon = new List <ChiTietHoaDon>();

            foreach (DataRow dr in dt.Rows)
            {
                ChiTietHoaDon chiTietHoaDon = new ChiTietHoaDon();
                chiTietHoaDon.MaHoaDon   = (int)dr["MaHoaDon"];
                chiTietHoaDon.MaSach     = (int)dr["MaSach"];
                chiTietHoaDon.SoLuongMua = (int)dr["SoLuongMua"];

                lstChiTietHoaDon.Add(chiTietHoaDon);
            }
            return(lstChiTietHoaDon);
        }
Esempio n. 4
0
        public static ChiTietHoaDon GetBillDetail(ChiTietHoaDon detail)
        {
            provider = new DataProvider();
            provider.Connect();

            string        cmdStr = "Execute proc_GetBillDetail " + detail.MaHoaDon + ", N'" + detail.TenMon + "'";
            SqlDataReader reader = provider.ExecuteReader(cmdStr);
            ChiTietHoaDon cthd   = null;

            if (reader.Read())
            {
                cthd = new ChiTietHoaDon
                {
                    MaHoaDon  = reader.GetInt32(0),
                    TenMon    = reader.GetString(1),
                    SoLuong   = reader.GetInt32(2),
                    ThanhTien = reader.GetInt32(3)
                };
            }

            provider.Disconnect();
            return(cthd);
        }
Esempio n. 5
0
 public static int DeleteThietBi(ChiTietHoaDon cthd)
 {
     return(ExecuteQuery.DeleteRows(cthd.Mahd, "CTHoaDon"));
 }
Esempio n. 6
0
 public static int AddCTHD(ChiTietHoaDon cthd)
 {
     return(ExecuteQuery.AddRows(cthd.ToString(), "CTHoaDon"));
 }
Esempio n. 7
0
 public void AddCTHoaDon(ChiTietHoaDon cthd)
 {
     db.ChiTietHoaDons.Add(cthd);
     db.SaveChanges();
 }