public ActionResult Create(FormCollection formcollection)
        {
            var phieuyeucau = new tbl_PhieuYeuCauNhap();
            //var userSession = (UserLogin)Session[Common.CommonConstants.USER_SESSION];
            //var IDNCC = formcollection["hdnNCC"];
            long IDNCC = long.Parse(formcollection["hdnNCC"]);

            phieuyeucau.IDncc = IDNCC;
            try
            {
                var id = new PhieuYeuCauDAO().Insert(phieuyeucau);
                var phieuyeucaulist = (List <PhieuYeuCauViewModel>)Session[SESSION_PRODUCT_YC];
                var detailDao       = new Model.DAO.ChiTietPhieuYCDAO();
                var addquantity     = new SanPhamDAO();
                foreach (var item in phieuyeucaulist)
                {
                    var phieuyeucaudetail = new tbl_ChiTietPhieuYC();
                    phieuyeucaudetail.IDSanPham     = item.sanPham.ID;
                    phieuyeucaudetail.IDPhieuYeuCau = id;
                    phieuyeucaudetail.iSoLuongYC    = item.iSoLuongYC;
                    detailDao.Insert(phieuyeucaudetail);
                    addquantity.addquantitySanPham(item.sanPham.ID, item.iSoLuongYC);
                }
            }
            catch (Exception ex)
            {
                return(Redirect("/Admin/PhieuYeuCauNhap/Create"));
            }
            Session[SESSION_PRODUCT_YC] = null;
            return(Redirect("/Admin/PhieuYeuCauNhap/Index"));
        }
 public long Insert(tbl_PhieuYeuCauNhap phieuyeucau)
 {
     db.tbl_PhieuYeuCauNhap.Add(phieuyeucau);
     db.SaveChanges();
     return(phieuyeucau.IDPhieuYeuCau);
 }