| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- /*******************************************************************************
- * Copyright(c) 2014 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:TAT_CMN_001.cs
- * 2.功能描述:选择员工信息
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 冯雪 2014/09/23 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
- namespace Dongke.IBOSS.PRD.Client.Controls.FormCommon
- {
- /// <summary>
- /// 选择员工信息
- /// </summary>
- public partial class TAT_CMN_001 : FormBase
- {
- #region 成员变量
- // 画面的数据源
- //private DataTable _dataSource;
- // 返回用户的DataRow
- private DataRow _staffRow;
- // 查询条件
- private int _managerSalaryID;
- // 员工编号
- private string _staffCode;
- // 员工档案实体
- private DKStaffEntity _staffEntity = new DKStaffEntity();
- // 是否单选
- private bool _isSelectOne = false;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public TAT_CMN_001()
- {
- InitializeComponent();
- // 按钮
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnOK.Text = ButtonText.BTN_OK;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- this.Text = FormTitles.S_CMN_010;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 返回选择的员工行
- /// </summary>
- public DataRow StaffRow
- {
- get
- {
- return _staffRow;
- }
- set
- {
- _staffRow = value;
- }
- }
- /// <summary>
- /// 返回选择的员工档案信息
- /// </summary>
- public DKStaffEntity StaffEntity
- {
- get
- {
- return _staffEntity;
- }
- set
- {
- _staffEntity = value;
- }
- }
- /// <summary>
- /// 工号
- /// </summary>
- public int ManagerSalaryID
- {
- get { return _managerSalaryID; }
- set { _managerSalaryID = value; }
- }
- public bool IsSelectOne
- {
- get
- {
- return _isSelectOne;
- }
- set
- {
- _isSelectOne = value;
- }
- }
- /// <summary>
- /// 员工编号
- /// </summary>
- public string StaffCode1
- {
- get { return _staffCode; }
- set { _staffCode = value; }
- }
- /// <summary>
- /// 选择的数据
- /// </summary>
- public DataTable SelTable { get; set; }
- #endregion
- #region 事件
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void S_CMN_010_Load(object sender, EventArgs e)
- {
- try
- {
- this.dgvStaff.AutoGenerateColumns = false;
- this.txtStaffCode.Text = this._staffCode;
- this.Search();
- if (_isSelectOne == true)
- {
- this.chkChooseAll.Visible = false;
- this.Sel.Visible = false;
- this.dgvStaff.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- }
- }
- 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 btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this.Search();
- }
- 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 btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- if (_isSelectOne == true)
- {
- isSelectOneOK();
- }
- else
- {
- Commit();
- }
- }
- 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 btnClose_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- /// <summary>
- /// 选择所有事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void chkChooseAll_CheckedChanged(object sender, EventArgs e)
- {
- for (int i = 0; i < this.dgvStaff.Rows.Count; i++)
- {
- this.dgvStaff.Rows[i].Cells["Sel"].Value = this.chkChooseAll.Checked;
- }
- }
- /// <summary>
- /// 清空按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.txtStaffCode.Clear();
- this.txtStaffName.Clear();
- this.dkTargetobs.JobsID = null;
- this.dkTargetobs.Text = "";
- }
- #endregion
- #region 方法
- /// <summary>
- /// 查询方法
- /// </summary>
- private void Search()
- {
- try
- {
- // 清空之前的查询结果
- this.dgvStaff.DataSource = null;
- // 为查询实体赋值
- SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
- searchStaffEntity.ManagerSalaryID = this.ManagerSalaryID;
- searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
- searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
- searchStaffEntity.Jobs = this.dkTargetobs.JobsID;
- DataSet result = (DataSet)DoAsync(() =>
- {
- return HRModuleProxy.Service.SearchManagersOrMembers(searchStaffEntity);
- });
- // 绑定明细数据
- this.dgvStaff.DataSource = result.Tables[0];
- this.dgvStaff.Focus();
- // 当没有查询结果时,提示无查询结构消息
- if (this.dgvStaff.RowCount <= Constant.INT_IS_ZERO)
- {
- MessageBox.Show(ControlsTips.DK_SearchBox_NoResult,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtStaffCode.Focus();
- this.btnOK.Enabled = false;
- return;
- }
- this.btnOK.Enabled = true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 提交时给取得的行赋值
- /// </summary>
- private void Commit()
- {
- try
- {
- DataTable invDt = (DataTable)this.dgvStaff.DataSource;
- if (invDt == null || invDt.Rows.Count == 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- invDt.AcceptChanges();
- invDt = invDt.Copy();
- string filter = "Sel = 1";
- invDt.DefaultView.RowFilter = filter;
- invDt = invDt.DefaultView.ToTable();
- // 如果选中了数据就关闭窗体,反之则不关
- if (invDt.Rows.Count > 0)
- {
- SelTable = invDt;
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- protected void isSelectOneOK()
- {
- try
- {
- if (this.dgvStaff.SelectedRows.Count != 0)
- {
- String Staffid = this.dgvStaff.SelectedRows[0].Cells["Staffid"].Value.ToString();
- DataTable invDt = (DataTable)this.dgvStaff.DataSource;
- if (invDt == null || invDt.Rows.Count == 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"),this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning);
- return;
- }
- invDt.AcceptChanges();
- invDt = invDt.Copy();
- string filter = "Staffid = " + Staffid;
- invDt.DefaultView.RowFilter = filter;
- invDt = invDt.DefaultView.ToTable();
- // 如果选中了数据就关闭窗体,反之则不关
- if (invDt.Rows.Count > 0)
- {
- SelTable = invDt;
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"),this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|