F_MST_1301.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_1301.cs
  5. * 2.功能描述:员工工位
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2020/11/06 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. namespace Dongke.IBOSS.PRD.Client.SystemModule
  19. {
  20. /// <summary>
  21. /// 员工工位
  22. /// </summary>
  23. public partial class F_MST_1301 : DockPanelBase
  24. {
  25. #region 成员变量
  26. private static F_MST_1301 _instance; // 单例模式
  27. #endregion
  28. #region 构造函数
  29. public F_MST_1301()
  30. {
  31. InitializeComponent();
  32. this.Text = FormTitles.F_MST_1301;
  33. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  34. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  35. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  36. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  37. }
  38. #endregion
  39. #region 单例模式
  40. /// <summary>
  41. /// 单例模式,防止重复创建窗体
  42. /// </summary>
  43. public static F_MST_1301 Instance
  44. {
  45. get
  46. {
  47. if (_instance == null)
  48. {
  49. _instance = new F_MST_1301();
  50. }
  51. return _instance;
  52. }
  53. }
  54. #endregion
  55. #region 事件
  56. /// <summary>
  57. /// 窗体加载事件
  58. /// </summary>
  59. /// <param name="sender"></param>
  60. /// <param name="e"></param>
  61. private void F_MST_1301_Load(object sender, EventArgs e)
  62. {
  63. // 加载权限
  64. FormPermissionManager.FormPermissionControl(this.Name, this,
  65. DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  66. DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  67. this.dgvWorkStation.AutoGenerateColumns = false;
  68. this.dgvUser.AutoGenerateColumns = false;
  69. }
  70. /// <summary>
  71. /// 搜索按钮事件
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void btnSearch_Click(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. dgvWorkStation.DataSource = null;
  80. dgvUser.DataSource = null;
  81. ClientRequestEntity cre = new ClientRequestEntity();
  82. cre.NameSpace = "F_MST_1301";
  83. cre.Name = "GetWorkStation";
  84. cre.Properties["workstationname"] = txtWorkStationName.Text.Trim();
  85. cre.Properties["remarks"] = txtRemarks.Text.Trim();
  86. // 异步处理
  87. this.btnSearch.Enabled = false;
  88. this.btnClearCondition.Enabled = false;
  89. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(
  90. () => { return SystemModuleProxy.Service.DoRequest(cre); });
  91. this.btnSearch.Enabled = true;
  92. this.btnClearCondition.Enabled = true;
  93. if (sre.Data.Tables[0].Rows.Count == 0)
  94. {
  95. // 提示未查找到数据
  96. MessageBox.Show(Messages.MSG_CMN_I002, Text,
  97. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  98. return;
  99. }
  100. dgvWorkStation.DataSource = sre.Data.Tables[0];
  101. }
  102. catch (Exception ex)
  103. {
  104. this.btnSearch.Enabled = true;
  105. this.btnClearCondition.Enabled = true;
  106. // 对异常进行共通处理
  107. ExceptionManager.HandleEventException(this.ToString(),
  108. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  109. }
  110. }
  111. /// <summary>
  112. /// 清空按钮事件
  113. /// </summary>
  114. /// <param name="sender"></param>
  115. /// <param name="e"></param>
  116. private void btnClearCondition_Click(object sender, EventArgs e)
  117. {
  118. this.txtWorkStationName.Clear();
  119. this.txtRemarks.Clear();
  120. }
  121. /// <summary>
  122. /// 工位工号配置按钮事件
  123. /// </summary>
  124. /// <param name="sender"></param>
  125. /// <param name="e"></param>
  126. private void tsbtnAddUser_Click(object sender, EventArgs e)
  127. {
  128. try
  129. {
  130. if (dgvWorkStation.CurrentRow == null || dgvUser.DataSource == null)
  131. {
  132. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "未选择任何工位"),
  133. Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  134. return;
  135. }
  136. F_MST_1302 frm = new F_MST_1302();
  137. frm.drWorkStation = (this.dgvWorkStation.CurrentRow.DataBoundItem as DataRowView).Row;
  138. frm.dtWorkStationUser = (dgvUser.DataSource as DataTable).Copy();
  139. DialogResult drs = frm.ShowDialog();
  140. if (drs == DialogResult.OK)
  141. {
  142. btnSearch_Click(null, null);
  143. }
  144. }
  145. catch (Exception ex)
  146. {
  147. // 对异常进行共通处理
  148. ExceptionManager.HandleEventException(this.ToString(),
  149. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  150. }
  151. }
  152. /// <summary>
  153. /// 自适应列宽
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  158. {
  159. this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  160. }
  161. /// <summary>
  162. /// 关闭按钮事件
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void tsbtnClose_Click(object sender, EventArgs e)
  167. {
  168. this.Close();
  169. }
  170. /// <summary>
  171. /// 工位行切换事件
  172. /// </summary>
  173. /// <param name="sender"></param>
  174. /// <param name="e"></param>
  175. private void dgvWorkStation_SelectionChanged(object sender, EventArgs e)
  176. {
  177. try
  178. {
  179. if (dgvWorkStation.CurrentCell != null)
  180. {
  181. int workstationid = Convert.ToInt32(dgvWorkStation.CurrentRow.Cells["WorkStationID"].Value.ToString());
  182. ClientRequestEntity cre = new ClientRequestEntity();
  183. cre.NameSpace = "F_MST_1301";
  184. cre.Name = "GetWorkStationUser";
  185. cre.Properties["workstationid"] = workstationid;
  186. // 异步处理
  187. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(
  188. () => { return SystemModuleProxy.Service.DoRequest(cre); });
  189. this.dgvUser.DataSource = sre.Data.Tables[0];
  190. }
  191. }
  192. catch (Exception ex)
  193. {
  194. // 对异常进行共通处理
  195. ExceptionManager.HandleEventException(this.ToString(),
  196. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  197. }
  198. }
  199. /// <summary>
  200. /// 单元格双击事件
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void dgvWorkStation_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  205. {
  206. tsbtnAddUser_Click(null, null);
  207. }
  208. /// <summary>
  209. /// 释放窗体
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. private void F_MST_1301_FormClosed(object sender, FormClosedEventArgs e)
  214. {
  215. _instance = null;
  216. }
  217. #endregion
  218. }
  219. }