F_MST_1202.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_1202.cs
  5. * 2.功能描述:工号分组
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2016/11/10 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. namespace Dongke.IBOSS.PRD.Client.SystemModule
  21. {
  22. /// <summary>
  23. /// 工号分组
  24. /// </summary>
  25. public partial class F_MST_1202 : DKFormBase
  26. {
  27. #region 成员变量
  28. private int _groupID = 0;
  29. private DataTable _info = null;
  30. private DataTable _users = null;
  31. #endregion
  32. #region 构造函数
  33. public F_MST_1202(int groupID)
  34. {
  35. InitializeComponent();
  36. if (groupID > 0)
  37. {
  38. this.Text = "编辑工号分组";
  39. }
  40. else
  41. {
  42. this.Text = "新建工号分组";
  43. }
  44. this.btnSave.Text = ButtonText.BTN_SAVE;
  45. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  46. this.dgvUser.AutoGenerateColumns = false;
  47. this._groupID = groupID;
  48. }
  49. #endregion
  50. #region 事件
  51. /// <summary>
  52. /// 关闭窗体
  53. /// </summary>
  54. private void btnCancel_Click(object sender, EventArgs e)
  55. {
  56. this.Close();
  57. }
  58. /// <summary>
  59. /// 提交新建
  60. /// </summary>
  61. private void btnSave_Click(object sender, EventArgs e)
  62. {
  63. try
  64. {
  65. if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
  66. {
  67. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "分组名称"), this.Text,
  68. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  69. this.txtName.Focus();
  70. return;
  71. }
  72. if (this.dkDefectTypeNameSearchBox1.DefectTypeID == null)
  73. {
  74. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "缺陷类别"), this.Text,
  75. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  76. this.dkDefectTypeNameSearchBox1.Focus();
  77. return;
  78. }
  79. int displayno = (this.txtDisplayNo.DataValue == null ? 0:Convert.ToInt32(this.txtDisplayNo.DataValue));
  80. this._info.Rows[0]["workergroupname"] = this.txtName.Text.Trim();
  81. this._info.Rows[0]["remarks"] = this.txtRemarks.Text;
  82. this._info.Rows[0]["displayno"] = displayno;
  83. this._info.Rows[0]["defecttypeid"] = this.dkDefectTypeNameSearchBox1.DefectTypeID.Value;
  84. ClientRequestEntity cre = new ClientRequestEntity();
  85. cre.NameSpace = "MST_WorkerGroup";
  86. cre.Name = "SetWorkerGroup";
  87. cre.Data = this._info.DataSet;
  88. cre.Data.AcceptChanges();
  89. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  90. {
  91. return SystemModuleProxy.Service.DoBarCodePrint(cre);
  92. }
  93. );
  94. if (sre.Status == Constant.ServiceResultStatus.Success)
  95. {
  96. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工号分组", "保存"),
  97. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  98. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  99. this.Close();
  100. return;
  101. }
  102. }
  103. catch (Exception ex)
  104. {
  105. // 对异常进行共通处理
  106. ExceptionManager.HandleEventException(this.ToString(),
  107. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  108. }
  109. }
  110. /// <summary>
  111. /// 窗体加载事件
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void F_MST_1202_Load(object sender, EventArgs e)
  116. {
  117. try
  118. {
  119. ClientRequestEntity cre = new ClientRequestEntity();
  120. cre.NameSpace = "MST_WorkerGroup";
  121. cre.Name = "GetWorkerGroupList";
  122. cre.Properties["GroupID"] = this._groupID;
  123. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  124. {
  125. return SystemModuleProxy.Service.DoBarCodePrint(cre);
  126. }
  127. );
  128. if (sre.Status != Constant.ServiceResultStatus.Success)
  129. {
  130. this.Close();
  131. return;
  132. }
  133. this._info = sre.Data.Tables[0];
  134. this._users = sre.Data.Tables[1];
  135. if (this._groupID > 0)
  136. {
  137. if (this._info.Rows.Count == 0)
  138. {
  139. MessageBox.Show("数据不存在,请确认后再操作。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  140. this.Close();
  141. return;
  142. }
  143. this.txtName.Text = this._info.Rows[0]["WorkerGroupName"].ToString();
  144. this.txtDisplayNo.Text = this._info.Rows[0]["DisplayNo"].ToString();
  145. this.txtRemarks.Text = this._info.Rows[0]["Remarks"].ToString();
  146. this.dkDefectTypeNameSearchBox1.DefectTypeID = Convert.ToInt32(this._info.Rows[0]["DefectTypeID"]);
  147. //this.dkDefectTypeNameSearchBox1.DefectTypeName = this._info.Rows[0]["DefectTypeName"].ToString();
  148. this.dkDefectTypeNameSearchBox1.Text = this._info.Rows[0]["DefectTypeName"].ToString();
  149. }
  150. else
  151. {
  152. DataRow newRow = this._info.NewRow();
  153. newRow["WorkerGroupID"] = 0;
  154. this._info.Rows.Add(newRow);
  155. }
  156. this.dgvUser.DataSource = this._users;
  157. }
  158. catch (Exception ex)
  159. {
  160. // 对异常进行共通处理
  161. ExceptionManager.HandleEventException(this.ToString(),
  162. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  163. }
  164. }
  165. #endregion
  166. private void btnAddUser_Click(object sender, EventArgs e)
  167. {
  168. try
  169. {
  170. S_CMN_013 frmSCMN013 = new S_CMN_013();
  171. DialogResult dialogResult = frmSCMN013.ShowDialog();
  172. if (dialogResult != System.Windows.Forms.DialogResult.OK)
  173. {
  174. return;
  175. }
  176. DataTable selDt = frmSCMN013.SelTable;
  177. if (selDt == null)
  178. {
  179. return;
  180. }
  181. foreach (DataRow userRow in selDt.Rows)
  182. {
  183. DataRow[] urs = this._users.Select(" userid = " + userRow["UserID"]);
  184. if (urs == null || urs.Length == 0)
  185. {
  186. this._users.Rows.Add(new object[] { userRow["UserID"], userRow["UserCode"], userRow["UserName"] });
  187. }
  188. }
  189. }
  190. catch (Exception ex)
  191. {
  192. // 对异常进行共通处理
  193. ExceptionManager.HandleEventException(this.ToString(),
  194. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  195. }
  196. }
  197. private void btnDeleteUser_Click(object sender, EventArgs e)
  198. {
  199. try
  200. {
  201. DataGridViewRow dgvRow = this.dgvUser.CurrentRow;
  202. if (dgvRow != null)
  203. {
  204. DataRowView drv = dgvRow.DataBoundItem as DataRowView;
  205. if (drv != null)
  206. {
  207. drv.Delete();
  208. drv.EndEdit();
  209. }
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. // 对异常进行共通处理
  215. ExceptionManager.HandleEventException(this.ToString(),
  216. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  217. }
  218. }
  219. #region 私有方法
  220. #endregion
  221. }
  222. }