F_RPT_040107.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. 
  2. /*******************************************************************************
  3. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  4. * 类的信息:
  5. * 1.程序名称:F_RPT_040107.cs
  6. * 2.功能描述:注浆产品工序分析表
  7. * 编辑履历:
  8. * 作者 日期 版本 修改内容
  9. * 袁新成 2015/4/14 1.00 新建
  10. *******************************************************************************/
  11. using System;
  12. using System.Data;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DockPanel;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.Client.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  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_040107 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static F_RPT_040107 _instance;
  32. //实体类
  33. private RPT040107_SE _rptse = null;
  34. //默认清空工序,重置回用户当前权限工序
  35. private string _currentUserPurview = null;
  36. //默认清空生产线,重置回用户当前权限生产线
  37. private string _currentUserLinePuview = null;
  38. #endregion
  39. #region 构造函数
  40. public F_RPT_040107()
  41. {
  42. InitializeComponent();
  43. // 窗体显示的Title
  44. this.Text = "注浆产品工序分析表";
  45. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  46. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  47. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  48. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  49. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  50. }
  51. #endregion
  52. #region 单例模式
  53. /// <summary>
  54. /// 单例模式,防止重复创建窗体
  55. /// </summary>
  56. public static F_RPT_040107 Instance
  57. {
  58. get
  59. {
  60. if (_instance == null || _instance.IsDisposed)
  61. {
  62. _instance = new F_RPT_040107();
  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_RPT_030103_1_Load(object sender, EventArgs e)
  75. {
  76. try
  77. {
  78. // 加载权限
  79. FormPermissionManager.FormPermissionControl(this.Name, this,
  80. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  81. this.dgvRptProcedure.AutoGenerateColumns = true;
  82. this.dkproductionLineSearchBox.IsEnablePurview = true;
  83. this.dkProcedureSearchBox.IsEnablePurview = true;
  84. // 初始化时间控件为当前日期
  85. this.dtpGDateStart.Value = DateTime.Now.Date;
  86. this.dtpGDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  87. getPurview();
  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 tsbtnAdaptive_Click(object sender, EventArgs e)
  103. {
  104. this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  105. }
  106. /// <summary>
  107. /// 窗体关闭事件
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. private void F_RPT_030103_1_FormClosed(object sender, FormClosedEventArgs e)
  112. {
  113. _instance = null;
  114. }
  115. /// <summary>
  116. /// 关闭按钮
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void tsbtnClose_Click(object sender, EventArgs e)
  121. {
  122. this.Close();
  123. }
  124. /// <summary>
  125. /// 查询按钮事件
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void btnSearch_Click(object sender, EventArgs e)
  130. {
  131. try
  132. {
  133. CreateSearchCondition();
  134. this.dgvRptProcedure.DataSource = null;
  135. this.dgvRptProcedure.Columns.Clear();
  136. this.dgvRptProcedure.DataSource = this.GetSearchTotalData();
  137. foreach (DataGridViewColumn item in this.dgvRptProcedure.Columns)
  138. {
  139. item.SortMode = DataGridViewColumnSortMode.NotSortable;
  140. if (item.Index > 1)
  141. {
  142. item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
  143. }
  144. }
  145. }
  146. catch (Exception ex)
  147. {
  148. this.btnSearch.Enabled = true;
  149. this.btnClearCondition.Enabled = true;
  150. // 对异常进行共通处理
  151. ExceptionManager.HandleEventException(this.ToString(),
  152. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  153. }
  154. }
  155. /// <summary>
  156. /// 清空条件按钮事件
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. private void btnClearCondition_Click(object sender, EventArgs e)
  161. {
  162. this.dkproductionLineSearchBox.ClearControl();
  163. this.scbGoodsType.ClearValue();
  164. this.txtGoodCode.Clear();
  165. this.dkProcedureSearchBox.ClearControl();
  166. this.dtpGDateStart.Value = DateTime.Now.Date;
  167. this.dtpGDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  168. this.chkspecialrepairflag.Checked = false;
  169. }
  170. #endregion
  171. #region 私有方法
  172. /// <summary>
  173. /// 搜索条件
  174. /// </summary>
  175. /// <returns></returns>
  176. private void CreateSearchCondition()
  177. {
  178. this._rptse = new RPT040107_SE();
  179. this._rptse.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  180. this._rptse.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  181. this._rptse.GoodsCode = this.txtGoodCode.Text.Trim();
  182. this._rptse.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  183. this._rptse.GTimeStart = DateTime.Parse(this.dtpGDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  184. this._rptse.GTimeEnd = DateTime.Parse(this.dtpGDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  185. this._rptse.Specialrepairflag = this.chkspecialrepairflag.Checked;
  186. }
  187. /// <summary>
  188. /// 查询出窑数量汇总表
  189. /// </summary>
  190. private DataTable GetSearchTotalData()
  191. {
  192. try
  193. {
  194. // 调用服务器端获取数据集
  195. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  196. {
  197. return ReportModuleProxy.Service.GetRPT040107SData(_rptse);
  198. }
  199. );
  200. if (sre.Status == Constant.ServiceResultStatus.Success)
  201. {
  202. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  203. {
  204. // 提示未查找到数据
  205. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  206. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  207. //清空数据
  208. return null;
  209. }
  210. return sre.Data.Tables[0];
  211. }
  212. return null;
  213. }
  214. catch (Exception ex)
  215. {
  216. throw ex;
  217. }
  218. }
  219. /// <summary>
  220. /// 获取权限(生产线)
  221. /// </summary>
  222. protected void getPurviewLine()
  223. {
  224. try
  225. {
  226. StringBuilder sbProcedurePurview = new StringBuilder();
  227. //得到工序查看权限
  228. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  229. {
  230. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  231. }));
  232. if (dsProcedurePurview != null)
  233. {
  234. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  235. if (drPurview.Length == 0)
  236. {
  237. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  238. {
  239. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  240. }
  241. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  242. {
  243. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  244. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  245. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  246. }
  247. }
  248. else
  249. {
  250. ProductionLineEntity line = new ProductionLineEntity();
  251. line.ValueFlags = new object[] { 1 };
  252. dsProcedurePurview = (DataSet)DoAsync(() =>
  253. {
  254. return PCModuleProxy.Service.SearchProductionLine(line);
  255. });
  256. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  257. {
  258. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  259. }
  260. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  261. {
  262. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  263. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  264. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  265. }
  266. }
  267. }
  268. }
  269. catch (Exception ex)
  270. {
  271. throw ex;
  272. }
  273. }
  274. /// <summary>
  275. /// 获取权限
  276. /// </summary>
  277. protected void getPurview()
  278. {
  279. try
  280. {
  281. StringBuilder sbProcedurePurview = new StringBuilder();
  282. //得到工序查看权限
  283. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  284. {
  285. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  286. }));
  287. if (dsProcedurePurview != null)
  288. {
  289. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  290. if (drPurview.Length == 0)
  291. {
  292. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  293. {
  294. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  295. }
  296. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  297. {
  298. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  299. //this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  300. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  301. }
  302. }
  303. else
  304. {
  305. SearchProductionLineEntity line = new SearchProductionLineEntity();
  306. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  307. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  308. {
  309. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  310. }
  311. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  312. {
  313. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  314. //this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  315. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  316. }
  317. }
  318. }
  319. }
  320. catch (Exception ex)
  321. {
  322. throw ex;
  323. }
  324. }
  325. #endregion
  326. }
  327. }