F_PM_2501.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*******************************************************************************
  2. * Copyright(c) 2017 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2501.cs
  5. * 2.功能描述:回收计件一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2017/7/20 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.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  22. namespace Dongke.IBOSS.PRD.Client.PMModule
  23. {
  24. /// <summary>
  25. /// 回收计件一览
  26. /// </summary>
  27. public partial class F_PM_2501 : DockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static Dictionary<int, F_PM_2501> _dicInstance;
  32. // 当前工序ID
  33. private int _currentProcedureID = 0;
  34. // 最后选择行
  35. private int _selecedRow;
  36. // 窗体显示的Title
  37. private string _fromTitle;
  38. #endregion
  39. #region 构造函数
  40. public F_PM_2501()
  41. {
  42. InitializeComponent();
  43. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  44. //编辑
  45. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  46. //自动适应列宽
  47. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  48. //关闭
  49. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  50. //查询
  51. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  52. //清空条件
  53. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  54. //查询条件
  55. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  56. }
  57. #endregion
  58. #region 单例模式
  59. /// <summary>
  60. /// 一个工序ID有一个单例,防止重复创建窗体
  61. /// </summary>
  62. /// <param name="procedureID">工序ID</param>
  63. /// <returns></returns>
  64. public static F_PM_2501 Instance(int procedureID, string fromTitle)
  65. {
  66. F_PM_2501 fInstance = null;
  67. if (_dicInstance == null)
  68. {
  69. _dicInstance = new Dictionary<int, F_PM_2501>();
  70. fInstance = new F_PM_2501();
  71. _dicInstance.Add(procedureID, fInstance);
  72. }
  73. else if (_dicInstance.ContainsKey(procedureID))
  74. {
  75. fInstance = _dicInstance[procedureID];
  76. }
  77. else
  78. {
  79. fInstance = new F_PM_2501();
  80. _dicInstance.Add(procedureID, fInstance);
  81. }
  82. fInstance._currentProcedureID = procedureID;
  83. fInstance._fromTitle = fromTitle;
  84. fInstance.Text = fromTitle;
  85. return fInstance;
  86. }
  87. #endregion
  88. #region 事件
  89. /// <summary>
  90. /// 窗体加载事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. private void F_PM_2001_Load(object sender, System.EventArgs e)
  95. {
  96. try
  97. {
  98. // 加载权限
  99. FormPermissionManager.FormPermissionControl(this.Name, this,
  100. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  101. // 设置表格不自动创建列
  102. this.dgvProduction.AutoGenerateColumns = false;
  103. // 初始化时间控件为当前日期
  104. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  105. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  106. // 设置ToolStripButton状态
  107. this.SetToolStripButtonEnable();
  108. }
  109. catch (Exception ex)
  110. {
  111. // 对异常进行共通处理
  112. ExceptionManager.HandleEventException(this.ToString(),
  113. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  114. }
  115. }
  116. /// <summary>
  117. /// 窗体关闭事件
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. private void F_PM_2001_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  122. {
  123. _dicInstance = null;
  124. }
  125. /// <summary>
  126. /// 自动适应列宽
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  131. {
  132. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  133. }
  134. /// <summary>
  135. /// 清空条件按钮事件
  136. /// </summary>
  137. /// <param name="sender"></param>
  138. /// <param name="e"></param>
  139. private void btnClearCondition_Click(object sender, EventArgs e)
  140. {
  141. this.txtBarCode.Text = "";
  142. this.txtGoodsCode.Text = "";
  143. this.txtGoodsName.Text = "";
  144. this.txtUserCode.Text = "";
  145. this.scbOrganization.ClearValue();
  146. //this.txtRemarks.Text = "";
  147. //this.statusIsReworked.ClearItemCheck();
  148. this.scbGoodsType.ClearValue();
  149. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  150. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  151. }
  152. /// <summary>
  153. /// 查询按钮事件
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. private void btnSearch_Click(object sender, EventArgs e)
  158. {
  159. try
  160. {
  161. // 记录当前选中行
  162. int selectRowIndex = this._selecedRow;
  163. // 异步处理
  164. this.btnSearch.Enabled = false;
  165. this.btnClearCondition.Enabled = false;
  166. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  167. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  168. {
  169. return PMModuleProxy.Service.GetProductionData(requestEntity);
  170. }));
  171. DataSet dsProductionData = new DataSet();
  172. dsProductionData.Tables.Add(dtProductionData);
  173. this.btnSearch.Enabled = true;
  174. this.btnClearCondition.Enabled = true;
  175. if (dsProductionData != null)
  176. {
  177. base.DataSource = dsProductionData;
  178. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  179. {
  180. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  181. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  182. {
  183. // 提示未查找到数据
  184. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  185. MessageBoxButtons.OK, MessageBoxIcon.Information);
  186. }
  187. else
  188. {
  189. if (selectRowIndex >= Constant.INT_IS_ZERO)
  190. {
  191. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  192. {
  193. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  194. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  195. }
  196. else
  197. {
  198. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  199. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. catch (Exception ex)
  207. {
  208. this.btnSearch.Enabled = true;
  209. this.btnClearCondition.Enabled = true;
  210. // 对异常进行共通处理
  211. ExceptionManager.HandleEventException(this.ToString(),
  212. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  213. }
  214. }
  215. /// <summary>
  216. /// 关闭按钮事件
  217. /// </summary>
  218. /// <param name="sender"></param>
  219. /// <param name="e"></param>
  220. private void tsbtnClose_Click(object sender, EventArgs e)
  221. {
  222. this.Close();
  223. }
  224. /// <summary>
  225. /// 新建按钮事件
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void tsbtnAdd_Click(object sender, EventArgs e)
  230. {
  231. try
  232. {
  233. F_PM_2502 frmPM2502 = new F_PM_2502(_currentProcedureID, _fromTitle);
  234. DialogResult dialogResult = frmPM2502.ShowDialog();
  235. // 重新加载GridView
  236. if (dialogResult == DialogResult.OK)
  237. {
  238. this.btnSearch_Click(null, null);
  239. }
  240. }
  241. catch (Exception ex)
  242. {
  243. // 对异常进行共通处理
  244. ExceptionManager.HandleEventException(this.ToString(),
  245. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  246. }
  247. }
  248. #endregion
  249. #region 私有方法
  250. /// <summary>
  251. /// 设置工具按钮的可用状态
  252. /// </summary>
  253. private void SetToolStripButtonEnable()
  254. {
  255. if (this.dgvProduction.CurrentCell != null)
  256. {
  257. this.tsbtnEdit.Enabled = true;
  258. }
  259. else
  260. {
  261. this.tsbtnEdit.Enabled = false;
  262. }
  263. }
  264. /// <summary>
  265. /// 搜索条件
  266. /// </summary>
  267. /// <returns></returns>
  268. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  269. {
  270. SearchProductionDataEntity result = new SearchProductionDataEntity();
  271. result.BarCode = this.txtBarCode.Text.Trim();
  272. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  273. result.GoodsName = this.txtGoodsName.Text.Trim();
  274. result.UserCode = this.txtUserCode.Text.Trim();
  275. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  276. result.Remarks = "";
  277. // this.txtRemarks.Text.Trim();
  278. //object[] objRework = this.statusIsReworked.SelectedValues;
  279. //string Rework = "";
  280. //for (int i = 0; i < objRework.Length; i++)
  281. //{
  282. // Rework += objRework[i] + ",";
  283. //}
  284. //Rework = Rework.TrimEnd(',');
  285. //result.IsRework = Rework;
  286. result.BeginDate = this.dtpStartTime.Value;
  287. result.EndDate = this.dtpEndTime.Value;
  288. result.ProcedureID = _currentProcedureID;
  289. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  290. return result;
  291. }
  292. #endregion
  293. }
  294. }