Exemplo n.º 1
0
        public static void DeleteHoaDon(string mahd, string masach)
        {
            using (dbMainDataContext dbMain = new dbMainDataContext())
            {
                var query = from h in dbMain.PhieuBans where h.MaPhieuBan == mahd && h.MaSach == masach select h;

                PhieuBan pb = query.SingleOrDefault();
                dbMain.PhieuBans.DeleteOnSubmit(pb);
                dbMain.SubmitChanges();
            }
        }
Exemplo n.º 2
0
        public static void InsertHoaDon(string mahd, string masach, int soluong)
        {
            using (dbMainDataContext dbMain = new dbMainDataContext())
            {
                PhieuBan pb = new PhieuBan();
                pb.MaPhieuBan = mahd;
                pb.MaSach     = masach;
                pb.SoLuong    = soluong;

                dbMain.PhieuBans.InsertOnSubmit(pb);
                dbMain.SubmitChanges();
            }
        }
Exemplo n.º 3
0
        public static void UpdateHoaDon(string mahd, string masach, int soluong)
        {
            using (dbMainDataContext dbMain = new dbMainDataContext())
            {
                var query = from h in dbMain.PhieuBans where h.MaPhieuBan == mahd && h.MaSach == masach select h;

                PhieuBan pb = query.SingleOrDefault();

                // pb.MaPhieuBan = mahd;

                pb.MaSach  = masach;
                pb.SoLuong = soluong;

                dbMain.SubmitChanges();
            }
        }
Exemplo n.º 4
0
        public PhieuBan LayPhieuBan(String id)
        {
            DataTable tbl = factory.LayPhieuBan(id);
            PhieuBan  ph  = null;

            if (tbl.Rows.Count > 0)
            {
                ph    = new PhieuBan();
                ph.Id = Convert.ToString(tbl.Rows[0]["ID"]);

                ph.NgayBan  = Convert.ToDateTime(tbl.Rows[0]["NGAY_BAN"]);
                ph.TongTien = Convert.ToInt64(tbl.Rows[0]["TONG_TIEN"]);
                ph.DaTra    = Convert.ToInt64(tbl.Rows[0]["DA_TRA"]);
                ph.ConNo    = Convert.ToInt64(tbl.Rows[0]["CON_NO"]);
                KhachHangController ctrlKH = new KhachHangController();
                ph.KhachHang = ctrlKH.LayKhachHang(Convert.ToString(tbl.Rows[0]["ID_KHACH_HANG"]));
                ChiTietPhieuBanController ctrl = new ChiTietPhieuBanController();
                ph.ChiTiet = ctrl.ChiTietPhieuBan(ph.Id);
            }
            return(ph);
        }