Esempio n. 1
0
        public ActionResult Chonhang(FormCollection collection)
        {
            Phieunhap   ddh = new Phieunhap();
            Nhanvien    nv  = (Nhanvien)Session["Taikhoan"];
            List <Nhap> gh  = Layds();

            ddh.NhanVien = nv.MaNV;
            ddh.Ngaylap  = DateTime.Now;

            kho.Phieunhaps.InsertOnSubmit(ddh);
            kho.SubmitChanges();
            foreach (var item in gh)
            {
                CTPHIEUNHAP ctpx = new CTPHIEUNHAP();
                ctpx.Manhap      = ddh.MaNhap;
                ctpx.MaMH        = item.iMaMH;
                ctpx.SoluongNhap = item.iSoluong;
                ctpx.Gianhap     = item.dDonggia;
                ctpx.Tongtien    = item.dThanhtien;
                kho.CTPHIEUNHAPs.InsertOnSubmit(ctpx);
                //ctdh.Masach = item.iMasach;
                //ctdh.Soluong = item.iSoluong;
                //ctdh.Dongia = (decimal)item.dDonggia;
                //data.CTDATHANGs.InsertOnSubmit(ctdh);
            }
            kho.SubmitChanges();
            Session["Nhap"] = null;
            return(RedirectToAction("Xacnhan", "Nhap"));
        }
Esempio n. 2
0
        public bool Them_NL(Phieunhap pn)
        {
            string query = $"Insert into Nguyenlieu(MaNL, tenNL,donvitinh) values(N'{pn._manl}',N'{pn._tennl}',N'{pn._donvitinh}')";

            Load_DB(query);
            return(true);
        }
Esempio n. 3
0
        public bool Sua_PN(Phieunhap pn)
        {
            string query = $"update Phieunhap set Manhap=N'{pn._manhap}', MaNV=N'{pn._manv}',ngaynhap=N'{pn._ngaynhap}' Where Manhap=N'{pn._manhap}' ";

            Load_DB(query);
            return(true);
        }
Esempio n. 4
0
        public bool Sua_NL(Phieunhap pn)
        {
            string query = $"update Nguyenlieu set MaNL=N'{pn._manl}', tenNL=N'{pn._tennl}',donvitinh=N'{pn._donvitinh}' Where MaNL=N'{pn._manl}' ";

            Load_DB(query);
            return(true);
        }
Esempio n. 5
0
        public bool Them_NVK(Phieunhap pn)
        {
            string query = $"Insert into Nhanvien(MaNV, tennv,soDT) values(N'{pn._manv}',N'{pn._tennv}',N'{pn._soDT}')";

            Load_DB(query);
            return(true);
        }
Esempio n. 6
0
        public bool Sua_NVK(Phieunhap pn)
        {
            string query = $"update Nhanvien set MaNV=N'{pn._manv}', tennv=N'{pn._tennv}',soDT=N'{pn._soDT}' Where MaNV=N'{pn._manv}' ";

            Load_DB(query);
            return(true);
        }
