예제 #1
0
        public PHIEUNHAPHANGTRUSO createNHTS(string matk)
        {
            db = new CMART8Entities();
            string             id   = autoID();
            PHIEUNHAPHANGTRUSO nhts = new PHIEUNHAPHANGTRUSO();

            nhts.SOPHIEU  = id;
            nhts.MATK     = matk;
            nhts.NGAYNHAP = DateTime.Now;
            db.PHIEUNHAPHANGTRUSOes.Add(nhts);
            db.SaveChanges();
            return(nhts);
        }
예제 #2
0
 //Delete PN
 public bool deletePN(PHIEUNHAPHANGTRUSO PN)
 {
     try
     {
         db = new CMART8Entities();
         PHIEUNHAPHANGTRUSO pn = db.PHIEUNHAPHANGTRUSOes.Find(PN.SOPHIEU);
         db.PHIEUNHAPHANGTRUSOes.Remove(pn);
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
예제 #3
0
 //update Phieu nhap hang tru so
 public bool updatePNHTS(PHIEUNHAPHANGTRUSO PN, string tongTien, string soPhieuDX)
 {
     try
     {
         db = new CMART8Entities();
         PHIEUNHAPHANGTRUSO pn = db.PHIEUNHAPHANGTRUSOes.Find(PN.SOPHIEU);
         pn.TONGTIEN        = ulong.Parse(tongTien);
         pn.SOPHIEUDX       = soPhieuDX;
         db.Entry(pn).State = System.Data.EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
예제 #4
0
        public void addCTNHTS(string tmp, PHIEUNHAPHANGTRUSO PN, TAIKHOAN TK)
        {
            db = new CMART8Entities();
            var ctpdx = db.CTPHIEUDEXUATs.Where(x => x.SOPHIEU.Equals(tmp)).ToList();

            foreach (var item in ctpdx)
            {
                CTPHIEUNHAPHANGTRUSO nhts = new CTPHIEUNHAPHANGTRUSO();
                nhts.SOPHIEUNHTS = PN.SOPHIEU;
                nhts.MASP        = item.MASP;
                nhts.SOLUONG     = item.SOLUONG;
                nhts.GIANHAP     = 0;
                nhts.HANSD       = DateTime.Now.AddMonths(6);
                nhts.TINHTRANG   = "Đủ";
                db.CTPHIEUNHAPHANGTRUSOes.Add(nhts);
                db.SaveChanges();
            }
        }