/******************************************************************************* * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PC_0601.cs * 2.功能描述:员工关联 * 编辑履历: * 作者 日期 版本 修改内容 * 袁新成 2015/04/17 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Reflection; 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.Controls; using Dongke.IBOSS.PRD.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.PCModule { /// /// 员工关联 /// public partial class F_PC_0601 : DKDockPanelBase { #region 成员变量 // 单例模式 private static F_PC_0601 _instance; // 正在查询 private bool _isSearching = false; #endregion #region 构造函数 public F_PC_0601() { InitializeComponent(); this.Text = FormTitles.F_PC_0601; this.tsbtnAdd.Text = ButtonText.TSBTN_ADD; this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; this.btnSearch.Text = ButtonText.BTN_SEARCH; this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PC_0601 Instance { get { if (_instance == null) { _instance = new F_PC_0601(); } return _instance; } } #endregion #region 事件 /// /// 搜索按钮事件 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { this._isSearching = true; this.dgvUser.DataSource = null; this.dgvStaff.DataSource = null; this.DataSource = this.GetSearchData(); if (this.DataSource != null) { this.dgvUser.DataSource = this.DataSource.Tables[0]; if (this.DataSource.Tables.Count > 1) { this.dgvStaff.DataSource = this.DataSource.Tables[1]; } } this._isSearching = false; } catch (Exception ex) { this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 清空按钮事件 /// /// /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtUserCode.Clear(); this.txtRemarks.Clear(); } /// /// 选定项改变事件 /// /// /// private void dgvUser_SelectionChanged(object sender, EventArgs e) { if (this._isSearching) { return; } try { DataGridViewRow currentRow = this.dgvUser.CurrentRow; if (currentRow != null) { int id = Convert.ToInt32(currentRow.Cells["userid"].Value); this.dgvStaff.DataSource = null; // 调用服务器端获取数据集 ServiceResultEntity sre = DoAsync(() => { return PCModuleProxyNew.Service.GetFPC0601SNData(id); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { this.dgvStaff.DataSource = sre.Data.Tables[0]; } } else { DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 新增按钮事件 /// /// /// private void tsbtnAddUser_Click(object sender, EventArgs e) { try { F_PC_0602 frmFPC0602 = new F_PC_0602(null, null); DialogResult dialogresult = frmFPC0602.ShowDialog(); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 单元格双击事件 /// /// /// private void dgvUser_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } this.tsbtnEditUser_Click(sender, e); } /// /// 编辑按钮事件 /// /// /// private void tsbtnEditUser_Click(object sender, EventArgs e) { try { if (this.dgvUser.SelectedRows.Count != 0) { string userId = this.dgvUser.SelectedRows[0].Cells["userId"].Value.ToString(); string userCode = this.dgvUser.SelectedRows[0].Cells["userCode"].Value.ToString(); F_PC_0602 frmFPC0602 = new F_PC_0602(Convert.ToInt32(userId), userCode); DialogResult dialogresult = frmFPC0602.ShowDialog(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体加载事件 /// /// /// private void F_PC_0601_Load(object sender, EventArgs e) { // 按钮权限控制 FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); } /// /// 自适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 关闭按钮事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 释放窗体 /// /// /// private void F_PC_0601_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } #endregion #region 私有方法 /// /// 根据界面查询条件获取数据集 /// private DataSet GetSearchData() { try { FPC0601_SE se = new FPC0601_SE(); se.UserCode = this.txtUserCode.Text; se.Remarks = this.txtRemarks.Text; // 调用服务器端获取数据集 ServiceResultEntity sre = DoAsync(() => { return PCModuleProxyNew.Service.GetFPC0601SData(se); } ); if (sre.Status == Constant.ServiceResultStatus.Success) { return sre.Data; } return null; } catch (Exception ex) { throw ex; } } #endregion } }