Ejemplo n.º 1
0
 public ActionResult Edit(MaterialIn materialin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(materialin).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(materialin);
 }
Ejemplo n.º 2
0
        public ActionResult Create(MaterialIn materialin)
        {
            if (ModelState.IsValid)
            {
                db.MaterialIns.Add(materialin);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(materialin);
        }
Ejemplo n.º 3
0
        public ActionResult MaterialInView(int id,string act)
        {
            if (!UserInfo.CurUser.HasRight("物资设备-物资入库查询")) return Redirect("~/content/AccessDeny.htm");
            var r = (from o in db.MaterialIns where o.Id == id select o).FirstOrDefault();

            if (r == null)
            {
                r = new MaterialIn();
            }
            ViewBag.Items = (from o in db.MaterialInItems where o.MaterialId == id select o).ToList();
            using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                conn.Open();
                var items =
                    conn.Query(
                        string.Format("select m.DepartmentId, m.Name,m.CatalogId,i.UnitPrice,i.Num from materialinitems i join materials m on i.materialid=m.id where i.inid={0}", r.Id));
                ViewBag.Items2 = items;
            }
            //ViewBag.Items1 = (from o in db.MaterialInItems select new { UnitPrice = o.UnitPrice, Num = o.Num }).ToList();
            if (act == "print")
                return View("MaterialInPrint", r);
            return View(r);
        }
Ejemplo n.º 4
0
        public ActionResult MaterialInEdit(int id, string itemsString, FormCollection collection)
        {
            if (!UserInfo.CurUser.HasRight("物资设备-物资入库输入")) return Redirect("~/content/AccessDeny.htm");
            MaterialIn r = (from o in db.MaterialIns where o.Id == id select o).FirstOrDefault();
            if (r == null)
            {
                r = new MaterialIn {MallId = mallid}; db.MaterialIns.Add(r);
            }
            MaterialIn v=new MaterialIn();
            TryUpdateModel(r, collection);
            r.PersonId = UserInfo.CurUser.Id;
            List<MaterialInItem> items = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MaterialInItem>>(itemsString);
            foreach (var materialInItem in items)
            {
                if (materialInItem.MaterialId == 0) ModelState.AddModelError("", "请选择物料");
            }
            if(items.Count==0)
            {
                ModelState.AddModelError("", "入库单的物料明细不能为空");
            }
            if (ModelState.IsValid == false)
            {
                ViewBag.ItemsString = Newtonsoft.Json.JsonConvert.SerializeObject(items);
                return View(r);
            }
            else
            {
                db.SaveChanges();
                (from o in db.MaterialInItems where o.InId == r.Id select o).ToList().ForEach(o => db.MaterialInItems.Remove(o));
                foreach (var item in items)
                {
                    item.InId = r.Id;
                    db.MaterialInItems.Add(item);
                }
                db.SaveChanges();
                return Redirect("../MaterialInView/" + r.Id);

            }
        }
Ejemplo n.º 5
0
 public ActionResult MaterialInEdit(int id)
 {
     if (!UserInfo.CurUser.HasRight("物资设备-物资入库输入")) return Redirect("~/content/AccessDeny.htm");
     var r = (from o in db.MaterialIns where o.Id == id select o).FirstOrDefault();
     if (r == null)
     {
         r = new MaterialIn();
     }
     List<MaterialInItem> items = (from o in db.MaterialInItems where o.InId == id select o).ToList();
     ViewBag.ItemsString = Newtonsoft.Json.JsonConvert.SerializeObject(items);
     return View(r);
 }