F_MST_1003.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_1003.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_1003 : DockPanelBase
  24. {
  25. #region 成员变量
  26. private static F_MST_1003 _instance; //单例模式
  27. #endregion
  28. #region 构造函数
  29. public F_MST_1003()
  30. {
  31. InitializeComponent();
  32. this.dgvGoods.AutoGenerateColumns = false;
  33. this.dgvGoodsSap.AutoGenerateColumns = false;
  34. this.Text = "产品对应辅件";
  35. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  36. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  37. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  38. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  39. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  40. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  41. }
  42. #endregion
  43. #region 单例模式
  44. /// <summary>
  45. /// 单例模式,防止重复创建窗体
  46. /// </summary>
  47. public static F_MST_1003 Instance
  48. {
  49. get
  50. {
  51. if (_instance == null)
  52. {
  53. _instance = new F_MST_1003();
  54. }
  55. return _instance;
  56. }
  57. }
  58. #endregion
  59. #region 事件
  60. /// <summary>
  61. /// 窗体加载
  62. /// </summary>
  63. private void F_MST_0501_Load(object sender, EventArgs e)
  64. {
  65. try
  66. {
  67. // 加载权限
  68. FormPermissionManager.FormPermissionControl(this.Name, this,
  69. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  70. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  71. this.chkCeaseFlag.AllItemCheck();
  72. this.chkValueFlag.AllItemCheck();
  73. //绑定辅件类别
  74. ClientRequestEntity cre1 = new ClientRequestEntity();
  75. cre1.NameSpace = "AccessoriesType";
  76. cre1.Name = "GetAccessoriesType";
  77. // 调用服务器端获取数据集
  78. ServiceResultEntity sre1 = SystemModuleProxy.Service.DoRequest(cre1);
  79. if (sre1 != null && sre1.Data != null && sre1.Data.Tables.Count > 0)
  80. {
  81. DICTIONARYVALUE.DisplayMember = "DICTIONARYVALUE";
  82. DICTIONARYVALUE.ValueMember = "DICTIONARYVALUE";
  83. DICTIONARYVALUE.DataSource = sre1.Data.Tables[0];
  84. }
  85. }
  86. catch (Exception ex)
  87. {
  88. // 对异常进行共通处理
  89. ExceptionManager.HandleEventException(this.ToString(),
  90. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  91. }
  92. }
  93. /// <summary>
  94. /// 获取数据事件
  95. /// </summary>
  96. private void btnSearch_Click(object sender, EventArgs e)
  97. {
  98. try
  99. {
  100. this.dgvGoods.DataSource = null;
  101. this.dgvGoodsSap.DataSource = null;
  102. this.dgvAccessories.DataSource = null;
  103. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  104. if (obGoodsResult != null)
  105. {
  106. DataSet dsGoods = (DataSet)obGoodsResult;
  107. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  108. {
  109. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  110. this.dgvGoods.ReadOnly = true;
  111. this.dgvGoodsSap.ReadOnly = true;
  112. if (this.dgvGoods.Rows.Count == Constant.INT_IS_ZERO)
  113. {
  114. // 提示未查找到数据
  115. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  116. MessageBoxButtons.OK, MessageBoxIcon.Information);
  117. }
  118. }
  119. }
  120. else
  121. {
  122. // 提示未查找到数据
  123. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  124. MessageBoxButtons.OK, MessageBoxIcon.Information);
  125. }
  126. }
  127. catch (Exception ex)
  128. {
  129. // 对异常进行共通处理
  130. ExceptionManager.HandleEventException(this.ToString(),
  131. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  132. }
  133. }
  134. /// <summary>
  135. /// 清空事件
  136. /// </summary>
  137. private void btnClearCondition_Click(object sender, EventArgs e)
  138. {
  139. this.txtGoodsCode.Text = "";
  140. this.txtGoodsModel.Text = "";
  141. this.txtGoodsName.Text = "";
  142. this.txtGoodsSpecification.Text = "";
  143. this.scbGoodsType.ClearValue();
  144. this.chkCeaseFlag.AllItemCheck();
  145. this.chkValueFlag.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. dgvAccessories.AutoResizeColumns();
  162. }
  163. /// <summary>
  164. /// 窗体关闭事件
  165. /// </summary>
  166. private void F_MST_0501_FormClosed(object sender, FormClosedEventArgs e)
  167. {
  168. _instance = null;
  169. }
  170. /// <summary>
  171. /// 添加产品事件
  172. /// </summary>
  173. private void tsbtnAddGoods_Click(object sender, EventArgs e)
  174. {
  175. try
  176. {
  177. F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Add, Constant.INT_IS_ZERO, Constant.INT_IS_ZERO);
  178. DialogResult dialogresult = frmMST1013.ShowDialog();
  179. if (dialogresult.Equals(DialogResult.OK))
  180. {
  181. this.dgvGoods.DataSource = null;
  182. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  183. if (obGoodsResult != null)
  184. {
  185. DataSet dsGoods = (DataSet)obGoodsResult;
  186. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  187. {
  188. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  189. this.dgvGoods.ReadOnly = true;
  190. }
  191. }
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. // 对异常进行共通处理
  197. ExceptionManager.HandleEventException(this.ToString(),
  198. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  199. }
  200. }
  201. /// <summary>
  202. /// 编辑产品事件
  203. /// </summary>
  204. private void tsbtnEditGoods_Click(object sender, EventArgs e)
  205. {
  206. try
  207. {
  208. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  209. if (currentRow != null)
  210. {
  211. int goodsId = 0;
  212. int logoid = 0;
  213. if (((System.Data.DataTable)this.dgvGoods.DataSource).DefaultView.Count < 1 || ((System.Data.DataTable)this.dgvGoodsSap.DataSource).DefaultView.Count < 1)
  214. {
  215. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  216. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  217. return;
  218. }
  219. else
  220. {
  221. goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  222. logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
  223. }
  224. DataGridViewRow currentRow1 = this.dgvAccessories.CurrentRow;
  225. int Accessorestypeid = Convert.ToInt32(currentRow1.Cells["ACCESSORIESTYPEID"].Value);
  226. string Accessorestypecode = currentRow1.Cells["ACCESSORIESCODE"].Value.ToString();
  227. string Accessorestypename = currentRow1.Cells["DICTIONARYVALUE"].Value.ToString();
  228. F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Edit, goodsId,logoid);
  229. DialogResult dialogresult = frmMST1013.ShowDialog();
  230. if (dialogresult.Equals(DialogResult.OK))
  231. {
  232. this.dgvGoods.DataSource = null;
  233. btnSearch_Click(sender,e);
  234. }
  235. }
  236. else
  237. {
  238. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  239. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  240. }
  241. }
  242. catch (Exception ex)
  243. {
  244. // 对异常进行共通处理
  245. ExceptionManager.HandleEventException(this.ToString(),
  246. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  247. }
  248. }
  249. /// <summary>
  250. /// 双击列表事件
  251. /// </summary>
  252. private void dgvGoods_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  253. {
  254. //try
  255. //{
  256. // if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
  257. // {
  258. // return;
  259. // }
  260. // int goodsId = Convert.ToInt32(this.dgvGoods.Rows[e.RowIndex].Cells["GoodsID"].Value);
  261. // int logoid = Convert.ToInt32(this.dgvGoodsSap.Rows[e.RowIndex].Cells["logoid"].Value);
  262. // F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Edit, goodsId,logoid,);
  263. // DialogResult dialogresult = frmMST1013.ShowDialog();
  264. // if (dialogresult.Equals(DialogResult.OK))
  265. // {
  266. // this.dgvGoods.DataSource = null;
  267. // object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  268. // if (obGoodsResult != null)
  269. // {
  270. // DataSet dsGoods = (DataSet)obGoodsResult;
  271. // if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  272. // {
  273. // this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  274. // this.dgvGoods.ReadOnly = true;
  275. // }
  276. // }
  277. // }
  278. //}
  279. //catch (Exception ex)
  280. //{
  281. // // 对异常进行共通处理
  282. // ExceptionManager.HandleEventException(this.ToString(),
  283. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  284. //}
  285. }
  286. #endregion
  287. #region 私有方法
  288. /// <summary>
  289. /// 根据查询条件获取数据集合
  290. /// </summary>
  291. public DataSet getGoods()
  292. {
  293. try
  294. {
  295. GoodsEntity goods = new GoodsEntity();
  296. goods.GoodsCode = this.txtGoodsCode.Text;
  297. goods.GoodsModel = this.txtGoodsModel.Text;
  298. goods.GoodsName = this.txtGoodsName.Text;
  299. goods.GoodsSpecification = this.txtGoodsSpecification.Text;
  300. goods.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  301. //判断选择框,如有选择则赋值
  302. object[] objListCease = chkCeaseFlag.SelectedValues;
  303. if (objListCease.Length == Constant.INT_IS_ONE)
  304. {
  305. goods.CeaseFlag = (int)objListCease[Constant.INT_IS_ZERO];
  306. }
  307. else if (objListCease.Length == Constant.INT_IS_ZERO)
  308. {
  309. return null;
  310. }
  311. object[] objListValue = chkValueFlag.SelectedValues;
  312. if (objListValue.Length == Constant.INT_IS_ONE)
  313. {
  314. goods.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
  315. }
  316. else if (objListValue.Length == Constant.INT_IS_ZERO)
  317. {
  318. return null;
  319. }
  320. return SystemModuleProxy.Service.SerachGoods(goods);
  321. }
  322. catch (Exception ex)
  323. {
  324. throw ex;
  325. }
  326. }
  327. #endregion
  328. private void dgvGoods_SelectionChanged(object sender, EventArgs e)
  329. {
  330. this.dgvAccessories.DataSource = null;
  331. this.dgvGoodsSap.DataSource = null;
  332. if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
  333. {
  334. this.dgvGoodsSap.DataSource = null;
  335. this.dgvAccessories.DataSource = null;
  336. return;
  337. }
  338. try
  339. {
  340. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  341. ClientRequestEntity cre = new ClientRequestEntity();
  342. cre.NameSpace = "GoodsLogo";
  343. cre.Name = "GetGoodsLogo";
  344. cre.Request = goodsid;
  345. // 调用服务器端获取数据集
  346. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  347. if (sre != null && sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  348. {
  349. this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
  350. }
  351. else
  352. {
  353. this.tsbtnEdit.Enabled = false;
  354. }
  355. }
  356. catch (Exception ex)
  357. {
  358. // 对异常进行共通处理
  359. ExceptionManager.HandleEventException(this.ToString(),
  360. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  361. }
  362. }
  363. private void dgvGoodsSap_SelectionChanged(object sender, EventArgs e)
  364. {
  365. if (this.dgvGoodsSap.DataSource == null || this.dgvGoodsSap.CurrentRow == null)
  366. {
  367. this.dgvAccessories.DataSource = null;
  368. return;
  369. }
  370. try
  371. {
  372. if (this.dgvGoods.DataSource != null&&this.dgvGoods.CurrentRow != null)
  373. {
  374. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  375. int logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
  376. ClientRequestEntity cre = new ClientRequestEntity();
  377. cre.NameSpace = "GoodsLogo";
  378. cre.Name = "GetAccessories";
  379. DataSet ds = new DataSet();
  380. DataTable tb = new DataTable();
  381. tb.Columns.Add("GoodsID");
  382. tb.Columns.Add("logoid");
  383. DataRow dr = tb.NewRow();
  384. dr["GoodsID"] = goodsid;
  385. dr["logoid"] = logoid;
  386. tb.Rows.Add(dr);
  387. ds.Tables.Add(tb);
  388. cre.Data = ds;
  389. // 调用服务器端获取数据集
  390. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  391. if (sre.Data.Tables[0].Rows.Count > 0)
  392. {
  393. this.tsbtnEdit.Enabled = true;
  394. this.dgvAccessories.DataSource = sre.Data.Tables[0];
  395. }
  396. else
  397. {
  398. this.tsbtnEdit.Enabled = false;
  399. //定义表格结构
  400. DataTable tb2 = new DataTable();
  401. tb2.Columns.Add("ACCESSORIESCODE");
  402. tb2.Columns.Add("ACCESSORIESNAME");
  403. tb2.Columns.Add("DICTIONARYVALUE");
  404. this.dgvAccessories.DataSource = tb2;
  405. }
  406. }
  407. }
  408. catch (Exception ex)
  409. {
  410. // 对异常进行共通处理
  411. ExceptionManager.HandleEventException(this.ToString(),
  412. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  413. }
  414. }
  415. //保存
  416. private void btnSave_Click(object sender, EventArgs e)
  417. {
  418. try
  419. {
  420. ((DataTable)this.dgvAccessories.DataSource).AcceptChanges();
  421. //信息必填
  422. foreach (DataGridViewRow gvrAcc in this.dgvAccessories.Rows)
  423. {
  424. if (gvrAcc.IsNewRow != true)
  425. {
  426. if (gvrAcc.Cells["DICTIONARYVALUE"].Value == null || gvrAcc.Cells["DICTIONARYVALUE"].Value == DBNull.Value)
  427. {
  428. MessageBox.Show("请选择辅件种类!",
  429. this.Text,
  430. MessageBoxButtons.OK,
  431. MessageBoxIcon.Information,
  432. MessageBoxDefaultButton.Button1);
  433. return;
  434. }
  435. if (gvrAcc.Cells["ACCESSORIESCODE"].Value == null || gvrAcc.Cells["ACCESSORIESCODE"].Value == DBNull.Value)
  436. {
  437. MessageBox.Show("请选择辅件编码!",
  438. this.Text,
  439. MessageBoxButtons.OK,
  440. MessageBoxIcon.Information,
  441. MessageBoxDefaultButton.Button1);
  442. return;
  443. }
  444. }
  445. }
  446. this.dgvAccessories.CurrentRow.ErrorText = string.Empty;
  447. DataTable dtAcc = (DataTable)this.dgvAccessories.DataSource;
  448. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  449. int logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
  450. ClientRequestEntity cre = new ClientRequestEntity();
  451. cre.NameSpace = "EditGoods";
  452. cre.Name = "EditGoodsLogo";
  453. DataSet ds = new DataSet();
  454. DataTable tb = new DataTable();
  455. tb.Columns.Add("GoodsID");
  456. tb.Columns.Add("logoid");
  457. DataRow dr1 = tb.NewRow();
  458. dr1["GoodsID"] = goodsid;
  459. dr1["logoid"] = logoid;
  460. tb.Rows.Add(dr1);
  461. ds.Tables.Add(dtAcc.Copy());
  462. ds.Tables.Add(tb.Copy());
  463. cre.Data = ds;
  464. // 调用服务器端获取数据集
  465. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  466. if (sre.OtherStatus != 0 && sre.OtherStatus > 0)
  467. {
  468. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "辅件", "保存"),
  469. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  470. this.DialogResult = DialogResult.OK;
  471. }
  472. }
  473. catch (Exception ex)
  474. {
  475. // 对异常进行共通处理
  476. ExceptionManager.HandleEventException(this.ToString(),
  477. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  478. }
  479. }
  480. }
  481. }