Esempio n. 7
0
        public bool addSach(Phieunhap phieunhap,CTPN[] ctpn)
        {
            try
            {//phieunhap.NgayNhap = DateTime.Today;
                NoNXB no = new NoNXB();
                Kho kho = new Kho();
                //tao dl ao
                no.NgayNhap = phieunhap.NgayNhap;
                no.IdNXB = phieunhap.IdNXB;
                kho.NgayGhi = phieunhap.NgayNhap;

                foreach (var i in ctpn) //code ctpn in here
                {
                    Sach sach = db.Saches.Find(i.IdSach);
                    kho.IdSach = sach.IdSach;
                    kho.SL = i.SoLuong;
                    no.TienNo = i.SoLuong * sach.GiaNhap;
                    UpdateNo(no);
                    UpdateKho(kho);
                    phieunhap.CTPNs.Add(i);
                    db.SaveChanges();

                }
                db.Phieunhaps.Add(phieunhap);
                db.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Esempio n. 8
0
        public bool Them_PN(Phieunhap pn)
        {
            string query = $"Insert into Phieunhap(Manhap, MaNV,ngaynhap) values(N'{pn._manhap}',N'{pn._manv}',N'{pn._ngaynhap}')";

            Load_DB(query);
            return(true);
        }
Esempio n. 9
0
        public ActionResult DeleteConfirmed(string id)
        {
            Phieunhap phieunhap = db.Phieunhaps.Find(id);

            db.Phieunhaps.Remove(phieunhap);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "Maphieunhap,Ngaytao,MaNCC")] Phieunhap phieunhap)
 {
     if (ModelState.IsValid)
     {
         db.Entry(phieunhap).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaNCC = new SelectList(db.NhaCCs, "MaNCC", "TenNCC", phieunhap.MaNCC);
     return(View(phieunhap));
 }
Esempio n. 11
0
 public ActionResult Edit([Bind(Include = "IdPn,NgayNhap,NguoiGiao,IdNXB,NguoiNhan")] Phieunhap phieunhap)
 {
     if (ModelState.IsValid)
     {
         db.Entry(phieunhap).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdNXB = new SelectList(db.NXBs, "IdNXB", "TenNXB", phieunhap.IdNXB);
     return(View(phieunhap));
 }
Esempio n. 12
0
        public ActionResult Create([Bind(Include = "Maphieunhap,Ngaytao,MaNCC")] Phieunhap phieunhap)
        {
            if (ModelState.IsValid)
            {
                db.Phieunhaps.Add(phieunhap);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaNCC = new SelectList(db.NhaCCs, "MaNCC", "TenNCC", phieunhap.MaNCC);
            return(View(phieunhap));
        }
Esempio n. 13
0
        // GET: Phieunhaps/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Phieunhap phieunhap = db.Phieunhaps.Find(id);

            if (phieunhap == null)
            {
                return(HttpNotFound());
            }
            return(View(phieunhap));
        }
Esempio n. 14
0
        public ActionResult Create([Bind(Include = "IdPn,NgayNhap,NguoiGiao,IdNXB,NguoiNhan")] Phieunhap phieunhap
                                   , [Bind(Prefix = "ct")] CTPN[] ctpn)
        {
            if (ModelState.IsValid)
            {
                if (bus.addSach(phieunhap, ctpn))
                {
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.IdNXB = new SelectList(db.NXBs, "IdNXB", "TenNXB", phieunhap.IdNXB);
            return(View(phieunhap));
        }
Esempio n. 15
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Phieunhap = await _context.Phieunhap.FirstOrDefaultAsync(m => m.ID == id);

            if (Phieunhap == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 16
0
        // GET: Phieunhaps/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Phieunhap phieunhap = db.Phieunhaps.Find(id);

            if (phieunhap == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MaNCC = new SelectList(db.NhaCCs, "MaNCC", "TenNCC", phieunhap.MaNCC);
            return(View(phieunhap));
        }
Esempio n. 17
0
        // GET: Phieunhaps/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Phieunhap phieunhap = db.Phieunhaps.Find(id);

            if (phieunhap == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdNXB = new SelectList(db.NXBs, "IdNXB", "TenNXB", phieunhap.IdNXB);
            return(View(phieunhap));
        }
Esempio n. 18
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Phieunhap = await _context.Phieunhap.FindAsync(id);

            if (Phieunhap != null)
            {
                _context.Phieunhap.Remove(Phieunhap);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 19
0
 public bool Them_NVK(Phieunhap pn)
 {
     return(dal.Them_NVK(pn));
 }
Esempio n. 20
0
 public bool Sua_NVK(Phieunhap pn)
 {
     return(dal.Sua_NVK(pn));
 }
Esempio n. 21
0
 public bool Them_PN(Phieunhap pn)
 {
     return(dal.Them_PN(pn));
 }
Esempio n. 22
0
 public bool Sua_PN(Phieunhap pn)
 {
     return(dal.Sua_PN(pn));
 }
Esempio n. 23
0
 public ActionResult Create(FormCollection collection, Phieunhap pn)
 {
     kho.Phieunhaps.InsertOnSubmit(pn);
     kho.SubmitChanges();
     return(RedirectToAction("Index", "Phieunhap"));
 }
Esempio n. 24
0
 public bool Them_NL(Phieunhap nl)
 {
     return(dal.Them_NL(nl));
 }