private void 综合查询toolStripButton3_Click(object sender, EventArgs e)
        {
            IAuthorization authorization = PlatformFactory.GetObject <IAuthorization>();
            string         businessID    = "";
            IQueryResult   qr            = null;
            List <string>  lstFindField  = new List <string>();

            IQueryable <View_HR_PersonnelArchive> directorGroup3 = m_personnerServer.GetDeptDirector(BasicInfo.DeptCode, "0");
            IQueryable <View_HR_PersonnelArchive> directorGroup  = m_personnerServer.GetDeptDirector(BasicInfo.DeptCode, "1");
            IQueryable <View_HR_PersonnelArchive> directorGroup2 = m_personnerServer.GetDeptDirector(BasicInfo.DeptCode, "2");

            authorization = PlatformFactory.GetObject <IAuthorization>();
            businessID    = "出差综合查询";
            string[] pare = { BasicInfo.DeptCode };
            qr = authorization.QueryMultParam(businessID, null, pare);

            DataColumnCollection columns = qr.DataCollection.Tables[0].Columns;

            if (qr.Succeeded && columns.Count > 0)
            {
                for (int i = 0; i < columns.Count; i++)
                {
                    lstFindField.Add(columns[i].ColumnName);
                }
            }

            FormConditionFind formFindCondition = new FormConditionFind(this, lstFindField.ToArray(), businessID, labelTitle.Text);

            formFindCondition.ShowDialog();
        }
