/*******************************************************************************
* 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 事件
///
/// 保存按钮事件
///
///
///
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(() =>
{
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);
}
}
///
/// 窗体加载事件
///
///
///
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);
}
}
///
/// 关闭按钮事件
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 自适应
///
///
///
private void btnAdaptive_Click(object sender, EventArgs e)
{
this.dgvGroutingLineDetail.AutoResizeColumns();
}
#endregion
#region 私有方法
///
/// 获取商标
///
///
public DataTable ReadTrademark() {
DataTable result = new DataTable();
try
{
DataTable dt = _dtBindSource;
var distinctGoodsIds = dt.AsEnumerable()
.Select(row => row.Field("GoodsID"))
.Distinct()
.Select(id => id.ToString());
ServiceResultEntity sre = DoAsync(() =>
{
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
}
}