F_RPT_080105.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. }
  90. catch (Exception ex)
  91. {
  92. // 对异常进行共通处理
  93. ExceptionManager.HandleEventException(this.ToString(),
  94. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  95. }
  96. }
  97. /// <summary>
  98. /// 窗体关闭事件
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void F_PM_0401_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  103. {
  104. _instance = null;
  105. }
  106. /// <summary>
  107. /// 自动适应列宽
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  112. {
  113. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  114. }
  115. /// <summary>
  116. /// 清空条件按钮事件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void btnClearCondition_Click(object sender, EventArgs e)
  121. {
  122. this.txtBarCode.Text = "";
  123. this.txtSTAFFNAME.Text = "";
  124. this.txtGoodsCode.Text = "";
  125. this.txtGoodsName.Text = "";
  126. this.txtUserCode.Text = "";
  127. this.scbOrganization.ClearValue();
  128. //this.txtRemarks.Text = "";
  129. this.scbGoodsType.ClearValue();
  130. //this.statusIsReworked.ClearItemCheck();
  131. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  132. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddSeconds(-1);
  133. this.dkproductionLineSearchBox.ClearControl();
  134. this.dkProcedureSearchBox.ClearControl();
  135. this.chkTestMouldFlag.AllItemCheck();
  136. }
  137. /// <summary>
  138. /// 查询按钮事件
  139. /// </summary>
  140. /// <param name="sender"></param>
  141. /// <param name="e"></param>
  142. private void btnSearch_Click(object sender, EventArgs e)
  143. {
  144. try
  145. {
  146. if (!string.IsNullOrEmpty(dkProcedureSearchBox.ProcedureIDS+""))
  147. {
  148. if ((','+dkProcedureSearchBox.ProcedureIDS+',').Contains(",18,"))
  149. {
  150. finishProcedureName.Visible = true;
  151. }
  152. else {
  153. finishProcedureName.Visible = false;
  154. }
  155. }
  156. else
  157. {
  158. finishProcedureName.Visible = false;
  159. }
  160. // 记录当前选中行
  161. int selectRowIndex = this._selecedRow;
  162. // 异步处理
  163. this.btnSearch.Enabled = false;
  164. this.btnClearCondition.Enabled = false;
  165. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  166. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  167. {
  168. return ReportModuleProxy.Service.GetProductionData(requestEntity);
  169. }));
  170. DataSet dsProductionData = new DataSet();
  171. dsProductionData.Tables.Add(dtProductionData);
  172. this.btnSearch.Enabled = true;
  173. this.btnClearCondition.Enabled = true;
  174. if (dsProductionData != null)
  175. {
  176. base.DataSource = dsProductionData;
  177. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  178. {
  179. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  180. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  181. {
  182. // 提示未查找到数据
  183. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  184. MessageBoxButtons.OK, MessageBoxIcon.Information);
  185. }
  186. else
  187. {
  188. if (selectRowIndex >= Constant.INT_IS_ZERO)
  189. {
  190. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  191. {
  192. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  193. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  194. }
  195. else
  196. {
  197. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  198. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. catch (Exception ex)
  206. {
  207. this.btnSearch.Enabled = true;
  208. this.btnClearCondition.Enabled = true;
  209. // 对异常进行共通处理
  210. ExceptionManager.HandleEventException(this.ToString(),
  211. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  212. }
  213. }
  214. /// <summary>
  215. /// 关闭按钮事件
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. private void tsbtnClose_Click(object sender, EventArgs e)
  220. {
  221. this.Close();
  222. }
  223. #endregion
  224. #region 私有方法
  225. /// <summary>
  226. /// 设置工具按钮的可用状态
  227. /// </summary>
  228. private void SetToolStripButtonEnable()
  229. {
  230. }
  231. /// <summary>
  232. /// 搜索条件
  233. /// </summary>
  234. /// <returns></returns>
  235. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  236. {
  237. SearchProductionDataEntity result = new SearchProductionDataEntity();
  238. result.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  239. result.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  240. result.BarCode = this.txtBarCode.Text.Trim();
  241. result.StaffName = this.txtSTAFFNAME.Text.Trim();
  242. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  243. result.GoodsName = this.txtGoodsName.Text.Trim();
  244. result.UserCode = this.txtUserCode.Text.Trim();
  245. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  246. result.Remarks = "";// this.txtRemarks.Text.Trim();
  247. result.BeginDate = this.dtpStartTime.Value;
  248. result.EndDate = this.dtpEndTime.Value;
  249. result.ProcedureID = _currentProcedureID;
  250. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  251. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  252. if (testMouldFlags.Length == 1)
  253. {
  254. result.TestMouldFlag = testMouldFlags[0].ToString();
  255. }
  256. return result;
  257. }
  258. #endregion
  259. }
  260. }