예제 #1
0
        void AddComboxItems(CE_HR_AttendanceExceptionType type)
        {
            cmb_BusinessType.Items.Clear();
            cmb_BusinessType.DataSource = null;

            if (type == CE_HR_AttendanceExceptionType.请假)
            {
                DataTable dt = _serviceLeave.GetLeaveTypeByCode(null);

                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        cmb_BusinessType.Items.Add(dt.Rows[i]["请假类别"].ToString());
                    }
                }
            }
            else if (type == CE_HR_AttendanceExceptionType.加班)
            {
                cmb_BusinessType.Items.Add("加班调休_公司内");
                cmb_BusinessType.Items.Add("加班补助_公司内");
                cmb_BusinessType.Items.Add("加班调休_公司外");
                cmb_BusinessType.Items.Add("加班补助_公司外");
            }

            cmb_BusinessType.SelectedIndex = -1;
        }
        /// <summary>
        /// 操作补单情况下的考勤流水与异常信息
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="billNo">关联单号</param>
        /// <param name="exceptionType">异常类型</param>
        /// <returns>成功返回True失败返回False</returns>
        public void OperationTimeException_Replenishments(DepotManagementDataContext dataContxt, string billNo, CE_HR_AttendanceExceptionType exceptionType)
        {
            IAttendanceAnalysis service = ServerModuleFactory.GetServerModule <IAttendanceAnalysis>();

            try
            {
                switch (exceptionType)
                {
                case CE_HR_AttendanceExceptionType.请假:

                    var varDataLeave = from a in dataContxt.HR_LeaveBill
                                       where a.ID == Convert.ToInt32(billNo)
                                       select a;

                    if (varDataLeave.Count() != 1)
                    {
                        throw new Exception("请假单数据有误");
                    }

                    service.Analysis_Main(dataContxt, varDataLeave.Single().BeginTime, varDataLeave.Single().EndTime, varDataLeave.Single().Applicant);
                    break;

                case CE_HR_AttendanceExceptionType.加班:
                    var varOverTime = from a in dataContxt.HR_OvertimeBill
                                      where a.ID == Convert.ToInt32(billNo)
                                      select a;

                    if (varOverTime.Count() != 1)
                    {
                        throw new Exception("请假单数据有误");
                    }

                    var varOverPersonnel = from a in dataContxt.HR_OvertimePersonnel
                                           where a.BillID == varOverTime.Single().ID
                                           select a;

                    foreach (var item in varOverPersonnel)
                    {
                        service.Analysis_Main(dataContxt, varOverTime.Single().BeginTime, Convert.ToDateTime(varOverTime.Single().EndTime), item.WorkID);
                    }

                    break;

                case CE_HR_AttendanceExceptionType.出差:
                    var varOnBusiness = from a in dataContxt.HR_OnBusinessBill
                                        where a.ID == Convert.ToInt32(billNo)
                                        select a;

                    if (varOnBusiness.Count() != 1)
                    {
                        throw new Exception("请假单数据有误");
                    }

                    var varPersonnel = from a in dataContxt.HR_OnBusinessPersonnel
                                       where a.BillID == varOnBusiness.Single().ID
                                       select a;

                    foreach (var item in varPersonnel)
                    {
                        service.Analysis_Main(dataContxt, varOnBusiness.Single().RealBeginTime, varOnBusiness.Single().RealEndTime, item.WorkID);
                    }

                    break;

                default:
                    break;
                }

                dataContxt.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #3
0
        void OperationBusiness()
        {
            string type = GetMode(panel2);
            string mode = GetMode(panel3);

            if (type.Trim().Length == 0 || mode.Trim().Length == 0)
            {
                MessageDialog.ShowPromptMessage("请选择【单据类型】、【操作类型】");
                return;
            }
            CE_HR_AttendanceExceptionType billType =
                GlobalObject.GeneralFunction.StringConvertToEnum <CE_HR_AttendanceExceptionType>(type);
            CE_OperatorMode operationMode =
                GlobalObject.GeneralFunction.StringConvertToEnum <CE_OperatorMode>(mode);

            if (!CheckData())
            {
                return;
            }

            List <object>             lstInfo      = new List <object>();
            List <PersonnelBasicInfo> lstPersonnel = new List <PersonnelBasicInfo>();

            lstInfo.Add(ServerTime.ConvertToDateTime(dtp_BeginTime.Value));
            lstInfo.Add(ServerTime.ConvertToDateTime(dtp_EndTime.Value));
            lstInfo.Add(cmb_BusinessType.Text);
            lstInfo.Add(txtContent.Text.Trim());
            lstInfo.Add(num_Hours.Value);

            if (operationMode == CE_OperatorMode.添加)
            {
                lstInfo.Add(null);

                MessageDialog.ShowPromptMessage(string.Format("请设置需要【{0}】的人员", billType.ToString()));
                FormSelectPersonnel2 frm = new FormSelectPersonnel2();

                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                else
                {
                    if (frm.SelectedNotifyPersonnelInfo.UserType != BillFlowMessage_ReceivedUserType.用户.ToString())
                    {
                        MessageDialog.ShowPromptMessage("请选择【用户】");
                        return;
                    }
                    else
                    {
                        lstPersonnel = frm.SelectedNotifyPersonnelInfo.PersonnelBasicInfoList;
                    }
                }

                _serviceAnalysis.Operation_Exception(billType, operationMode, lstInfo, lstPersonnel);
            }
            else if (operationMode == CE_OperatorMode.修改)
            {
                lstInfo.Add((int)customDataGridView1.CurrentRow.Cells["单据号"].Value);

                if (MessageDialog.ShowEnquiryMessage("你确定要【" + operationMode.ToString() + "】?") == DialogResult.No)
                {
                    return;
                }

                _serviceAnalysis.Operation_Exception(billType, operationMode, lstInfo, lstPersonnel);
            }
            else if (operationMode == CE_OperatorMode.除)
            {
                if (MessageDialog.ShowEnquiryMessage("你确定要【" + operationMode.ToString() + "】?") == DialogResult.No)
                {
                    return;
                }

                if (customDataGridView1.SelectedRows.Count == 0)
                {
                    MessageDialog.ShowPromptMessage("请选择需要【删除】的记录");
                    return;
                }

                foreach (DataGridViewRow dgvr in customDataGridView1.SelectedRows)
                {
                    lstInfo.Add((int)dgvr.Cells["单据号"].Value);
                    lstPersonnel = new List <PersonnelBasicInfo>();
                    PersonnelBasicInfo personnel = new PersonnelBasicInfo();

                    personnel.工号 = dgvr.Cells["执行人"].Value.ToString();
                    lstPersonnel.Add(personnel);

                    _serviceAnalysis.Operation_Exception(billType, operationMode, lstInfo, lstPersonnel);
                }
            }

            MessageDialog.ShowPromptMessage(string.Format("【{0}单{1}成功】", billType.ToString(), operationMode.ToString()));
            RefreshDataGridView();
        }