/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_MST_1301.cs * 2.功能描述:员工工位 * 编辑履历: * 作者 日期 版本 修改内容 * 付斌 2020/11/06 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.DockPanel; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.SystemModule { /// /// 员工工位 /// public partial class F_MST_1301 : DockPanelBase { #region 成员变量 private static F_MST_1301 _instance; // 单例模式 #endregion #region 构造函数 public F_MST_1301() { InitializeComponent(); this.Text = FormTitles.F_MST_1301; 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_MST_1301 Instance { get { if (_instance == null) { _instance = new F_MST_1301(); } return _instance; } } #endregion #region 事件 /// /// 窗体加载事件 /// /// /// private void F_MST_1301_Load(object sender, EventArgs e) { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); this.dgvWorkStation.AutoGenerateColumns = false; this.dgvUser.AutoGenerateColumns = false; } /// /// 搜索按钮事件 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { dgvWorkStation.DataSource = null; dgvUser.DataSource = null; ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_MST_1301"; cre.Name = "GetWorkStation"; cre.Properties["workstationname"] = txtWorkStationName.Text.Trim(); cre.Properties["remarks"] = txtRemarks.Text.Trim(); // 异步处理 this.btnSearch.Enabled = false; this.btnClearCondition.Enabled = false; ServiceResultEntity sre = (ServiceResultEntity)DoAsync( () => { return SystemModuleProxy.Service.DoRequest(cre); }); this.btnSearch.Enabled = true; this.btnClearCondition.Enabled = true; if (sre.Data.Tables[0].Rows.Count == 0) { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } dgvWorkStation.DataSource = sre.Data.Tables[0]; } 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.txtWorkStationName.Clear(); this.txtRemarks.Clear(); } /// /// 工位工号配置按钮事件 /// /// /// private void tsbtnAddUser_Click(object sender, EventArgs e) { try { if (dgvWorkStation.CurrentRow == null || dgvUser.DataSource == null) { MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "未选择任何工位"), Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } F_MST_1302 frm = new F_MST_1302(); frm.drWorkStation = (this.dgvWorkStation.CurrentRow.DataBoundItem as DataRowView).Row; frm.dtWorkStationUser = (dgvUser.DataSource as DataTable).Copy(); DialogResult drs = frm.ShowDialog(); if (drs == DialogResult.OK) { btnSearch_Click(null, null); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 自适应列宽 /// /// /// 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 dgvWorkStation_SelectionChanged(object sender, EventArgs e) { try { if (dgvWorkStation.CurrentCell != null) { int workstationid = Convert.ToInt32(dgvWorkStation.CurrentRow.Cells["WorkStationID"].Value.ToString()); ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_MST_1301"; cre.Name = "GetWorkStationUser"; cre.Properties["workstationid"] = workstationid; // 异步处理 ServiceResultEntity sre = (ServiceResultEntity)DoAsync( () => { return SystemModuleProxy.Service.DoRequest(cre); }); this.dgvUser.DataSource = sre.Data.Tables[0]; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 单元格双击事件 /// /// /// private void dgvWorkStation_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { tsbtnAddUser_Click(null, null); } /// /// 释放窗体 /// /// /// private void F_MST_1301_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } #endregion } }