Exemplo n.º 1
0
        public JsonResult changeJob(string[] changeJob)
        {
            //string StaffNr = changeJob[0];
            //int CompanyId = Convert.ToInt16(changeJob[1]);
            //int DepartmentId = Convert.ToInt16(changeJob[2]);
            //int JobTitleId = Convert.ToInt16(changeJob[3]);

            IStaffService ss            = new StaffService(Settings.Default.db);
            Staff         staff         = ss.FindByNr(changeJob[0]);
            string        oldCompany    = staff.Company == null ? string.Empty : staff.Company.name;
            string        oldDepartment = staff.Department == null ? string.Empty : staff.Department.name;
            string        oldJobTitle   = staff.JobTitle == null ? string.Empty : staff.JobTitle.name;
            string        oldJobStr     = string.Format("{0}-{1}-{2}", oldCompany, oldDepartment, oldJobTitle);
            bool          JobReturn     = ss.ChangeJob(changeJob);

            ResultMessage msg;

            if (JobReturn)
            {
                msg = new ResultMessage()
                {
                    Success = true
                };
                //将ID返回给前端用来删除
                msg.Content = "调岗成功";

                // 创建调岗记录##User##
                try
                {
                    Staff  newStaff           = ss.FindByNr(changeJob[0]);
                    string newCompany         = newStaff.Company == null ? string.Empty : newStaff.Company.name;
                    string newDepartment      = newStaff.Department == null ? string.Empty : newStaff.Department.name;
                    string newJobTitle        = newStaff.JobTitle == null ? string.Empty : newStaff.JobTitle.name;
                    string newJobStr          = string.Format("{0}-{1}-{2}", newCompany, newDepartment, newJobTitle);
                    IMessageRecordService mrs = new MessageRecordService(Settings.Default.db);

                    mrs.CreateStaffShiftJobMessage(changeJob[0], (Session["user"] as User).id, oldJobStr, newJobStr);
                }
                catch { }
            }
            else
            {
                msg = new ResultMessage()
                {
                    Success = false
                };
                msg.Content = "调岗失败";
            }

            return(Json(msg, JsonRequestBehavior.DenyGet));
        }