Exemplo n.º 1
0
        public ResponseModel <bool> Leave_Add(LeaveViewModel model)
        {
            LeaveOffice leave = new LeaveOffice();

            leave.Id         = Guid.NewGuid();
            leave.StaffName  = model.StaffName;
            leave.No         = "0";
            leave.JobId      = new Guid(model.JobId);
            leave.LeaveType  = model.LeaveType == "离职" ? "0" : "1";
            leave.CreateTime = DateTime.Now;
            leave.UpdateTime = DateTime.Now;
            leave.ApplyDate  = model.ApplyTime;
            leave.Reason     = model.Reason;
            db.LeaveOffice.Add(leave);
            int num = db.SaveChanges();

            if (num > 0)
            {
                return(new ResponseModel <bool> {
                    code = (int)code.Success, data = true, message = "添加离职信息成功"
                });
            }
            return(new ResponseModel <bool> {
                code = (int)code.AddLeaveFail, data = false, message = "添加离职信息失败"
            });
        }
Exemplo n.º 2
0
        public static int Save(LeaveOffice leaveOffice)
        {
            var a = new LeaveOffice
            {
                LeaveOfficeNo = leaveOffice.LeaveOfficeNo,
                PersonnelNo   = leaveOffice.PersonnelNo,
                BasicSalary   = leaveOffice.BasicSalary,
                DateFiled     = leaveOffice.DateFiled,
                OfficeAgency  = leaveOffice.OfficeAgency,
                Position      = leaveOffice.Position
            };

            using (_d = new DataRepository <LeaveOffice>())
            {
                if (leaveOffice.LeaveOfficeNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.LeaveOfficeNo);
        }
Exemplo n.º 3
0
        public static bool Delete(LeaveOffice leaveOffice)
        {
            using (_d = new DataRepository <LeaveOffice>())
            {
                _d.Delete(leaveOffice);
                _d.SaveChanges();
            }

            return(true);
        }
        public async Task <ActionResult> UpdateLeaveOffice([FromBody] LeaveOffice leaveOffice)
        {
            string log = string.Empty;

            if (await Task.Factory.StartNew(() => _leaveOfficeService.UpdateLeaveOffices(leaveOffice, ref log)))
            {
                responseInfo.successIn = log;
            }
            else
            {
                responseInfo.unsuccessful = log;
            }

            return(Ok(responseInfo));
        }
Exemplo n.º 5
0
        public ActionResult LeaveApproveAdd(string StaffName, string JobId, string LeaveType, string CreateTime, string Reason, string ExplanationHandover, string HandoverSatffId)
        {
            LeaveOffice l = new LeaveOffice();

            l.Id                  = Guid.NewGuid();
            l.StaffName           = StaffName;
            l.JobId               = new Guid(JobId);
            l.LeaveType           = LeaveType;
            l.CreateTime          = Convert.ToDateTime(CreateTime);
            l.Reason              = Reason;
            l.ExplanationHandover = ExplanationHandover;
            l.HandoverSatffId     = new Guid(HandoverSatffId);
            db.LeaveOffice.Add(l);
            int i = db.SaveChanges();

            return(Json(i > 0, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public ActionResult LeaveApproverDel(string Id)
        {
            Guid        id = new Guid(Id);
            LeaveOffice l  = db.LeaveOffice.Where(r => r.Id == id).FirstOrDefault();

            //如果查询有参数
            if (l != null)
            {
                db.LeaveOffice.Remove(l);
                int i = db.SaveChanges();
                return(Json(i > 0, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 7
0
        public ActionResult LeaveApproverUpdate(string Id, string StaffName, string JobId, string LeaveType, string CreateTime, string Reason, string ExplanationHandover, string HandoverSatffId)
        {
            LeaveOffice l = new LeaveOffice();

            l = (from aps in db.LeaveOffice
                 where (aps.Id == new Guid(Id))
                 select aps).Single();
            l.StaffName           = StaffName;
            l.JobId               = new Guid(JobId);
            l.LeaveType           = LeaveType;
            l.CreateTime          = Convert.ToDateTime(CreateTime);
            l.Reason              = Reason;
            l.ExplanationHandover = ExplanationHandover;
            l.HandoverSatffId     = new Guid(HandoverSatffId);
            db.Entry(l).State     = EntityState.Modified;
            int i = db.SaveChanges();

            return(Json(i > 0, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 修改员工离职申请数据
        /// </summary>
        /// <param name="leaveOffice"></param>
        /// <returns></returns>
        public string updataLeaveOfficesInfoAll(LeaveOffice leaveOffice)
        {
            string LeaveType = leaveOffice.LeaveType == "正常提交离职表" ? "1" : leaveOffice.LeaveType == "自动离职" ? "2" : "3";

            if (_leaveOfficeResposit.UpdateInfo(x => new LeaveOffice()
            {
                JobId = leaveOffice.JobId,
                StaffName = leaveOffice.StaffName,
                Reason = leaveOffice.Reason,
                ExplanationHandover = leaveOffice.ExplanationHandover,
                HandoverSatffId = leaveOffice.HandoverSatffId,
                LeaveType = LeaveType,
                UpdateTime = DateTime.Now
            }, x => x.Id == leaveOffice.Id) > 0)
            {
                return("ok");
            }
            return("修改失败!");
        }
Exemplo n.º 9
0
 public async Task <ActionResult <IEnumerable <LeaveOffice> > > UpdataLeaveOfficesInfoAll([FromBody] LeaveOffice leaveOffice)
 {
     return(Ok(await Task.Factory.StartNew(() => _staffService.updataLeaveOfficesInfoAll(leaveOffice))));
 }
Exemplo n.º 10
0
        /// <summary>
        /// 增添员工离职申请
        /// </summary>
        /// <param name="leaveOffice"></param>
        /// <returns></returns>
        public string addLeaveOfficesInfoAll(LeaveOffice leaveOffice)
        {
            string isOk      = "添加失败!";
            Staff  staffInfo = _staffResposit.FindAll().FirstOrDefault(x => x.NoN == leaveOffice.NoN);

            if (staffInfo == null)
            {
                isOk = "未查询到此人";
                return(isOk);
            }
            //开启事务
            _leaveOfficeResposit.StatrAffair(() => {
                leaveOffice.ApplyDate     = DateTime.Now;
                leaveOffice.isyes         = 1;
                leaveOffice.IsDel         = "0";
                leaveOffice.ApplyPersonId = staffInfo.Id.ToString();
                leaveOffice.CreateTime    = DateTime.Now;

                int leaveId = _leaveOfficeResposit.AddCreateInfo(leaveOffice);

                ProcessStepRecord processStepRecord = new ProcessStepRecord();
                processStepRecord.Typed             = ProcessType.员工离职审批流程.ToString();

                if (leaveOffice.JobId == (int)JobEmun.油站员工)
                {
                    processStepRecord.OilStation = 1;
                }
                else if (leaveOffice.JobId == (int)JobEmun.人事员工)
                {
                    processStepRecord.ExecutiveDirector = 1; //人事经理
                }
                else if (leaveOffice.JobId == (int)JobEmun.油站经理 || leaveOffice.JobId == (int)JobEmun.财务经理)
                {
                    processStepRecord.ExecutiveDirector      = 1; //人事经理
                    processStepRecord.GeneralManagerOfPerson = 1; //主管
                }
                else if (leaveOffice.JobId == (int)JobEmun.人事经理 || leaveOffice.JobId == (int)JobEmun.主管)
                {
                    processStepRecord.GeneralManager = 1; //总经理
                    processStepRecord.ChiefInspector = 1; //总监
                }
                else if (leaveOffice.JobId == (int)JobEmun.总经理)
                {
                    processStepRecord.ChiefInspector = 1;
                }


                #region 生成non号 不可重复 (后期数据多了之后需要改进)
                bool isok  = true;
                string non = "";
                while (isok)
                {
                    non      = GetTime.randomPwd() + GetTime.randomPwd() + GetTime.randomPwd();
                    var list = (from pr in _processStepRecordResposit.FindAll()
                                where non == pr.NoN
                                select new { }).ToList();
                    if (list.Count == 0)
                    {
                        isok = false;
                    }
                }
                #endregion
                processStepRecord.CreateTime       = DateTime.Now;
                processStepRecord.WhetherToExecute = 1;
                processStepRecord.NoN        = non;
                processStepRecord.RefOrderId = leaveId;  //关联的离职申请表的主键id
                processStepRecord.Result     = 0;
                _processStepRecordResposit.AddInfo(processStepRecord);
                isOk = "ok";
            });
            return(isOk);
        }
 /// <summary>
 /// 删除离职
 /// </summary>
 /// <param name="leaveOffice"></param>
 /// <returns></returns>
 public async Task <ActionResult> DeleteLeaveOffice([FromQuery] LeaveOffice leaveOffice)
 {
     return(Ok(await Task.Factory.StartNew(() => _leaveOfficeService.DeleteLeaveOffices(leaveOffice))));
 }
 /// <summary>
 /// 添加离职记录
 /// </summary>
 /// <param name="leaveOffice"></param>
 /// <returns></returns>
 public async Task <ActionResult> AddLeaveOffice([FromBody] LeaveOffice leaveOffice)
 {
     return(Ok(await Task.Factory.StartNew(() => _leaveOfficeService.AddLeaveOffices(leaveOffice))));
 }