F_MST_0501.cs 14 KB

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