F_MST_1201.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_1201.cs
  5. * 2.功能描述:工号分组一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2016/11/10 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Reflection;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Client.CommonModule;
  15. using Dongke.IBOSS.PRD.Client.Controls;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.WinForm.Controls;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. public partial class F_MST_1201 : DKDockPanelBase
  22. {
  23. #region 成员变量
  24. private ClientRequestEntity _clientRequestEntity = null; // 查询条件实体
  25. private static F_MST_1201 _instance = null;
  26. #endregion
  27. #region 构造函数
  28. public F_MST_1201()
  29. {
  30. InitializeComponent();
  31. // 窗口标题
  32. this.Text = "工号分组(缺陷类型)";
  33. // 工具栏按钮文本赋值
  34. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  35. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  36. this.tsbtnStop.Text = ButtonText.TSBTN_DISABLE;
  37. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  38. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  39. // 查询、清空条件按钮文本赋值
  40. this.tsbtnSearch.Text = ButtonText.BTN_SEARCH;
  41. this.tsbtnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  42. // 设置表格不自动创建列
  43. this.dgvGroup.AutoGenerateColumns = false;
  44. this.chkValueFlag.FlagBoxChecked = FlagCheckBoxChecked.Yes;
  45. // 编辑、导出和预览按钮不可用
  46. this.tsbtnEdit.Enabled = false;
  47. this.tsbtnStop.Visible = false;
  48. }
  49. #endregion
  50. #region 单例模式
  51. /// <summary>
  52. /// 单例模式,防止重复创建窗体
  53. /// </summary>
  54. public static F_MST_1201 Instance
  55. {
  56. get
  57. {
  58. if (_instance == null)
  59. {
  60. _instance = new F_MST_1201();
  61. }
  62. return _instance;
  63. }
  64. }
  65. #endregion
  66. #region 控件事件
  67. /// <summary>
  68. /// 打开画面
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void F_MST_1201_Load(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. // 加载权限
  77. FormPermissionManager.FormPermissionControl(this.Name, this,
  78. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  79. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. }
  81. catch (Exception ex)
  82. {
  83. // 对异常进行共通处理
  84. ExceptionManager.HandleEventException(this.ToString(),
  85. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  86. }
  87. }
  88. /// <summary>
  89. /// 画面关闭
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void F_MST_012001_FormClosed(object sender, FormClosedEventArgs e)
  94. {
  95. _instance = null;
  96. }
  97. /// <summary>
  98. /// 查询
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void tsbtnSearch_Click(object sender, EventArgs e)
  103. {
  104. try
  105. {
  106. this.QueryDataFromOther();
  107. }
  108. catch (Exception ex)
  109. {
  110. // 对异常进行共通处理
  111. ExceptionManager.HandleEventException(this.ToString(),
  112. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  113. }
  114. }
  115. /// <summary>
  116. /// 清空查询条件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  121. {
  122. this.ClearConditions();
  123. }
  124. /// <summary>
  125. /// 点击新建票据按钮,新建票据
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void tsbtnAddInvoice_Click(object sender, System.EventArgs e)
  130. {
  131. try
  132. {
  133. F_MST_1202 frm012002 = new F_MST_1202(0);
  134. DialogResult dialogresult = frm012002.ShowDialog();
  135. if (DialogResult.OK == dialogresult)
  136. {
  137. QueryDataFromOther();
  138. }
  139. }
  140. catch (Exception ex)
  141. {
  142. // 对异常进行共通处理
  143. ExceptionManager.HandleEventException(this.ToString(),
  144. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  145. }
  146. }
  147. /// <summary>
  148. /// 点击编辑按钮,编辑现有票据基本信息
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void tsbtnEdit_Click(object sender, EventArgs e)
  153. {
  154. try
  155. {
  156. // 获取活动行
  157. DataGridViewRow currentRow = this.dgvGroup.CurrentRow;
  158. if (currentRow != null)
  159. {
  160. int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value);
  161. F_MST_1202 frm012002 = new F_MST_1202(id);
  162. DialogResult dialogresult = frm012002.ShowDialog();
  163. if (DialogResult.OK == dialogresult)
  164. {
  165. QueryDataFromOther();
  166. }
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. // 对异常进行共通处理
  172. ExceptionManager.HandleEventException(this.ToString(),
  173. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  174. }
  175. }
  176. /// <summary>
  177. /// 单击自适应列宽,将所有的列宽都自动去适应内容
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void tsbtnAdaptive_Click(object sender, System.EventArgs e)
  182. {
  183. this.dgvGroup.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  184. this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  185. }
  186. /// <summary>
  187. /// KeyDown事件
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void dgvInvoice_KeyDown(object sender, KeyEventArgs e)
  192. {
  193. try
  194. {
  195. if (e.KeyData == (Keys.Control | Keys.C))
  196. {
  197. if (dgvGroup.CurrentRow != null
  198. && !string.IsNullOrEmpty(dgvGroup.CurrentRow.Cells
  199. [dgvGroup.CurrentCell.ColumnIndex].EditedFormattedValue + ""))
  200. {
  201. try
  202. {
  203. Clipboard.SetText(dgvGroup.CurrentRow.Cells
  204. [dgvGroup.CurrentCell.ColumnIndex].EditedFormattedValue + "");
  205. }
  206. catch { }
  207. }
  208. }
  209. }
  210. catch (Exception ex)
  211. {
  212. // 对异常进行共通处理
  213. ExceptionManager.HandleEventException(this.ToString(),
  214. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  215. }
  216. }
  217. /// <summary>
  218. /// 关闭页面
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. private void tsbtnClose_Click(object sender, EventArgs e)
  223. {
  224. this.Close();
  225. }
  226. /// <summary>
  227. /// 所选数据发生改变时
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. private void dgvInvoice_SelectionChanged(object sender, EventArgs e)
  232. {
  233. try
  234. {
  235. if (this.dgvGroup.CurrentCell == null)
  236. {
  237. this.tsbtnEdit.Enabled = false;
  238. this.tsbtnStop.Visible = false;
  239. }
  240. else
  241. {
  242. this.tsbtnEdit.Enabled = true;
  243. this.tsbtnStop.Visible = true;
  244. }
  245. DataGridViewRow currentRow = this.dgvGroup.CurrentRow;
  246. if (currentRow != null)
  247. {
  248. string flag = currentRow.Cells["valueflag"].Value.ToString();
  249. if ("1" == flag)
  250. {
  251. this.tsbtnStop.Text = ButtonText.TSBTN_DISABLE;
  252. }
  253. else
  254. {
  255. this.tsbtnStop.Text = "启用(&S)";
  256. }
  257. this.tsbtnStop.Tag = flag;
  258. int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value);
  259. ClientRequestEntity cre = new ClientRequestEntity();
  260. cre.NameSpace = "MST_WorkerGroup";
  261. cre.Name = "GetWorkerGroupList";
  262. cre.Properties["WorkerGroupDetail"] = 1;
  263. cre.Properties["GroupID"] = id;
  264. this.dgvUser.DataSource = null;
  265. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  266. {
  267. return SystemModuleProxy.Service.DoBarCodePrint(cre);
  268. }
  269. );
  270. if (sre.Status == Constant.ServiceResultStatus.Success)
  271. {
  272. // 查询成功
  273. this.dgvUser.DataSource = sre.Data.Tables[0];
  274. if (sre.Data.Tables[0].Rows.Count > 0)
  275. {
  276. this.dgvUser.Rows[0].Selected = true;
  277. }
  278. }
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. // 对异常进行共通处理
  284. ExceptionManager.HandleEventException(this.ToString(),
  285. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  286. }
  287. }
  288. /// <summary>
  289. /// 双击进入编辑页面
  290. /// </summary>
  291. /// <param name="sender"></param>
  292. /// <param name="e"></param>
  293. private void dgvInvoice_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  294. {
  295. if (-1 < e.RowIndex && -1 < e.ColumnIndex && this.tsbtnEdit.Enabled)
  296. {
  297. this.tsbtnEdit_Click(sender, e);
  298. }
  299. }
  300. /// <summary>
  301. /// 停用
  302. /// </summary>
  303. /// <param name="sender"></param>
  304. /// <param name="e"></param>
  305. private void tsbtnStop_Click(object sender, EventArgs e)
  306. {
  307. try
  308. {
  309. DataGridViewRow currentRow = this.dgvGroup.CurrentRow;
  310. if (currentRow != null)
  311. {
  312. string flag = currentRow.Cells["valueflag"].Value.ToString();
  313. int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value);
  314. ClientRequestEntity cre = new ClientRequestEntity();
  315. cre.NameSpace = "MST_WorkerGroup";
  316. cre.Name = "SetWorkerGroupValueFlag";
  317. cre.Properties["ValueFlag"] = ("1" == flag ? "0" : "1");
  318. cre.Properties["GroupID"] = id;
  319. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  320. {
  321. return SystemModuleProxy.Service.DoBarCodePrint(cre);
  322. }
  323. );
  324. if (sre.Status == Constant.ServiceResultStatus.Success)
  325. {
  326. // 查询成功
  327. QueryDataFromOther();
  328. }
  329. }
  330. }
  331. catch (Exception ex)
  332. {
  333. // 对异常进行共通处理
  334. ExceptionManager.HandleEventException(this.ToString(),
  335. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  336. }
  337. }
  338. #endregion
  339. #region 重写方法
  340. /// <summary>
  341. /// 查询数据
  342. /// </summary>
  343. /// <returns>验证通过true,其他false</returns>
  344. private void QueryDataFromOther()
  345. {
  346. try
  347. {
  348. this.SearchSelectEntity();
  349. this.dgvGroup.DataSource = null;
  350. this.dgvUser.DataSource = null;
  351. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  352. {
  353. return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
  354. }
  355. );
  356. if (sre.Status == Constant.ServiceResultStatus.Success)
  357. {
  358. // 查询成功
  359. this.dgvGroup.DataSource = sre.Data.Tables[0];
  360. if (sre.Data.Tables[0].Rows.Count > 0)
  361. {
  362. this.dgvGroup.Rows[0].Selected = true;
  363. }
  364. this.dgvUser.DataSource = sre.Data.Tables[1];
  365. }
  366. }
  367. catch (Exception ex)
  368. {
  369. throw ex;
  370. }
  371. }
  372. /// <summary>
  373. /// 清除查询条件
  374. /// </summary>
  375. public void ClearConditions()
  376. {
  377. this.txtGroupName.Text = string.Empty;
  378. this.dkDefectTypeNameSearchBox1.ClearControl();
  379. this.txtRemarks.Text = string.Empty;
  380. this.chkValueFlag.FlagBoxChecked = FlagCheckBoxChecked.Yes;
  381. }
  382. #endregion
  383. #region 私有方法
  384. /// <summary>
  385. /// 获取查询实体
  386. /// </summary>
  387. private void SearchSelectEntity()
  388. {
  389. this._clientRequestEntity = new ClientRequestEntity();
  390. this._clientRequestEntity.NameSpace = "MST_WorkerGroup";
  391. this._clientRequestEntity.Name = "GetWorkerGroupList";
  392. // 模板名称
  393. this._clientRequestEntity.Properties["GroupName"] = this.txtGroupName.Text.Trim();
  394. this._clientRequestEntity.Properties["Remarks"] = this.txtRemarks.Text;
  395. if (!string.IsNullOrEmpty(this.dkDefectTypeNameSearchBox1.DefectTypeIDS))
  396. {
  397. this._clientRequestEntity.Properties["DefectTypes"] = "," +this.dkDefectTypeNameSearchBox1.DefectTypeIDS + ",";
  398. }
  399. // 正常标识
  400. if (this.chkValueFlag.FlagBoxChecked == FlagCheckBoxChecked.Yes)
  401. {
  402. this._clientRequestEntity.Properties["valueflag"] = "1";
  403. }
  404. else if (this.chkValueFlag.FlagBoxChecked == FlagCheckBoxChecked.No)
  405. {
  406. this._clientRequestEntity.Properties["valueflag"] = "0";
  407. }
  408. }
  409. #endregion
  410. }
  411. }