Exemple #2
0
        private void 修改toolStripButton_Click(object sender, EventArgs e)
        {
            if (txtStatus.Text.Trim() == "已完成" || txtStatus.Text.Trim() == "等待下次排班")
            {
                MessageDialog.ShowPromptMessage("单据已经完成,不能修改");
                return;
            }

            if (!CheckControl())
            {
                return;
            }

            List <HR_WorkSchedulingDetail> lstPersonnel = new List <HR_WorkSchedulingDetail>();

            int day1 = GlobalObject.Year.GetDays(dtpBegin.Value);
            int days = 0;

            for (int i = dtpBegin.Value.Day; i <= day1; i++)
            {
                days++;
            }

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                DataGridViewCellCollection cells = dataGridView1.Rows[i].Cells;

                for (int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    HR_WorkSchedulingDetail    personnel         = new HR_WorkSchedulingDetail();
                    DataGridViewComboBoxColumn dgvComboBoxColumn = dataGridView1.Columns[j] as DataGridViewComboBoxColumn;

                    if (dataGridView1.Columns[j].CellType.Name == "DataGridViewComboBoxCell" && cells[j].Value != null)
                    {
                        personnel.WorkID = dataGridView1.Rows[i].Cells["工号"].Value.ToString();
                        personnel.Code   = cells[j].Value.ToString();

                        if (dtpBegin.Value.Month == dtpEnd.Value.Month)
                        {
                            if (j - 1 <= days)
                            {
                                personnel.Date = Convert.ToDateTime(numYear.Value + "-" + dtpBegin.Value.Month + "-" + dataGridView1.Columns[j].HeaderText);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            if (j - 1 <= days)
                            {
                                personnel.Date = Convert.ToDateTime(numYear.Value + "-" + dtpBegin.Value.Month + "-" + dataGridView1.Columns[j].HeaderText);
                            }
                            else
                            {
                                personnel.Date = Convert.ToDateTime(numYear.Value + "-" + dtpEnd.Value.Month + "-" + dataGridView1.Columns[j].HeaderText);
                            }
                        }

                        lstPersonnel.Add(personnel);
                    }
                }
            }

            HR_WorkScheduling workSchedule = new HR_WorkScheduling();
            bool isDeptDirector            = false;

            IQueryable <View_HR_PersonnelArchive> directorGroup = m_personnerServer.GetDeptDirector(m_personnerServer.GetPersonnelInfo(txtCreaterWorkID.Tag.ToString()).Dept, "0");
            bool flag = false;

            if (directorGroup != null && directorGroup.Count() > 0)
            {
                isDeptDirector = true;
                foreach (var item in directorGroup)
                {
                    if (BasicInfo.LoginID == item.员工编号)
                    {
                        flag = true;
                        break;
                    }
                }
            }

            IQueryable <View_HR_PersonnelArchive> directorGroup1 = m_personnerServer.GetDeptDirector(m_personnerServer.GetPersonnelInfo(txtCreaterWorkID.Tag.ToString()).Dept, "1");
            bool flagPri = false;

            if (directorGroup1 != null && directorGroup1.Count() > 0)
            {
                foreach (var item in directorGroup1)
                {
                    if (BasicInfo.LoginID == item.员工编号)
                    {
                        flagPri = true;
                        break;
                    }
                }
            }

            if (!flag && !flagPri)
            {
                if (isDeptDirector)
                {
                    workSchedule.BillStatus = OverTimeBillStatus.等待主管审核.ToString();
                }
                else
                {
                    workSchedule.BillStatus = OverTimeBillStatus.等待部门负责人审核.ToString();
                }
            }
            else if (flag && !flagPri)
            {
                workSchedule.BillStatus = OverTimeBillStatus.等待部门负责人审核.ToString();
            }
            else
            {
                workSchedule.BillStatus = OverTimeBillStatus.已完成.ToString();
            }

            workSchedule.ScheduleName  = txtScheduleName.Text;
            workSchedule.CreateDate    = dtpCreateDate.Value;
            workSchedule.CreaterWorkID = txtCreaterWorkID.Tag.ToString();
            workSchedule.BeginDate     = dtpBegin.Value;
            workSchedule.EndDate       = dtpEnd.Value;
            workSchedule.Remark        = txtRemark.Text;
            workSchedule.Year          = Convert.ToInt32(numYear.Value);
            workSchedule.Month         = Convert.ToInt32(numMonth.Value);
            workSchedule.PendingDate   = Convert.ToDateTime(dateTimePendingDate.Value.ToShortDateString());

            if (!m_workSchedulingServer.UpdateWorkScheduling(workSchedule, lstPersonnel, Convert.ToInt32(txtBillNo.Text), out error))
            {
                MessageDialog.ShowPromptMessage(error);
                return;
            }
            else
            {
                MessageDialog.ShowPromptMessage("修改成功!");
            }

            this.Close();
        }
        /// <summary>
        /// 检查控件
        /// </summary>
        /// <returns>信息正确返回True,失败返回False</returns>
        bool CheckControl()
        {
            if (dtpEndTime.Value <= dtpBeginTime.Value)
            {
                MessageDialog.ShowPromptMessage("【起始时间】必须小于【结束时间】");
                return(false);
            }

            if (MessageDialog.ShowEnquiryMessage("请确认您的\r\n【加班起始时间】:"
                                                 + dtpBeginTime.Value.ToString("yyyy-MM-dd HH:mm") + "\r\n【加班结束时间】:"
                                                 + dtpEndTime.Value.ToString("yyyy-MM-dd HH:mm")) == DialogResult.No)
            {
                return(false);
            }

            if (txtErrand.Text.Trim() == "")
            {
                MessageDialog.ShowPromptMessage("请填写加班任务描述!");
                return(false);
            }

            if (numHours.Value == 0)
            {
                MessageDialog.ShowPromptMessage("请填写需要加班小时!");
                return(false);
            }

            if (cmbCompensateMode.Text.Trim() == "")
            {
                MessageDialog.ShowPromptMessage("请选择加班补偿方式!");
                return(false);
            }

            if (cmbOvertimeAddress.SelectedIndex == -1)
            {
                MessageDialog.ShowPromptMessage("请选择加班地点!");
                return(false);
            }

            if (dataGridView2.Rows.Count > 0)
            {
                DateTime starDate = ServerTime.Time;
                DateTime endDate  = ServerTime.Time;

                if (cmbCompensateMode.SelectedIndex == 0)
                {
                    string month = "";

                    if (dtpBeginTime.Value.Month < 10)
                    {
                        month = "0" + dtpBeginTime.Value.Month;
                    }
                    else
                    {
                        month = dtpBeginTime.Value.Month.ToString();
                    }

                    starDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + "01");
                    endDate  = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + GetDays());

                    if (m_highDept.Contains("ZZ") || m_highDept == "SC")
                    {
                        if (dtpBeginTime.Value.Month == 1)
                        {
                            starDate = Convert.ToDateTime((dtpBeginTime.Value.Year - 1).ToString() + "-12-26");
                            endDate  = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + "26");
                        }
                        else
                        {
                            starDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + (dtpBeginTime.Value.Month - 1).ToString() + "-" + "26");
                            endDate  = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + "26");
                        }
                    }
                }

                for (int i = 0; i < dataGridView2.Rows.Count; i++)
                {
                    DataGridViewCellCollection cells = dataGridView2.Rows[i].Cells;

                    if (cells["员工编号"].Value == null || GlobalObject.GeneralFunction.IsNullOrEmpty(cells["员工编号"].Value.ToString()))
                    {
                        MessageDialog.ShowPromptMessage(string.Format("第 {0} 行, 请选择加班人员", i + 1));
                        return(false);
                    }

                    if (cmbCompensateMode.SelectedIndex == 0)
                    {
                        if (!m_attendanceServer.GetAllowMobileVacationHour(cells["员工编号"].Value.ToString()))
                        {
                            if (m_overTimeServer.GetMonthRealHour(cells["员工编号"].Value.ToString(), starDate, endDate) <= 0)
                            {
                                MessageDialog.ShowPromptMessage(UniversalFunction.GetPersonnelName(cells["员工编号"].Value.ToString())
                                                                + "有欠班,只能选择调休!");
                                return(false);
                            }
                        }
                    }
                }
            }
            else if (dataGridView2.Rows.Count == 0)
            {
                MessageDialog.ShowPromptMessage("请选择加班人员");
                return(false);
            }

            IQueryable <View_HR_PersonnelArchive> directorGroup = m_personnerServer.GetDeptDirector(
                m_personnerServer.GetPersonnelInfo(txtApplicant.Tag.ToString()).Dept, "2");
            bool flag = false;

            if (directorGroup != null && directorGroup.Count() > 0)
            {
                foreach (var item in directorGroup)
                {
                    if (BasicInfo.LoginID == item.员工编号)
                    {
                        flag = true;

                        break;
                    }
                }
            }

            if (flag)
            {
                MessageDialog.ShowPromptMessage("您是分管领导,不用填写加班单!");
                return(false);
            }

            if ((ServerTime.Time - dtpBeginTime.Value).Days > 3 && !BasicInfo.ListRoles.Contains(CE_RoleEnum.人力资源部办公室文员.ToString()))
            {
                string starTemp = dtpBeginTime.Value.ToShortDateString() + " " + "08:30";

                DataTable dt = m_holidayServer.GetHolidayDays(Convert.ToDateTime(starTemp), ServerTime.Time);

                if (dt != null && dt.Rows.Count > 0)
                {
                    int days = Convert.ToInt32(dt.Rows[0]["days"] == DBNull.Value ? "0" : dt.Rows[0]["days"]);

                    if (days > 0)
                    {
                        if ((ServerTime.Time - dtpBeginTime.Value).Days > 3 + days)
                        {
                            MessageDialog.ShowPromptMessage("只能补三天内的加班单!");
                            return(false);
                        }
                    }
                    else
                    {
                        MessageDialog.ShowPromptMessage("只能补三天内的加班单!");
                        return(false);
                    }
                }
                else
                {
                    MessageDialog.ShowPromptMessage("只能补三天内的加班单!");
                    return(false);
                }
            }

            HR_AttendanceSetting attendanceSet = m_attendanceSchemeServer.GetAttendanceSettingByWorkID(BasicInfo.LoginID);

            string[] schemeCode = attendanceSet.SchemeCode.Split(' ');
            string   mode       = m_attendanceSchemeServer.GetAttendanceSchemeByCode(schemeCode[0]).AttendanceMode;

            Hashtable hsTable = new Hashtable();

            hsTable.Add("@ParentCode", "ZZGC");
            hsTable.Add("@WorkID", BasicInfo.LoginID);

            DataTable tempTable = GlobalObject.DatabaseServer.QueryInfoPro("HR_Personnel_GetParentDept", hsTable, out error);

            #region 2017.10.27 夏石友, 向菲菲将工务人员、车间人员修改为非自然月排班考勤后出现必须加班2小时才可以填写加班单的现象
            //if (mode.Contains("非自然月考勤"))
            if (mode.Contains("非自然月考勤") || mode.Contains("非自然月排班考勤") || tempTable.Rows.Count > 0)
            #endregion
            {
                if (numHours.Value < 1)
                {
                    MessageDialog.ShowPromptMessage("加班1小时以上才可以填写加班申请单!");
                    return(false);
                }
            }
            else
            {
                if (numHours.Value < 2)
                {
                    MessageDialog.ShowPromptMessage("加班2小时以上才可以填写加班申请单!");
                    return(false);
                }
            }

            return(true);
        }