示例#1
0
        public ActionResult status(string id)
        {
            try
            {
                var ID    = int.Parse(id);
                var model = dbcontext.TimeManagement_EmployeeTimeAttendanceTransaction_Header.FirstOrDefault(m => m.ID == ID);
                var st    = dbcontext.status.FirstOrDefault(m => m.ID == model.statID);
                ViewBag.statue = dbcontext.status.ToList().Select(m => new { code = m.approved_by });
                var my_model = new employeestate {
                    status = st, empid = ID
                };

                //if (my_model.status.approved_by == null)
                //    my_model.status.approved_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                //if (my_model.status.Rejected_by == null)
                //    my_model.status.Rejected_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                //if (my_model.status.return_to_reviewby == null)
                //    my_model.status.return_to_reviewdate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                //if (my_model.status.cancaled_by == null)
                //    my_model.status.cancaled_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                return(View(my_model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("index"));
            }
        }
示例#2
0
 public ActionResult status(string id)
 {
     try
     {
         var ID    = int.Parse(id);
         var model = dbcontext.Exit_permission_request.FirstOrDefault(m => m.ID == ID);
         var st    = dbcontext.status.FirstOrDefault(m => m.ID == model.statusID);
         ViewBag.statue = dbcontext.status.ToList().Select(m => new { code = m.approved_by });
         var my_model = new employeestate {
             status = model.status, opertion_id = model.ID
         };
         if (my_model.status.approved_by == null)
         {
             my_model.status.approved_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (my_model.status.Rejected_by == null)
         {
             my_model.status.Rejected_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (my_model.status.return_to_reviewby == null)
         {
             my_model.status.return_to_reviewdate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (my_model.status.cancaled_by == null)
         {
             my_model.status.cancaled_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         return(View(my_model));
     }
     catch (Exception e)
     {
         return(RedirectToAction("index"));
     }
 }
        public ActionResult status(employeestate model)
        {
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.new_contrct.FirstOrDefault(m => m.ID == model.opertion_id);

            if (model.check_status == check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                sta.statu           = check_status.Approved;
                dbcontext.SaveChanges();
                var flag = add_contract_(model.opertion_id.ToString());
                if (flag == true)
                {
                    var ms = HR.Resource.pers_2.addedSuccessfully;
                    return(RedirectToAction("Index", new { mess = ms }));
                }
                else
                {
                    var ms = HR.Resource.pers_2.Faild;
                    return(RedirectToAction("Index", new { mess = ms }));
                }
            }
            //else if (model.check_status == check_status.Canceled)
            //{

            //    sta.cancaled_by = model.status.cancaled_by;
            //    sta.cancaled_bydate = model.status.cancaled_bydate;
            //    sta.statu = check_status.Canceled;
            //    dbcontext.SaveChanges();
            //}
            //else if (model.check_status == check_status.created)
            //{
            //    sta.created_by = model.status.created_by;
            //    sta.created_bydate = model.status.created_bydate;
            //    sta.statu = check_status.created;
            //    dbcontext.SaveChanges();
            //}
            else if (model.check_status == check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                sta.statu           = check_status.Rejected;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                sta.statu = check_status.Return_To_Review;
                dbcontext.SaveChanges();
            }

            return(RedirectToAction("index"));
        }
示例#4
0
        public ActionResult status(employeestate model)
        {
            //  var sta = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.Exit_permission_request.FirstOrDefault(m => m.ID == model.opertion_id);
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == record.statusID);

            if (model.check_status == check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                sta.statu           = check_status.Approved;
                record.check_status = check_status.Approved;
                dbcontext.SaveChanges();
            }
            //else if (model.check_status == check_status.Canceled)
            //{
            //    sta.cancaled_by = model.status.cancaled_by;
            //    sta.cancaled_bydate = model.status.cancaled_bydate;
            //    sta.statu = check_status.Canceled;
            //    record.check_status = check_status.Canceled;
            //    record.sss = record.check_status.GetType().ToString();
            //    record.name_state = nameof(check_status.Canceled);
            //    dbcontext.SaveChanges();
            //}
            //else if (model.check_status == check_status.created)
            //{
            //    sta.created_by = model.status.created_by;
            //    sta.created_bydate = model.status.created_bydate;
            //    sta.statu = check_status.created;
            //    record.check_status = check_status.created;
            //    record.sss = record.check_status.GetType().ToString();
            //    record.name_state = nameof(check_status.created);
            //    dbcontext.SaveChanges();
            //}
            else if (model.check_status == check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                sta.statu           = check_status.Rejected;
                record.check_status = check_status.Rejected;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                sta.statu           = check_status.Return_To_Review;
                record.check_status = check_status.Return_To_Review;
                dbcontext.SaveChanges();
            }

            return(RedirectToAction("index"));
        }
 public ActionResult status(string id)
 {
     try
     {
         var ID    = int.Parse(id);
         var model = dbcontext.Committe_Resolution_Recuirtment.FirstOrDefault(m => m.ID == ID);
         var st    = dbcontext.status.FirstOrDefault(m => m.ID == model.statID);
         ViewBag.statue = dbcontext.status.ToList().Select(m => new { code = m.approved_by });
         var my_model = new employeestate {
             status = st, empid = ID
         };
         return(View(my_model));
     }
     catch (Exception e)
     {
         return(RedirectToAction("index"));
     }
 }
示例#6
0
 public ActionResult status(string id)
 {
     try
     {
         var ID    = int.Parse(id);
         var model = dbcontext.ManualPaymentTransactionEntry.FirstOrDefault(m => m.ID == ID);
         var st    = dbcontext.status.FirstOrDefault(m => m.ID == model.statID);
         ViewBag.statue = dbcontext.status.ToList().Select(m => new { code = m.approved_by });
         var my_model = new employeestate {
             status = st, empid = ID
         };
         if (st.approved_by == null)
         {
             st.approved_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (st.Rejected_by == null)
         {
             st.Rejected_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (st.return_to_reviewby == null)
         {
             st.return_to_reviewdate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (st.cancaled_by == null)
         {
             st.cancaled_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (st.closed_by == null)
         {
             st.closed_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         if (st.Recervied_by == null)
         {
             st.Recervied_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
         }
         return(View(my_model));
     }
     catch (Exception e)
     {
         return(RedirectToAction("index"));
     }
 }
示例#7
0
        public ActionResult status(employeestate model)
        {
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.TimeManagement_EmployeeTimeAttendanceTransaction_Header.FirstOrDefault(m => m.ID == model.empid);

            //var committe = dbcontext.Committe_Resolution_Recuirtment.Select(a => a.Committe_Resolution_Status).ToList();
            if (model.check_status == HR.Models.Infra.check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                record.check_status = HR.Models.Infra.check_status.Approved;
                record.name_state   = nameof(check_status.Approved);
                record.ApprovedBy   = User.Identity.Name;
                record.ApprovedDate = DateTime.Now.Date;

                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                record.check_status = HR.Models.Infra.check_status.Rejected;
                record.name_state   = nameof(check_status.Rejected);
                record.RejectedBy   = User.Identity.Name;
                record.RejectedDate = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                record.check_status      = HR.Models.Infra.check_status.Return_To_Review;
                record.name_state        = nameof(check_status.Return_To_Review);
                record.ReportAsReadyBy   = User.Identity.Name;
                record.ReportAsReadyDate = DateTime.Now.Date;

                dbcontext.SaveChanges();
            }

            return(RedirectToAction("index"));
        }
        public ActionResult status(string id)
        {
            try
            {
                var ID    = int.Parse(id);
                var model = dbcontext.Employee_records.FirstOrDefault(m => m.ID == ID);
                var st    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
                ViewBag.statue = dbcontext.status.ToList().Select(m => new { code = m.approved_by });
                var my_model = new employeestate {
                    status = st, empid = ID
                };
                //my_model.status.approved_by = User.Identity.GetUserName();
                //my_model.status.Rejected_by = User.Identity.GetUserName();
                //my_model.status.approved_bydate = DateTime.Now.Date;
                //my_model.status.Rejected_bydate = DateTime.Now.Date;

                if (my_model.status.approved_by == null)
                {
                    my_model.status.approved_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                }
                if (my_model.status.Rejected_by == null)
                {
                    my_model.status.Rejected_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                }
                if (my_model.status.return_to_reviewby == null)
                {
                    my_model.status.return_to_reviewdate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                }
                if (my_model.status.cancaled_by == null)
                {
                    my_model.status.cancaled_bydate = Convert.ToDateTime(DateTime.Now.Date.ToShortDateString());
                }
                return(View(my_model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("index"));
            }
        }
        public ActionResult status(employeestate model)
        {
            var sta      = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record   = dbcontext.Committe_Resolution_Recuirtment.FirstOrDefault(m => m.ID == model.empid);
            var committe = dbcontext.Committe_Resolution_Recuirtment.Select(a => a.Committe_Resolution_Status).ToList();

            if (model.check_status == check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                record.check_status = check_status.Approved;
                record.name_state   = nameof(check_status.Approved);
                record.Committe_Resolution_Status = Committe_Resolution_Status.Approved;
                dbcontext.SaveChanges();
            }

            else if (model.check_status == check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                record.check_status = check_status.Rejected;
                record.name_state   = nameof(check_status.Rejected);
                record.Committe_Resolution_Status = Committe_Resolution_Status.Rejected;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == check_status.Return_To_Review)
            {
                sta.return_to_reviewby            = User.Identity.GetUserName();
                sta.return_to_reviewdate          = model.status.return_to_reviewdate;
                record.check_status               = check_status.Return_To_Review;
                record.name_state                 = nameof(check_status.Return_To_Review);
                record.Committe_Resolution_Status = Committe_Resolution_Status.Canceled;
                dbcontext.SaveChanges();
            }
            return(RedirectToAction("index"));
        }
        public ActionResult status(employeestate model)
        {
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.Employee_records.FirstOrDefault(m => m.ID == model.empid);

            if (model.check_status == check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                record.check_status = check_status.Approved;
                record.name_state   = nameof(check_status.Approved);
                dbcontext.SaveChanges();
            }
            //else if (model.check_status == check_status.Canceled)
            //{

            //    sta.cancaled_by = model.status.cancaled_by;
            //    sta.cancaled_bydate = model.status.cancaled_bydate;
            //    record.check_status = check_status.Canceled;
            //    record.name_state = nameof(check_status.Canceled);
            //    dbcontext.SaveChanges();
            //}
            //else if (model.check_status == check_status.created)
            //{
            //    sta.created_by = model.status.created_by;
            //    sta.created_bydate = model.status.created_bydate;
            //    record.check_status = check_status.created;
            //    record.name_state = nameof(check_status.created);
            //    dbcontext.SaveChanges();
            //}
            else if (model.check_status == check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                record.check_status = check_status.Rejected;
                record.name_state   = nameof(check_status.Rejected);
                dbcontext.SaveChanges();
            }
            else if (model.check_status == check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                record.check_status      = check_status.Return_To_Review;
                record.name_state        = nameof(check_status.Return_To_Review);
                dbcontext.SaveChanges();
            }
            //=================================check for alert==================================
            var get_result_check = HR.Controllers.check.check_alert("employee record process", HR.Models.user.Action.Create, HR.Models.user.type_field.form);

            if (get_result_check != null)
            {
                var inbox = new Models.user.Alert_inbox {
                    send_from_user_id = User.Identity.Name, send_to_user_id = get_result_check.send_to_ID_user, title = get_result_check.Subject + model.check_status, Subject = get_result_check.Message
                };
                if (get_result_check.until != null)
                {
                    if (get_result_check.until.Value.Year != 0001)
                    {
                        inbox.until = get_result_check.until;
                    }
                }
                ApplicationDbContext dbcontext = new ApplicationDbContext();
                dbcontext.Alert_inbox.Add(inbox);
                dbcontext.SaveChanges();
            }
            //===================================================================================
            return(RedirectToAction("index"));
        }
        public ActionResult status(employeestate model)
        {
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.LeavesRequestMaster.FirstOrDefault(m => m.ID == model.empid);

            //var committe = dbcontext.Committe_Resolution_Recuirtment.Select(a => a.Committe_Resolution_Status).ToList();
            if (model.check_status == HR.Models.Infra.check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                sta.statu           = Models.Infra.check_status.Approved;
                record.check_status = HR.Models.Infra.check_status.Approved;
                record.name_state   = nameof(check_status.Approved);
                record.Approved     = check_status.Approved.GetHashCode();
                record.ApprovedBy   = User.Identity.Name;
                //record.ApprovedDate = DateTime.Now.Date;

                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                sta.statu           = Models.Infra.check_status.Rejected;
                record.check_status = HR.Models.Infra.check_status.Rejected;
                record.name_state   = nameof(check_status.Rejected);
                record.Approved     = check_status.Rejected.GetHashCode();
                record.RejectedBy   = User.Identity.Name;
                //record.RejectedDate = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                sta.statu              = Models.Infra.check_status.Return_To_Review;
                record.check_status    = HR.Models.Infra.check_status.Return_To_Review;
                record.name_state      = nameof(check_status.Return_To_Review);
                record.Approved        = check_status.Return_To_Review.GetHashCode();
                record.ReportAsReadyBy = User.Identity.Name;
                //record.ReportAsReadyDate = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Closed)
            {
                sta.closed_by     = User.Identity.GetUserName();
                sta.closed_bydate = model.status.closed_bydate;
                sta.statu         = HR.Models.Infra.check_status.Closed;
                dbcontext.SaveChanges();
                record.check_status = HR.Models.Infra.check_status.Closed;
                record.name_state   = nameof(check_status.Closed);
                record.Approved     = check_status.Closed.GetHashCode();
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Canceled)
            {
                sta.cancaled_by     = User.Identity.GetUserName();
                sta.cancaled_bydate = model.status.cancaled_bydate;
                sta.statu           = Models.Infra.check_status.Canceled;
                dbcontext.SaveChanges();
                record.check_status = HR.Models.Infra.check_status.Canceled;
                record.name_state   = nameof(check_status.Canceled);
                record.Approved     = check_status.Canceled.GetHashCode();
                record.CanceledBy   = User.Identity.Name;
                //record.CanceledDate = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Recervied)
            {
                sta.Recervied_by     = User.Identity.GetUserName();
                sta.Recervied_bydate = model.status.Recervied_bydate;
                sta.statu            = Models.Infra.check_status.Recervied;
                dbcontext.SaveChanges();
                record.check_status = HR.Models.Infra.check_status.Recervied;
                record.name_state   = nameof(check_status.Recervied);
                record.Approved     = check_status.Recervied.GetHashCode();
                dbcontext.SaveChanges();
            }

            return(RedirectToAction("index"));
        }
        public ActionResult status(employeestate model)
        {
            //  var sta = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.EOS_Request.FirstOrDefault(m => m.ID == model.opertion_id);
            var sta    = record.status;

            if (model.check_status == check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                sta.statu           = check_status.Approved;
                record.check_status = check_status.Approved;
                record.sss          = record.check_status.GetTypeCode().ToString();

                record.name_state = nameof(check_status.Approved);
                dbcontext.SaveChanges();


                var employee = dbcontext.Employee_Profile.FirstOrDefault(m => m.ID == model.empid);
                employee.Service_Information.EOS_date          = record.Date_of_EOS;
                employee.Service_Information.Last_working_date = record.last_work_day_before_request;
                employee.Active = false;
                dbcontext.SaveChanges();
                ////    employee.Employee_Positions_Profile.EOS_reasons = record.EOS_type;
                var current_postion = dbcontext.Position_Information.FirstOrDefault(m => m.Primary_Position == true && m.Employee_Profile.ID == employee.ID);
                current_postion.End_of_service_date = record.last_Date_of_work_after_notice_period;
                current_postion.Last_working_date   = record.last_work_day_before_request;
                current_postion.Primary_Position    = false;
                dbcontext.SaveChanges();
                var slot_id = int.Parse(current_postion.SlotdescId);
                var slot    = dbcontext.Slots.FirstOrDefault(m => m.ID == slot_id);
                var job     = dbcontext.job_title_cards.FirstOrDefault(m => m.ID == slot.job_title_cards.ID);////update vacant and hired number
                job.number_hired  = job.number_hired - 1;
                job.number_vacant = job.number_vacant + 1;
                dbcontext.SaveChanges();
                slot.Employee_Profile = null;
                slot.EmployeeID       = null;
                slot.EmployeeName     = null;
                dbcontext.SaveChanges();
            }
            //else if (model.check_status == check_status.Canceled)
            //{
            //    sta.cancaled_by = model.status.cancaled_by;
            //    sta.cancaled_bydate = model.status.cancaled_bydate;
            //    sta.statu = check_status.Canceled;
            //    record.check_status = check_status.Canceled;
            //    record.sss = record.check_status.GetType().ToString();
            //    record.name_state = nameof(check_status.Canceled);
            //    dbcontext.SaveChanges();
            //}
            //else if (model.check_status == check_status.created)
            //{
            //    sta.created_by = model.status.created_by;
            //    sta.created_bydate = model.status.created_bydate;
            //    sta.statu = check_status.created;
            //    record.check_status = check_status.created;
            //    record.sss = record.check_status.GetType().ToString();
            //    record.name_state = nameof(check_status.created);
            //    dbcontext.SaveChanges();
            //}
            else if (model.check_status == check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                sta.statu           = check_status.Rejected;
                record.check_status = check_status.Rejected;
                record.sss          = record.check_status.GetType().ToString();
                record.name_state   = nameof(check_status.Rejected);
                dbcontext.SaveChanges();
            }
            else if (model.check_status == check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                sta.statu           = check_status.Return_To_Review;
                record.check_status = check_status.Return_To_Review;
                record.sss          = record.check_status.GetHashCode().ToString();
                record.name_state   = nameof(check_status.Return_To_Review);
                dbcontext.SaveChanges();
            }

            return(RedirectToAction("index"));
        }
示例#13
0
        public ActionResult status(employeestate model)
        {
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.ManualPaymentTransactionEntry.FirstOrDefault(m => m.ID == model.empid);

            if (model.check_status == HR.Models.Infra.check_status.Approved)
            {
                sta.approved_by          = User.Identity.GetUserName();
                sta.approved_bydate      = model.status.approved_bydate;
                sta.statu                = Models.Infra.check_status.Approved;
                record.check_status      = HR.Models.Infra.check_status.Approved;
                record.name_state        = nameof(check_status.Approved);
                record.TransactionStatus = check_status.Approved.GetHashCode();
                record.ApprovedBy        = User.Identity.Name;
                record.ApprovedDate      = DateTime.Now.Date;

                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Rejected)
            {
                sta.Rejected_by          = User.Identity.GetUserName();
                sta.Rejected_bydate      = model.status.Rejected_bydate;
                sta.statu                = Models.Infra.check_status.Rejected;
                record.check_status      = HR.Models.Infra.check_status.Rejected;
                record.name_state        = nameof(check_status.Rejected);
                record.TransactionStatus = check_status.Rejected.GetHashCode();
                record.RejectedBy        = User.Identity.Name;
                record.RejectedDate      = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                sta.statu                = Models.Infra.check_status.Return_To_Review;
                record.check_status      = HR.Models.Infra.check_status.Return_To_Review;
                record.name_state        = nameof(check_status.Return_To_Review);
                record.TransactionStatus = check_status.Return_To_Review.GetHashCode();
                record.ReportAsReadyBy   = User.Identity.Name;
                record.ReportAsReadyDate = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Closed)
            {
                sta.closed_by     = User.Identity.GetUserName();
                sta.closed_bydate = model.status.closed_bydate;
                sta.statu         = HR.Models.Infra.check_status.Closed;
                dbcontext.SaveChanges();
                record.check_status      = HR.Models.Infra.check_status.Closed;
                record.name_state        = nameof(check_status.Closed);
                record.TransactionStatus = check_status.Closed.GetHashCode();
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Canceled)
            {
                sta.cancaled_by     = User.Identity.GetUserName();
                sta.cancaled_bydate = model.status.cancaled_bydate;
                sta.statu           = Models.Infra.check_status.Canceled;
                dbcontext.SaveChanges();
                record.check_status      = HR.Models.Infra.check_status.Canceled;
                record.name_state        = nameof(check_status.Canceled);
                record.TransactionStatus = check_status.Canceled.GetHashCode();
                record.CanceledBy        = User.Identity.Name;
                record.CanceledDate      = DateTime.Now.Date;
                dbcontext.SaveChanges();
            }
            else if (model.check_status == HR.Models.Infra.check_status.Recervied)
            {
                sta.Recervied_by     = User.Identity.GetUserName();
                sta.Recervied_bydate = model.status.Recervied_bydate;
                sta.statu            = Models.Infra.check_status.Recervied;
                dbcontext.SaveChanges();
                record.check_status      = HR.Models.Infra.check_status.Recervied;
                record.name_state        = nameof(check_status.Recervied);
                record.TransactionStatus = check_status.Recervied.GetHashCode();
                dbcontext.SaveChanges();
            }
            return(RedirectToAction("index"));
        }
示例#14
0
        public ActionResult status(employeestate model)
        {
            var sta    = dbcontext.status.FirstOrDefault(m => m.ID == model.status.ID);
            var record = dbcontext.personnel_transaction.FirstOrDefault(m => m.ID == model.opertion_id);

            if (model.check_status == check_status.Approved)
            {
                sta.approved_by     = User.Identity.GetUserName();
                sta.approved_bydate = model.status.approved_bydate;
                record.check_status = check_status.Approved;
                record.name_state   = nameof(check_status.Approved);
                dbcontext.SaveChanges();
                var go = new TRANS_VM {
                    personnel_transaction = record, selected_employee = model.empid
                };
                ///////////////update old position//////////
                var old_position = dbcontext.Position_Information.FirstOrDefault(m => m.Primary_Position == true && m.Employee_ProfileId == go.selected_employee.ToString());
                old_position.Primary_Position = false;
                old_position.To_date          = go.personnel_transaction.Last_working_date;
                dbcontext.SaveChanges();
                //old_slot = new Slots();
                var slot_id  = int.Parse(old_position.SlotdescId);
                var old_slot = dbcontext.Slots.FirstOrDefault(m => m.ID == slot_id);
                ////var emp = dbcontext.Employee_Profile.FirstOrDefault(m => m.ID == old_slot.Employee_Profile.ID);
                var job = dbcontext.job_title_cards.FirstOrDefault(m => m.ID == old_slot.job_title_cards.ID);////update vacant and hired number
                job.number_hired  = job.number_hired - 1;
                job.number_vacant = job.number_vacant + 1;
                dbcontext.SaveChanges();
                old_slot.Employee_Profile = null;
                dbcontext.SaveChanges();
                old_slot.EmployeeName = null;
                old_slot.EmployeeID   = null;
                dbcontext.SaveChanges();

                add_new_postion(go);
            }
            //else if (model.check_status == check_status.Canceled)
            //{

            //    sta.cancaled_by = model.status.cancaled_by;
            //    sta.cancaled_bydate = model.status.cancaled_bydate;
            //    record.check_status = check_status.Canceled;

            //    record.name_state = nameof(check_status.Canceled);
            //    dbcontext.SaveChanges();
            //}
            //else if (model.check_status == check_status.created)
            //{
            //    sta.created_by = model.status.created_by;
            //    sta.created_bydate = model.status.created_bydate;
            //    record.check_status = check_status.created;

            //    record.name_state = nameof(check_status.created);
            //    dbcontext.SaveChanges();
            //}
            else if (model.check_status == check_status.Rejected)
            {
                sta.Rejected_by     = User.Identity.GetUserName();
                sta.Rejected_bydate = model.status.Rejected_bydate;
                record.check_status = check_status.Rejected;
                record.name_state   = nameof(check_status.Rejected);
                dbcontext.SaveChanges();
            }
            else if (model.check_status == check_status.Return_To_Review)
            {
                sta.return_to_reviewby   = User.Identity.GetUserName();
                sta.return_to_reviewdate = model.status.return_to_reviewdate;
                record.check_status      = check_status.Return_To_Review;
                record.name_state        = nameof(check_status.Return_To_Review);
                dbcontext.SaveChanges();
            }
            //=================================check for alert==================================
            var get_result_check = HR.Controllers.check.check_alert("personnel transaction process", HR.Models.user.Action.Create, HR.Models.user.type_field.form);

            if (get_result_check != null)
            {
                var inbox = new Models.user.Alert_inbox {
                    send_from_user_id = User.Identity.Name, send_to_user_id = get_result_check.send_to_ID_user, title = get_result_check.Subject + model.check_status, Subject = get_result_check.Message
                };
                if (get_result_check.until != null)
                {
                    if (get_result_check.until.Value.Year != 0001)
                    {
                        inbox.until = get_result_check.until;
                    }
                }
                ApplicationDbContext dbcontext = new ApplicationDbContext();
                dbcontext.Alert_inbox.Add(inbox);
                dbcontext.SaveChanges();
            }
            //===================================================================================
            return(RedirectToAction("index"));
        }