F_MST_GoodsImage.cs 9.4 KB

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