Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            FacPopulation facPopulation = _db.FacPopulation.Find(id);

            _db.FacPopulation.Remove(facPopulation);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Create([Bind(Include = "PopID,Date,FacID,PopTotal,PopNew,PopLeft,PopLeft3")] FacPopulation facPopulation)
 {
     if (ModelState.IsValid)
     {
         _db.FacPopulation.Add(facPopulation);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(facPopulation));
 }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "PopID,Date,FacID,PopTotal,PopNew,PopLeft,PopLeft3")] FacPopulation facPopulation)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(facPopulation).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Factory = new SelectList(_db.Factories, "FacID", "FacName", facPopulation.FacID);
     return(View(facPopulation));
 }
Esempio n. 4
0
        //以下刪除
        // GET: FacPopulations/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FacPopulation facPopulation = _db.FacPopulation.Find(id);

            if (facPopulation == null)
            {
                return(HttpNotFound());
            }
            return(View(facPopulation));
        }
Esempio n. 5
0
        //以下修改
        // GET: FacPopulations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FacPopulation facPopulation = _db.FacPopulation.Find(id);

            if (facPopulation == null)
            {
                return(HttpNotFound());
            }

            int userdata = 0;

            if (User.Identity.IsAuthenticated)
            {
                FormsIdentity             idd    = (FormsIdentity)HttpContext.User.Identity;
                FormsAuthenticationTicket ticket = idd.Ticket;
                userdata = Convert.ToInt32(ticket.UserData);
                Session.Add("userdata", userdata);
                PCGEntities db = new PCGEntities();

                var query = (from ad in db.Administrators
                             where ad.EmployeeID == userdata
                             select ad.Name).First();
                string name = query;
                Session.Add("Name", name);
            }
            else
            {
                Session.Add("Name", "Guset");
            }
            eid = Convert.ToInt32(Session["userdata"]);
            var qq = _db.Permission.Where(x => x.EmployeeID == eid).Select(x => x.FacNo);

            if (eid != 5)
            {
                ViewBag.Factory = new SelectList(_db.Factories.Where(x => x.FacNo == qq.FirstOrDefault()), "FacID", "FacName", facPopulation.FacID);
            }
            else
            {
                ViewBag.Factory = new SelectList(_db.Factories, "FacID", "FacName", facPopulation.FacID);
            }
            return(View(facPopulation));
        }