F_RPT_080105.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. public partial class F_RPT_080105 : DockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_080105 _instance;
  28. // 当前工序ID
  29. private int _currentProcedureID = 0;
  30. // 最后选择行
  31. private int _selecedRow;
  32. // 窗体显示的Title
  33. private string _fromTitle;
  34. #endregion
  35. #region 构造函数
  36. public F_RPT_080105()
  37. {
  38. InitializeComponent();
  39. //自动适应列宽
  40. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  41. //关闭
  42. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  43. //查询
  44. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  45. //清空条件
  46. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  47. //查询条件
  48. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  49. this.Text = FormTitles.F_RPT_080105;
  50. }
  51. #endregion
  52. #region 单例模式
  53. /// <summary>
  54. /// 单例模式,防止重复创建窗体
  55. /// </summary>
  56. public static F_RPT_080105 Instance
  57. {
  58. get
  59. {
  60. if (_instance == null || _instance.IsDisposed)
  61. {
  62. _instance = new F_RPT_080105();
  63. }
  64. return _instance;
  65. }
  66. }
  67. #endregion
  68. #region 事件
  69. /// <summary>
  70. /// 窗体加载事件
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. private void F_PM_0401_Load(object sender, System.EventArgs e)
  75. {
  76. try
  77. {
  78. // 加载权限
  79. FormPermissionManager.FormPermissionControl(this.Name, this,
  80. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  81. // 设置表格不自动创建列
  82. this.dgvProduction.AutoGenerateColumns = false;
  83. // 初始化时间控件为当前日期
  84. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  85. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddSeconds(-1);
  86. // 设置ToolStripButton状态
  87. this.SetToolStripButtonEnable();
  88. this.chkTestMouldFlag.AllItemCheck();
  89. // 除CW001外,其他工号不要这个功能
  90. if (LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode != "CW001")
  91. {
  92. lblEBELN.Visible = false;
  93. txtEBELN.Visible = false;
  94. lblEBELP.Visible = false;
  95. txtEBELP.Visible = false;
  96. EBELN.Visible = false;
  97. EBELP.Visible = false;
  98. SCANTIME.Visible = false;
  99. }
  100. }
  101. catch (Exception ex)
  102. {
  103. // 对异常进行共通处理
  104. ExceptionManager.HandleEventException(this.ToString(),
  105. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  106. }
  107. }
  108. /// <summary>
  109. /// 窗体关闭事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void F_PM_0401_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  114. {
  115. _instance = null;
  116. }
  117. /// <summary>
  118. /// 自动适应列宽
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  123. {
  124. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  125. }
  126. /// <summary>
  127. /// 清空条件按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnClearCondition_Click(object sender, EventArgs e)
  132. {
  133. this.txtBarCode.Text = "";
  134. this.txtGoodsCode.Text = "";
  135. this.txtGoodsName.Text = "";
  136. this.txtUserCode.Text = "";
  137. this.scbOrganization.ClearValue();
  138. //this.txtRemarks.Text = "";
  139. this.scbGoodsType.ClearValue();
  140. //this.statusIsReworked.ClearItemCheck();
  141. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  142. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddSeconds(-1);
  143. this.dkproductionLineSearchBox.ClearControl();
  144. this.dkProcedureSearchBox.ClearControl();
  145. this.chkTestMouldFlag.AllItemCheck();
  146. txtEBELN.Text = "";
  147. txtEBELP.Text = "";
  148. }
  149. /// <summary>
  150. /// 查询按钮事件
  151. /// </summary>
  152. /// <param name="sender"></param>
  153. /// <param name="e"></param>
  154. private void btnSearch_Click(object sender, EventArgs e)
  155. {
  156. try
  157. {
  158. if (!string.IsNullOrEmpty(dkProcedureSearchBox.ProcedureIDS+""))
  159. {
  160. if ((','+dkProcedureSearchBox.ProcedureIDS+',').Contains(",18,"))
  161. {
  162. finishProcedureName.Visible = true;
  163. }
  164. else {
  165. finishProcedureName.Visible = false;
  166. }
  167. }
  168. else
  169. {
  170. finishProcedureName.Visible = false;
  171. }
  172. // 记录当前选中行
  173. int selectRowIndex = this._selecedRow;
  174. // 异步处理
  175. this.btnSearch.Enabled = false;
  176. this.btnClearCondition.Enabled = false;
  177. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  178. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  179. {
  180. return ReportModuleProxy.Service.GetProductionData(requestEntity);
  181. }));
  182. DataSet dsProductionData = new DataSet();
  183. dsProductionData.Tables.Add(dtProductionData);
  184. this.btnSearch.Enabled = true;
  185. this.btnClearCondition.Enabled = true;
  186. if (dsProductionData != null)
  187. {
  188. base.DataSource = dsProductionData;
  189. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  190. {
  191. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  192. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  193. {
  194. // 提示未查找到数据
  195. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  196. MessageBoxButtons.OK, MessageBoxIcon.Information);
  197. }
  198. else
  199. {
  200. if (selectRowIndex >= Constant.INT_IS_ZERO)
  201. {
  202. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  203. {
  204. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  205. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  206. }
  207. else
  208. {
  209. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  210. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. catch (Exception ex)
  218. {
  219. this.btnSearch.Enabled = true;
  220. this.btnClearCondition.Enabled = true;
  221. // 对异常进行共通处理
  222. ExceptionManager.HandleEventException(this.ToString(),
  223. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  224. }
  225. }
  226. /// <summary>
  227. /// 关闭按钮事件
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. private void tsbtnClose_Click(object sender, EventArgs e)
  232. {
  233. this.Close();
  234. }
  235. #endregion
  236. #region 私有方法
  237. /// <summary>
  238. /// 设置工具按钮的可用状态
  239. /// </summary>
  240. private void SetToolStripButtonEnable()
  241. {
  242. }
  243. /// <summary>
  244. /// 搜索条件
  245. /// </summary>
  246. /// <returns></returns>
  247. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  248. {
  249. SearchProductionDataEntity result = new SearchProductionDataEntity();
  250. result.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  251. result.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  252. result.BarCode = this.txtBarCode.Text.Trim();
  253. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  254. result.GoodsName = this.txtGoodsName.Text.Trim();
  255. result.UserCode = this.txtUserCode.Text.Trim();
  256. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  257. result.Remarks = "";// this.txtRemarks.Text.Trim();
  258. result.BeginDate = this.dtpStartTime.Value;
  259. result.EndDate = this.dtpEndTime.Value;
  260. result.ProcedureID = _currentProcedureID;
  261. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  262. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  263. result.EBELN = this.txtEBELN.Text.Trim();
  264. result.EBELP = this.txtEBELP.Text.Trim();
  265. if (testMouldFlags.Length == 1)
  266. {
  267. result.TestMouldFlag = testMouldFlags[0].ToString();
  268. }
  269. return result;
  270. }
  271. #endregion
  272. }
  273. }