F_RPT_010401.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. this.chkTestMouldFlag.AllItemCheck();
  94. getPurview();
  95. getPurviewLine();//
  96. }
  97. catch (Exception ex)
  98. {
  99. // 对异常进行共通处理
  100. ExceptionManager.HandleEventException(this.ToString(),
  101. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  102. }
  103. }
  104. /// <summary>
  105. /// 窗体关闭事件
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void F_RPT_010401_FormClosed(object sender, FormClosedEventArgs e)
  110. {
  111. _instance = null;
  112. }
  113. /// <summary>
  114. /// 关闭按钮事件
  115. /// </summary>
  116. /// <param name="sender"></param>
  117. /// <param name="e"></param>
  118. private void tsbtnClose_Click(object sender, EventArgs e)
  119. {
  120. this.Close();
  121. }
  122. /// <summary>
  123. /// 查询按钮事件
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. private void btnSearch_Click(object sender, EventArgs e)
  128. {
  129. try
  130. {
  131. if (string.IsNullOrEmpty(this._currentUserPurview))
  132. {
  133. // 提示未查找到数据
  134. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  135. MessageBoxButtons.OK, MessageBoxIcon.Information);
  136. return;
  137. }
  138. this.dgvInProduction.DataSource = null;
  139. this.dgvInProduction.DataSource = this.GetSearchData();
  140. }
  141. catch (Exception ex)
  142. {
  143. this.btnSearch.Enabled = true;
  144. this.btnClearCondition.Enabled = true;
  145. // 对异常进行共通处理
  146. ExceptionManager.HandleEventException(this.ToString(),
  147. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  148. }
  149. }
  150. /// <summary>
  151. /// 自动适应列宽
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  156. {
  157. this.dgvInProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  158. }
  159. /// <summary>
  160. /// 清空条件按钮事件
  161. /// </summary>
  162. /// <param name="sender"></param>
  163. /// <param name="e"></param>
  164. private void btnClearCondition_Click(object sender, EventArgs e)
  165. {
  166. //清空更多条件内容
  167. this.scbGoods.ClearValue();
  168. scbGoodsType.ClearValue();
  169. this.scbGMouldType.ClearValue();
  170. this.txtGroutingLineCode.Clear();
  171. this.dkProcedureSearchBox.ClearControl();
  172. this.dkproductionLineSearchBox.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.txtSTAFFNAME.Text = string.Empty;
  181. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  182. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  183. this.radAll.Checked = true;
  184. this.radNormal.Checked = false;
  185. this.radScrap.Checked = false;
  186. this.chkTestMouldFlag.AllItemCheck();
  187. }
  188. /// <summary>
  189. /// 交坯日期
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. private void chkCreateTime_CheckedChanged(object sender, EventArgs e)
  194. {
  195. this.dtpCreateTimeStart.Enabled = this.chkCreateTime.Checked;
  196. this.dtpCreateTimeEnd.Enabled = this.chkCreateTime.Checked;
  197. }
  198. private void chkUpdateTime_CheckedChanged(object sender, EventArgs e)
  199. {
  200. this.dtpUpdateTimeStart.Enabled = this.chkUpdateTime.Checked;
  201. this.dtpUpdateTimeEnd.Enabled = this.chkUpdateTime.Checked;
  202. }
  203. #endregion
  204. #region 私有方法
  205. /// <summary>
  206. /// 根据界面查询条件获取数据集
  207. /// </summary>
  208. private DataTable GetSearchData()
  209. {
  210. try
  211. {
  212. RPT010401_SE se = new RPT010401_SE();
  213. se.Barcode = txtBarCode.Text.Trim();
  214. se.StaffName = txtSTAFFNAME.Text.Trim();
  215. se.ProductionLineIDS = dkproductionLineSearchBox.ProductionLineIDS;
  216. se.ProcedureIDS = dkProcedureSearchBox.ProcedureIDS;
  217. se.GoodsIDS = this.scbGoods.CheckedPKMember;
  218. se.GroutingUserCodes = this.GroutingUsersCode.Text;
  219. se.GoodsCode = this.goodscodeText.Text;
  220. se.GroutingLineCode = this.txtGroutingLineCode.Text;
  221. se.GMouldTypeIDS = this.scbGMouldType.CheckedPKMember;
  222. if (this.chkCreateTime.Checked == true)
  223. {
  224. //se.CreateTimeStart = DateTime.Parse(this.dtpCreateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  225. //se.CreateTimeEnd = DateTime.Parse(this.dtpCreateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  226. se.CreateTimeStart = this.dtpCreateTimeStart.Value;
  227. se.CreateTimeEnd = this.dtpCreateTimeEnd.Value;
  228. }
  229. if (this.chkUpdateTime.Checked == true)
  230. {
  231. //se.UpdateTimeStart = DateTime.Parse(this.dtpUpdateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  232. //se.UpdateTimeEnd = DateTime.Parse(this.dtpUpdateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  233. se.UpdateTimeStart = this.dtpUpdateTimeStart.Value;
  234. se.UpdateTimeEnd = this.dtpUpdateTimeEnd.Value;
  235. }
  236. se.inscrapflag = radAll.Checked ? 2 : radNormal.Checked ? 0 : 1;
  237. se.IsReworkFlag = chkIsReworkFlag.Checked ? 1 : 0;
  238. se.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  239. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  240. if (testMouldFlags.Length == 1)
  241. {
  242. se.TestMouldFlag = testMouldFlags[0].ToString();
  243. }
  244. // 调用服务器端获取数据集
  245. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  246. {
  247. return ReportModuleProxy.Service.GetRPT010401SData(se);
  248. }
  249. );
  250. if (sre.Status == Constant.ServiceResultStatus.Success)
  251. {
  252. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  253. {
  254. // 提示未查找到数据
  255. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  256. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  257. //清空数据
  258. return null;
  259. }
  260. return sre.Data.Tables[0];
  261. }
  262. return null;
  263. }
  264. catch (Exception ex)
  265. {
  266. throw ex;
  267. }
  268. }
  269. /// <summary>
  270. /// 获取权限
  271. /// </summary>
  272. protected void getPurview()
  273. {
  274. try
  275. {
  276. StringBuilder sbProcedurePurview = new StringBuilder();
  277. //得到工序查看权限
  278. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  279. {
  280. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  281. }));
  282. if (dsProcedurePurview != null)
  283. {
  284. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  285. if (drPurview.Length == 0)
  286. {
  287. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  288. {
  289. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  290. }
  291. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  292. {
  293. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  294. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  296. }
  297. }
  298. else
  299. {
  300. SearchProductionLineEntity line = new SearchProductionLineEntity();
  301. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  302. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  303. {
  304. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  305. }
  306. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  307. {
  308. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  309. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  310. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  311. }
  312. }
  313. }
  314. }
  315. catch (Exception ex)
  316. {
  317. throw ex;
  318. }
  319. }
  320. /// <summary>
  321. /// 获取权限(生产线)
  322. /// </summary>
  323. protected void getPurviewLine()
  324. {
  325. try
  326. {
  327. StringBuilder sbProcedurePurview = new StringBuilder();
  328. //得到工序查看权限
  329. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  330. {
  331. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  332. }));
  333. if (dsProcedurePurview != null)
  334. {
  335. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  336. if (drPurview.Length == 0)
  337. {
  338. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  339. {
  340. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  341. }
  342. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  343. {
  344. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  345. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  346. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  347. }
  348. }
  349. else
  350. {
  351. ProductionLineEntity line = new ProductionLineEntity();
  352. line.ValueFlags = new object[] { 1 };
  353. dsProcedurePurview = (DataSet)DoAsync(() =>
  354. {
  355. return PCModuleProxy.Service.SearchProductionLine(line);
  356. });
  357. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  358. {
  359. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  360. }
  361. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  362. {
  363. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  364. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  365. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  366. }
  367. }
  368. }
  369. }
  370. catch (Exception ex)
  371. {
  372. throw ex;
  373. }
  374. }
  375. #endregion
  376. }
  377. }