public ActionResult Edit(int id, schedule sc)
        {
            try
            {
                using (inventorymgtEntities db = new inventorymgtEntities())
                {
                    db.Entry(sc).State = EntityState.Modified;
                    if (sc.Image == null)
                    {
                        var scheduleContext = db.Entry(sc);
                        scheduleContext.State = EntityState.Modified;

                        var clientValues = scheduleContext.CurrentValues.Clone().ToObject();
                        scheduleContext.Reload();
                        scheduleContext.CurrentValues.SetValues(clientValues);

                        var currentValues  = scheduleContext.Entity;
                        var databaseValues = (schedule)scheduleContext.OriginalValues.ToObject();

                        scheduleContext.Entity.Image = databaseValues.Image;
                    }
                    db.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult Details(user user)
        {
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    string filename  = user.fname.ToLower() + "_" + user.lname.ToLower();
                    string extension = Path.GetExtension(user.ImageFile.FileName);
                    filename      = filename + DateTime.Now.ToString("yymmssfff") + extension;
                    user.img_path = "~/image/" + filename;
                    filename      = Path.Combine(Server.MapPath("~/image/"), filename);
                    user.ImageFile.SaveAs(filename);

                    dbModel.Entry(user).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Details", new { id = user.regId }));
            }
            catch (Exception e)
            {
                Response.Write(e.StackTrace.ToString());
                return(RedirectToAction("Details", new { id = user.regId }));
            }
        }
Beispiel #3
0
        public ActionResult Attendance(int id)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                var userDetails = dbModel.users.Where(x => x.regId == id).FirstOrDefault();
                var atndDetails = dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault();

                //if (DateTime.Now.Date > atndDetails.date_)

                DateTime dt = DateTime.Parse(atndDetails.date_);
                if (DateTime.Now.Date.CompareTo(dt) > 0)
                {
                    atndDetails.status_ = "false";

                    dbModel.Entry(atndDetails).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                int cdays = (int)atndDetails.no_of_days;

                Session["username"] = userDetails.fname + " " + userDetails.lname;
                Session["userId"]   = userDetails.regId;
                Session["progress"] = (100 / 45) * cdays;
                Session["rDays"]    = 45 - cdays;

                return(View(dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault()));
            }
        }
Beispiel #4
0
        public ActionResult Attendance(int id)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                var userDetails = dbModel.users.Where(x => x.regId == id).FirstOrDefault();
                var atndDetails = dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault();

                //if (DateTime.Now.Date > atndDetails.date_)



                DateTime dt = DateTime.Parse(atndDetails.date_);
                if (DateTime.Now.Date.CompareTo(dt) > 0)
                {
                    atndDetails.status_ = "false";

                    dbModel.Entry(atndDetails).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                int cdays = (int)atndDetails.no_of_days;
                int sPlan = 0;
                if (userDetails != null && userDetails.shedule != null)
                {
                    if (userDetails.shedule.ToString() == "D30")
                    {
                        sPlan = 30;
                    }
                    else if (userDetails.shedule.ToString() == "D40")
                    {
                        sPlan = 40;
                    }
                    else if (userDetails.shedule.ToString() == "D45")
                    {
                        sPlan = 45;
                    }
                    else
                    {
                        sPlan = 50;
                    }
                }

                Session["username"] = userDetails.fname + " " + userDetails.lname;
                Session["userId"]   = userDetails.regId;
                Session["progress"] = ((double)cdays / (double)sPlan) * 100 /*/(100 / 45) * cdays*/;
                Session["rDays"]    = sPlan - cdays;

                return(View(dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault()));
            }
        }
