F_PC_0101_1_8.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_0101_1_8.cs
  5. * 2.功能描述:配置商标
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 李士越 2024/12/10 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Windows.Forms;
  12. using System.Data;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using System.Linq;
  19. namespace Dongke.IBOSS.PRD.Client.PCModule
  20. {
  21. public partial class F_PC_0101_1_8 : DKFormBase
  22. {
  23. #region 成员变量
  24. // 实例窗体
  25. //private F_PC_0101 _fpc0101;
  26. private DataTable _dtBindSource = null;
  27. //模具状态
  28. private int _GMouldStatus = 0;
  29. #endregion
  30. #region 构造函数
  31. public F_PC_0101_1_8(DataTable dtBindSource, int GMouldStatus)
  32. {
  33. InitializeComponent();
  34. _dtBindSource = dtBindSource;
  35. this.Text = "模具管理-配置商标";
  36. this._GMouldStatus = GMouldStatus;
  37. this.btnSave.Text = ButtonText.BTN_SAVE;
  38. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  39. if (GMouldStatus != 6)
  40. {
  41. this.txtGroutingLineCode.Text = dtBindSource.Rows[0]["GroutingLineCode"].ToString();
  42. }
  43. if (GMouldStatus == 0 || GMouldStatus == 1)
  44. {
  45. this.dgvGroutingLineDetail.AllowUserToDeleteRows = true;
  46. }
  47. }
  48. public int GroutingLineID
  49. {
  50. get;
  51. set;
  52. }
  53. public string GroutingLineCode
  54. {
  55. get
  56. {
  57. return this.txtGroutingLineCode.Text;
  58. }
  59. set
  60. {
  61. this.txtGroutingLineCode.Text = value;
  62. }
  63. }
  64. public DateTime LineOPTimeStamp
  65. {
  66. get;
  67. set;
  68. }
  69. #endregion
  70. #region 事件
  71. /// <summary>
  72. /// 保存按钮事件
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void btnSave_Click(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. DataTable dtName = this.dgvGroutingLineDetail.DataSource as DataTable;
  81. dtName.AcceptChanges();
  82. if (dtName.Rows.Count == 0)
  83. {
  84. MessageBox.Show("没有选择任何数据", this.Text,
  85. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  86. return;
  87. }
  88. string respone = "[";
  89. for (int i = 0; i < dtName.Rows.Count; i++)
  90. {
  91. respone += $"{{\"GROUTINGLINEDETAILID\":\"{dtName.Rows[i]["GROUTINGLINEDETAILID"]}\"," +
  92. $"\"LOGOID\":\"{dtName.Rows[i]["LOGOID"]}\"," +
  93. $"\"GOODSID\":\"{dtName.Rows[i]["GOODSID"]}\"}}";
  94. // 如果不是最后一个元素,则添加逗号
  95. if (i < dtName.Rows.Count - 1)
  96. {
  97. respone += ",";
  98. }
  99. }
  100. respone += "]";
  101. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  102. {
  103. ClientRequestEntity cre = new ClientRequestEntity();
  104. cre.NameSpace = "F_PC_0101_1_8";
  105. cre.Name = "UpDataTrademark";
  106. cre.Properties["Respone"] = respone;
  107. return SystemModuleProxy.Service.DoRequest(cre);
  108. });
  109. if (sre.Status== Constant.ServiceResultStatus.Success)
  110. {
  111. MessageBox.Show("商标配置成功", this.Text, MessageBoxButtons.OK);
  112. }
  113. else
  114. {
  115. MessageBox.Show("商标配置失败", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  116. }
  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 F_PC_0101_1_8_Load(object sender, EventArgs e)
  131. {
  132. try
  133. {
  134. this.dgvGroutingLineDetail.AutoGenerateColumns = false;
  135. DateTime accountDate = CommonModuleProxy.Service.GetAccountDate();
  136. this.txtDateStart.Value = accountDate;
  137. this.Trademark.DataSource = ReadTrademark();
  138. this.Trademark.ValueMember = "LOGOID";
  139. this.Trademark.DisplayMember = "LOGO";
  140. _dtBindSource.Columns.Add("Trademark", typeof(decimal));
  141. this.dgvGroutingLineDetail.DataSource = _dtBindSource;
  142. // 设置可输入单元格的颜色
  143. this.dgvGroutingLineDetail.IsSetInputColumnsColor = true;
  144. if (this._GMouldStatus == 4 || this._GMouldStatus == 5 || this._GMouldStatus == 6 || this._GMouldStatus == 7)
  145. {
  146. DataRow[] dr = _dtBindSource.Select("MouldID is not null");
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. // 对异常进行共通处理
  152. ExceptionManager.HandleEventException(this.ToString(),
  153. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  154. }
  155. }
  156. /// <summary>
  157. /// 关闭按钮事件
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. private void btnCancel_Click(object sender, EventArgs e)
  162. {
  163. this.Close();
  164. }
  165. /// <summary>
  166. /// 自适应
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. private void btnAdaptive_Click(object sender, EventArgs e)
  171. {
  172. this.dgvGroutingLineDetail.AutoResizeColumns();
  173. }
  174. #endregion
  175. #region 私有方法
  176. /// <summary>
  177. /// 获取商标
  178. /// </summary>
  179. /// <returns></returns>
  180. public DataTable ReadTrademark() {
  181. DataTable result = new DataTable();
  182. try
  183. {
  184. DataTable dt = _dtBindSource;
  185. var distinctGoodsIds = dt.AsEnumerable()
  186. .Select(row => row.Field<decimal>("GoodsID"))
  187. .Distinct()
  188. .Select(id => id.ToString());
  189. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  190. {
  191. ClientRequestEntity cre = new ClientRequestEntity();
  192. cre.NameSpace = "F_PC_0101_1_8";
  193. cre.Name = "ReadTrademark";
  194. cre.Properties["goodsid"]= string.Join(",", distinctGoodsIds);
  195. return SystemModuleProxy.Service.DoRequest(cre);
  196. });
  197. if (sre.Data.Tables[0].Rows.Count!=0)
  198. {
  199. result = sre.Data.Tables[0];
  200. }
  201. }
  202. catch
  203. {
  204. }
  205. return result;
  206. }
  207. #endregion
  208. }
  209. }