F_MST_0501.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. #endregion
  29. #region 构造函数
  30. public F_MST_0501()
  31. {
  32. InitializeComponent();
  33. this.dgvGoods.AutoGenerateColumns = false;
  34. this.dgvGoodsSap.AutoGenerateColumns = false;
  35. this.Text = FormTitles.F_MST_0501;
  36. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  37. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  38. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  39. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  40. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  41. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  42. this.tsbtnAttachment.Text = ButtonText.TSBTN_ATTACHMENT;
  43. }
  44. #endregion
  45. #region 单例模式
  46. /// <summary>
  47. /// 单例模式,防止重复创建窗体
  48. /// </summary>
  49. public static F_MST_0501 Instance
  50. {
  51. get
  52. {
  53. if (_instance == null)
  54. {
  55. _instance = new F_MST_0501();
  56. }
  57. return _instance;
  58. }
  59. }
  60. #endregion
  61. #region 事件
  62. /// <summary>
  63. /// 窗体加载
  64. /// </summary>
  65. private void F_MST_0501_Load(object sender, EventArgs e)
  66. {
  67. try
  68. {
  69. // 加载权限
  70. FormPermissionManager.FormPermissionControl(this.Name, this,
  71. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  72. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  73. this.chkCeaseFlag.AllItemCheck();
  74. this.chkValueFlag.AllItemCheck();
  75. this.LoadDataSource();
  76. }
  77. catch (Exception ex)
  78. {
  79. // 对异常进行共通处理
  80. ExceptionManager.HandleEventException(this.ToString(),
  81. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  82. }
  83. }
  84. /// <summary>
  85. /// 获取数据事件
  86. /// </summary>
  87. private void btnSearch_Click(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. this.dgvGoods.DataSource = null;
  92. this.dgvGoodsSap.DataSource = null;
  93. this._glazeTypeID = this.ddlGlazeTypeID.SelectedValue == null
  94. ? null : (int?)Convert.ToInt32(this.ddlGlazeTypeID.SelectedValue);
  95. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  96. if (obGoodsResult != null)
  97. {
  98. DataSet dsGoods = (DataSet)obGoodsResult;
  99. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  100. {
  101. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  102. this.dgvGoods.ReadOnly = true;
  103. this.dgvGoodsSap.ReadOnly = true;
  104. if (this.dgvGoods.Rows.Count == Constant.INT_IS_ZERO)
  105. {
  106. // 提示未查找到数据
  107. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  108. MessageBoxButtons.OK, MessageBoxIcon.Information);
  109. }
  110. }
  111. }
  112. else
  113. {
  114. // 提示未查找到数据
  115. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  116. MessageBoxButtons.OK, MessageBoxIcon.Information);
  117. }
  118. }
  119. catch (Exception ex)
  120. {
  121. // 对异常进行共通处理
  122. ExceptionManager.HandleEventException(this.ToString(),
  123. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  124. }
  125. }
  126. /// <summary>
  127. /// 清空事件
  128. /// </summary>
  129. private void btnClearCondition_Click(object sender, EventArgs e)
  130. {
  131. this.txtGoodsCode.Text = "";
  132. this.txtGoodsModel.Text = "";
  133. this.txtGoodsName.Text = "";
  134. this.txtGoodsSpecification.Text = "";
  135. this.ddlGlazeTypeID.Text = "";
  136. this.txtRemarks.Text = "";
  137. this.scbGoodsType.ClearValue();
  138. this.chkCeaseFlag.AllItemCheck();
  139. this.chkValueFlag.AllItemCheck();
  140. }
  141. /// <summary>
  142. /// 关闭窗体事件
  143. /// </summary>
  144. private void tsbtnClose_Click(object sender, EventArgs e)
  145. {
  146. this.Close();
  147. }
  148. /// <summary>
  149. /// 自适应事件
  150. /// </summary>
  151. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  152. {
  153. this.dgvGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  154. dgvGoodsSap.AutoResizeColumns();
  155. }
  156. /// <summary>
  157. /// 窗体关闭事件
  158. /// </summary>
  159. private void F_MST_0501_FormClosed(object sender, FormClosedEventArgs e)
  160. {
  161. _instance = null;
  162. }
  163. /// <summary>
  164. /// 添加产品事件
  165. /// </summary>
  166. private void tsbtnAddGoods_Click(object sender, EventArgs e)
  167. {
  168. try
  169. {
  170. F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Add, Constant.INT_IS_ZERO);
  171. DialogResult dialogresult = frmMST0502.ShowDialog();
  172. if (dialogresult.Equals(DialogResult.OK))
  173. {
  174. this.dgvGoods.DataSource = null;
  175. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  176. if (obGoodsResult != null)
  177. {
  178. DataSet dsGoods = (DataSet)obGoodsResult;
  179. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  180. {
  181. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  182. this.dgvGoods.ReadOnly = true;
  183. }
  184. }
  185. }
  186. }
  187. catch (Exception ex)
  188. {
  189. // 对异常进行共通处理
  190. ExceptionManager.HandleEventException(this.ToString(),
  191. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  192. }
  193. }
  194. /// <summary>
  195. /// 编辑产品事件
  196. /// </summary>
  197. private void tsbtnEditGoods_Click(object sender, EventArgs e)
  198. {
  199. try
  200. {
  201. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  202. if (currentRow != null)
  203. {
  204. int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  205. F_MST_0502 frmMST0502 = new F_MST_0502(Constant.FormMode.Edit, goodsId);
  206. DialogResult dialogresult = frmMST0502.ShowDialog();
  207. if (dialogresult.Equals(DialogResult.OK))
  208. {
  209. this.dgvGoods.DataSource = null;
  210. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  211. if (obGoodsResult != null)
  212. {
  213. DataSet dsGoods = (DataSet)obGoodsResult;
  214. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  215. {
  216. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  217. this.dgvGoods.ReadOnly = true;
  218. }
  219. }
  220. }
  221. }
  222. else
  223. {
  224. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  225. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  226. }
  227. }
  228. catch (Exception ex)
  229. {
  230. // 对异常进行共通处理
  231. ExceptionManager.HandleEventException(this.ToString(),
  232. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  233. }
  234. }
  235. /// <summary>
  236. /// 双击列表事件
  237. /// </summary>
  238. private void dgvGoods_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  239. {
  240. try
  241. {
  242. if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
  243. {
  244. return;
  245. }
  246. int goodsId = Convert.ToInt32(this.dgvGoods.Rows[e.RowIndex].Cells["GoodsID"].Value);
  247. F_MST_0502 frmMST0702 = new F_MST_0502(Constant.FormMode.Edit, goodsId);
  248. DialogResult dialogresult = frmMST0702.ShowDialog();
  249. if (dialogresult.Equals(DialogResult.OK))
  250. {
  251. this.dgvGoods.DataSource = null;
  252. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  253. if (obGoodsResult != null)
  254. {
  255. DataSet dsGoods = (DataSet)obGoodsResult;
  256. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  257. {
  258. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  259. this.dgvGoods.ReadOnly = true;
  260. }
  261. }
  262. }
  263. }
  264. catch (Exception ex)
  265. {
  266. // 对异常进行共通处理
  267. ExceptionManager.HandleEventException(this.ToString(),
  268. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  269. }
  270. }
  271. /// <summary>
  272. /// 附件按钮事件
  273. /// </summary>
  274. /// <param name="sender"></param>
  275. /// <param name="e"></param>
  276. private void tsbtnAttachment_Click(object sender, EventArgs e)
  277. {
  278. try
  279. {
  280. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  281. if (currentRow != null)
  282. {
  283. int goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  284. F_CMN_0101 frmCMN0101 = new F_CMN_0101(goodsId);
  285. DialogResult dialogresult = frmCMN0101.ShowDialog();
  286. if (dialogresult.Equals(DialogResult.OK))
  287. {
  288. }
  289. }
  290. else
  291. {
  292. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  293. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  294. }
  295. }
  296. catch (Exception ex)
  297. {
  298. // 对异常进行共通处理
  299. ExceptionManager.HandleEventException(this.ToString(),
  300. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  301. }
  302. }
  303. /// <summary>
  304. /// 设置产品工序
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. private void tsbtnSet_Click(object sender, EventArgs e)
  309. {
  310. try
  311. {
  312. DataTable data = this.dgvGoods.DataSource as DataTable;
  313. if (data == null || data.Rows.Count == 0)
  314. {
  315. return;
  316. }
  317. data = data.Copy();
  318. F_MST_0503 fMST0503 = new F_MST_0503(1, data);
  319. fMST0503.ShowDialog();
  320. }
  321. catch (Exception ex)
  322. {
  323. // 对异常进行共通处理
  324. ExceptionManager.HandleEventException(this.ToString(),
  325. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  326. }
  327. }
  328. /// <summary>
  329. /// 撤销产品工序设置
  330. /// </summary>
  331. /// <param name="sender"></param>
  332. /// <param name="e"></param>
  333. private void tsbtnUndo_Click(object sender, EventArgs e)
  334. {
  335. try
  336. {
  337. DataTable data = this.dgvGoods.DataSource as DataTable;
  338. if (data == null || data.Rows.Count == 0)
  339. {
  340. return;
  341. }
  342. data = data.Copy();
  343. F_MST_0503 fMST0503 = new F_MST_0503(2, data);
  344. fMST0503.ShowDialog();
  345. }
  346. catch (Exception ex)
  347. {
  348. // 对异常进行共通处理
  349. ExceptionManager.HandleEventException(this.ToString(),
  350. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  351. }
  352. }
  353. #endregion
  354. #region 私有方法
  355. /// <summary>
  356. /// 根据查询条件获取数据集合
  357. /// </summary>
  358. public DataSet getGoods()
  359. {
  360. try
  361. {
  362. GoodsEntity goods = new GoodsEntity();
  363. goods.GoodsCode = this.txtGoodsCode.Text;
  364. goods.GoodsModel = this.txtGoodsModel.Text;
  365. goods.GoodsName = this.txtGoodsName.Text;
  366. goods.GoodsSpecification = this.txtGoodsSpecification.Text;
  367. goods.GlazeTypeID = this._glazeTypeID;
  368. goods.Remarks = this.txtRemarks.Text;
  369. goods.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  370. //判断选择框,如有选择则赋值
  371. object[] objListCease = chkCeaseFlag.SelectedValues;
  372. if (objListCease.Length == Constant.INT_IS_ONE)
  373. {
  374. goods.CeaseFlag = (int)objListCease[Constant.INT_IS_ZERO];
  375. }
  376. else if (objListCease.Length == Constant.INT_IS_ZERO)
  377. {
  378. return null;
  379. }
  380. object[] objListValue = chkValueFlag.SelectedValues;
  381. if (objListValue.Length == Constant.INT_IS_ONE)
  382. {
  383. goods.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
  384. }
  385. else if (objListValue.Length == Constant.INT_IS_ZERO)
  386. {
  387. return null;
  388. }
  389. return SystemModuleProxy.Service.SerachGoods(goods);
  390. }
  391. catch (Exception ex)
  392. {
  393. throw ex;
  394. }
  395. }
  396. /// <summary>
  397. /// 加载页面所需的数据源
  398. /// </summary>
  399. private void LoadDataSource()
  400. {
  401. try
  402. {
  403. // 绑定釉料类别
  404. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(
  405. Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  406. if (dtGlazeType != null)
  407. {
  408. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  409. ddlGlazeTypeID.ValueMember = "DictionaryID";
  410. ddlGlazeTypeID.DataSource = dtGlazeType;
  411. ddlGlazeTypeID.SelectedText = "";
  412. ddlGlazeTypeID.Text = "";
  413. }
  414. }
  415. catch (Exception ex)
  416. {
  417. throw ex;
  418. }
  419. }
  420. #endregion
  421. private void dgvGoods_SelectionChanged(object sender, EventArgs e)
  422. {
  423. if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
  424. {
  425. this.dgvGoodsSap.DataSource = null;
  426. return;
  427. }
  428. try
  429. {
  430. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  431. ClientRequestEntity cre = new ClientRequestEntity();
  432. cre.NameSpace = "MST_Goods";
  433. cre.Name = "GetGoodsSAP";
  434. cre.Request = goodsid;
  435. // 调用服务器端获取数据集
  436. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  437. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  438. {
  439. this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
  440. }
  441. }
  442. catch (Exception ex)
  443. {
  444. // 对异常进行共通处理
  445. ExceptionManager.HandleEventException(this.ToString(),
  446. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  447. }
  448. }
  449. }
  450. }