F_RPT_080105.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. MessageBox.Show("生产工序为必选项,请选择!", this.Text,
  171. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  172. finishProcedureName.Visible = false;
  173. return;
  174. }
  175. //判断时间不超过一个月
  176. DateTime startTime = this.dtpStartTime.Value;
  177. DateTime endTime = this.dtpEndTime.Value;
  178. TimeSpan timeSpan = (endTime > startTime) ? endTime - startTime : startTime - endTime;
  179. if (timeSpan.TotalDays > 31)
  180. {
  181. MessageBox.Show("查询时间不允许超过一个月,数据量过大!", this.Text,
  182. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  183. return;
  184. }
  185. // 记录当前选中行
  186. int selectRowIndex = this._selecedRow;
  187. // 异步处理
  188. this.btnSearch.Enabled = false;
  189. this.btnClearCondition.Enabled = false;
  190. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  191. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  192. {
  193. return ReportModuleProxy.Service.GetProductionData(requestEntity);
  194. }));
  195. DataSet dsProductionData = new DataSet();
  196. dsProductionData.Tables.Add(dtProductionData);
  197. this.btnSearch.Enabled = true;
  198. this.btnClearCondition.Enabled = true;
  199. if (dsProductionData != null)
  200. {
  201. base.DataSource = dsProductionData;
  202. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  203. {
  204. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  205. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  206. {
  207. // 提示未查找到数据
  208. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  209. MessageBoxButtons.OK, MessageBoxIcon.Information);
  210. }
  211. else
  212. {
  213. if (selectRowIndex >= Constant.INT_IS_ZERO)
  214. {
  215. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  216. {
  217. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  218. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  219. }
  220. else
  221. {
  222. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  223. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. this.btnSearch.Enabled = true;
  233. this.btnClearCondition.Enabled = true;
  234. // 对异常进行共通处理
  235. ExceptionManager.HandleEventException(this.ToString(),
  236. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  237. }
  238. }
  239. /// <summary>
  240. /// 关闭按钮事件
  241. /// </summary>
  242. /// <param name="sender"></param>
  243. /// <param name="e"></param>
  244. private void tsbtnClose_Click(object sender, EventArgs e)
  245. {
  246. this.Close();
  247. }
  248. #endregion
  249. #region 私有方法
  250. /// <summary>
  251. /// 设置工具按钮的可用状态
  252. /// </summary>
  253. private void SetToolStripButtonEnable()
  254. {
  255. }
  256. /// <summary>
  257. /// 搜索条件
  258. /// </summary>
  259. /// <returns></returns>
  260. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  261. {
  262. SearchProductionDataEntity result = new SearchProductionDataEntity();
  263. result.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  264. result.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  265. result.BarCode = this.txtBarCode.Text.Trim();
  266. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  267. result.GoodsName = this.txtGoodsName.Text.Trim();
  268. result.UserCode = this.txtUserCode.Text.Trim();
  269. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  270. result.Remarks = "";// this.txtRemarks.Text.Trim();
  271. result.BeginDate = this.dtpStartTime.Value;
  272. result.EndDate = this.dtpEndTime.Value;
  273. result.ProcedureID = _currentProcedureID;
  274. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  275. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  276. result.EBELN = this.txtEBELN.Text.Trim();
  277. result.EBELP = this.txtEBELP.Text.Trim();
  278. if (testMouldFlags.Length == 1)
  279. {
  280. result.TestMouldFlag = testMouldFlags[0].ToString();
  281. }
  282. return result;
  283. }
  284. #endregion
  285. }
  286. }