F_RPT_010402.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_010402.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_010402 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static F_RPT_010402 _instance;
  32. //默认清空生产线,重置回用户当前权限生产线
  33. private string _currentUserLinePuview = null;
  34. #endregion
  35. #region 构造函数
  36. public F_RPT_010402()
  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_010402 Instance
  58. {
  59. get
  60. {
  61. if (_instance == null || _instance.IsDisposed)
  62. {
  63. _instance = new F_RPT_010402();
  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. DateTime nowDate = DateTime.Now.Date;
  86. this.dtpCreateTimeStart.Value = nowDate;
  87. this.dtpCreateTimeEnd.Value = nowDate;
  88. this.dtpAccountDateStart.Value = nowDate;
  89. this.dtpAccountDateEnd.Value = nowDate.AddDays(1).AddSeconds(-1);
  90. this.dkproductionLineSearchBox.IsEnablePurview = true;
  91. getPurviewLine();
  92. }
  93. catch (Exception ex)
  94. {
  95. // 对异常进行共通处理
  96. ExceptionManager.HandleEventException(this.ToString(),
  97. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  98. }
  99. }
  100. /// <summary>
  101. /// 查询按钮事件
  102. /// </summary>
  103. /// <param name="sender"></param>
  104. /// <param name="e"></param>
  105. private void btnSearch_Click(object sender, EventArgs e)
  106. {
  107. try
  108. {
  109. if (string.IsNullOrEmpty(this._currentUserLinePuview))
  110. {
  111. // 提示未查找到数据
  112. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  113. MessageBoxButtons.OK, MessageBoxIcon.Information);
  114. return;
  115. }
  116. this.dgvFinishedProduction.DataSource = null;
  117. this.dgvFinishedProduction.DataSource = this.GetSearchData();
  118. }
  119. catch (Exception ex)
  120. {
  121. this.btnSearch.Enabled = true;
  122. this.btnClearCondition.Enabled = true;
  123. // 对异常进行共通处理
  124. ExceptionManager.HandleEventException(this.ToString(),
  125. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  126. }
  127. }
  128. /// <summary>
  129. /// 窗体关闭事件
  130. /// </summary>
  131. /// <param name="sender"></param>
  132. /// <param name="e"></param>
  133. private void F_RPT_010402_FormClosed(object sender, FormClosedEventArgs e)
  134. {
  135. _instance = null;
  136. }
  137. /// <summary>
  138. /// 关闭按钮事件
  139. /// </summary>
  140. /// <param name="sender"></param>
  141. /// <param name="e"></param>
  142. private void tsbtnClose_Click(object sender, EventArgs e)
  143. {
  144. this.Close();
  145. }
  146. /// <summary>
  147. /// 清空条件按钮事件
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. private void btnClearCondition_Click(object sender, EventArgs e)
  152. {
  153. chkCreateTime.Checked = false;
  154. this.txtBarCode.Text = string.Empty;
  155. this.scbGMouldType.ClearValue();
  156. this.scbGoods.ClearValue();
  157. this.scbGroutingLine.ClearValue();
  158. this.dkproductionLineSearchBox.ClearControl();
  159. DateTime nowDate = DateTime.Now.Date;
  160. this.dtpCreateTimeStart.Value = nowDate;
  161. this.dtpCreateTimeEnd.Value = nowDate;
  162. this.dtpAccountDateStart.Value = nowDate;
  163. this.dtpAccountDateEnd.Value = nowDate.AddDays(1).AddSeconds(-1);
  164. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  165. }
  166. /// <summary>
  167. /// 自动适应列宽
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  172. {
  173. this.dgvFinishedProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  174. }
  175. private void chkCreateTime_CheckedChanged(object sender, EventArgs e)
  176. {
  177. dtpCreateTimeStart.Enabled = this.chkCreateTime.Checked;
  178. dtpCreateTimeEnd.Enabled = this.chkCreateTime.Checked;
  179. }
  180. #endregion
  181. #region 私有方法
  182. /// <summary>
  183. /// 根据界面查询条件获取数据集
  184. /// </summary>
  185. private DataTable GetSearchData()
  186. {
  187. try
  188. {
  189. RPT010402_SE se = new RPT010402_SE();
  190. se.Barcode = txtBarCode.Text.Trim();
  191. se.ProductionLineIDS = dkproductionLineSearchBox.ProductionLineIDS;
  192. se.GoodsIDS = scbGoods.CheckedPKMember;
  193. se.GroutingLineIDS = this.scbGroutingLine.CheckedPKMember;
  194. se.GMouldTypeIDS = this.scbGMouldType.CheckedPKMember;
  195. //se.AccountDateStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  196. //se.AccountDateEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  197. se.AccountDateStart = this.dtpAccountDateStart.Value;
  198. se.AccountDateEnd = this.dtpAccountDateEnd.Value;
  199. if (this.chkCreateTime.Checked)
  200. {
  201. se.CreateTimeStart = DateTime.Parse(this.dtpCreateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  202. se.CreateTimeEnd = DateTime.Parse(this.dtpCreateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  203. }
  204. // 调用服务器端获取数据集
  205. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  206. {
  207. return ReportModuleProxy.Service.GetRPT010402SData(se);
  208. }
  209. );
  210. if (sre.Status == Constant.ServiceResultStatus.Success)
  211. {
  212. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  213. {
  214. // 提示未查找到数据
  215. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  216. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  217. //清空数据
  218. return null;
  219. }
  220. return sre.Data.Tables[0];
  221. }
  222. return null;
  223. }
  224. catch (Exception ex)
  225. {
  226. throw ex;
  227. }
  228. }
  229. /// <summary>
  230. /// 获取权限(生产线)
  231. /// </summary>
  232. protected void getPurviewLine()
  233. {
  234. try
  235. {
  236. StringBuilder sbProcedurePurview = new StringBuilder();
  237. //得到工序查看权限
  238. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  239. {
  240. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  241. }));
  242. if (dsProcedurePurview != null)
  243. {
  244. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  245. if (drPurview.Length == 0)
  246. {
  247. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  248. {
  249. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  250. }
  251. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  252. {
  253. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  254. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  255. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  256. }
  257. }
  258. else
  259. {
  260. ProductionLineEntity line = new ProductionLineEntity();
  261. line.ValueFlags = new object[] { 1 };
  262. dsProcedurePurview = (DataSet)DoAsync(() =>
  263. {
  264. return PCModuleProxy.Service.SearchProductionLine(line);
  265. });
  266. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  267. {
  268. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  269. }
  270. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  271. {
  272. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  273. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  274. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  275. }
  276. }
  277. }
  278. }
  279. catch (Exception ex)
  280. {
  281. throw ex;
  282. }
  283. }
  284. #endregion
  285. }
  286. }