F_MST_GoodsImage.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_GoodsImage.cs
  5. * 2.功能描述:产品线性图
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 冯林勇 2024-04-15 1.00 一览
  9. *******************************************************************************/
  10. using Dongke.IBOSS.PRD.Basics.BaseResources;
  11. using Dongke.IBOSS.PRD.Client.CommonModule;
  12. using Dongke.IBOSS.PRD.WCF.DataModels;
  13. using Dongke.IBOSS.PRD.WCF.Proxys;
  14. using Dongke.WinForm.Controls;
  15. using System;
  16. using System.Reflection;
  17. using System.Windows.Forms;
  18. namespace Dongke.IBOSS.PRD.Client.Controls
  19. {
  20. public partial class F_MST_GoodsImage : DKDockPanelBase
  21. {
  22. #region 静态变量
  23. #endregion
  24. #region 成员变量
  25. // 窗体单例模式
  26. private static F_MST_GoodsImage _instance = null;
  27. private string _materialcode = null;
  28. #endregion
  29. #region 构造函数
  30. public F_MST_GoodsImage()
  31. {
  32. InitializeComponent();
  33. // 工具栏按钮文本赋值
  34. this.tsbtnAddInvoice.Text = ButtonText.TSBTN_ADD;
  35. this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE;
  36. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  37. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  38. // 查询、清空条件按钮文本赋值
  39. this.tsbtnSearch.Text = ButtonText.BTN_SEARCH;
  40. this.tsbtnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  41. // 设置表格不自动创建列
  42. this.dgvGoodsImage.AutoGenerateColumns = false;
  43. // 删除
  44. this.tsbtnDelete.Enabled = false;
  45. }
  46. #endregion
  47. #region 单例模式
  48. /// <summary>
  49. /// 单例模式,防止重复创建窗体
  50. /// </summary>
  51. public static F_MST_GoodsImage Instance
  52. {
  53. get
  54. {
  55. if (_instance == null)
  56. {
  57. _instance = new F_MST_GoodsImage();
  58. }
  59. return _instance;
  60. }
  61. }
  62. #endregion
  63. #region 控件事件
  64. /// <summary>
  65. /// 画面打开
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void F_MST_GoodsImage_Load(object sender, EventArgs e)
  70. {
  71. try
  72. {
  73. }
  74. catch (Exception ex)
  75. {
  76. // 对异常进行共通处理
  77. ExceptionManager.HandleEventException(this.ToString(),
  78. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  79. }
  80. }
  81. /// <summary>
  82. /// 画面关闭
  83. /// </summary>
  84. /// <param name="sender"></param>
  85. /// <param name="e"></param>
  86. private void F_MST_GoodsImage_FormClosed(object sender, FormClosedEventArgs e)
  87. {
  88. _instance = null;
  89. }
  90. /// <summary>
  91. /// 查询
  92. /// </summary>
  93. /// <param name="sender"></param>
  94. /// <param name="e"></param>
  95. private void tsbtnSearch_Click(object sender, EventArgs e)
  96. {
  97. try
  98. {
  99. this.QueryDataFromOther();
  100. }
  101. catch (Exception ex)
  102. {
  103. // 对异常进行共通处理
  104. ExceptionManager.HandleEventException(this.ToString(),
  105. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  106. }
  107. }
  108. /// <summary>
  109. /// 清空查询条件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  114. {
  115. try
  116. {
  117. this.txtMATNR.Text = "";
  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. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void tsbtnAddInvoice_Click(object sender, System.EventArgs e)
  132. {
  133. try
  134. {
  135. F_MST_GoodsImageAdd frmGoodAdd = new F_MST_GoodsImageAdd(String.Empty, String.Empty);
  136. DialogResult dialogresult = frmGoodAdd.ShowDialog();
  137. if (DialogResult.OK == dialogresult)
  138. {
  139. QueryDataFromOther();
  140. }
  141. }
  142. catch (Exception ex)
  143. {
  144. // 对异常进行共通处理
  145. ExceptionManager.HandleEventException(this.ToString(),
  146. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  147. }
  148. }
  149. #region 编辑(目前不考虑,删除重新上传)
  150. /// <summary>
  151. /// 点击编辑按钮,编辑现有票据基本信息
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. private void tsbtnEdit_Click(object sender, EventArgs e)
  156. {
  157. try
  158. {
  159. // 获取活动行
  160. DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
  161. string winStatus = "Edit";
  162. string matnr = currentRow.Cells["MATERIALCODE"].Value.ToString();
  163. F_MST_GoodsImageAdd frmGoodAdd = new F_MST_GoodsImageAdd(winStatus, matnr);
  164. DialogResult dialogresult = frmGoodAdd.ShowDialog();
  165. if (DialogResult.OK == dialogresult)
  166. {
  167. QueryDataFromOther();
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. // 对异常进行共通处理
  173. ExceptionManager.HandleEventException(this.ToString(),
  174. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  175. }
  176. }
  177. #endregion
  178. #region 预览后期添加 本期预留
  179. /// <summary>
  180. /// 预览票据按钮按下
  181. /// </summary>
  182. /// <param name="sender"></param>
  183. /// <param name="e"></param>
  184. private void tsbtnPreviewInvoice_Click(object sender, EventArgs e)
  185. {
  186. try
  187. {
  188. //// 获取活动行
  189. //DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
  190. //if (currentRow != null)
  191. //{
  192. // // 给票据预览画面赋值,并打开
  193. // F_MST_012005 frm012005 = new F_MST_012005();
  194. // frm012005.LayoutID = Convert.ToInt32(currentRow.Cells["InvoiceLayoutID"].Value);
  195. // frm012005.ShowDialog();
  196. //}
  197. }
  198. catch (Exception ex)
  199. {
  200. // 对异常进行共通处理
  201. ExceptionManager.HandleEventException(this.ToString(),
  202. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  203. }
  204. }
  205. #endregion
  206. /// <summary>
  207. /// 点击删除按钮
  208. /// </summary>
  209. /// <param name="sender"></param>
  210. /// <param name="e"></param>
  211. private void tsbtnDelete_Click(object sender, EventArgs e)
  212. {
  213. try
  214. {
  215. // 获取活动行
  216. DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
  217. if (currentRow != null)
  218. {
  219. DialogResult dr = MessageBox.Show("是否删除当前选择数据。", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  220. if (dr != System.Windows.Forms.DialogResult.Yes)
  221. {
  222. return;
  223. }
  224. string materialcode = currentRow.Cells["materialcode"].Value.ToString();
  225. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  226. {
  227. ClientRequestEntity cre = new ClientRequestEntity();
  228. cre.NameSpace = "F_MST_GoodsImage";
  229. cre.Name = "DeleteGoodsImage";
  230. cre.Properties["MATERIALCODE"] = materialcode;
  231. return SystemModuleProxy.Service.DoRequest(cre);
  232. });
  233. if (sre.Status == Constant.ServiceResultStatus.Success)
  234. {
  235. MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "产品线性图", "删除"),
  236. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  237. QueryDataFromOther();
  238. }
  239. }
  240. else
  241. {
  242. MessageBox.Show("没有选择任何数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  243. }
  244. }
  245. catch (Exception ex)
  246. {
  247. // 对异常进行共通处理
  248. ExceptionManager.HandleEventException(this.ToString(),
  249. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  250. }
  251. }
  252. /// <summary>
  253. /// 单击自适应列宽,将所有的列宽都自动去适应内容
  254. /// </summary>
  255. /// <param name="sender"></param>
  256. /// <param name="e"></param>
  257. private void tsbtnAdaptive_Click(object sender, System.EventArgs e)
  258. {
  259. this.dgvGoodsImage.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  260. }
  261. /// <summary>
  262. /// 关闭页面
  263. /// </summary>
  264. /// <param name="sender"></param>
  265. /// <param name="e"></param>
  266. private void tsbtnClose_Click(object sender, EventArgs e)
  267. {
  268. this.Close();
  269. }
  270. /// <summary>
  271. /// 所选数据发生改变时
  272. /// </summary>
  273. /// <param name="sender"></param>
  274. /// <param name="e"></param>
  275. private void dgvInvoice_SelectionChanged(object sender, EventArgs e)
  276. {
  277. try
  278. {
  279. if (this.dgvGoodsImage.CurrentCell == null
  280. || this.dgvGoodsImage.SelectedRows.Count == 0)
  281. {
  282. this.tsbtnDelete.Enabled = false;
  283. }
  284. else
  285. {
  286. this.tsbtnDelete.Enabled = true;
  287. }
  288. }
  289. catch (Exception ex)
  290. {
  291. // 对异常进行共通处理
  292. ExceptionManager.HandleEventException(this.ToString(),
  293. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  294. }
  295. }
  296. /// <summary>
  297. /// 双击查看
  298. /// </summary>
  299. /// <param name="sender"></param>
  300. /// <param name="e"></param>
  301. private void dgvGoodsImage_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  302. {
  303. try
  304. {
  305. // 获取活动行
  306. DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
  307. if (currentRow != null)
  308. {
  309. this._materialcode = currentRow.Cells["MATERIALCODE"].Value.ToString();
  310. F_MST_GoodsImageAdd frmGoodAdd = new F_MST_GoodsImageAdd("Edit", _materialcode);
  311. DialogResult dialogresult = frmGoodAdd.ShowDialog();
  312. if (DialogResult.OK == dialogresult)
  313. {
  314. QueryDataFromOther();
  315. }
  316. }
  317. }
  318. catch (Exception ex)
  319. {
  320. // 对异常进行共通处理
  321. ExceptionManager.HandleEventException(this.ToString(),
  322. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  323. }
  324. }
  325. #endregion
  326. #region 重写方法
  327. /// <summary>
  328. /// 查询数据
  329. /// </summary>
  330. /// <returns>验证通过true,其他false</returns>
  331. private void QueryDataFromOther()
  332. {
  333. try
  334. {
  335. this.dgvGoodsImage.DataSource = null;
  336. ClientRequestEntity cre = new ClientRequestEntity();
  337. cre.NameSpace = "F_MST_GoodsImage";
  338. cre.Name = "getGoodsImage";
  339. cre.Properties["MATNR"] = this.txtMATNR.TextValue;
  340. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  341. {
  342. return SystemModuleProxy.Service.DoRequest(cre);
  343. });
  344. if (sre.Status == Constant.ServiceResultStatus.Success)
  345. {
  346. // 查询成功
  347. this.dgvGoodsImage.DataSource = sre.Data.Tables[0];
  348. if (sre.Data.Tables[0].Rows.Count > 0)
  349. {
  350. this.dgvGoodsImage.Rows[0].Selected = true;
  351. }
  352. }
  353. }
  354. catch (Exception ex)
  355. {
  356. throw ex;
  357. }
  358. }
  359. #endregion
  360. #region 私有方法
  361. #endregion
  362. }
  363. }