Example #1
0
        public ActionResult nhapHang2(int maTB, int maCauHinh)
        {
            saveTemp s = new saveTemp(maTB, maCauHinh);

            ViewBag.NhaCungCap = new SelectList(tx.tblNhaCungCap.ToList(), "MaNCC", "TenNCC");
            return(View());
        }
Example #2
0
 public ActionResult nhapHang2(FormCollection c, HttpPostedFileBase fileUpLoad)
 {
     try
     {
         saveTemp s         = new saveTemp();
         int      maTB      = s.getMa1();
         int      maCauHinh = s.getMa2();
         //phieu nhap
         int              soLuong = int.Parse(c["sl"]);
         double           donGia  = double.Parse(c["gia"]);
         int              ncc     = int.Parse(c["NhaCungCap"]);
         tblPhieuNhapHang pn      = new tblPhieuNhapHang();
         tblNhanVien      tk      = Session["dangnhap"] as tblNhanVien;
         if (tk != null)
         {
             pn.MaNVNhanHang = tk.MaNV;
         }
         else
         {
             pn.MaNVNhanHang = 1;
         }
         pn.MaNCC    = ncc;
         pn.TongTien = (double)(soLuong * donGia);
         pn.NgayNhap = DateTime.Now;
         tx.tblPhieuNhapHang.Add(pn);
         tx.SaveChanges();
         //chi tiet
         tblChiTietPhieuNhap ct = new tblChiTietPhieuNhap();
         int maPn = pn.MaPhieuNH;
         ct.MaPhieuNH = maPn;
         ct.MaTB      = maTB;
         ct.MaCauHinh = maCauHinh;
         ct.SoLuong   = soLuong;
         ct.DonGia    = (decimal)donGia;
         ct.ThanhTien = (decimal)(soLuong * donGia);
         tx.tblChiTietPhieuNhap.Add(ct);
         tx.SaveChanges();
         //update sl
         tblChiTietThietBi ctt = tx.tblChiTietThietBi.SingleOrDefault(n => n.MaTB == maTB && n.MaCauHinh == maCauHinh);
         ctt.SoLuong = ctt.SoLuong + soLuong;
         tx.SaveChanges();
         //thong bao
         setAlert("Nhập Sản Phẩm Thành Công", "success");
         return(RedirectToAction("nhapHang"));
     }
     catch (Exception ee)
     {
         setAlert("Error", "error");
         return(RedirectToAction("nhaphang"));
     }
 }