F_MST_0501.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. #endregion
  356. #region 私有方法
  357. /// <summary>
  358. /// 根据查询条件获取数据集合
  359. /// </summary>
  360. public DataSet getGoods()
  361. {
  362. try
  363. {
  364. GoodsEntity goods = new GoodsEntity();
  365. goods.GoodsCode = this.txtGoodsCode.Text;
  366. goods.GoodsModel = this.txtGoodsModel.Text;
  367. goods.GoodsName = this.txtGoodsName.Text;
  368. goods.GoodsSpecification = this.txtGoodsSpecification.Text;
  369. goods.GlazeTypeID = this._glazeTypeID;
  370. goods.Remarks = this.txtRemarks.Text;
  371. goods.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  372. //判断选择框,如有选择则赋值
  373. object[] objListCease = chkCeaseFlag.SelectedValues;
  374. if (objListCease.Length == Constant.INT_IS_ONE)
  375. {
  376. goods.CeaseFlag = (int)objListCease[Constant.INT_IS_ZERO];
  377. }
  378. else if (objListCease.Length == Constant.INT_IS_ZERO)
  379. {
  380. return null;
  381. }
  382. object[] objListValue = chkValueFlag.SelectedValues;
  383. if (objListValue.Length == Constant.INT_IS_ONE)
  384. {
  385. goods.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
  386. }
  387. else if (objListValue.Length == Constant.INT_IS_ZERO)
  388. {
  389. return null;
  390. }
  391. object[] objPlanFlag = chkPlanFlag.SelectedValues;
  392. if (objPlanFlag.Length == 1)
  393. {
  394. goods.PlanFlag = objPlanFlag[0].ToString();
  395. }
  396. else if (objPlanFlag.Length == Constant.INT_IS_ZERO)
  397. {
  398. return null;
  399. }
  400. return SystemModuleProxy.Service.SerachGoods(goods);
  401. }
  402. catch (Exception ex)
  403. {
  404. throw ex;
  405. }
  406. }
  407. /// <summary>
  408. /// 加载页面所需的数据源
  409. /// </summary>
  410. private void LoadDataSource()
  411. {
  412. try
  413. {
  414. // 绑定釉料类别
  415. DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(
  416. Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
  417. if (dtGlazeType != null)
  418. {
  419. ddlGlazeTypeID.DisplayMember = "DictionaryValue";
  420. ddlGlazeTypeID.ValueMember = "DictionaryID";
  421. ddlGlazeTypeID.DataSource = dtGlazeType;
  422. ddlGlazeTypeID.SelectedText = "";
  423. ddlGlazeTypeID.Text = "";
  424. }
  425. }
  426. catch (Exception ex)
  427. {
  428. throw ex;
  429. }
  430. }
  431. #endregion
  432. private void dgvGoods_SelectionChanged(object sender, EventArgs e)
  433. {
  434. if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
  435. {
  436. this.dgvGoodsSap.DataSource = null;
  437. return;
  438. }
  439. try
  440. {
  441. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  442. ClientRequestEntity cre = new ClientRequestEntity();
  443. cre.NameSpace = "MST_Goods";
  444. cre.Name = "GetGoodsSAP";
  445. cre.Request = goodsid;
  446. // 调用服务器端获取数据集
  447. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  448. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 0)
  449. {
  450. this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
  451. }
  452. }
  453. catch (Exception ex)
  454. {
  455. // 对异常进行共通处理
  456. ExceptionManager.HandleEventException(this.ToString(),
  457. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  458. }
  459. }
  460. }
  461. }