F_PM_1101.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1101.cs
  5. * 2.功能描述:废弃产品信息一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/25 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  19. namespace Dongke.IBOSS.PRD.Client.PMModule
  20. {
  21. /// <summary>
  22. /// 废弃产品信息一览
  23. /// </summary>
  24. public partial class F_PM_1101 : DockPanelBase
  25. {
  26. #region 成员变量
  27. //单例模式
  28. private static F_PM_1101 _instance;
  29. //产品分级类别ID
  30. private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage);
  31. //页面审核状态值
  32. private int? _AuditStatus;
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 废弃一览构造
  37. /// </summary>
  38. public F_PM_1101()
  39. {
  40. InitializeComponent();
  41. this.Text = FormTitles.F_PM_1101;
  42. //this.cbSelectTime.Checked = false;
  43. this.cbSelectTime.Checked = true;
  44. this.txtScrapDateStart.Enabled = true;
  45. this.txtScrapDateEnd.Enabled = true;
  46. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  47. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  48. this.tsbtnApprover.Text = ButtonText.TSBTN_AUDIT;
  49. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  50. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  51. }
  52. #endregion
  53. #region 单例模式
  54. /// <summary>
  55. /// 单例模式,防止重复创建窗体
  56. /// </summary>
  57. public static F_PM_1101 Instance
  58. {
  59. get
  60. {
  61. if (_instance == null)
  62. {
  63. _instance = new F_PM_1101();
  64. }
  65. return _instance;
  66. }
  67. }
  68. #endregion
  69. #region 事件
  70. /// <summary>
  71. /// 打开新建窗体事件
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void tsbtnAdd_Click(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. F_PM_1102 frmFPM1102 = new F_PM_1102(Constant.FormMode.Add, "", 0,this.tsbtnApprover.Visible);
  80. DialogResult dialogresult = frmFPM1102.ShowDialog();
  81. if (dialogresult.Equals(DialogResult.OK))
  82. {
  83. this.dgvScrapProduct.DataSource = null;
  84. DataSet dsScrap = (DataSet)DoAsync(new AsyncMethod(() =>
  85. {
  86. return this.GetScrapProduct();
  87. }));
  88. if (dsScrap != null)
  89. {
  90. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  91. {
  92. this.dgvScrapProduct.DataSource = ((DataSet)dsScrap).Tables[Constant.INT_IS_ZERO];
  93. this.dgvScrapProduct.ReadOnly = true;
  94. }
  95. }
  96. }
  97. }
  98. catch (Exception ex)
  99. {
  100. // 对异常进行共通处理
  101. ExceptionManager.HandleEventException(this.ToString(),
  102. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  103. }
  104. }
  105. /// <summary>
  106. /// 查询事件
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void btnSearch_Click(object sender, EventArgs e)
  111. {
  112. try
  113. {
  114. if (this.cbAuditStatus.Text != string.Empty)
  115. {
  116. this._AuditStatus = Convert.ToInt32(this.cbAuditStatus.SelectedValue);
  117. }
  118. else
  119. {
  120. this._AuditStatus = null;
  121. }
  122. DataSet dsScrapProduct = (DataSet)DoAsync(new AsyncMethod(() =>
  123. {
  124. return this.GetScrapProduct();
  125. }));
  126. if (dsScrapProduct != null)
  127. {
  128. if (dsScrapProduct.Tables[0].Rows.Count != Constant.INT_IS_ZERO)
  129. {
  130. this.dgvScrapProduct.DataSource = ((DataSet)dsScrapProduct).Tables[Constant.INT_IS_ZERO];
  131. this.dgvScrapProduct.ReadOnly = true;
  132. }
  133. else
  134. {
  135. this.dgvScrapProduct.DataSource = null;
  136. // 提示未查找到数据
  137. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  138. MessageBoxButtons.OK, MessageBoxIcon.Information);
  139. }
  140. }
  141. else
  142. {
  143. this.dgvScrapProduct.DataSource = null;
  144. // 提示未查找到数据
  145. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  146. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. // 对异常进行共通处理
  152. ExceptionManager.HandleEventException(this.ToString(),
  153. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  154. }
  155. }
  156. /// <summary>
  157. /// 时间有效性切换
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. private void cbSelectTime_CheckedChanged(object sender, EventArgs e)
  162. {
  163. this.txtScrapDateStart.Enabled = this.cbSelectTime.Checked;
  164. this.txtScrapDateEnd.Enabled = this.cbSelectTime.Checked;
  165. }
  166. /// <summary>
  167. /// 清空条件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void btnClearCondition_Click(object sender, EventArgs e)
  172. {
  173. this.txtProductionLineCode.Text = "";
  174. this.txtProductionLineName.Text = "";
  175. this.txtResponProcedureCode.Text = "";
  176. this.txtResponProcedureName.Text = "";
  177. this.txtBarCode.Text = "";
  178. //this.dkUser.UserID = null;
  179. //this.dkUser.Text = "";
  180. this.txtUserCode.Text = "";
  181. this.cbSelectTime.Checked = true;
  182. this.txtGoodsCode.Text = "";
  183. this.txtGoodsName.Text = "";
  184. this.txtRemarks.Text = "";
  185. this.txtRreason.Text = "";
  186. this.txtGroutingUserCode.Text = "";
  187. }
  188. /// <summary>
  189. /// 编辑窗体打开
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. private void tsbtnEdit_Click(object sender, EventArgs e)
  194. {
  195. try
  196. {
  197. DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow;
  198. if (currentRow != null)
  199. {
  200. string barCode = currentRow.Cells["BarCode"].Value.ToString();
  201. int SPId = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value.ToString());
  202. F_PM_1102 frmFPM1102 = new F_PM_1102(Constant.FormMode.Edit, barCode, SPId,this.tsbtnApprover.Visible);
  203. DialogResult dialogresult = frmFPM1102.ShowDialog();
  204. if (dialogresult.Equals(DialogResult.OK))
  205. {
  206. this.dgvScrapProduct.DataSource = null;
  207. object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct));
  208. if (obScrapResult != null)
  209. {
  210. DataSet dsScrap = (DataSet)obScrapResult;
  211. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  212. {
  213. this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO];
  214. this.dgvScrapProduct.ReadOnly = true;
  215. }
  216. }
  217. }
  218. }
  219. else
  220. {
  221. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  222. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  223. }
  224. }
  225. catch (Exception ex)
  226. {
  227. // 对异常进行共通处理
  228. ExceptionManager.HandleEventException(this.ToString(),
  229. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  230. }
  231. }
  232. /// <summary>
  233. /// 编辑窗体打开
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. private void dgvScrapProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  238. {
  239. try
  240. {
  241. DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow;
  242. if (currentRow != null)
  243. {
  244. string barCode = currentRow.Cells["BarCode"].Value.ToString();
  245. int SPId = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value.ToString());
  246. F_PM_1102 frmFPM1102 = new F_PM_1102(Constant.FormMode.Edit, barCode, SPId,this.tsbtnApprover.Visible);
  247. DialogResult dialogresult = frmFPM1102.ShowDialog();
  248. if (dialogresult.Equals(DialogResult.OK))
  249. {
  250. this.dgvScrapProduct.DataSource = null;
  251. object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct));
  252. if (obScrapResult != null)
  253. {
  254. DataSet dsScrap = (DataSet)obScrapResult;
  255. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  256. {
  257. this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO];
  258. this.dgvScrapProduct.ReadOnly = true;
  259. }
  260. }
  261. }
  262. }
  263. else
  264. {
  265. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  266. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  267. }
  268. }
  269. catch (Exception ex)
  270. {
  271. // 对异常进行共通处理
  272. ExceptionManager.HandleEventException(this.ToString(),
  273. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  274. }
  275. }
  276. /// <summary>
  277. /// 关闭一览窗体
  278. /// </summary>
  279. /// <param name="sender"></param>
  280. /// <param name="e"></param>
  281. private void tsbtnClose_Click(object sender, EventArgs e)
  282. {
  283. this.Close();
  284. }
  285. /// <summary>
  286. /// 窗体关闭事件
  287. /// </summary>
  288. /// <param name="sender"></param>
  289. /// <param name="e"></param>
  290. private void F_PM_1101_FormClosed(object sender, FormClosedEventArgs e)
  291. {
  292. _instance = null;
  293. }
  294. /// <summary>
  295. /// 自动列宽
  296. /// </summary>
  297. /// <param name="sender"></param>
  298. /// <param name="e"></param>
  299. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  300. {
  301. this.dgvScrapProduct.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  302. }
  303. /// <summary>
  304. /// 审批按钮事件
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. private void tsbtnApprover_Click(object sender, EventArgs e)
  309. {
  310. try
  311. {
  312. DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow;
  313. if (currentRow != null)
  314. {
  315. string barCode = currentRow.Cells["BarCode"].Value.ToString();
  316. int ScrapProductID = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value);
  317. string GoodsLevelTypeID = currentRow.Cells["GoodsLevelTypeID"].Value.ToString();
  318. if (GoodsLevelTypeID != _goodsLevelTypeID.ToString())
  319. {
  320. return;
  321. }
  322. F_PM_1103 frmFPM1103 = new F_PM_1103(barCode, 0, ScrapProductID);
  323. DialogResult dialogresult = frmFPM1103.ShowDialog();
  324. if (dialogresult.Equals(DialogResult.OK))
  325. {
  326. this.dgvScrapProduct.DataSource = null;
  327. object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct));
  328. if (obScrapResult != null)
  329. {
  330. DataSet dsScrap = (DataSet)obScrapResult;
  331. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  332. {
  333. this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO];
  334. this.dgvScrapProduct.ReadOnly = true;
  335. }
  336. }
  337. }
  338. }
  339. else
  340. {
  341. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  342. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  343. }
  344. }
  345. catch (Exception ex)
  346. {
  347. // 对异常进行共通处理
  348. ExceptionManager.HandleEventException(this.ToString(),
  349. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  350. }
  351. }
  352. /// <summary>
  353. /// 窗体加载
  354. /// </summary>
  355. /// <param name="sender"></param>
  356. /// <param name="e"></param>
  357. private void F_PM_1101_Load(object sender, EventArgs e)
  358. {
  359. try
  360. {
  361. // 加载权限
  362. FormPermissionManager.FormPermissionControl(this.Name, this,
  363. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  364. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  365. DataSet dsStatus = SystemModuleProxy.Service.GetAuditStatus();
  366. this.cbAuditStatus.DataSource = dsStatus.Tables[0];
  367. this.cbAuditStatus.ValueMember = "AuditStatusID";
  368. this.cbAuditStatus.DisplayMember = "AuditStatusName";
  369. this.cbAuditStatus.Text = "";
  370. }
  371. catch (Exception ex)
  372. {
  373. // 对异常进行共通处理
  374. ExceptionManager.HandleEventException(this.ToString(),
  375. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  376. }
  377. }
  378. #endregion
  379. #region 私有方法
  380. /// <summary>
  381. /// 根据界面查询条件获取数据集
  382. /// </summary>
  383. private DataSet GetScrapProduct()
  384. {
  385. try
  386. {
  387. this.dgvScrapProduct.AutoGenerateColumns = false;
  388. ScrapProductEntity scrapProductEntity = new ScrapProductEntity();
  389. scrapProductEntity.ProductionLineCode = this.txtProductionLineCode.Text.Trim();
  390. scrapProductEntity.ProductionLineName = this.txtProductionLineName.Text.Trim();
  391. scrapProductEntity.ResponProcedureCode = this.txtResponProcedureCode.Text.Trim();
  392. scrapProductEntity.ResponProcedureName = this.txtResponProcedureName.Text.Trim();
  393. scrapProductEntity.GroutingUserCode = this.txtGroutingUserCode.Text.Trim();
  394. scrapProductEntity.BarCode = this.txtBarCode.Text.Trim();
  395. //scrapProductEntity.ResponUserID = this.dkUser.UserID;
  396. scrapProductEntity.ResponUserCode = this.txtUserCode.Text.Trim();
  397. if (this.cbSelectTime.Checked == true)
  398. {
  399. scrapProductEntity.ScrapDate = Convert.ToDateTime(this.txtScrapDateStart.Text);
  400. scrapProductEntity.ScrapDateEnd = Convert.ToDateTime(this.txtScrapDateEnd.Text);
  401. }
  402. scrapProductEntity.GoodsCode = this.txtGoodsCode.Text.Trim();
  403. scrapProductEntity.GoodsName = this.txtGoodsName.Text.Trim();
  404. scrapProductEntity.Remarks = this.txtRemarks.Text.Trim();
  405. scrapProductEntity.Rreason = this.txtRreason.Text.Trim();
  406. if (this._AuditStatus != null)
  407. {
  408. scrapProductEntity.AuditStatus = this._AuditStatus;
  409. }
  410. return PMModuleProxy.Service.GetScrapProduct(scrapProductEntity);
  411. }
  412. catch (Exception ex)
  413. {
  414. throw ex;
  415. }
  416. }
  417. #endregion
  418. }
  419. }