F_PM_0401.cs 10 KB

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