geboshi_V1/LeatherProject/LeatherApp/Page/AddErpFrm.cs

112 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DocumentFormat.OpenXml.EMMA;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LeatherApp.Page
{
public partial class AddErpFrm : UIEditForm
{
private Service.ProductService service = new Service.ProductService();
string _ErpID;
string[] Material = new string[6];
public AddErpFrm(string erpID)
{
InitializeComponent();
_ErpID = erpID;
FrmInit();
}
private void FrmInit()
{
tbERPID.Text = _ErpID;
Material[0] = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 0).Value<string>("name");
Material[1] = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 1).Value<string>("name");
Material[2] = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 2).Value<string>("name");
Material[3] = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 3).Value<string>("name");
Material[4] = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 4).Value<string>("name");
Material[5] = Config.materialNameList.FirstOrDefault(x => x.Value<int>("code") == 5).Value<string>("name");
var lstColor = Config.colorNameList.Select(x => new { code = x.Value<int>("code"), name = x.Value<string>("name") }).ToList();
var modellist = service.GetListNav();
foreach (var model in modellist)
{
string pdtName = "";
if (model.Material == "0")
pdtName += Material[0];
else if (model.Material == "1")
pdtName += Material[1];
else if (model.Material == "2")
pdtName += Material[2];
else if (model.Material == "3")
pdtName += Material[3];
else if (model.Material == "4")
pdtName += Material[4];
else if (model.Material == "5")
pdtName += Material[5];
else
pdtName += "错误材质";
var tp = lstColor.Find(x => x.code == model.Color);
if (tp != null)
pdtName += "_" + tp.name;
else
pdtName += "_无效颜色";
cbPdtList.Items.Add(pdtName);
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
try
{
var temp = cbPdtList.Text.Split('_');
string MaterialID = "";
if (temp[0] == Material[0])
MaterialID = "0";
else if (temp[0] == Material[1])
MaterialID = "1";
else if (temp[0] == Material[2])
MaterialID = "2";
else if (temp[0] == Material[3])
MaterialID = "3";
else if (temp[0] == Material[4])
MaterialID = "4";
else if (temp[0] == Material[5])
MaterialID = "5";
var lstColor = Config.colorNameList.Select(x => new { code = x.Value<int>("code"), name = x.Value<string>("name") }).ToList();
int colorID = lstColor.Find(x => x.name == temp[1]).code;
var modellist = service.GetListNav();
var model = modellist.Find(x => (x.Material == MaterialID && x.Color == colorID));
if (string.IsNullOrEmpty(model.Spec))
model.Spec += _ErpID;
else
model.Spec += $",{_ErpID}";
if(service.UpdateNav(model))
UIMessageTip.ShowOk($"Erp信息绑定成功", 2000);
else
UIMessageTip.ShowOk($"Erp信息绑定失败请重新保存检测标准", 2000);
}
catch (Exception ex)
{
UIMessageTip.ShowError($"Erp信息绑定失败:{ex.Message}", 2000);
}
}
}
}