F_RPT_010403.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_010403.cs
  5. * 2.功能描述:生产数据明细表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/4/9 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  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.Controls;
  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. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. /// <summary>
  25. /// 生产数据明细表
  26. /// </summary>
  27. public partial class F_RPT_010403 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static F_RPT_010403 _instance;
  32. //默认清空生产线,重置回用户当前权限生产线
  33. private string _currentUserLinePuview = null;
  34. #endregion
  35. #region 构造函数
  36. public F_RPT_010403()
  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. // 窗体显示的Title
  50. //this.Text = FormTitles.F_RPT_010402;
  51. }
  52. #endregion
  53. #region 单例模式
  54. /// <summary>
  55. /// 单例模式,防止重复创建窗体
  56. /// </summary>
  57. public static F_RPT_010403 Instance
  58. {
  59. get
  60. {
  61. if (_instance == null || _instance.IsDisposed)
  62. {
  63. _instance = new F_RPT_010403();
  64. }
  65. return _instance;
  66. }
  67. }
  68. #endregion
  69. #region 事件
  70. /// <summary>
  71. /// 窗体加载事件
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void F_RPT_010402_Load(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. // 设置表格不自动创建列
  80. this.dgvFinishedProduction.AutoGenerateColumns = false;
  81. // 加载权限
  82. FormPermissionManager.FormPermissionControl(this.Name, this,
  83. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  84. // 初始化时间控件为当前日期
  85. this.dtpDateStart.Value = DateTime.Now.Date;
  86. this.dtpDateEnd.Value = DateTime.Now.Date;
  87. //this.dkproductionLineSearchBox.IsEnablePurview = true;
  88. //getPurviewLine();
  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 btnSearch_Click(object sender, EventArgs e)
  103. {
  104. try
  105. {
  106. //if (string.IsNullOrEmpty(this._currentUserLinePuview))
  107. //{
  108. // // 提示未查找到数据
  109. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  110. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  111. // return;
  112. //}
  113. this.dgvFinishedProduction.DataSource = null;
  114. this.dgvFinishedProduction.DataSource = this.GetSearchData();
  115. }
  116. catch (Exception ex)
  117. {
  118. this.btnSearch.Enabled = true;
  119. this.btnClearCondition.Enabled = true;
  120. // 对异常进行共通处理
  121. ExceptionManager.HandleEventException(this.ToString(),
  122. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  123. }
  124. }
  125. /// <summary>
  126. /// 窗体关闭事件
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void F_RPT_010402_FormClosed(object sender, FormClosedEventArgs e)
  131. {
  132. _instance = null;
  133. }
  134. /// <summary>
  135. /// 关闭按钮事件
  136. /// </summary>
  137. /// <param name="sender"></param>
  138. /// <param name="e"></param>
  139. private void tsbtnClose_Click(object sender, EventArgs e)
  140. {
  141. this.Close();
  142. }
  143. /// <summary>
  144. /// 清空条件按钮事件
  145. /// </summary>
  146. /// <param name="sender"></param>
  147. /// <param name="e"></param>
  148. private void btnClearCondition_Click(object sender, EventArgs e)
  149. {
  150. this.txtBarCode.Text = string.Empty;
  151. this.dkproductionLineSearchBox.ClearControl();
  152. this.txtGoodsCode.Clear();
  153. this.scbGoodsType.ClearValue();
  154. this.dtpDateStart.Value = DateTime.Now.Date;
  155. this.dtpDateEnd.Value = DateTime.Now.Date;
  156. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  157. }
  158. /// <summary>
  159. /// 自动适应列宽
  160. /// </summary>
  161. /// <param name="sender"></param>
  162. /// <param name="e"></param>
  163. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  164. {
  165. this.dgvFinishedProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  166. }
  167. #endregion
  168. #region 私有方法
  169. /// <summary>
  170. /// 根据界面查询条件获取数据集
  171. /// </summary>
  172. private DataTable GetSearchData()
  173. {
  174. try
  175. {
  176. RPT010403_SE se = new RPT010403_SE();
  177. se.Barcode = txtBarCode.Text.Trim();
  178. se.ProductionLineID = dkproductionLineSearchBox.ProductionLineID;
  179. se.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  180. se.GoodsCode = txtGoodsCode.Text.Trim();
  181. se.CreateTimeStart = this.dtpDateStart.Value;
  182. se.CreateTimeEnd = this.dtpDateEnd.Value.AddDays(1).AddSeconds(-1);
  183. // 调用服务器端获取数据集
  184. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  185. {
  186. return ReportModuleProxy.Service.GetRPT010403SData(se);
  187. }
  188. );
  189. if (sre.Status == Constant.ServiceResultStatus.Success)
  190. {
  191. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  192. {
  193. // 提示未查找到数据
  194. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  195. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  196. //清空数据
  197. return null;
  198. }
  199. return sre.Data.Tables[0];
  200. }
  201. return null;
  202. }
  203. catch (Exception ex)
  204. {
  205. throw ex;
  206. }
  207. }
  208. /// <summary>
  209. /// 获取权限(生产线)
  210. /// </summary>
  211. protected void getPurviewLine()
  212. {
  213. try
  214. {
  215. StringBuilder sbProcedurePurview = new StringBuilder();
  216. //得到工序查看权限
  217. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  218. {
  219. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  220. }));
  221. if (dsProcedurePurview != null)
  222. {
  223. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  224. if (drPurview.Length == 0)
  225. {
  226. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  227. {
  228. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  229. }
  230. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  231. {
  232. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  233. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  234. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  235. }
  236. }
  237. else
  238. {
  239. ProductionLineEntity line = new ProductionLineEntity();
  240. line.ValueFlags = new object[] { 1 };
  241. dsProcedurePurview = (DataSet)DoAsync(() =>
  242. {
  243. return PCModuleProxy.Service.SearchProductionLine(line);
  244. });
  245. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  246. {
  247. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  248. }
  249. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  250. {
  251. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  252. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  253. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  254. }
  255. }
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. throw ex;
  261. }
  262. }
  263. #endregion
  264. }
  265. }