Ejemplo n.º 1
0
        public ActionResult Create()
        {
            try
            {
                ViewBag.emp     = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                ViewBag.type    = dbcontext.Exit_permission_type.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                ViewBag.reasons = dbcontext.Exit_Permission_Reason.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });


                var    model    = new Exit_permission_request();
                var    stru     = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Personnel).Structure_Code;
                var    all_data = dbcontext.Exit_permission_request.ToList();
                string number;
                if (all_data.Count > 0)
                {
                    number = stru + (all_data.LastOrDefault().ID + 1).ToString();
                }
                else
                {
                    number = stru + 1;
                }
                model.Request_Number = number; model.Date = DateTime.Now.Date;
                return(View(model));
            }
            catch (Exception)
            {
                return(RedirectToAction("index"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(Exit_permission_request model, FormCollection form)
        {
            try
            {
                ViewBag.emp     = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                ViewBag.type    = dbcontext.Exit_permission_type.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                ViewBag.reasons = dbcontext.Exit_Permission_Reason.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                var s = form["From"].Split(',');
                var e = form["To"].Split(',');
                model.From = Convert.ToDateTime(s[0]).TimeOfDay;
                model.To   = Convert.ToDateTime(e[0]).TimeOfDay;

                var Date  = Convert.ToDateTime("1/1/1900");
                var state = new status {
                    statu = check_status.created, approved_bydate = Date, cancaled_bydate = Date, created_bydate = DateTime.Now.Date, Rejected_bydate = Date, return_to_reviewdate = Date
                };
                state.created_by = User.Identity.GetUserName();
                var st = dbcontext.status.Add(state);
                dbcontext.SaveChanges();

                model.statusID     = st.ID;
                model.check_status = check_status.created;


                dbcontext.Exit_permission_request.Add(model);
                dbcontext.SaveChanges();
                return(RedirectToAction("index"));
            }
            catch (Exception)
            {
                return(View(model));
            }
        }
Ejemplo n.º 3
0
        public ActionResult edit(Exit_permission_request model, FormCollection form)
        {
            try
            {
                ViewBag.emp     = dbcontext.Employee_Profile.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                ViewBag.type    = dbcontext.Exit_permission_type.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });
                ViewBag.reasons = dbcontext.Exit_Permission_Reason.ToList().Select(m => new { Code = m.Code + "-[" + m.Name + ']', ID = m.ID });

                var old_record = dbcontext.Exit_permission_request.FirstOrDefault(m => m.ID == model.ID);
                old_record.Date = model.Date;
                old_record.Employee_ProfileID       = model.Employee_ProfileID;
                old_record.Exit_Permission_ReasonID = model.Exit_Permission_ReasonID;
                old_record.Exit_permission_typeID   = model.Exit_permission_typeID;
                old_record.Notes = model.Notes;
                var s = form["From"].Split(',');
                var e = form["To"].Split(',');
                old_record.From = Convert.ToDateTime(s[0]).TimeOfDay;
                old_record.To   = Convert.ToDateTime(e[0]).TimeOfDay;
                dbcontext.SaveChanges();
                return(RedirectToAction("index"));
            }
            catch (Exception)
            {
                return(View(model));
            }
        }