F_MST_1003.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. catch (Exception ex)
  75. {
  76. // 对异常进行共通处理
  77. ExceptionManager.HandleEventException(this.ToString(),
  78. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  79. }
  80. }
  81. /// <summary>
  82. /// 获取数据事件
  83. /// </summary>
  84. private void btnSearch_Click(object sender, EventArgs e)
  85. {
  86. try
  87. {
  88. this.dgvGoods.DataSource = null;
  89. this.dgvGoodsSap.DataSource = null;
  90. this.dgvAccessories.DataSource = null;
  91. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  92. if (obGoodsResult != null)
  93. {
  94. DataSet dsGoods = (DataSet)obGoodsResult;
  95. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  96. {
  97. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  98. this.dgvGoods.ReadOnly = true;
  99. this.dgvGoodsSap.ReadOnly = true;
  100. if (this.dgvGoods.Rows.Count == Constant.INT_IS_ZERO)
  101. {
  102. // 提示未查找到数据
  103. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  104. MessageBoxButtons.OK, MessageBoxIcon.Information);
  105. }
  106. }
  107. }
  108. else
  109. {
  110. // 提示未查找到数据
  111. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  112. MessageBoxButtons.OK, MessageBoxIcon.Information);
  113. }
  114. }
  115. catch (Exception ex)
  116. {
  117. // 对异常进行共通处理
  118. ExceptionManager.HandleEventException(this.ToString(),
  119. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  120. }
  121. }
  122. /// <summary>
  123. /// 清空事件
  124. /// </summary>
  125. private void btnClearCondition_Click(object sender, EventArgs e)
  126. {
  127. this.txtGoodsCode.Text = "";
  128. this.txtGoodsModel.Text = "";
  129. this.txtGoodsName.Text = "";
  130. this.txtGoodsSpecification.Text = "";
  131. this.scbGoodsType.ClearValue();
  132. this.chkCeaseFlag.AllItemCheck();
  133. this.chkValueFlag.AllItemCheck();
  134. }
  135. /// <summary>
  136. /// 关闭窗体事件
  137. /// </summary>
  138. private void tsbtnClose_Click(object sender, EventArgs e)
  139. {
  140. this.Close();
  141. }
  142. /// <summary>
  143. /// 自适应事件
  144. /// </summary>
  145. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  146. {
  147. this.dgvGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  148. dgvGoodsSap.AutoResizeColumns();
  149. dgvAccessories.AutoResizeColumns();
  150. }
  151. /// <summary>
  152. /// 窗体关闭事件
  153. /// </summary>
  154. private void F_MST_0501_FormClosed(object sender, FormClosedEventArgs e)
  155. {
  156. _instance = null;
  157. }
  158. /// <summary>
  159. /// 添加产品事件
  160. /// </summary>
  161. private void tsbtnAddGoods_Click(object sender, EventArgs e)
  162. {
  163. try
  164. {
  165. F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Add, Constant.INT_IS_ZERO, Constant.INT_IS_ZERO);
  166. DialogResult dialogresult = frmMST1013.ShowDialog();
  167. if (dialogresult.Equals(DialogResult.OK))
  168. {
  169. this.dgvGoods.DataSource = null;
  170. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  171. if (obGoodsResult != null)
  172. {
  173. DataSet dsGoods = (DataSet)obGoodsResult;
  174. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  175. {
  176. this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  177. this.dgvGoods.ReadOnly = true;
  178. }
  179. }
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. // 对异常进行共通处理
  185. ExceptionManager.HandleEventException(this.ToString(),
  186. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  187. }
  188. }
  189. /// <summary>
  190. /// 编辑产品事件
  191. /// </summary>
  192. private void tsbtnEditGoods_Click(object sender, EventArgs e)
  193. {
  194. try
  195. {
  196. DataGridViewRow currentRow = this.dgvGoods.CurrentRow;
  197. if (currentRow != null)
  198. {
  199. int goodsId = 0;
  200. int logoid = 0;
  201. if (((System.Data.DataTable)this.dgvGoods.DataSource).DefaultView.Count < 1 || ((System.Data.DataTable)this.dgvGoodsSap.DataSource).DefaultView.Count < 1)
  202. {
  203. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  204. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  205. return;
  206. }
  207. else
  208. {
  209. goodsId = Convert.ToInt32(currentRow.Cells["GoodsID"].Value);
  210. logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
  211. }
  212. DataGridViewRow currentRow1 = this.dgvAccessories.CurrentRow;
  213. int Accessorestypeid = Convert.ToInt32(currentRow1.Cells["ACCESSORIESTYPEID"].Value);
  214. string Accessorestypecode = currentRow1.Cells["ACCESSORIESCODE"].Value.ToString();
  215. string Accessorestypename = currentRow1.Cells["DICTIONARYVALUE"].Value.ToString();
  216. F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Edit, goodsId,logoid);
  217. DialogResult dialogresult = frmMST1013.ShowDialog();
  218. if (dialogresult.Equals(DialogResult.OK))
  219. {
  220. this.dgvGoods.DataSource = null;
  221. btnSearch_Click(sender,e);
  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. // int logoid = Convert.ToInt32(this.dgvGoodsSap.Rows[e.RowIndex].Cells["logoid"].Value);
  250. // F_MST_1013 frmMST1013 = new F_MST_1013(Constant.FormMode.Edit, goodsId,logoid,);
  251. // DialogResult dialogresult = frmMST1013.ShowDialog();
  252. // if (dialogresult.Equals(DialogResult.OK))
  253. // {
  254. // this.dgvGoods.DataSource = null;
  255. // object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(getGoods));
  256. // if (obGoodsResult != null)
  257. // {
  258. // DataSet dsGoods = (DataSet)obGoodsResult;
  259. // if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  260. // {
  261. // this.dgvGoods.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  262. // this.dgvGoods.ReadOnly = true;
  263. // }
  264. // }
  265. // }
  266. //}
  267. //catch (Exception ex)
  268. //{
  269. // // 对异常进行共通处理
  270. // ExceptionManager.HandleEventException(this.ToString(),
  271. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  272. //}
  273. }
  274. #endregion
  275. #region 私有方法
  276. /// <summary>
  277. /// 根据查询条件获取数据集合
  278. /// </summary>
  279. public DataSet getGoods()
  280. {
  281. try
  282. {
  283. GoodsEntity goods = new GoodsEntity();
  284. goods.GoodsCode = this.txtGoodsCode.Text;
  285. goods.GoodsModel = this.txtGoodsModel.Text;
  286. goods.GoodsName = this.txtGoodsName.Text;
  287. goods.GoodsSpecification = this.txtGoodsSpecification.Text;
  288. goods.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  289. //判断选择框,如有选择则赋值
  290. object[] objListCease = chkCeaseFlag.SelectedValues;
  291. if (objListCease.Length == Constant.INT_IS_ONE)
  292. {
  293. goods.CeaseFlag = (int)objListCease[Constant.INT_IS_ZERO];
  294. }
  295. else if (objListCease.Length == Constant.INT_IS_ZERO)
  296. {
  297. return null;
  298. }
  299. object[] objListValue = chkValueFlag.SelectedValues;
  300. if (objListValue.Length == Constant.INT_IS_ONE)
  301. {
  302. goods.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
  303. }
  304. else if (objListValue.Length == Constant.INT_IS_ZERO)
  305. {
  306. return null;
  307. }
  308. return SystemModuleProxy.Service.SerachGoods(goods);
  309. }
  310. catch (Exception ex)
  311. {
  312. throw ex;
  313. }
  314. }
  315. #endregion
  316. private void dgvGoods_SelectionChanged(object sender, EventArgs e)
  317. {
  318. this.dgvAccessories.DataSource = null;
  319. if (this.dgvGoods.DataSource == null || this.dgvGoods.CurrentRow == null)
  320. {
  321. this.dgvGoodsSap.DataSource = null;
  322. this.dgvAccessories.DataSource = null;
  323. return;
  324. }
  325. try
  326. {
  327. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  328. ClientRequestEntity cre = new ClientRequestEntity();
  329. cre.NameSpace = "GoodsLogo";
  330. cre.Name = "GetGoodsLogo";
  331. cre.Request = goodsid;
  332. // 调用服务器端获取数据集
  333. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  334. if (sre != null && sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
  335. {
  336. this.dgvGoodsSap.DataSource = sre.Data.Tables[0];
  337. }
  338. else
  339. {
  340. this.tsbtnEdit.Enabled = false;
  341. }
  342. }
  343. catch (Exception ex)
  344. {
  345. // 对异常进行共通处理
  346. ExceptionManager.HandleEventException(this.ToString(),
  347. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  348. }
  349. }
  350. private void dgvGoodsSap_SelectionChanged(object sender, EventArgs e)
  351. {
  352. if (this.dgvGoodsSap.DataSource == null || this.dgvGoodsSap.CurrentRow == null)
  353. {
  354. this.dgvAccessories.DataSource = null;
  355. return;
  356. }
  357. try
  358. {
  359. if (this.dgvGoods.DataSource != null&&this.dgvGoods.CurrentRow != null)
  360. {
  361. int goodsid = Convert.ToInt32(this.dgvGoods.CurrentRow.Cells["GoodsID"].Value);
  362. int logoid = Convert.ToInt32(this.dgvGoodsSap.CurrentRow.Cells["logoid"].Value);
  363. ClientRequestEntity cre = new ClientRequestEntity();
  364. cre.NameSpace = "GoodsLogo";
  365. cre.Name = "GetAccessories";
  366. DataSet ds = new DataSet();
  367. DataTable tb = new DataTable();
  368. tb.Columns.Add("GoodsID");
  369. tb.Columns.Add("logoid");
  370. DataRow dr = tb.NewRow();
  371. dr["GoodsID"] = goodsid;
  372. dr["logoid"] = logoid;
  373. tb.Rows.Add(dr);
  374. ds.Tables.Add(tb);
  375. cre.Data = ds;
  376. // 调用服务器端获取数据集
  377. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  378. if (sre.Data.Tables[0].Rows.Count > 0)
  379. {
  380. this.tsbtnEdit.Enabled = true;
  381. this.dgvAccessories.DataSource = sre.Data.Tables[0];
  382. }
  383. else
  384. {
  385. this.tsbtnEdit.Enabled = false;
  386. }
  387. }
  388. }
  389. catch (Exception ex)
  390. {
  391. // 对异常进行共通处理
  392. ExceptionManager.HandleEventException(this.ToString(),
  393. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  394. }
  395. }
  396. }
  397. }