private void 修改toolStripButton2_Click(object sender, EventArgs e)
        {
            if (!CheckControl())
            {
                return;
            }

            HR_AttendanceScheme attendance = new HR_AttendanceScheme();

            attendance.AttendanceMode = cmbAttendanceMode.Text;
            attendance.AutoOvertimeInPublicHoliday = cbInPublicHoliday.Checked;

            if (cmbAttendanceMode.SelectedIndex != 3)
            {
                if (dtpBeginTimeAfternoon.Checked == false || dtpBeginTimeMorning.Checked == false ||
                    dtpEndTimeAfternoon.Checked == false || dtpEndTimeMorning.Checked == false ||
                    dtpPunchInBeginTime.Checked == false || dtpPunchInEndTime.Checked == false ||
                    dtpPunchOutBeginTime.Checked == false || dtpPunchOutEndTime.Checked == false)
                {
                    MessageDialog.ShowPromptMessage("请填写上下班时间和上下班的打卡时间!");
                    return;
                }

                if (cmbAttendanceMode.SelectedIndex == 1)
                {
                    attendance.BeginDateOfLastMonth = Convert.ToInt32(numBeginDateMonth.Value);
                    attendance.EndDateOfThisMonth   = Convert.ToInt32(numEndDateMonth.Value);
                }

                attendance.BeginTimeInTheAfternoon = dtpBeginTimeAfternoon.Value;
                attendance.BeginTimeInTheMorning   = dtpBeginTimeMorning.Value;
                attendance.EndTimeInTheAfternoon   = dtpEndTimeAfternoon.Value;
                attendance.EndTimeInTheMorning     = dtpEndTimeMorning.Value;
                attendance.PunchInBeginTime        = dtpPunchInBeginTime.Value;
                attendance.PunchInEndTime          = dtpPunchInEndTime.Value;
                attendance.PunchOutBeginTime       = dtpPunchOutBeginTime.Value;
                attendance.PunchOutEndTime         = dtpPunchOutEndTime.Value;
            }

            attendance.Recorder   = BasicInfo.LoginID;
            attendance.RecordTime = ServerTime.Time;
            attendance.Remark     = txtRemark.Text;
            attendance.SchemeCode = txtSchemeCode.Text;
            attendance.SchemeName = txtSchemeName.Text;

            if (!m_attendanceServer.AddAttendanceScheme(attendance, out error))
            {
                MessageDialog.ShowPromptMessage(error);
                return;
            }

            RefreshControl();
        }
Beispiel #2
0
        /// <summary>
        /// 新增修改考勤方案
        /// </summary>
        /// <param name="attendance">考勤方案数据集</param>
        /// <param name="error">错误信息</param>
        /// <returns>成功返回True失败返回False</returns>
        public bool AddAttendanceScheme(HR_AttendanceScheme attendance, out string error)
        {
            error = "";

            try
            {
                DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext;

                var result = from a in dataContxt.HR_AttendanceScheme
                             where a.SchemeCode == attendance.SchemeCode
                             select a;

                if (result.Count() > 0)
                {
                    HR_AttendanceScheme attendanceList = result.Single();

                    attendanceList.SchemeName                  = attendance.SchemeName;
                    attendanceList.Remark                      = attendance.Remark;
                    attendanceList.RecordTime                  = attendance.RecordTime;
                    attendanceList.Recorder                    = attendance.Recorder;
                    attendanceList.PunchOutEndTime             = attendance.PunchOutEndTime;
                    attendanceList.PunchOutBeginTime           = attendance.PunchOutBeginTime;
                    attendanceList.PunchInEndTime              = attendance.PunchInEndTime;
                    attendanceList.PunchInBeginTime            = attendance.PunchInBeginTime;
                    attendanceList.EndTimeInTheMorning         = attendance.EndTimeInTheMorning;
                    attendanceList.EndTimeInTheAfternoon       = attendance.EndTimeInTheAfternoon;
                    attendanceList.EndDateOfThisMonth          = attendance.EndDateOfThisMonth;
                    attendanceList.BeginTimeInTheMorning       = attendance.BeginTimeInTheMorning;
                    attendanceList.BeginTimeInTheAfternoon     = attendance.BeginTimeInTheAfternoon;
                    attendanceList.BeginDateOfLastMonth        = attendance.BeginDateOfLastMonth;
                    attendanceList.AutoOvertimeInPublicHoliday = attendance.AutoOvertimeInPublicHoliday;
                    attendanceList.AttendanceMode              = attendance.AttendanceMode;
                }
                else
                {
                    dataContxt.HR_AttendanceScheme.InsertOnSubmit(attendance);
                }

                dataContxt.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }