F_PM_1401.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1401.cs
  5. * 2.功能描述:在产产品数据
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/10/22 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;
  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_1401 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_PM_1401 _instance;
  31. //在产产品实体类
  32. private SearchInProductionEntity _inProductionEntity = new SearchInProductionEntity();
  33. //生产线权限集
  34. private string _productionLinePurviews = string.Empty;
  35. //成型线权限集
  36. private string _groutingLinePurviews = string.Empty;
  37. //完成工序权限集
  38. private string _procedurePurviews = string.Empty;
  39. //生产工号权限集
  40. private string _userPurviews = string.Empty;
  41. #endregion
  42. #region 构造函数
  43. public F_PM_1401()
  44. {
  45. InitializeComponent();
  46. //自动适应列宽
  47. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  48. //关闭
  49. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  50. //查询
  51. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  52. //清空条件
  53. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  54. //查询条件
  55. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  56. // 窗体显示的Title
  57. this.Text = FormTitles.F_PM_1401;
  58. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  59. }
  60. #endregion
  61. #region 单例模式
  62. /// <summary>
  63. /// 单例模式,防止重复创建窗体
  64. /// </summary>
  65. public static F_PM_1401 Instance
  66. {
  67. get
  68. {
  69. if (_instance == null || _instance.IsDisposed)
  70. {
  71. _instance = new F_PM_1401();
  72. }
  73. return _instance;
  74. }
  75. }
  76. #endregion
  77. #region 事件
  78. /// <summary>
  79. /// 窗体加载事件
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. private void F_PM_1401_Load(object sender, EventArgs e)
  84. {
  85. try
  86. {
  87. // 加载权限
  88. FormPermissionManager.FormPermissionControl(this.Name, this,
  89. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  90. // 设置表格不自动创建列
  91. this.dgvInProduction.AutoGenerateColumns = false;
  92. // 初始化时间控件为当前日期
  93. this.dtpCreateTimeStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  94. this.dtpCreateTimeEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  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_PM_1401_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. SearchInProductionEntity requestEntity = CreatesearchProductionDataRequestEntity();
  131. DataSet dsInProductioData = (DataSet)DoAsync(new AsyncMethod(() =>
  132. {
  133. return PMModuleProxy.Service.GetInProductionData(requestEntity);
  134. }));
  135. if (dsInProductioData != null)
  136. {
  137. if (dsInProductioData.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  138. {
  139. // 提示未查找到数据
  140. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  141. MessageBoxButtons.OK, MessageBoxIcon.Information);
  142. //清空数据
  143. this.dgvInProduction.DataSource = null;
  144. }
  145. else
  146. {
  147. this.dgvInProduction.DataSource = dsInProductioData.Tables[Constant.INT_IS_ZERO];
  148. }
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. this.btnSearch.Enabled = true;
  154. this.btnClearCondition.Enabled = true;
  155. // 对异常进行共通处理
  156. ExceptionManager.HandleEventException(this.ToString(),
  157. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  158. }
  159. }
  160. /// <summary>
  161. /// 自动适应列宽
  162. /// </summary>
  163. /// <param name="sender"></param>
  164. /// <param name="e"></param>
  165. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  166. {
  167. this.dgvInProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  168. }
  169. /// <summary>
  170. /// 清空条件按钮事件
  171. /// </summary>
  172. /// <param name="sender"></param>
  173. /// <param name="e"></param>
  174. private void btnClearCondition_Click(object sender, EventArgs e)
  175. {
  176. //清空更多条件内容
  177. this.scbGoods.ClearValue();
  178. this.scbGMouldType.ClearValue();
  179. this.scbGroutingLine.ClearValue();
  180. this.dkProcedureSearchBox.ClearControl();
  181. this.dkproductionLineSearchBox.ClearControl();
  182. this.scbUser.ClearValue();
  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. }
  186. /// <summary>
  187. /// 更多条件按钮事件
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void tsbtnMoreCondition_Click(object sender, EventArgs e)
  192. {
  193. F_PM_1402 fpm1402 = new F_PM_1402();
  194. fpm1402.searchInProductionEntity = _inProductionEntity;
  195. if (fpm1402.ShowDialog() == DialogResult.OK)
  196. {
  197. this._inProductionEntity = fpm1402.searchInProductionEntity;
  198. }
  199. }
  200. #endregion
  201. #region 私有方法
  202. /// <summary>
  203. /// 搜索条件
  204. /// </summary>
  205. /// <returns></returns>
  206. private SearchInProductionEntity CreatesearchProductionDataRequestEntity()
  207. {
  208. SearchInProductionEntity searchInProductionEntity = new SearchInProductionEntity();
  209. searchInProductionEntity.BarCode = this.txtBarCode.Text.Trim();
  210. searchInProductionEntity.GoodsIDS = this.scbGoods.CheckedPKMember;
  211. searchInProductionEntity.ProductionLineIDS = this.dkproductionLineSearchBox.ProductionLineIDS;
  212. searchInProductionEntity.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  213. searchInProductionEntity.GMouldTypeIDS = this.scbGMouldType.CheckedPKMember;
  214. searchInProductionEntity.UserIDS = scbUser.CheckedPKMember;
  215. searchInProductionEntity.GroutingLineIDS = this.scbGroutingLine.CheckedPKMember;
  216. string createTimeStart = this.dtpCreateTimeStart.Value.ToString("yyyy-MM-dd") + " 0:0:0";
  217. searchInProductionEntity.CreateTimeStart = Convert.ToDateTime(createTimeStart);
  218. string createTimeEnd = this.dtpCreateTimeEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59";
  219. searchInProductionEntity.CreateTimeEnd = Convert.ToDateTime(createTimeEnd);
  220. return searchInProductionEntity;
  221. }
  222. /// <summary>
  223. /// 获取当前用户的权限
  224. /// </summary>
  225. protected void getPurview()
  226. {
  227. try
  228. {
  229. //得到生产线查看权限
  230. StringBuilder sbProductionlinePurview = new StringBuilder();
  231. DataSet dsProductionlinePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  232. {
  233. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  234. }));
  235. if (dsProductionlinePurview != null)
  236. {
  237. foreach (DataRow dr in dsProductionlinePurview.Tables[Constant.INT_IS_ZERO].Rows)
  238. {
  239. sbProductionlinePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  240. }
  241. if (sbProductionlinePurview.Length != Constant.INT_IS_ZERO)
  242. {
  243. this._productionLinePurviews = sbProductionlinePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProductionlinePurview.Length - 1);
  244. this.dkproductionLineSearchBox.Purview = this._productionLinePurviews;
  245. }
  246. }
  247. //得到工序查看权限
  248. StringBuilder sbProcedurePurview = new StringBuilder();
  249. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  250. {
  251. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  252. }));
  253. if (dsProcedurePurview != null)
  254. {
  255. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  256. {
  257. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  258. }
  259. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  260. {
  261. this._procedurePurviews = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  262. this.dkProcedureSearchBox.Purview = this._procedurePurviews;
  263. }
  264. }
  265. //得到成型线查看权限
  266. //StringBuilder sbGroutingLinePurview = new StringBuilder();
  267. //DataSet dsGroutingLinePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  268. //{
  269. // return SystemModuleProxy.Service.GetUserPurview(5, LogInUserInfo.CurrentUser.UserID);
  270. //}));
  271. //if (dsGroutingLinePurview != null)
  272. //{
  273. // foreach (DataRow dr in dsGroutingLinePurview.Tables[Constant.INT_IS_ZERO].Rows)
  274. // {
  275. // sbGroutingLinePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  276. // }
  277. // if (sbGroutingLinePurview.Length != Constant.INT_IS_ZERO)
  278. // {
  279. // this._groutingLinePurviews = sbGroutingLinePurview.ToString().Substring(Constant.INT_IS_ZERO, sbGroutingLinePurview.Length - 1);
  280. // this.dkGroutingLineSearchBox.Purview = this._groutingLinePurviews;
  281. // }
  282. //}
  283. //得到生产工号查看权限
  284. StringBuilder sbUserPurview = new StringBuilder();
  285. DataSet dsUserPurview = (DataSet)DoAsync(new AsyncMethod(() =>
  286. {
  287. return SystemModuleProxy.Service.GetUserPurview(3, LogInUserInfo.CurrentUser.UserID);
  288. }));
  289. if (dsUserPurview != null)
  290. {
  291. foreach (DataRow dr in dsUserPurview.Tables[Constant.INT_IS_ZERO].Rows)
  292. {
  293. sbUserPurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  294. }
  295. if (sbUserPurview.Length != Constant.INT_IS_ZERO)
  296. {
  297. this._userPurviews = sbUserPurview.ToString().Substring(Constant.INT_IS_ZERO, sbUserPurview.Length - 1);
  298. }
  299. }
  300. }
  301. catch (Exception ex)
  302. {
  303. throw ex;
  304. }
  305. }
  306. #endregion
  307. }
  308. }