| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_0101_1_8.cs
- * 2.功能描述:配置商标
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 李士越 2024/12/10 1.00 新建
- *******************************************************************************/
- using System;
- using System.Windows.Forms;
- using System.Data;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.Client.Controls;
- using System.Linq;
- namespace Dongke.IBOSS.PRD.Client.PCModule
- {
- public partial class F_PC_0101_1_8 : DKFormBase
- {
- #region 成员变量
- // 实例窗体
- //private F_PC_0101 _fpc0101;
- private DataTable _dtBindSource = null;
- //模具状态
- private int _GMouldStatus = 0;
- #endregion
- #region 构造函数
- public F_PC_0101_1_8(DataTable dtBindSource, int GMouldStatus)
- {
- InitializeComponent();
- _dtBindSource = dtBindSource;
- this.Text = "模具管理-配置商标";
- this._GMouldStatus = GMouldStatus;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- if (GMouldStatus != 6)
- {
- this.txtGroutingLineCode.Text = dtBindSource.Rows[0]["GroutingLineCode"].ToString();
- }
- if (GMouldStatus == 0 || GMouldStatus == 1)
- {
- this.dgvGroutingLineDetail.AllowUserToDeleteRows = true;
- }
- }
- public int GroutingLineID
- {
- get;
- set;
- }
- public string GroutingLineCode
- {
- get
- {
- return this.txtGroutingLineCode.Text;
- }
- set
- {
- this.txtGroutingLineCode.Text = value;
- }
- }
- public DateTime LineOPTimeStamp
- {
- get;
- set;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- DataTable dtName = this.dgvGroutingLineDetail.DataSource as DataTable;
- dtName.AcceptChanges();
- if (dtName.Rows.Count == 0)
- {
- MessageBox.Show("没有选择任何数据", this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string respone = "[";
- for (int i = 0; i < dtName.Rows.Count; i++)
- {
-
- respone += $"{{\"GROUTINGLINEDETAILID\":\"{dtName.Rows[i]["GROUTINGLINEDETAILID"]}\"," +
- $"\"LOGOID\":\"{dtName.Rows[i]["LOGOID"]}\"," +
- $"\"GOODSID\":\"{dtName.Rows[i]["GOODSID"]}\"}}";
- // 如果不是最后一个元素,则添加逗号
- if (i < dtName.Rows.Count - 1)
- {
- respone += ",";
- }
- }
- respone += "]";
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PC_0101_1_8";
- cre.Name = "UpDataTrademark";
- cre.Properties["Respone"] = respone;
- return SystemModuleProxy.Service.DoRequest(cre);
- });
- if (sre.Status== Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show("商标配置成功", this.Text, MessageBoxButtons.OK);
- }
- else
- {
- MessageBox.Show("商标配置失败", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0101_1_8_Load(object sender, EventArgs e)
- {
- try
- {
- this.dgvGroutingLineDetail.AutoGenerateColumns = false;
- DateTime accountDate = CommonModuleProxy.Service.GetAccountDate();
- this.txtDateStart.Value = accountDate;
- this.Trademark.DataSource = ReadTrademark();
- this.Trademark.ValueMember = "LOGOID";
- this.Trademark.DisplayMember = "LOGO";
- _dtBindSource.Columns.Add("Trademark", typeof(decimal));
- this.dgvGroutingLineDetail.DataSource = _dtBindSource;
- // 设置可输入单元格的颜色
- this.dgvGroutingLineDetail.IsSetInputColumnsColor = true;
- if (this._GMouldStatus == 4 || this._GMouldStatus == 5 || this._GMouldStatus == 6 || this._GMouldStatus == 7)
- {
- DataRow[] dr = _dtBindSource.Select("MouldID is not null");
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自适应
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvGroutingLineDetail.AutoResizeColumns();
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 获取商标
- /// </summary>
- /// <returns></returns>
- public DataTable ReadTrademark() {
- DataTable result = new DataTable();
- try
- {
- DataTable dt = _dtBindSource;
- var distinctGoodsIds = dt.AsEnumerable()
- .Select(row => row.Field<decimal>("GoodsID"))
- .Distinct()
- .Select(id => id.ToString());
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PC_0101_1_8";
- cre.Name = "ReadTrademark";
- cre.Properties["goodsid"]= string.Join(",", distinctGoodsIds);
- return SystemModuleProxy.Service.DoRequest(cre);
- });
- if (sre.Data.Tables[0].Rows.Count!=0)
- {
- result = sre.Data.Tables[0];
- }
- }
- catch
- {
- }
- return result;
- }
-
- #endregion
- }
- }
|