Пример #1
0
        public ActionResult Edit(WorkNC_WorkZone workZone, HttpPostedFileBase upload)
        {
            List <WorkNC_Factory> listFactory = new List <WorkNC_Factory>();
            List <WorkNC_Machine> listMachine = new List <WorkNC_Machine>();

            using (WorkNCDbContext context = new WorkNCDbContext())
            {
                listFactory = db.WorkNC_Factory.ToList();
                listMachine = db.WorkNC_Machine.ToList();
            }
            ViewBag.Factory = new SelectList(listFactory.OrderBy(n => n.Name), "FactoryId", "Name");
            ViewBag.Machine = new SelectList(listMachine.OrderBy(n => n.Name), "MachineId", "Name");

            try
            {
                if (ModelState.IsValid)
                {
                    if (upload != null && upload.ContentLength > 0)
                    {
                    }
                    //workZone.FactoryId = ViewBag.Factory("Name");
                    workZone.ModifiedDate    = DateTime.Now;
                    workZone.ModifiedAccount = User.Identity.Name;
                    db.Entry(workZone).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(workZone));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", e);
                return(View());
            }
        }
Пример #2
0
 public ActionResult Create(WorkNC_Machine machine)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(machine).State = EntityState.Added;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(machine));
     }
     catch
     {
         return(View());
     }
 }
Пример #3
0
 public ActionResult Create(WorkNC_Factory factory)
 {
     try
     {
         if (ModelState.IsValid)
         {
             factory.ModifiedAccount = User.Identity.Name;
             factory.ModifiedDate    = DateTime.Now;
             factory.CreateDate      = DateTime.Now;
             factory.CreateAccount   = User.Identity.Name;
             db.Entry(factory).State = EntityState.Added;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(factory));
     }
     catch
     {
         return(View());
     }
 }
Пример #4
0
 public ActionResult Edit(int?id, WorkNC_WorkZoneDetail zoneDetail)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(zoneDetail).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Edit", "WorkZone", new { id = zoneDetail.WorkZoneId }));
         }
         return(View(zoneDetail));
     }
     catch
     {
         return(View());
     }
 }
Пример #5
0
 public ActionResult Register(WorkNC_UserPermission user)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(user).State = EntityState.Added;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(user));
     }
     catch (Exception)
     {
         return(View());
     }
 }
Пример #6
0
 public ActionResult Edit(WorkNC_Company company)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             company.ModifiedAccount = User.Identity.Name;
             company.ModifiedDate    = DateTime.Now;
             db.Entry(company).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(company));
     }
     catch
     {
         return(View());
     }
 }