Exemple #1
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;
        }
Exemple #2
0
        private bool GetAttenDt(DateTime minDt, DateTime maxDt)
        {
            bool flag = false;

            m_AttenDt = m_mainDbOp.GetDataTable(Common.Table_Atten, string.Format("{0} between #{1}# and #{2}# order by {0} asc",
                                                                                  Common.Column_AttenDate, minDt.ToString("yyyy-MM-dd"), maxDt.ToString("yyyy-MM-dd"), Common.Column_AttendanceDate));
            if (m_AttenDt == null || m_AttenDt.Rows.Count == 0)
            {
                XtraMessageBox.Show("未导入打卡记录,请先导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "*.xls|*.xls|*.xlsx|*.xlsx";
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return(flag);
                }
                string    selectFileName = openFileDialog.FileName;
                DataTable pExcleDt       = ExcelHelper.GetTableFromFile(selectFileName);
                if (pExcleDt == null)
                {
                    XtraMessageBox.Show("读取Excel数据出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(flag);
                }
                pExcleDt.TableName = Common.Table_Atten;
                if (m_mainDbOp.ImportDataTable(pExcleDt))
                {
                    XtraMessageBox.Show("成功导入考勤数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                m_AttenDt = m_mainDbOp.GetDataTable(Common.Table_Atten, string.Format("{0} between #{1}# and #{2}# order by {0} asc",
                                                                                      Common.Column_AttenDate, minDt.ToString("yyyy-MM-dd"), maxDt.ToString("yyyy-MM-dd"), Common.Column_AttendanceDate));
                if (m_AttenDt == null || m_AttenDt.Rows.Count == 0)
                {
                    return(flag);
                }
                else
                {
                    flag = true;
                }
            }
            else
            {
                flag = true;
            }
            return(flag);
        }
Exemple #3
0
        /// <summary>
        /// 获取考勤列表并保存到数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (m_gvTable.Rows.Count == 0)
            {
                XtraMessageBox.Show("提示", "先生成考勤日期", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (m_AttenTable == null)
            {
                m_AttenTable = new DataTable(Common.Column_AttendanceDate);
                DataColumn col = new DataColumn();
                col.ColumnName = Common.Column_AttendanceDate;
                col.DataType   = Type.GetType("System.DateTime");
                m_AttenTable.Columns.Add(col);
                col            = new DataColumn();
                col.ColumnName = Common.Column_AttenType;
                col.DataType   = Type.GetType("System.String");
                m_AttenTable.Columns.Add(col);
            }
            else
            {
                m_AttenTable.Rows.Clear();
            }
            int selectYear  = int.Parse(seYear.EditValue.ToString());
            int selectMonth = 0;

            foreach (int key in m_dicMothn.Keys)
            {
                if (m_dicMothn[key] == cbMonth.SelectedItem.ToString())
                {
                    selectMonth = key;
                    break;
                }
            }
            foreach (DataRow pRow in m_gvTable.Rows)
            {
                foreach (DataColumn col in m_gvTable.Columns)
                {
                    if (pRow[col] != DBNull.Value)
                    {
                        string[] rowValue = pRow[col].ToString().Split('-');
                        DataRow  pNewRow  = m_AttenTable.NewRow();
                        DateTime dt       = new DateTime(selectYear, selectMonth, int.Parse(rowValue[0]));
                        pNewRow[Common.Column_AttendanceDate] = dt;
                        pNewRow[Common.Column_AttenType]      = (int)m_dicAttenType[rowValue[1]];
                        m_AttenTable.Rows.Add(pNewRow);
                    }
                }
            }
            //先删后加
            DateTime minDt = new DateTime(selectYear, selectMonth, 1);
            DateTime maxDt = minDt.AddMonths(1);

            maxDt = maxDt.AddDays(0 - maxDt.Day);

            if (!m_dbOperator.DelData(Common.Table_AttenDate,
                                      string.Format("{0} between #{1}# and #{2}#",
                                                    Common.Column_AttendanceDate, minDt.ToString("yyyy-MM-dd"), maxDt.ToString("yyyy-MM-dd"))))
            {
                XtraMessageBox.Show("删除数据出错", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (m_dbOperator.ImportDataTable(m_AttenTable))
            {
                XtraMessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                XtraMessageBox.Show("保存失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }