F_RPT_080105.cs 7.8 KB

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