Esempio 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));
        }
Esempio n. 2
0
        public ActionResult DoResign([Bind(Include = "resignTypeId, staffNr, resignAt,resignChecker,remark")] ResignRecord record)
        {
            //用户创建员工离职记录:
            //•	离职原因(选择,不可空)
            //•	离职日期(选择,不可空)
            //•	离职批准人(输入,可空)
            //•	备注(输入,可空)
            //如果离职记录创建成功,则将人员在职状态改为:离职

            ResultMessage msg = new ResultMessage();

            IResignRecordService ss = new ResignRecordService(Settings.Default.db);

            msg = ss.Create(record);

            if (msg.Success)
            {
                IStaffService staffSi = new StaffService(Settings.Default.db);
                Staff         staff   = staffSi.FindByNr(record.staffNr);

                staff.workStatus = (int)WorkStatus.OffWork;
                staff.resignAt   = record.resignAt;
                staffSi.Update(staff);
            }

            // 创建离职记录##User##
            try
            {
                IMessageRecordService mrs = new MessageRecordService(Settings.Default.db);
                mrs.CreateStaffResignMessage(record.staffNr, (Session["user"] as User).id);
            }
            catch { }
            return(Json(msg));
        }
Esempio n. 3
0
        public ActionResult ToFullMemeber(string nr)
        {
            IStaffService ss    = new StaffService(Settings.Default.db);
            Staff         staff = ss.FindByNr(nr);

            return(View(staff));
        }
Esempio n. 4
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);

            CertificateSearchModel q = new CertificateSearchModel();

            ICertificateService ss = new CertificateService(Settings.Default.db);

            q.StaffActNr = this.Request.QueryString["nr"];
            IPagedList <Certificate> certfs = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            CertificateInfoModel info = ss.GetCertificateInfo(q);

            ViewBag.Info = info;

            //get staff info
            string        staffNr = this.Request.QueryString["nr"];
            IStaffService sts     = new StaffService(Settings.Default.db);

            Staff stfModel = sts.FindByNr(staffNr);

            ViewBag.StfModel = stfModel;


            return(View(certfs));
        }
Esempio n. 5
0
        public ActionResult Resign(string nr)
        {
            IStaffService ss    = new StaffService(Settings.Default.db);
            Staff         staff = ss.FindByNr(nr);

            SetResignTypeList(null);
            return(View(staff));
        }
Esempio n. 6
0
        public ResultMessage DoValidation(ShiftSchedule model)
        {
            ResultMessage msg = new ResultMessage();

            if (string.IsNullOrEmpty(model.staffNr))
            {
                msg.Success = false;
                msg.Content = "员工不能为空";

                return(msg);
            }

            if (model.scheduleAt == null || model.scheduleAt == DateTime.MinValue)
            {
                msg.Success = false;
                msg.Content = "日期不能为空";

                return(msg);
            }

            if (model.shiftId == 0)
            {
                msg.Success = false;
                msg.Content = "班次不能为空";

                return(msg);
            }

            IStaffService ss = new StaffService(Settings.Default.db);

            if (ss.FindByNr(model.staffNr) == null)
            {
                msg.Success = false;
                msg.Content = "员工号不存在";

                return(msg);
            }

            IShiftScheduleService cs = new ShiftSheduleService(Settings.Default.db);

            if (cs.IsDup(model))
            {
                msg.Success = false;
                msg.Content = "排班已存在,不可重复排班";

                return(msg);
            }

            return(new ResultMessage()
            {
                Success = true, Content = ""
            });
        }
Esempio n. 7
0
        public ActionResult Edit(string nr)
        {
            IStaffService ss = new StaffService(Settings.Default.db);

            Staff staff = ss.FindByNr(nr);

            SetDropDownList(staff);
            StaffSearchModel q = new StaffSearchModel();

            try
            {
                q.companyId    = staff.companyId;
                q.departmentId = staff.departmentId;
            }
            catch (Exception)
            {
                q.companyId    = null;
                q.departmentId = null;
            }
            ViewBag.Query = q;

            return(View(staff));
        }
Esempio n. 8
0
        //•	员工号(输入,不可空)
        //•	缺勤类别(选择,不可空)
        //•	缺勤原因(输入,可空),
        //•	缺勤的小时或天长。(输入,不可空)
        //•	时间单位(选择,不可空,选项为: 小时/天,默认为小时)
        public ResultMessage DoValidation(AbsenceRecrod model)
        {
            ResultMessage msg = new ResultMessage();

            if (string.IsNullOrEmpty(model.staffNr))
            {
                msg.Success = false;
                msg.Content = "员工号不能为空";

                return(msg);
            }
            else
            {
                IStaffService ss = new StaffService(Settings.Default.db);
                if (ss.FindByNr(model.staffNr) == null)
                {
                    msg.Success = false;
                    msg.Content = "员工号不存在";

                    return(msg);
                }
            }

            if (model.absenceTypeId <= 0)
            {
                msg.Success = false;
                msg.Content = "缺勤类别不能为空";

                return(msg);
            }

            if (model.absenceDate == null)
            {
                msg.Success = false;
                msg.Content = "缺勤时间不能为空,或格式必须正确";

                return(msg);
            }

            if (model.duration <= 0)
            {
                msg.Success = false;
                msg.Content = "缺勤时长不能为空";

                return(msg);
            }

            //IAbsenceRecordService cs = new AbsenceRecordService(Settings.Default.db);
            //List<AbsenceRecrod> abs = cs.GetAll();

            //if (model.id <= 0)
            //{
            //    bool isRecordExists = abs.Where(p => p.staffNr == model.staffNr || p.absenceTypeId == model.absenceTypeId
            //    || p.remark == model.remark || p.duration == model.duration).ToList().Count() > 0;

            //    if (isRecordExists)
            //    {
            //        msg.Success = false;
            //        msg.Content = "数据已经存在!";

            //        return msg;
            //    }
            //}
            //else
            //{
            //    bool isRecordExists = abs.Where(p => (p.staffNr == model.staffNr || p.absenceTypeId == model.absenceTypeId
            //    || p.remark == model.remark || p.duration == model.duration) && p.id != model.id).ToList().Count() > 0;

            //    if (isRecordExists)
            //    {
            //        msg.Success = false;
            //        msg.Content = "数据已经存在!";

            //        return msg;
            //    }
            //}

            return(new ResultMessage()
            {
                Success = true, Content = ""
            });
        }