F_RPT_010401.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_010401.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.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. /// <summary>
  24. /// 在产产品数据
  25. /// </summary>
  26. public partial class F_RPT_010401 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_RPT_010401 _instance;
  31. //默认清空工序,重置回用户当前权限工序
  32. private string _currentUserPurview = null;
  33. //默认清空生产线,重置回用户当前权限生产线
  34. private string _currentUserLinePuview = null;
  35. #endregion
  36. #region 构造函数
  37. public F_RPT_010401()
  38. {
  39. InitializeComponent();
  40. //自动适应列宽
  41. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  42. //关闭
  43. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  44. //查询
  45. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  46. //清空条件
  47. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  48. //查询条件
  49. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  50. // 窗体显示的Title
  51. this.Text = FormTitles.F_RPT_010401;
  52. }
  53. #endregion
  54. #region 单例模式
  55. /// <summary>
  56. /// 单例模式,防止重复创建窗体
  57. /// </summary>
  58. public static F_RPT_010401 Instance
  59. {
  60. get
  61. {
  62. if (_instance == null || _instance.IsDisposed)
  63. {
  64. _instance = new F_RPT_010401();
  65. }
  66. return _instance;
  67. }
  68. }
  69. #endregion
  70. #region 事件
  71. /// <summary>
  72. /// 窗体加载事件
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_RPT_010401_Load(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. // 加载权限
  81. FormPermissionManager.FormPermissionControl(this.Name, this,
  82. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  83. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  84. // 设置表格不自动创建列
  85. this.dgvInProduction.AutoGenerateColumns = false;
  86. // 初始化时间控件为当前日期
  87. this.dtpCreateTimeStart.Value = DateTime.Now.Date;
  88. this.dtpCreateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  89. this.dkproductionLineSearchBox.IsEnablePurview = true;
  90. this.dkProcedureSearchBox.IsEnablePurview = true;
  91. this.dtpUpdateTimeStart.Value = DateTime.Now.Date;
  92. this.dtpUpdateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  93. getPurview();
  94. getPurviewLine();//
  95. }
  96. catch (Exception ex)
  97. {
  98. // 对异常进行共通处理
  99. ExceptionManager.HandleEventException(this.ToString(),
  100. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  101. }
  102. }
  103. /// <summary>
  104. /// 窗体关闭事件
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. private void F_RPT_010401_FormClosed(object sender, FormClosedEventArgs e)
  109. {
  110. _instance = null;
  111. }
  112. /// <summary>
  113. /// 关闭按钮事件
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. private void tsbtnClose_Click(object sender, EventArgs e)
  118. {
  119. this.Close();
  120. }
  121. /// <summary>
  122. /// 查询按钮事件
  123. /// </summary>
  124. /// <param name="sender"></param>
  125. /// <param name="e"></param>
  126. private void btnSearch_Click(object sender, EventArgs e)
  127. {
  128. try
  129. {
  130. if (string.IsNullOrEmpty(this._currentUserPurview))
  131. {
  132. // 提示未查找到数据
  133. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  134. MessageBoxButtons.OK, MessageBoxIcon.Information);
  135. return;
  136. }
  137. this.dgvInProduction.DataSource = null;
  138. this.dgvInProduction.DataSource = this.GetSearchData();
  139. }
  140. catch (Exception ex)
  141. {
  142. this.btnSearch.Enabled = true;
  143. this.btnClearCondition.Enabled = true;
  144. // 对异常进行共通处理
  145. ExceptionManager.HandleEventException(this.ToString(),
  146. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  147. }
  148. }
  149. /// <summary>
  150. /// 自动适应列宽
  151. /// </summary>
  152. /// <param name="sender"></param>
  153. /// <param name="e"></param>
  154. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  155. {
  156. this.dgvInProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  157. }
  158. /// <summary>
  159. /// 清空条件按钮事件
  160. /// </summary>
  161. /// <param name="sender"></param>
  162. /// <param name="e"></param>
  163. private void btnClearCondition_Click(object sender, EventArgs e)
  164. {
  165. //清空更多条件内容
  166. this.scbGoods.ClearValue();
  167. scbGoodsType.ClearValue();
  168. this.scbGMouldType.ClearValue();
  169. this.scbGroutingLine.ClearValue();
  170. this.dkProcedureSearchBox.ClearControl();
  171. this.dkproductionLineSearchBox.ClearControl();
  172. this.dkUserInfoSearchBox.ClearControl();
  173. this.dtpCreateTimeStart.Value = DateTime.Now.Date;
  174. this.dtpCreateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  175. this.dtpUpdateTimeStart.Value = DateTime.Now.Date;
  176. this.dtpUpdateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  177. this.chkCreateTime.Checked = true;
  178. this.chkUpdateTime.Checked = true;
  179. this.txtBarCode.Text = string.Empty;
  180. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  181. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  182. this.radAll.Checked = true;
  183. this.radNormal.Checked = false;
  184. this.radScrap.Checked = false;
  185. }
  186. /// <summary>
  187. /// 交坯日期
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void chkCreateTime_CheckedChanged(object sender, EventArgs e)
  192. {
  193. this.dtpCreateTimeStart.Enabled = this.chkCreateTime.Checked;
  194. this.dtpCreateTimeEnd.Enabled = this.chkCreateTime.Checked;
  195. }
  196. private void chkUpdateTime_CheckedChanged(object sender, EventArgs e)
  197. {
  198. this.dtpUpdateTimeStart.Enabled = this.chkUpdateTime.Checked;
  199. this.dtpUpdateTimeEnd.Enabled = this.chkUpdateTime.Checked;
  200. }
  201. #endregion
  202. #region 私有方法
  203. /// <summary>
  204. /// 根据界面查询条件获取数据集
  205. /// </summary>
  206. private DataTable GetSearchData()
  207. {
  208. try
  209. {
  210. RPT010401_SE se = new RPT010401_SE();
  211. se.Barcode = txtBarCode.Text.Trim();
  212. se.ProductionLineIDS = dkproductionLineSearchBox.ProductionLineIDS;
  213. se.ProcedureIDS = dkProcedureSearchBox.ProcedureIDS;
  214. se.GoodsIDS = this.scbGoods.CheckedPKMember;
  215. se.UserIDS = dkUserInfoSearchBox.UserIDS;
  216. se.GroutingLineIDS = (this.scbGroutingLine.SearchedPKMember == 0 ? null : this.scbGroutingLine.SearchedPKMember.ToString());
  217. se.GMouldTypeIDS = this.scbGMouldType.CheckedPKMember;
  218. if (this.chkCreateTime.Checked == true)
  219. {
  220. //se.CreateTimeStart = DateTime.Parse(this.dtpCreateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  221. //se.CreateTimeEnd = DateTime.Parse(this.dtpCreateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  222. se.CreateTimeStart = this.dtpCreateTimeStart.Value;
  223. se.CreateTimeEnd = this.dtpCreateTimeEnd.Value;
  224. }
  225. if (this.chkUpdateTime.Checked == true)
  226. {
  227. //se.UpdateTimeStart = DateTime.Parse(this.dtpUpdateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  228. //se.UpdateTimeEnd = DateTime.Parse(this.dtpUpdateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  229. se.UpdateTimeStart = this.dtpUpdateTimeStart.Value;
  230. se.UpdateTimeEnd = this.dtpUpdateTimeEnd.Value;
  231. }
  232. se.inscrapflag = radAll.Checked ? 2 : radNormal.Checked ? 0 : 1;
  233. se.IsReworkFlag = chkIsReworkFlag.Checked ? 1 : 0;
  234. se.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  235. // 调用服务器端获取数据集
  236. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  237. {
  238. return ReportModuleProxy.Service.GetRPT010401SData(se);
  239. }
  240. );
  241. if (sre.Status == Constant.ServiceResultStatus.Success)
  242. {
  243. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  244. {
  245. // 提示未查找到数据
  246. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  247. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  248. //清空数据
  249. return null;
  250. }
  251. return sre.Data.Tables[0];
  252. }
  253. return null;
  254. }
  255. catch (Exception ex)
  256. {
  257. throw ex;
  258. }
  259. }
  260. /// <summary>
  261. /// 获取权限
  262. /// </summary>
  263. protected void getPurview()
  264. {
  265. try
  266. {
  267. StringBuilder sbProcedurePurview = new StringBuilder();
  268. //得到工序查看权限
  269. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  270. {
  271. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  272. }));
  273. if (dsProcedurePurview != null)
  274. {
  275. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  276. if (drPurview.Length == 0)
  277. {
  278. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  279. {
  280. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  281. }
  282. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  283. {
  284. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  285. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  286. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  287. }
  288. }
  289. else
  290. {
  291. SearchProductionLineEntity line = new SearchProductionLineEntity();
  292. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  293. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  294. {
  295. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  296. }
  297. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  298. {
  299. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  300. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  301. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  302. }
  303. }
  304. }
  305. }
  306. catch (Exception ex)
  307. {
  308. throw ex;
  309. }
  310. }
  311. /// <summary>
  312. /// 获取权限(生产线)
  313. /// </summary>
  314. protected void getPurviewLine()
  315. {
  316. try
  317. {
  318. StringBuilder sbProcedurePurview = new StringBuilder();
  319. //得到工序查看权限
  320. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  321. {
  322. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  323. }));
  324. if (dsProcedurePurview != null)
  325. {
  326. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  327. if (drPurview.Length == 0)
  328. {
  329. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  330. {
  331. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  332. }
  333. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  334. {
  335. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  336. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  337. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  338. }
  339. }
  340. else
  341. {
  342. ProductionLineEntity line = new ProductionLineEntity();
  343. line.ValueFlags = new object[] { 1 };
  344. dsProcedurePurview = (DataSet)DoAsync(() =>
  345. {
  346. return PCModuleProxy.Service.SearchProductionLine(line);
  347. });
  348. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  349. {
  350. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  351. }
  352. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  353. {
  354. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  355. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  356. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  357. }
  358. }
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. throw ex;
  364. }
  365. }
  366. #endregion
  367. }
  368. }