Beispiel #5
0
        public ActionResult Edit(int id, storeproduct storepro)
        {
            try
            {
                db.Entry(storepro).State = EntityState.Modified;
                db.SaveChanges();
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, supplier sup)
        {
            try
            {
                using (invtModel)
                {
                    invtModel.Entry(sup).State = EntityState.Modified;
                    invtModel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #7
0
        public ActionResult Edit(int id, trainer Trainer)
        {
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities()) {
                    dbModel.Entry(Trainer).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #8
0
 public ActionResult ChangePassword(user user)
 {
     using (inventorymgtEntities dbModel = new inventorymgtEntities())
     {
         try
         {
             dbModel.Entry(user).State = EntityState.Modified;
             dbModel.SaveChanges();
             return(RedirectToAction("../Login/Login"));
         }
         catch (Exception e)
         {
             Response.Write(e.StackTrace.ToString());
             return(RedirectToAction("Details", new { id = user.regId }));
         }
     }
 }
Beispiel #9
0
        public ActionResult Edit(int id, inventory invent)
        {
            try
            {
                using (inventorymgtEntities invtModel = new inventorymgtEntities())
                {
                    invtModel.Entry(invent).State = EntityState.Modified;
                    invtModel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, leave leave)
        {
            try
            {
                using (inventorymgtEntities inventorymgtEntities = new inventorymgtEntities())
                {
                    inventorymgtEntities.Entry(leave).State = System.Data.Entity.EntityState.Modified;
                    inventorymgtEntities.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #11
0
        public ActionResult Edit(user user)
        {
            // TODO: Add update logic here
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    dbModel.Entry(user).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Details", new { id = user.regId }));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #12
0
        public ActionResult Edit(int id, employee employee)
        {
            try
            {
                using (inventorymgtEntities empModel = new inventorymgtEntities())
                {
                    empModel.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                    empModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #13
0
        public ActionResult Attendance(attendance atd)
        {
            try
            {
                int rdays = 45, cdays = 0;


                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    cdays = (int)atd.no_of_days + 1;
                    if (cdays <= 45)
                    {
                        atd.status_    = "true";
                        atd.date_      = DateTime.Now.Date.ToString();
                        atd.no_of_days = cdays;
                    }
                    else
                    {
                        atd.no_of_days = 1;
                        cdays          = 1;
                    }
                    atd.user_ = (int)Session["userId"];
                    dbModel.Entry(atd).State = EntityState.Modified;
                    dbModel.SaveChanges();

                    rdays = rdays - cdays;
                }

                Session["progress"] = (100 / 45) * cdays;
                Session["rDays"]    = rdays;

                return(View(atd));
            }
            catch (Exception e)
            {
                Response.Write("Error, " + e.StackTrace.ToString());
            }

            return(View(atd));
        }
Beispiel #14
0
        public ActionResult Attendance(attendance atd)
        {
            try
            {
                int rdays = 0, cdays = 0;
                int userId = (int)Session["userId"];
                atd.user_ = userId;

                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    var userDetails = dbModel.users.Where(x => x.regId == userId).FirstOrDefault();
                    if (userDetails != null && userDetails.shedule != null)
                    {
                        if (userDetails.shedule.ToString() == "D30")
                        {
                            rdays = 30;
                        }
                        else if (userDetails.shedule.ToString() == "D40")
                        {
                            rdays = 40;
                        }
                        else if (userDetails.shedule.ToString() == "D45")
                        {
                            rdays = 45;
                        }
                        else
                        {
                            rdays = 50;
                        }
                    }



                    cdays = (int)atd.no_of_days + 1;
                    if (cdays <= rdays)
                    {
                        atd.status_    = "true";
                        atd.date_      = DateTime.Now.Date.ToString();
                        atd.no_of_days = cdays;
                    }
                    else if (cdays > rdays)
                    {
                        atd.no_of_days = 1;
                        cdays          = rdays - 1;
                    }
                    else
                    {
                        atd.no_of_days = 1;
                        cdays          = 1;
                    }

                    var atdDetails = dbModel.attendances.Where(x => x.user_ == userId).FirstOrDefault();

                    if (DateTime.Now.Date.CompareTo(DateTime.Parse(atdDetails.date_)) > 0)
                    {
                        atdDetails.no_of_days           = atd.no_of_days;
                        atdDetails.date_                = atd.date_;
                        dbModel.Entry(atdDetails).State = EntityState.Modified;
                        dbModel.SaveChanges();
                        rdays = rdays - cdays;

                        Session["progress"] = (100 / 45) * cdays;
                        Session["rDays"]    = rdays;
                    }
                }



                return(RedirectToAction("Attendance", "proifle", new { id = userId }));
                //return View(atd);
            }
            catch (Exception e)
            {
                Response.Write("Error, " + e.StackTrace.ToString());
            }

            return(View(atd));
        }