Exemplo n.º 1
0
        public static List <ExtraWorkRecord> Convert(List <ExtraWorkRecordExcelModel> models)
        {
            List <ExtraWorkRecord> records = new List <ExtraWorkRecord>();

            models.ForEach(p =>
            {
                bool hasValid = p.ValidateMessage != null && p.ValidateMessage.Success;

                if (hasValid)
                {
                    ExtraWorkRecord abr = new ExtraWorkRecord();
                    abr.extraWorkTypeId = p.ExtraWorkTypeId;
                    abr.staffNr         = p.StaffNr;
                    abr.duration        = double.Parse(p.Duration);
                    abr.durationType    = (int)BlueHrLib.Data.Enum.DurationType.Hour; // p.DurationType;
                    abr.otReason        = p.OtReason;
                    abr.otTime          = p.OtTime;
                    abr.startHour       = p.StartHour;
                    abr.endHour         = p.EndHour;
                    records.Add(abr);
                }
            });

            return(records);
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "extraWorkTypeId,staffNr,otTime,startHour,endHour,duration,durationType,otReason")] ExtraWorkRecord model)
        {
            ResultMessage msg = new ResultMessage();

            try
            {
                model.durationType = (int)DurationType.Hour;

                msg = DoValidation(model);

                if (!msg.Success)
                {
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    IExtraWorkRecordService cs = new ExtraWorkRecordService(Settings.Default.db);
                    bool isSucceed             = cs.Create(model);

                    msg.Success = isSucceed;
                    msg.Content = isSucceed ? "" : "添加失败";

                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new ResultMessage()
                {
                    Success = false, Content = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
0
        // GET: ExtraWorkRecord/Delete/5
        public ActionResult Delete(int id)
        {
            IExtraWorkRecordService cs = new ExtraWorkRecordService(Settings.Default.db);

            ExtraWorkRecord cp = cs.FindById(id);

            SetDropDownList(cp);
            return(View(cp));
        }
Exemplo n.º 4
0
        // GET: ExtraWorkRecord/Edit/5
        public ActionResult Edit(int id)
        {
            IExtraWorkRecordService cs = new ExtraWorkRecordService(Settings.Default.db);

            ExtraWorkRecord jt = cs.FindById(id);

            SetDropDownList(jt);
            return(View(jt));
        }
Exemplo n.º 5
0
 private void SetDropDownList(ExtraWorkRecord model)
 {
     if (model != null)
     {
         SetExtraWorkTypeList(model.extraWorkTypeId);
         SetDurationTypeCodeList(model.durationType);
     }
     else
     {
         SetExtraWorkTypeList(null);
         SetDurationTypeCodeList(null);
     }
 }
Exemplo n.º 6
0
        //•	员工号(输入,不可空)
        //•	缺勤类别(选择,不可空)
        //•	缺勤原因(输入,可空),
        //•	缺勤的小时或天长。(输入,不可空)
        //•	时间单位(选择,不可空,选项为: 小时/天,默认为小时)
        public ResultMessage DoValidation(ExtraWorkRecord 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.extraWorkTypeId <= 0)
            {
                msg.Success = false;
                msg.Content = "加班类别不能为空";

                return(msg);
            }

            if (model.otTime == 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 = ""
            });
        }
Exemplo n.º 7
0
 public bool Update(ExtraWorkRecord model)
 {
     return(rep.Update(model));
 }
Exemplo n.º 8
0
 public bool Create(ExtraWorkRecord model)
 {
     return(rep.Create(model));
 }