F_MST_0501.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0501.cs
  5. * 2.功能描述:产品档案
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/13 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. namespace Dongke.IBOSS.PRD.Client.SystemModule
  19. {
  20. /// <summary>
  21. /// 产品档案
  22. /// </summary>
  23. public partial class F_MST_0501 : DockPanelBase
  24. {
  25. #region 成员变量
  26. private static F_MST_0501 _instance; //单例模式
  27. private int? _glazeTypeID = null; //釉料类别
  28. private Boolean _PlateLimit = false; //装板权限
  29. private Boolean _Edit = false; //编辑权限
  30. #endregion
  31. #region 构造函数
  32. public F_MST_0501()
  33. {
  34. InitializeComponent();
  35. this.dgvGoods.AutoGenerateColumns = false;
  36. this.dgvGoodsSap.AutoGenerateColumns = false;
  37. this.Text = FormTitles.F_MST_0501;
  38. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  39. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  40. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  41. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  42. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  43. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  44. this.tsbtnAttachment.Text = ButtonText.TSBTN_ATTACHMENT;
  45. }
  46. #endregion
  47. #region 单例模式
  48. /// <summary>
  49. /// 单例模式,防止重复创建窗体
  50. /// </summary>
  51. public static F_MST_0501 Instance
  52. {
  53. get
  54. {
  55. if (_instance == null)
  56. {
  57. _instance = new F_MST_0501();
  58. }
  59. return _instance;
  60. }
  61. }
  62. #endregion
  63. #region 事件
  64. /// <summary>
  65. /// 窗体加载
  66. /// </summary>
  67. private void F_MST_0501_Load(object sender, EventArgs e)
  68. {
  69. try
  70. {
  71. // 加载权限
  72. FormPermissionManager.FormPermissionControl(this.Name, this,
  73. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  74. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  75. this.chkCeaseFlag.AllItemCheck();
  76. this.chkValueFlag.AllItemCheck();
  77. this.chkPlanFlag.AllItemCheck();
  78. this.LoadDataSource();
  79. //装板限制数量权限
  80. PlateLimitNumPrivileges();
  81. }
  82. catch (Exception ex)
  83. {
  84. // 对异常进行共通处理
  85. ExceptionManager.HandleEventException(this.ToString(),
  86. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  87. }
  88. }
  89. /// <summary>
  90. /// 获取数据事件
  91. /// </summary>
  92. private void btnSearch_Click(object sender, EventArgs e)
  93. {
  94. try
  95. {
  96. this.dgvGoods.DataSource = null;
  97. this.dgvGoodsSap.DataSource = null;
  98. this._glazeTypeID = this.ddlGlazeTypeID.SelectedValue == null
  99. ? null : (int?)Convert.ToInt32(this.ddlGlazeTypeID.SelectedValue);
  100. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  101. if (obGoodsResult != null)
  102. {
  103. DataSet dsGoods = (DataSet)obGoodsResult;
  104. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  105. {
  106. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  107. this.dgvGoods.ReadOnly = true;
  108. this.dgvGoodsSap.ReadOnly = true;
  109. if (this.dgvGoods.Rows.Count == Constant.INT_IS_ZERO)
  110. {
  111. // 提示未查找到数据
  112. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  113. MessageBoxButtons.OK, MessageBoxIcon.Information);
  114. }
  115. }
  116. }
  117. else
  118. {
  119. // 提示未查找到数据
  120. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  121. MessageBoxButtons.OK, MessageBoxIcon.Information);
  122. }
  123. }
  124. catch (Exception ex)
  125. {
  126. // 对异常进行共通处理
  127. ExceptionManager.HandleEventException(this.ToString(),
  128. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  129. }
  130. }
  131. /// <summary>
  132. /// 清空事件
  133. /// </summary>
  134. private void btnClearCondition_Click(object sender, EventArgs e)
  135. {
  136. this.txtGoodsCode.Text = "";
  137. this.txtGoodsModel.Text = "";
  138. this.txtGoodsName.Text = "";
  139. this.txtGoodsSpecification.Text = "";
  140. this.ddlGlazeTypeID.Text = "";
  141. this.txtRemarks.Text = "";
  142. this.scbGoodsType.ClearValue();
  143. this.chkCeaseFlag.AllItemCheck();
  144. this.chkValueFlag.AllItemCheck();
  145. this.chkPlanFlag.AllItemCheck();
  146. }
  147. /// <summary>
  148. /// 关闭窗体事件
  149. /// </summary>
  150. private void tsbtnClose_Click(object sender, EventArgs e)
  151. {
  152. this.Close();
  153. }
  154. /// <summary>
  155. /// 自适应事件
  156. /// </summary>
  157. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  158. {
  159. this.dgvGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  160. dgvGoodsSap.AutoResizeColumns();
  161. }
  162. /// <summary>
  163. /// 窗体关闭事件
  164. /// </summary>
  165. private void F_MST_0501_FormClosed(object sender, FormClosedEventArgs e)
  166. {
  167. _instance = null;
  168. }
  169. /// <summary>
  170. /// 添加产品事件
  171. /// </summary>
  172. private void tsbtnAddGoods_Click(object sender, EventArgs e)
  173. {
  174. try
  175. {
  176. F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Add, Constant.INT_IS_ZERO,0);
  177. DialogResult dialogresult = frmMST0502.ShowDialog();
  178. if (dialogresult.Equals(DialogResult.OK))
  179. {
  180. this.dgvGoods.DataSource = null;
  181. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  182. if (obGoodsResult != null)
  183. {
  184. DataSet dsGoods = (DataSet)obGoodsResult;
  185. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  186. {
  187. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  188. this.dgvGoods.ReadOnly = true;
  189. }
  190. }
  191. }
  192. }
  193. catch (Exception ex)
  194. {
  195. // 对异常进行共通处理
  196. ExceptionManager.HandleEventException(this.ToString(),
  197. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  198. }
  199. }
  200. /// <summary>
  201. /// 编辑产品事件
  202. /// </summary>
  203. private void tsbtnEditGoods_Click(object sender, EventArgs e)
  204. {
  205. try
  206. {
  207. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  208. if (currentRow != null)
  209. {
  210. int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  211. F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Edit, goodsId,0);
  212. DialogResult dialogresult = frmMST0502.ShowDialog();
  213. if (dialogresult.Equals(DialogResult.OK))
  214. {
  215. this.dgvGoods.DataSource = null;
  216. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  217. if (obGoodsResult != null)
  218. {
  219. DataSet dsGoods = (DataSet)obGoodsResult;
  220. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  221. {
  222. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  223. this.dgvGoods.ReadOnly = true;
  224. }
  225. }
  226. }
  227. }
  228. else
  229. {
  230. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  231. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  232. }
  233. }
  234. catch (Exception ex)
  235. {
  236. // 对异常进行共通处理
  237. ExceptionManager.HandleEventException(this.ToString(),
  238. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  239. }
  240. }
  241. /// <summary>
  242. /// 双击列表事件
  243. /// </summary>
  244. private void dgvGoods_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  245. {
  246. try
  247. {
  248. if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
  249. {
  250. return;
  251. }
  252. int goodsId = Convert.ToInt32(this.dgvGoods.Rows[e.RowIndex].Cells["GoodsID"].Value);
  253. int EditPlateLimit = 0;
  254. if (_PlateLimit = true && _Edit == false)
  255. {
  256. EditPlateLimit = 1;
  257. }
  258. else if (_Edit == true)
  259. {
  260. EditPlateLimit = 0;
  261. }
  262. else {
  263. return;
  264. }
  265. F_MST_0502 frmMST0702 = new F_MST_0502(Constant.FormMode.Edit, goodsId, EditPlateLimit);
  266. DialogResult dialogresult = frmMST0702.ShowDialog();
  267. if (dialogresult.Equals(DialogResult.OK))
  268. {
  269. this.dgvGoods.DataSource = null;
  270. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  271. if (obGoodsResult != null)
  272. {
  273. DataSet dsGoods = (DataSet)obGoodsResult;
  274. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  275. {
  276. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  277. this.dgvGoods.ReadOnly = true;
  278. }
  279. }
  280. }
  281. }
  282. catch (Exception ex)
  283. {
  284. // 对异常进行共通处理
  285. ExceptionManager.HandleEventException(this.ToString(),
  286. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  287. }
  288. }
  289. /// <summary>
  290. /// 附件按钮事件
  291. /// </summary>
  292. /// <param name="sender"></param>
  293. /// <param name="e"></param>
  294. private void tsbtnAttachment_Click(object sender, EventArgs e)
  295. {
  296. try
  297. {
  298. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  299. if (currentRow != null)
  300. {
  301. int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  302. F_CMN_0101 frmCMN0101 = new F_CMN_0101(goodsId);
  303. DialogResult dialogresult = frmCMN0101.ShowDialog();
  304. if (dialogresult.Equals(DialogResult.OK))
  305. {
  306. }
  307. }
  308. else
  309. {
  310. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  311. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. // 对异常进行共通处理
  317. ExceptionManager.HandleEventException(this.ToString(),
  318. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  319. }
  320. }
  321. /// <summary>
  322. /// 设置产品工序
  323. /// </summary>
  324. /// <param name="sender"></param>
  325. /// <param name="e"></param>
  326. private void tsbtnSet_Click(object sender, EventArgs e)
  327. {
  328. try
  329. {
  330. DataTable data = this.dgvGoods.DataSource as DataTable;
  331. if (data == null || data.Rows.Count == 0)
  332. {
  333. return;
  334. }
  335. data = data.Copy();
  336. F_MST_0503 fMST0503 = new F_MST_0503(1, data);
  337. fMST0503.ShowDialog();
  338. }
  339. catch (Exception ex)
  340. {
  341. // 对异常进行共通处理
  342. ExceptionManager.HandleEventException(this.ToString(),
  343. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  344. }
  345. }
  346. /// <summary>
  347. /// 撤销产品工序设置
  348. /// </summary>
  349. /// <param name="sender"></param>
  350. /// <param name="e"></param>
  351. private void tsbtnUndo_Click(object sender, EventArgs e)
  352. {
  353. try
  354. {
  355. DataTable data = this.dgvGoods.DataSource as DataTable;
  356. if (data == null || data.Rows.Count == 0)
  357. {
  358. return;
  359. }
  360. data = data.Copy();
  361. F_MST_0503 fMST0503 = new F_MST_0503(2, data);
  362. fMST0503.ShowDialog();
  363. }
  364. catch (Exception ex)
  365. {
  366. // 对异常进行共通处理
  367. ExceptionManager.HandleEventException(this.ToString(),
  368. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  369. }
  370. }
  371. /// <summary>
  372. /// 行切换事件
  373. /// </summary>
  374. /// <param name="sender"></param>
  375. /// <param name="e"></param>
  376. private void dgvGoods_SelectionChanged(object sender, EventArgs e)
  377. {
  378. if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
  379. {
  380. this.dgvGoodsSap.DataSource = null;
  381. return;
  382. }
  383. try
  384. {
  385. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  386. ClientRequestEntity cre = new ClientRequestEntity();
  387. cre.NameSpace = "MST_Goods";
  388. cre.Name = "GetGoodsSAP";
  389. cre.Request = goodsid;
  390. // 调用服务器端获取数据集
  391. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  392. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  393. {
  394. this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
  395. }
  396. }
  397. catch (Exception ex)
  398. {
  399. // 对异常进行共通处理
  400. ExceptionManager.HandleEventException(this.ToString(),
  401. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  402. }
  403. }
  404. //编辑装板
  405. private void toolStripButton1_Click(object sender, EventArgs e)
  406. {
  407. try
  408. {
  409. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  410. if (currentRow != null)
  411. {
  412. int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  413. F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Edit, goodsId,1);
  414. DialogResult dialogresult = frmMST0502.ShowDialog();
  415. if (dialogresult.Equals(DialogResult.OK))
  416. {
  417. this.dgvGoods.DataSource = null;
  418. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  419. if (obGoodsResult != null)
  420. {
  421. DataSet dsGoods = (DataSet)obGoodsResult;
  422. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  423. {
  424. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  425. this.dgvGoods.ReadOnly = true;
  426. }
  427. }
  428. }
  429. }
  430. else
  431. {
  432. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  433. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  434. }
  435. }
  436. catch (Exception ex)
  437. {
  438. // 对异常进行共通处理
  439. ExceptionManager.HandleEventException(this.ToString(),
  440. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  441. }
  442. }
  443. #endregion
  444. #region 私有方法
  445. /// <summary>
  446. /// 根据查询条件获取数据集合
  447. /// </summary>
  448. public DataSet getGoods()
  449. {
  450. try
  451. {
  452. GoodsEntity goods = new GoodsEntity();
  453. goods.GoodsCode = this.txtGoodsCode.Text;
  454. goods.GoodsModel = this.txtGoodsModel.Text;
  455. goods.GoodsName = this.txtGoodsName.Text;
  456. goods.GoodsSpecification = this.txtGoodsSpecification.Text;
  457. goods.GlazeTypeID = this._glazeTypeID;
  458. goods.Remarks = this.txtRemarks.Text;
  459. goods.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  460. //判断选择框,如有选择则赋值
  461. object[] objListCease = chkCeaseFlag.SelectedValues;
  462. if (objListCease.Length == Constant.INT_IS_ONE)
  463. {
  464. goods.CeaseFlag = (int)objListCease[Constant.INT_IS_ZERO];
  465. }
  466. else if (objListCease.Length == Constant.INT_IS_ZERO)
  467. {
  468. return null;
  469. }
  470. object[] objListValue = chkValueFlag.SelectedValues;
  471. if (objListValue.Length == Constant.INT_IS_ONE)
  472. {
  473. goods.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
  474. }
  475. else if (objListValue.Length == Constant.INT_IS_ZERO)
  476. {
  477. return null;
  478. }
  479. object[] objPlanFlag = chkPlanFlag.SelectedValues;
  480. if (objPlanFlag.Length == 1)
  481. {
  482. goods.PlanFlag = objPlanFlag[0].ToString();
  483. }
  484. else if (objPlanFlag.Length == Constant.INT_IS_ZERO)
  485. {
  486. return null;
  487. }
  488. return SystemModuleProxy.Service.SerachGoods(goods);
  489. }
  490. catch (Exception ex)
  491. {
  492. throw ex;
  493. }
  494. }
  495. /// <summary>
  496. /// 加载页面所需的数据源
  497. /// </summary>
  498. private void LoadDataSource()
  499. {
  500. try
  501. {
  502. // 绑定釉料类别
  503. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(
  504. Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  505. if (dtGlazeType != null)
  506. {
  507. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  508. ddlGlazeTypeID.ValueMember = "DictionaryID";
  509. ddlGlazeTypeID.DataSource = dtGlazeType;
  510. ddlGlazeTypeID.SelectedText = "";
  511. ddlGlazeTypeID.Text = "";
  512. }
  513. }
  514. catch (Exception ex)
  515. {
  516. throw ex;
  517. }
  518. }
  519. ///<summary>
  520. ///修改装板数量权限
  521. /// </summary>
  522. private void PlateLimitNumPrivileges()
  523. {
  524. ClientRequestEntity cre = new ClientRequestEntity();
  525. cre.NameSpace = "MST_PlateLimitNum";
  526. cre.Name = "PlateLimitNumPrivileges";
  527. // 调用服务器端获取数据集
  528. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  529. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  530. {
  531. this.tsbtnAdd.Enabled = false;
  532. this.tsbtnEdit.Enabled = false;
  533. this.tsbtnAttachment.Enabled = false;
  534. this.tsEditPlateLimitNum.Enabled = false;
  535. this.tsbtnSet.Enabled = false;
  536. this.tsbtnUndo.Enabled = false;
  537. for (int i = 0; i < sre.Data.Tables[0].Rows.Count; i++)
  538. {
  539. //附件
  540. if (sre.Data.Tables[0].Rows[i]["FUNCTIONCODE"].ToString() == "01030305")
  541. {
  542. this.tsbtnAttachment.Enabled = true;
  543. this.tsbtnSet.Enabled = true;
  544. this.tsbtnUndo.Enabled = true;
  545. }
  546. //新建
  547. else if (sre.Data.Tables[0].Rows[i]["FUNCTIONCODE"].ToString() == "01030301")
  548. {
  549. this.tsbtnAdd.Enabled = true;
  550. this.tsbtnSet.Enabled = true;
  551. this.tsbtnUndo.Enabled = true;
  552. }
  553. //编辑
  554. else if (sre.Data.Tables[0].Rows[i]["FUNCTIONCODE"].ToString() == "01030302")
  555. {
  556. this.tsbtnEdit.Enabled = true;
  557. this.tsbtnSet.Enabled = true;
  558. this.tsbtnUndo.Enabled = true;
  559. _Edit = true;
  560. }
  561. //编辑装板数量
  562. else if (sre.Data.Tables[0].Rows[i]["FUNCTIONCODE"].ToString() == "01030303")
  563. {
  564. this.tsEditPlateLimitNum.Enabled = true;
  565. _PlateLimit = true;
  566. }
  567. }
  568. }
  569. }
  570. #endregion
  571. }
  572. }