Exemple #1
0
        public ActionResult Edit(tblmachineallocation tblmachine)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            string       CorrectedDate = null;
            tbldaytiming StartTime     = db.tbldaytimings.Where(m => m.IsDeleted == 0).SingleOrDefault();
            TimeSpan     Start         = StartTime.StartTime;

            if (Start <= DateTime.Now.TimeOfDay)
            {
                CorrectedDate = DateTime.Now.ToString("yyyy-MM-dd");
            }
            else
            {
                CorrectedDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            }
            tblmachine.CorrectedDate = CorrectedDate;
            tblmachine.ModifiedBy    = Convert.ToInt32(Session["UserId"]);
            tblmachine.ModifiedOn    = DateTime.Now;
            tblmachine.IsDeleted     = 0;

            if (ModelState.IsValid)
            {
                db.Entry(tblmachine).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserID = new SelectList(db.tblusers.Where(m => m.IsDeleted == 0 && m.PrimaryRole == 3), "UserID", "DisplayName", tblmachine.UserID);
            //  ViewBag.ShiftID = new SelectList(db.tblshiftdetails_machinewise.Where(m => m.IsDeleted == 0).GroupBy(m => m.ShiftDetailsID), "ShiftDetailsID", "ShiftName");
            ViewBag.MachineID = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0), "MachineID", "MachineDispName", tblmachine.MachineID);

            return(View(tblmachine));
        }
Exemple #2
0
        //
        // GET: /ShiftMaster/Edit/5

        public ActionResult Edit(int id = 0)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            tblmachineallocation tblmachineallocatin = db.tblmachineallocations.Find(id);

            if (tblmachineallocatin == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserID    = new SelectList(db.tblusers.Where(m => m.IsDeleted == 0 && m.PrimaryRole == 3), "UserID", "DisplayName", tblmachineallocatin.UserID);
            ViewBag.ShiftID   = new SelectList(db.tblshift_mstr.Where(m => m.IsDeleted == 0), "ShiftID", "ShiftName", tblmachineallocatin.ShiftID);
            ViewBag.MachineID = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0), "MachineID", "MachineDispName", tblmachineallocatin.MachineID);
            return(View(tblmachineallocatin));
        }
Exemple #3
0
        //
        // GET: /ShiftMaster/Delete/5

        public ActionResult Delete(int id = 0)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            tblmachineallocation tblmachine = db.tblmachineallocations.Find(id);

            if (tblmachine == null)
            {
                return(HttpNotFound());
            }
            tblmachine.IsDeleted       = 1;
            tblmachine.ModifiedBy      = 1;
            tblmachine.ModifiedOn      = System.DateTime.Now;
            db.Entry(tblmachine).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }