Пример #1
0
        /// <summary>
        /// 获取考勤日期
        /// </summary>
        /// <param name="minDt">最小考勤日期</param>
        /// <param name="maxDt">最大考勤日期</param>
        /// <returns></returns>
        private bool GetAttenDateDt(DateTime minDt, DateTime maxDt)
        {
            bool flag = false;

            m_AttenDateDt = m_mainDbOp.GetDataTable(Common.Table_AttenDate, string.Format("{0} between #{1}# and #{2}# order by {0} asc",
                                                                                          Common.Column_AttendanceDate, minDt.ToString("yyyy-MM-dd"), maxDt.ToString("yyyy-MM-dd"), Common.Column_AttendanceDate));
            if (m_AttenDateDt == null || m_AttenDateDt.Rows.Count == 0)
            {
                XtraMessageBox.Show("考勤日期未配置,请先生成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                AttenDateForm attenDateForm = new AttenDateForm(m_mainDbOp);
                if (attenDateForm.ShowDialog() != DialogResult.OK)
                {
                    return(flag);
                }
                else
                {
                    m_AttenDateDt = m_mainDbOp.GetDataTable(Common.Table_AttenDate, string.Format("{0} between #{1}# and #{2}# order by {0} asc",
                                                                                                  Common.Column_AttendanceDate, minDt.ToString("yyyy-MM-dd"), maxDt.ToString("yyyy-MM-dd"), Common.Column_AttendanceDate));
                    if (m_AttenDateDt == null || m_AttenDateDt.Rows.Count == 0)
                    {
                        return(flag);
                    }
                    else
                    {
                        flag = true;
                    }
                }
            }
            else
            {
                flag = true;
            }
            return(flag);
        }
Пример #2
0
        /// <summary>
        /// 导入员工表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImportEmployee_ItemClick(object sender, ItemClickEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "*.xls|*.xls|*.xlsx|*.xlsx";
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string    selectFileName = openFileDialog.FileName;
            DataTable pExcleDt       = ExcelHelper.GetTableFromFile(selectFileName);

            if (pExcleDt == null)
            {
                XtraMessageBox.Show("读取Excel数据出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            pExcleDt.TableName = Common.Table_Employe;
            if (m_MianDbOp.ImportDataTable(pExcleDt))
            {
                XtraMessageBox.Show("成功导入员工数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            DataTable pEmployeeDt = m_MianDbOp.GetDataTable(Common.Table_Employe);

            Common.CoverTableCaption(pEmployeeDt);
            mainGridControl.DataSource = pEmployeeDt;
        }
Пример #3
0
        /// <summary>
        /// 判断当前日期员工是否在休假
        /// </summary>
        /// <param name="Dt"></param>
        /// <returns>True:在休假;Flase:不在休假</returns>
        public bool IsVacioning(DateTime Dt)
        {
            bool      flag       = false;
            DataTable VacationDt = m_DbOperator.GetDataTable(Common.Table_Vacation, string.Format("{0}<=#{1}# and {2}>=#{1}# and {3}='{4}'",
                                                                                                  Common.Column_VacaBegin, Dt, Common.Column_VacaEnd, Common.Column_EmployeCode, m_Employee.Employee_Code));

            if (VacationDt == null || VacationDt.Rows.Count == 0)
            {
                return(false);
            }
            else
            {
                flag = true;
            }
            _VacationStart = Convert.ToDateTime(VacationDt.Rows[0][Common.Column_VacaBegin]);
            _VacationEnd   = Convert.ToDateTime(VacationDt.Rows[0][Common.Column_VacaEnd]);
            double.TryParse(VacationDt.Rows[0][Common.Column_VacaDura].ToString(), out _VacationDura);
            int tempInt = 0;

            if (int.TryParse(VacationDt.Rows[0][Common.Column_VacaType].ToString(), out tempInt))
            {
                _EmployeeVacationType = (VacationType)tempInt;
            }
            return(flag);
        }
Пример #4
0
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            DbOperatorFactory dbFc = new DbOperatorFactory(m_MainDbConfig);

            m_MianDbOp = dbFc.GetDbOperator();
            if (m_MianDbOp == null)
            {
                XtraMessageBox.Show("获取数据库连接出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            Common.T_MetaTable = m_MianDbOp.GetDataTable(Common.Table_ColumnInfo);
            //加载员工表
            DataTable pEmployeDt = m_MianDbOp.GetDataTable(Common.Table_Employe);

            mainGridControl.DataSource = pEmployeDt;
        }
Пример #5
0
        /// <summary>
        /// 是否在加班
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public bool IsOverTime(DateTime dt)
        {
            bool      flag       = false;
            DataTable overtimeDt = m_Dboperator.GetDataTable(Common.Table_OverTime, string.Format("{0}<#{1}# and {2}>#{1}# and {3}='{4}'",
                                                                                                  Common.Column_OverTimeBegin, dt, Common.Column_OverTimeEnd, dt, Common.Column_EmployeCode, m_Employee.Employee_Code));

            if (overtimeDt == null || overtimeDt.Rows.Count == 0)
            {
                return(flag);
            }
            else
            {
                flag = true;
            }
            _OTStartTime = Convert.ToDateTime(overtimeDt.Rows[0][Common.Column_OverTimeBegin]);
            _OTEndtime   = Convert.ToDateTime(overtimeDt.Rows[0][Common.Column_OverTimeEnd]);
            double.TryParse(overtimeDt.Rows[0][Common.Column_VacaDura].ToString(), out _OTDuration);
            return(flag);
        }
Пример #6
0
        private void GetExistAttenDate(int gYear, int gMonth)
        {
            DateTime minDt = new DateTime(gYear, gMonth, 1);
            DateTime maxDt = minDt.AddMonths(1);

            maxDt        = maxDt.AddDays(0 - maxDt.Day);
            m_AttenTable = m_dbOperator.GetDataTable(Common.Table_AttenDate,
                                                     string.Format("{0} between #{1}# and #{2}# order by {0} asc",
                                                                   Common.Column_AttendanceDate, minDt.ToString("yyyy-MM-dd"), maxDt.ToString("yyyy-MM-dd")));
            if (m_AttenTable != null && m_AttenTable.Rows.Count > 0)
            {
                if (m_AttenTable.Columns.Contains("ID"))
                {
                    m_AttenTable.Columns.Remove("ID");
                }
                m_gvTable.Rows.Clear();
                gridAttenDate.RefreshDataSource();
                DataRow pNewRow  = null;
                int     rowCount = m_AttenTable.Rows.Count;
                for (int i = 0; i < rowCount; i++)
                {
                    DataRow  pRow  = m_AttenTable.Rows[i];
                    DateTime pTime = Convert.ToDateTime(pRow[Common.Column_AttendanceDate]);
                    if (i == 0 || pTime.DayOfWeek == DayOfWeek.Monday)
                    {
                        pNewRow = m_gvTable.NewRow();
                    }
                    switch (pTime.DayOfWeek)
                    {
                    case DayOfWeek.Monday:
                        pNewRow["colmonday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;

                    case DayOfWeek.Saturday:
                        pNewRow["colsaturday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;

                    case DayOfWeek.Sunday:
                        pNewRow["colsunday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;

                    case DayOfWeek.Thursday:
                        pNewRow["colthursday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;

                    case DayOfWeek.Tuesday:
                        pNewRow["coltuesday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;

                    case DayOfWeek.Wednesday:
                        pNewRow["colwednesday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;

                    case DayOfWeek.Friday:
                        pNewRow["colfriday"] = string.Format("{0}-{1}", pTime.ToString("dd"), GetAttenTypeStr(pRow[Common.Column_AttenType]));
                        break;
                    }
                    if (pTime.DayOfWeek == DayOfWeek.Sunday)
                    {
                        m_gvTable.Rows.Add(pNewRow);
                        if (i == 0)
                        {
                            pNewRow = m_gvTable.NewRow();
                        }
                    }
                    if (i == rowCount - 1 && pTime.DayOfWeek != DayOfWeek.Sunday)
                    {
                        m_gvTable.Rows.Add(pNewRow);
                    }
                }
                gridAttenDate.RefreshDataSource();
            }
        }