| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_HR_0401.cs
- * 2.功能描述:员工离职
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 张国印 2014/09/16 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.HRModule
- {
- /// <summary>
- /// 员工离职
- /// </summary>
- public partial class F_HR_0401 : DockPanelBase
- {
- #region 成员变量
- // 窗体的单例模式
- private static F_HR_0401 _instance;
- //Grid当前选中的行
- private int _selectedRowIndex;
- // 查询条件实体
- private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
- //用户编辑的ID集合
- int[] _staffIDList;
- // 员工ID
- private int _staffID;
- #endregion
- #region 构造函数处理
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_HR_0401()
- {
- InitializeComponent();
- this.SetFromTitleInfo();
- // 设置ToolStripButton状态
- //this.SetToolStripButtonEnable();
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_HR_0401 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_HR_0401();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_HR_0401_Load(object sender, EventArgs e)
- {
- try
- {
- FormPermissionManager.FormPermissionControl(this.Name, this,
- LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- this.tsbtnDisable.Visible = false;
- // 加载员工状态
- DataTable dtStaffStatus = LogInUserInfo.CurrentUser.GetSystemParameterByName(Constant.SysCacheTable.TP_SYS_StaffStatus);
- this.SelStaffStatus.DataSource = dtStaffStatus;
- this.SelStaffStatus.SelectedValues = new object[] { 0, 1, 2 };
- //this.SelStaffStatus.AllItemCheck();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_HR_0401_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 行获取焦点后查看明细
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvStaff_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvStaff.CurrentCell != null)
- {
- // 记录最后选择行
- this._selectedRowIndex = this.dgvStaff.CurrentCell.RowIndex;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 单元格鼠标双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- // private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- // {
- // if (Constant.INT_IS_NEGATIE_ONE < e.RowIndex && Constant.INT_IS_NEGATIE_ONE < e.ColumnIndex
- // && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
- // {
- //this.tsbtnTurnover_Click(sender, e);
- // }
- // }
- /// <summary>
- /// 添加按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- //private void tsbtnAdd_Click(object sender, EventArgs e)
- //{
- // try
- // {
- //F_HR_0402 frmHR0402 = new F_HR_0402(Constant.FormMode.Add, Constant.INT_IS_NEGATIE_ONE, Constant.INT_IS_NEGATIE_ONE);
- //if (frmHR0402.ShowDialog() == DialogResult.OK)
- //{
- // this._staffIDList = frmHR0402.StaffIDList.ToArray();
- // DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.GetDataGridViewInfo));
- // if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
- // && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- // {
- // this.dgvStaff.DataSource = null;
- // this.dgvStaff.DataSource = userDataSet.Tables[0];
- // // 设置ToolStripButton按钮状态
- // this.SetToolStripButtonEnable();
- // this.dgvStaff.ReadOnly = true;
- // }
- //}
- // }
- // catch (Exception ex)
- // {
- // // 对异常进行共通处理
- // ExceptionManager.HandleEventException(this.ToString(),
- // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- // }
- //}
- /// <summary>
- /// 编辑按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- //private void tsbtnEdit_Click(object sender, EventArgs e)
- //{
- // try
- // {
- //if (this.dgvStaff.CurrentRow != null)
- //{
- // if (this.dgvStaff.CurrentRow.Cells["ApprovalStatus"].Value == null || this.dgvStaff.CurrentRow.Cells["RecordType"].Value == null)
- // {
- // MessageBox.Show(string.Format(Messages.MSG_HR_W007, "员工离职", "编辑"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- // }
- // string strApprovalStatus = this.dgvStaff.CurrentRow.Cells["ApprovalStatus"].Value.ToString();
- // string strRecordType = this.dgvStaff.CurrentRow.Cells["RecordType"].Value.ToString();
- // if (Constant.ApprovalStatus.Pending.GetHashCode().ToString().Equals(strApprovalStatus)
- // && Constant.StaffRecordType.Departure.GetHashCode().ToString().Equals(strRecordType))
- // {
- // int intStaffID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffID"].Value);
- // int intStaffRecordID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffRecordID"].Value);
- // F_HR_0402 frmHR0402 = new F_HR_0402(Constant.FormMode.Edit, intStaffID, intStaffRecordID);
- // if (frmHR0402.ShowDialog() == DialogResult.OK)
- // {
- // this._staffIDList = frmHR0402.StaffIDList.ToArray();
- // DataSet userDataSet = (DataSet)DoAsync(new AsyncMethod(this.GetDataGridViewInfo));
- // if (userDataSet != null && userDataSet.Tables.Count > Constant.INT_IS_ZERO
- // && userDataSet.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- // {
- // this.dgvStaff.DataSource = null;
- // this.dgvStaff.DataSource = userDataSet.Tables[0];
- // // 设置ToolStripButton按钮状态
- // this.SetToolStripButtonEnable();
- // this.dgvStaff.ReadOnly = true;
- // }
- // }
- // }
- // else
- // {
- // MessageBox.Show(string.Format(Messages.MSG_HR_W007, "员工离职", "编辑"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- // }
- //}
- // }
- // catch (Exception ex)
- // {
- // // 对异常进行共通处理
- // ExceptionManager.HandleEventException(this.ToString(),
- // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- // }
- //}
- /// <summary>
- /// 停用按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnDisable_Click(object sender, EventArgs e)
- {
- try
- {
- DialogResult msgBoxResult = MessageBox.Show(
- string.Format(Messages.MSG_CMN_Q002, "该员工", "停用"), this.Text,
- MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (msgBoxResult == DialogResult.Yes)
- {
- int staffid = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffRecordID"].Value);
- this._staffID = staffid;
- HRResultEntity resultStaff = (HRResultEntity)DoAsync(() =>
- {
- return HRModuleProxy.Service.SetStaffRecordValueFlag(_staffID);
- }
- );
- //this.dgvStaff.ReadOnly = true;
- // 修改成功
- if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工离职", "停用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.btnSearch_Click(sender, e);
- }
- else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_FIVE)
- {
- MessageBox.Show(Messages.MSG_HR_W002,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "员工离职", "停用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 更多条件按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnMoreCondition_Click(object sender, EventArgs e)
- {
- HR_CMN_001 frmCMN001 = new HR_CMN_001();
- frmCMN001.StaffEntity = _staffEntity;
- if (frmCMN001.ShowDialog() == DialogResult.OK)
- {
- this.txtOtherWhere.Text = frmCMN001.StaffEntity.GetSqlDispText();
- this._staffEntity = frmCMN001.StaffEntity;
- }
- }
- /// <summary>
- /// 自动适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 查询按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this._staffIDList = null;
- // 记录当前选中行
- int selectRowIndex = this._selectedRowIndex;
- DataSet dsResultStaff = (DataSet)DoAsync(new AsyncMethod(this.GetDataGridViewInfo));
- if (dsResultStaff != null)
- {
- if (!dsResultStaff.Tables[0].Columns.Contains("Sel"))
- {
- dsResultStaff.Tables[0].Columns.Add("Sel", typeof(int));
- }
- base.DataSource = dsResultStaff;
- if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvStaff.DataSource = this.DataSource.Tables[0];
- if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- #region 选择原有行
- if (selectRowIndex >= Constant.INT_IS_ZERO)
- {
- if (selectRowIndex >= dsResultStaff.Tables[0].Rows.Count)
- {
- this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
- this.dgvStaff.CurrentCell = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffCode"];
- }
- else
- {
- this.dgvStaff.Rows[selectRowIndex].Selected = true;
- this.dgvStaff.CurrentCell = this.dgvStaff.Rows[selectRowIndex].Cells["StaffCode"];
- }
- }
- #endregion
- }
- }
- foreach (DataGridViewColumn col in this.dgvStaff.Columns)
- {
- col.ReadOnly = col.Name == "Sel" ? false:true;
- }
- }
- //this.SetToolStripButtonEnable();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- // 加载员工状态
- DataTable dtStaffStatus = LogInUserInfo.CurrentUser.GetSystemParameterByName(Constant.SysCacheTable.TP_SYS_StaffStatus);
- this.SelStaffStatus.DataSource = dtStaffStatus;
- this.SelStaffStatus.SelectedValues = new object[] { 0, 1, 2 };
- //this.SelStaffStatus.AllItemCheck();
- this.txtStaffCode.Clear();
- this.txtStaffName.Clear();
- this.txtOtherWhere.Clear();
- this._staffEntity.ClearEntityValue();
- }
- /// <summary>
- /// 导入按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnImport_Click(object sender, EventArgs e)
- {
- try
- {
- this.oFileDialog.Filter = "Excel文件|*.xls;*.xlsx|Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
- this.oFileDialog.FileName = string.Empty;
- if (this.oFileDialog.ShowDialog() != DialogResult.OK)
- {
- return;
- }
- int v = (".xlsx" == System.IO.Path.GetExtension(this.oFileDialog.FileName)) ? 1 : 0;
- DataTable dtStaffInfo = ExcelLayer.GetDataTable(this.oFileDialog.FileName, "Staff", v);
- #region 对数据进行验证
- if (dtStaffInfo == null || dtStaffInfo.Rows.Count < 1)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "文件正在被占用 或 导入的Excel文件中没有符合规则的数据!"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!CheckImportExcel(dtStaffInfo))
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "导入模板错误!"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!CheckImportExcelData(dtStaffInfo))
- {
- return;
- }
- if (dtStaffInfo.Rows.Count < 1)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "导入的Excel文件中的数据没有员工编码!"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- #endregion
- if (MessageBox.Show("导入成功,是否全部离职", this.Text,
- MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
- {
- DataSet dsStaffInfo = new DataSet();
- dsStaffInfo.Tables.Add(dtStaffInfo.Copy());
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "HR001";
- cre.Name = "ImportStaffTurnover";
- cre.Data = dsStaffInfo;
- ServiceResultEntity result = CommonModuleProxy.Service.DoRequest(cre);
- if (result.Status == Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工离职", "导入"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- // 导入成功之后,查询
- string[] ids = (result.Result + "").Split(',');
- this._staffIDList = new int[ids.Length];
- for (int i = 0; i < ids.Length; i++)
- {
- this._staffIDList[i] = int.Parse(ids[i]);
- }
- DataSet dsHrStaff = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaff));
- if (dsHrStaff != null && dsHrStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsHrStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dgvStaff.DataSource = null;
- this.dgvStaff.DataSource = dsHrStaff.Tables[0];
- }
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, result.Message),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 下载模板按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnDown_Click(object sender, EventArgs e)
- {
- try
- {
- TempletFileEntity resultTemplet = (TempletFileEntity)DoAsync(new AsyncMethod(() =>
- {
- return CommonModuleProxy.Service.GetTempletFileContentByUrl(Constant.HR_STAFF_DIMISSION_TEMPLET);
- }));
- if (string.IsNullOrEmpty(resultTemplet.FileName))
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_W021, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- this.sfDialogTemplet.FileName = resultTemplet.FileName;
- this.sfDialogTemplet.Filter = "Excel文件(*.xlsx)|*.xlsx";
- if (this.sfDialogTemplet.ShowDialog() == DialogResult.OK)
- {
- string localFilePath = this.sfDialogTemplet.FileName.ToString(); //获得文件路径
- System.IO.File.WriteAllBytes(localFilePath, resultTemplet.FileContent);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 离职按钮点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnTurnover_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvStaff.DataSource == null || this.dgvStaff.CurrentRow == null)
- {
- // 提示未查找到数据
- MessageBox.Show("未选择任何数据", this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- (this.dgvStaff.DataSource as DataTable).AcceptChanges();
- DataTable dtStaff = (this.dgvStaff.DataSource as DataTable).Copy();
- dtStaff.DefaultView.RowFilter = "Sel = 1";
- dtStaff = dtStaff.DefaultView.ToTable();
- if (dtStaff.Rows.Count == 0)
- {
- // 提示未查找到数据
- MessageBox.Show("未选择任何数据", this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (MessageBox.Show("是否进行离职操作?", this.Text,
- MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
- {
- string staffIDs = string.Empty;
- foreach (DataRow row in dtStaff.Rows)
- {
- staffIDs += row["StaffID"] + ",";
- }
- staffIDs = staffIDs.Substring(0, staffIDs.Length - 1);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "HR001";
- cre.Name = "StaffTurnover";
- cre.Properties["staffIDs"] = staffIDs;
- DataSet dsStaff = new DataSet();
- dsStaff.Tables.Add(dtStaff);
- cre.Data = dsStaff;
- ServiceResultEntity result = CommonModuleProxy.Service.DoRequest(cre);
- if (result.Status == Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工离职", "离职"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- // 操作成功之后,查询
- string[] ids = staffIDs.Split(',');
- this._staffIDList = new int[ids.Length];
- for (int i = 0; i < ids.Length; i++)
- {
- this._staffIDList[i] = int.Parse(ids[i]);
- }
- DataSet dsHrStaff = (DataSet)DoAsync(new AsyncMethod(this.SearchHrStaff));
- if (dsHrStaff != null && dsHrStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsHrStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dgvStaff.DataSource = null;
- this.dgvStaff.DataSource = dsHrStaff.Tables[0];
- // 设置ToolStripButton按钮状态
- //this.SetToolStripButtonEnable();
- }
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, result.Message),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 提交对选择列的修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvStaff_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvStaff.CurrentRow != null && this.dgvStaff.IsCurrentCellDirty)
- {
- if ("Sel".Equals(this.dgvStaff.Columns[this.dgvStaff.CurrentCell.ColumnIndex].Name))
- {
- this.dgvStaff.CommitEdit(DataGridViewDataErrorContexts.Commit);
- if ("已离职".Equals(this.dgvStaff.CurrentRow.Cells["StaffStatusName"].Value + ""))
- {
- MessageBox.Show("不能选择已经离职的员工",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.dgvStaff.CurrentRow.Cells["Sel"].Value = 0;
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 获取员工档案数据集
- /// </summary>
- /// <returns></returns>
- private DataSet SearchHrStaff()
- {
- SearchStaffEntity pSearchStaff = new SearchStaffEntity();
- if (this._staffIDList != null && this._staffIDList.Length > Constant.INT_IS_ZERO)
- {
- pSearchStaff.RStaffRecordIDList = this._staffIDList;
- this._staffIDList = null;
- }
- else
- {
- DataConvert.Convert(_staffEntity, pSearchStaff);
- pSearchStaff.StaffCode = this.txtStaffCode.Text.Trim();
- pSearchStaff.StaffName = this.txtStaffName.Text.Trim();
- pSearchStaff.ValueFlag = true;
- pSearchStaff.StaffStatusArray = SelStaffStatus.SelectedArray;
- }
- try
- {
- return HRModuleProxy.Service.SearchHrStaff(pSearchStaff);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 设置工具按钮的可用状态
- /// </summary>
- /// <remarks>
- //private void SetToolStripButtonEnable()
- // {
- // if (this.dgvStaff.CurrentCell != null)
- // {
- // this.tsbtnEdit.Enabled = true;
- // }
- // else
- // {
- // this.tsbtnEdit.Enabled = false;
- // }
- // }
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- private void SetFromTitleInfo()
- {
- this.Text = FormTitles.F_HR_0401;
- //this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- //this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
- this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
- }
- /// <summary>
- /// 根据查询条件获取要显示的数据
- /// </summary>
- /// <returns>返回查询的结果集</returns>
- private DataSet GetDataGridViewInfo()
- {
- SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
- DataConvert.Convert(this._staffEntity, searchStaffEntity);
- searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
- searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
- //searchStaffEntity.Recordtype = Constant.StaffRecordType.Departure.GetHashCode(); //6:离职
- //searchStaffEntity.RValueflag = Constant.ValueFlag.Effective.GetHashCode(); //1:正常
- searchStaffEntity.StaffStatusArray = SelStaffStatus.SelectedArray;
- searchStaffEntity.ValueFlag = true;
- if (this._staffIDList != null && this._staffIDList.Length > Constant.INT_IS_ZERO)
- {
- searchStaffEntity.RStaffRecordIDList = this._staffIDList;
- }
- //return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
- return WCF.Proxys.HRModuleProxy.Service.SearchHrStaff(searchStaffEntity);
- }
- /// <summary>
- /// 导入的Excel列验证
- /// </summary>
- /// <param name="datatable"></param>
- /// <returns></returns>
- private bool CheckImportExcel(DataTable datatable)
- {
- if (datatable.Columns.Count < 1)
- {
- return false;
- }
- if (!datatable.Columns.Contains("员工编码"))
- {
- return false;
- }
- if (!datatable.Columns.Contains("离职日期"))
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 导入的Excel数据验证
- /// </summary>
- /// <param name="datatable"></param>
- /// <returns></returns>
- private bool CheckImportExcelData(DataTable datatable)
- {
- List<string> codes = new List<string>();
- string code = string.Empty;
- foreach (DataRow item in datatable.Rows)
- {
- code = item["员工编码"] + "";
- if (string.IsNullOrWhiteSpace(code))
- {
- item.Delete();
- continue;
- }
- if (codes.Contains(code))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "员工编码【" + code + "】重复。"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
- codes.Add(code);
- }
- datatable.AcceptChanges();
- return true;
- }
- #endregion
- }
- }
|