Beispiel #1
0
        public ActionResult UpdateActHour(int id)
        {
            ResultMessage msg          = new ResultMessage();
            double        actHour      = 0;
            double        actExtraHour = 0;

            if (!double.TryParse(Request.Form["actWorkingHourRound"], out actHour))
            {
                msg.Content = "工作日工时必须是数字";
                return(Json(msg));
            }

            // 加班时间可以为空
            // 如果加班为空, 直接写入0
            // 如果不为空, 则所填必须为数字
            if (!string.IsNullOrWhiteSpace(Request.Form["actExtraWorkingHourRound"]) && !double.TryParse(Request.Form["actExtraWorkingHourRound"], out actExtraHour))
            {
                msg.Content = "加班工时必须是数字";
                return(Json(msg));
            }

            bool handled = false;

            if (!bool.TryParse(Request.Form["isExceptionHandled"], out handled))
            {
                msg.Content = "是否处理值非法,请刷新页面重新填写";
                return(Json(msg));
            }

            IAttendanceRecordCalService ss     = new AttendanceRecordCalService(Settings.Default.db);
            AttendanceRecordCal         record = ss.FindById(id);

            string oldHour    = record.actWorkingHour.ToString();
            string oldActHour = record.actExtraWorkingHour.ToString();

            //判断加班类型是否为空, 如果为空, 就返回null
            // 如果做判断,直接使用int.Parse转,会报异常

            int?ExtraWorkType = null;

            if (!string.IsNullOrWhiteSpace(Request.Form["extraWorkType"]))
            {
                ExtraWorkType = int.Parse(Request.Form["extraWorkType"]);
            }

            msg = ss.UpdateActHourById(id, actHour, actExtraHour, handled, Request.Form["remark"], ExtraWorkType);

            string newHour    = actHour.ToString();
            string newActHour = actExtraHour.ToString();

            // 创建调整考勤记录##User##
            try
            {
                IMessageRecordService mrs = new MessageRecordService(Settings.Default.db);
                mrs.CreateStaffUpdateAttHourMessage(record.staffNr, (Session["user"] as User).id, oldHour, newHour, oldActHour, newActHour);
            }
            catch { }

            return(Json(msg));
        }
Beispiel #2
0
        // GET: AttendanceRecordCal/Delete/5
        public ActionResult Delete(int id)
        {
            IAttendanceRecordCalService arcs = new AttendanceRecordCalService(Settings.Default.db);

            AttendanceRecordCal record = arcs.FindById(id);

            SetExtraWorkTypeList(record.extraworkType);



            if (record != null)
            {
                AbsenceRecordView   absenceRecord   = new AbsenceRecordService(Settings.Default.db).FindViewByStaffNrAndDate(record.staffNr, record.attendanceDate);
                ExtraWorkRecordView extraWorkRecord = new ExtraWorkRecordService(Settings.Default.db).FindViewByStaffNrAndDate(record.staffNr, record.attendanceDate);

                List <AttendanceRecordDetailView> records = new List <AttendanceRecordDetailView>();
                IAttendanceRecordDetailService    s       = new AttendanceRecordDetailService(Settings.Default.db);
                records = s.GetDetailsViewByStaffAndDateWithExtrawork(record.staffNr, record.attendanceDate);
                ViewData["attendRecords"]   = records;
                ViewData["absenceRecord"]   = absenceRecord;
                ViewData["extraWorkRecord"] = extraWorkRecord;
            }
            else
            {
                SetExtraWorkTypeList(null);
            }


            return(View(record));
        }