F_PM_1501.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1501.cs
  5. * 2.功能描述:产成品数据
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/10/24 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.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 产成品数据
  25. /// </summary>
  26. public partial class F_PM_1501 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_PM_1501 _instance;
  31. //完成产品实体类
  32. SearchFinishedProductEntity _finishedProductionEntity = new SearchFinishedProductEntity();
  33. //生产线权限集
  34. private string _productionLinePurviews = string.Empty;
  35. //成型线权限集
  36. private string _groutingLinePurviews = string.Empty;
  37. #endregion
  38. #region 构造函数
  39. public F_PM_1501()
  40. {
  41. InitializeComponent();
  42. //自动适应列宽
  43. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  44. //关闭
  45. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  46. //查询
  47. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  48. //清空条件
  49. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  50. //查询条件
  51. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  52. // 窗体显示的Title
  53. this.Text = FormTitles.F_PM_1501;
  54. }
  55. #endregion
  56. #region 单例模式
  57. /// <summary>
  58. /// 单例模式,防止重复创建窗体
  59. /// </summary>
  60. public static F_PM_1501 Instance
  61. {
  62. get
  63. {
  64. if (_instance == null || _instance.IsDisposed)
  65. {
  66. _instance = new F_PM_1501();
  67. }
  68. return _instance;
  69. }
  70. }
  71. #endregion
  72. #region 事件
  73. /// <summary>
  74. /// 窗体加载事件
  75. /// </summary>
  76. /// <param name="sender"></param>
  77. /// <param name="e"></param>
  78. private void F_PM_1501_Load(object sender, EventArgs e)
  79. {
  80. try
  81. {
  82. // 设置表格不自动创建列
  83. this.dgvFinishedProduction.AutoGenerateColumns = false;
  84. // 加载权限
  85. FormPermissionManager.FormPermissionControl(this.Name, this,
  86. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  87. // 初始化时间控件为当前日期
  88. this.dtpCreateTimeStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  89. this.dtpCreateTimeEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  90. this.dtpAccountDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  91. this.dtpAccountDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  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. SearchFinishedProductEntity requestFinishedEntity = CreatesearchFinishedProductionDataRequestEntity();
  110. DataSet dsfinishedProductioData = (DataSet)DoAsync(new AsyncMethod(() =>
  111. {
  112. return PMModuleProxy.Service.GetFinishedProductionData(requestFinishedEntity);
  113. }));
  114. if (dsfinishedProductioData != null)
  115. {
  116. if (dsfinishedProductioData.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  117. {
  118. // 提示未查找到数据
  119. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  120. MessageBoxButtons.OK, MessageBoxIcon.Information);
  121. //清空数据
  122. this.dgvFinishedProduction.DataSource = null;
  123. }
  124. else
  125. {
  126. this.dgvFinishedProduction.DataSource = dsfinishedProductioData.Tables[Constant.INT_IS_ZERO];
  127. }
  128. }
  129. }
  130. catch (Exception ex)
  131. {
  132. this.btnSearch.Enabled = true;
  133. this.btnClearCondition.Enabled = true;
  134. // 对异常进行共通处理
  135. ExceptionManager.HandleEventException(this.ToString(),
  136. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  137. }
  138. }
  139. /// <summary>
  140. /// 窗体关闭事件
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. private void F_PM_1501_FormClosed(object sender, FormClosedEventArgs e)
  145. {
  146. _instance = null;
  147. }
  148. /// <summary>
  149. /// 关闭按钮事件
  150. /// </summary>
  151. /// <param name="sender"></param>
  152. /// <param name="e"></param>
  153. private void tsbtnClose_Click(object sender, EventArgs e)
  154. {
  155. this.Close();
  156. }
  157. /// <summary>
  158. /// 更多条件按钮事件
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. private void tsbtnMoreCondition_Click(object sender, EventArgs e)
  163. {
  164. F_PM_1502 fpm1502 = new F_PM_1502();
  165. fpm1502.searchFinishedProductionEntity = _finishedProductionEntity;
  166. if (fpm1502.ShowDialog() == DialogResult.OK)
  167. {
  168. this._finishedProductionEntity = fpm1502.searchFinishedProductionEntity;
  169. }
  170. }
  171. /// <summary>
  172. /// 清空条件按钮事件
  173. /// </summary>
  174. /// <param name="sender"></param>
  175. /// <param name="e"></param>
  176. private void btnClearCondition_Click(object sender, EventArgs e)
  177. {
  178. this.txtBarCode.Text = string.Empty;
  179. this.scbGMouldType.ClearValue();
  180. this.scbGoods.ClearValue();
  181. this.scbGroutingLine.ClearValue();
  182. this.dkproductionLineSearchBox.ClearControl();
  183. this.dtpCreateTimeStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  184. this.dtpCreateTimeEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  185. this.dtpAccountDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  186. this.dtpAccountDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  187. }
  188. /// <summary>
  189. /// 自动适应列宽
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  194. {
  195. this.dgvFinishedProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  196. }
  197. #endregion
  198. #region 私有方法
  199. #region 获取查询条件
  200. private SearchFinishedProductEntity CreatesearchFinishedProductionDataRequestEntity()
  201. {
  202. SearchFinishedProductEntity searchFinishedProductionEntity = new SearchFinishedProductEntity();
  203. searchFinishedProductionEntity.BarCode = this.txtBarCode.Text.Trim();
  204. searchFinishedProductionEntity.ProductionLineIDS = this.dkproductionLineSearchBox.ProductionLineIDS;
  205. searchFinishedProductionEntity.GMouldTypeIDS = this.scbGMouldType.CheckedPKMember;
  206. searchFinishedProductionEntity.GoodsIDS = this.scbGoods.CheckedPKMember;
  207. searchFinishedProductionEntity.GroutingLineIDS = this.scbGroutingLine.CheckedPKMember;
  208. string createTimeStart = this.dtpCreateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0";
  209. searchFinishedProductionEntity.CreateTimeStart = Convert.ToDateTime(createTimeStart);
  210. string createTimeEnd = this.dtpCreateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59";
  211. searchFinishedProductionEntity.CreateTimeEnd = Convert.ToDateTime(createTimeEnd);
  212. string accountDateStart = this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0";
  213. searchFinishedProductionEntity.AccountDateStart = Convert.ToDateTime(accountDateStart);
  214. string accountDateEnd = this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59";
  215. searchFinishedProductionEntity.AccountDateEnd = Convert.ToDateTime(accountDateEnd);
  216. return searchFinishedProductionEntity;
  217. }
  218. #endregion
  219. /// <summary>
  220. /// 获取当前用户的权限
  221. /// </summary>
  222. protected void getPurview()
  223. {
  224. try
  225. {
  226. //得到生产线查看权限
  227. StringBuilder sbProductionlinePurview = new StringBuilder();
  228. DataSet dsProductionlinePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  229. {
  230. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  231. }));
  232. if (dsProductionlinePurview != null)
  233. {
  234. foreach (DataRow dr in dsProductionlinePurview.Tables[Constant.INT_IS_ZERO].Rows)
  235. {
  236. sbProductionlinePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  237. }
  238. if (sbProductionlinePurview.Length != Constant.INT_IS_ZERO)
  239. {
  240. this._productionLinePurviews = sbProductionlinePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProductionlinePurview.Length - 1);
  241. this.dkproductionLineSearchBox.Purview = this._productionLinePurviews;
  242. }
  243. }
  244. //得到成型线查看权限
  245. //StringBuilder sbGroutingLinePurview = new StringBuilder();
  246. //DataSet dsGroutingLinePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  247. //{
  248. // return SystemModuleProxy.Service.GetUserPurview(5, LogInUserInfo.CurrentUser.UserID);
  249. //}));
  250. //if (dsGroutingLinePurview != null)
  251. //{
  252. // foreach (DataRow dr in dsGroutingLinePurview.Tables[Constant.INT_IS_ZERO].Rows)
  253. // {
  254. // sbGroutingLinePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  255. // }
  256. // if (sbGroutingLinePurview.Length != Constant.INT_IS_ZERO)
  257. // {
  258. // this._groutingLinePurviews = sbGroutingLinePurview.ToString().Substring(Constant.INT_IS_ZERO, sbGroutingLinePurview.Length - 1);
  259. // this.dkGroutingLineSearchBox.Purview = this._groutingLinePurviews;
  260. // }
  261. //}
  262. }
  263. catch (Exception ex)
  264. {
  265. throw ex;
  266. }
  267. }
  268. #endregion
  269. }
  270. }