This commit is contained in:
admin
2020-12-18 16:35:46 +08:00
parent 600fd27b76
commit 9881320eda
5 changed files with 126 additions and 109 deletions

View File

@@ -35,6 +35,7 @@ namespace U8AppMain
this.kryptonDataGridView1 = new ComponentFactory.Krypton.Toolkit.KryptonDataGridView(); this.kryptonDataGridView1 = new ComponentFactory.Krypton.Toolkit.KryptonDataGridView();
this.BtnImportExcel = new System.Windows.Forms.Button(); this.BtnImportExcel = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.kryptonDataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonDataGridView1)).BeginInit();
@@ -42,6 +43,7 @@ namespace U8AppMain
// //
// panel1 // panel1
// //
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.BtnImportExcel); this.panel1.Controls.Add(this.BtnImportExcel);
this.panel1.Controls.Add(this.BtnBomImport); this.panel1.Controls.Add(this.BtnBomImport);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
@@ -96,12 +98,23 @@ namespace U8AppMain
// //
// textBox1 // textBox1
// //
this.textBox1.Location = new System.Drawing.Point(145, 193); this.textBox1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.textBox1.Location = new System.Drawing.Point(0, 147);
this.textBox1.Multiline = true; this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1"; this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(515, 246); this.textBox1.Size = new System.Drawing.Size(800, 261);
this.textBox1.TabIndex = 1; this.textBox1.TabIndex = 1;
// //
// button1
//
this.button1.Location = new System.Drawing.Point(211, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "请购单导入";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// FrmMain // FrmMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -127,6 +140,7 @@ namespace U8AppMain
private ComponentFactory.Krypton.Toolkit.KryptonDataGridView kryptonDataGridView1; private ComponentFactory.Krypton.Toolkit.KryptonDataGridView kryptonDataGridView1;
private System.Windows.Forms.Button BtnImportExcel; private System.Windows.Forms.Button BtnImportExcel;
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
} }
} }

View File

@@ -22,38 +22,15 @@ namespace U8AppMain
private DataTable dataTable; private DataTable dataTable;
private async void BtnBomImport_Click(object sender, EventArgs e) private async void BtnBomImport_Click(object sender, EventArgs e)
{ {
// 判断是否是BOM导入的格式
//母件编码 BOM类别 版本号 版本说明 版本生效日 替代标识 替代说明 母件损耗率 子件编码 行号 基本用量 - 分子 基础数量 - 分母 子件损耗率 供应类型 创建日期 创建人
var colums = new Dictionary<string, string>();
colums.Add("母件编码", "InvCode");
colums.Add("BOM类别", "BomType");
colums.Add("版本号", "Version");
colums.Add("版本说明", "VersionDesc");
colums.Add("版本生效日", "版本号");
colums.Add("替代标识", "版本号");
colums.Add("替代说明", "版本号");
colums.Add("母件损耗率", "ParentScrap");
colums.Add("子件编码", "InvCode");
colums.Add("行号", "SortSeq");
colums.Add("基本用量分子", "BaseQtyN");
colums.Add("基础数量分母", "BaseQtyD");
colums.Add("子件损耗率", "CompScrap");
colums.Add("供应类型", "WIPType");
colums.Add("创建日期", "VersionEffDate");
var bomLookup = new Dictionary<string, Bom.ufinterface>(); var bomLookup = new Dictionary<string, Bom.ufinterface>();
foreach (DataRow row in this.dataTable.Rows) foreach (DataRow row in this.dataTable.Rows)
{ {
var bom = new Bom.ufinterface(); var bom = new Bom.ufinterface();
var comp = new Bom.ComponentBody(); var comp = new Bom.ComponentBody();
bom.Bom.Version.Version = Convert.ToInt32(row["版本号"]); bom.Bom.Version.Version = Convert.ToInt32(row["版本号"]);
bom.Bom.Version.VersionDesc = row.Field<string>("版本说明"); bom.Bom.Version.VersionDesc = row.Field<string>("版本说明");
bom.Bom.Parent.InvCode = row.Field<string>("母件编码"); bom.Bom.Parent.InvCode = row.Field<string>("母件编码");
bom.Bom.Version.VersionEffDate = DateTime.Parse(row["版本生效日"].ToString()); bom.Bom.Version.VersionEffDate = DateTime.Parse(row["版本生效日"].ToString());
//bom.Bom.Version.BomType ="1" row.Field<string>("BOM类别"); //bom.Bom.Version.BomType ="1" row.Field<string>("BOM类别");
bom.Bom.Parent.ParentScrap = decimal.Parse(row["母件损耗率"].ToString()); bom.Bom.Parent.ParentScrap = decimal.Parse(row["母件损耗率"].ToString());
@@ -68,7 +45,6 @@ namespace U8AppMain
} }
comp.Component.OpComponentId = bom.Bom.ComponentBodies.Count; comp.Component.OpComponentId = bom.Bom.ComponentBodies.Count;
comp.Component.EffBegDate = bom.Bom.Version.VersionEffDate; comp.Component.EffBegDate = bom.Bom.Version.VersionEffDate;
comp.Component.InvCode = row.Field<string>("子件编码"); comp.Component.InvCode = row.Field<string>("子件编码");
comp.Component.SortSeq = row.Field<string>("行号"); comp.Component.SortSeq = row.Field<string>("行号");
comp.Component.OptionsId = bom.Bom.ComponentBodies.Count; comp.Component.OptionsId = bom.Bom.ComponentBodies.Count;
@@ -79,42 +55,77 @@ namespace U8AppMain
comp.ComponentOpt.OptionsId = bom.Bom.ComponentBodies.Count; comp.ComponentOpt.OptionsId = bom.Bom.ComponentBodies.Count;
bom.Bom.ComponentBodies.Add(comp); bom.Bom.ComponentBodies.Add(comp);
} }
//colums.Add("创建人", "版本号");
//var bom = new Bom.ufinterface();
//bom.Bom.ComponentBodies.Add(new Bom.ComponentBody());
//bom.Bom.ComponentBodies.Add(new Bom.ComponentBody());
foreach (var item in bomLookup.Values) foreach (var item in bomLookup.Values)
{ {
var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8); var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8);
var response = await HttpHelper.Post("", strbody); var response = await HttpHelper.Post("", strbody);
this.textBox1.Text += response; this.textBox1.Text += response;
} }
} }
private void BtnImportExcel_Click(object sender, EventArgs e) private void BtnImportExcel_Click(object sender, EventArgs e)
{ {
var opentFileDlg = new OpenFileDialog(); var opentFileDlg = new OpenFileDialog
opentFileDlg.Filter = "EXCEL2003|*.xls|EXCLE2007|*.xlsx"; {
Filter = "EXCEL2003|*.xls|EXCLE2007|*.xlsx"
};
if (opentFileDlg.ShowDialog() == DialogResult.OK) if (opentFileDlg.ShowDialog() == DialogResult.OK)
{ {
var file = new FileStream(opentFileDlg.FileName, FileMode.Open);
dataTable = ExcelHelper.ExcelToDataTable(file); using (var file = new FileStream(opentFileDlg.FileName, FileMode.Open))
this.kryptonDataGridView1.DataSource = dataTable; {
dataTable = ExcelHelper.ExcelToDataTable(file);
this.kryptonDataGridView1.DataSource = dataTable;
}
} }
return; return;
} }
private async void button1_Click(object sender, EventArgs e)
{
var bomLookup = new Dictionary<string, Purchase.ufinterface>();
foreach (DataRow row in this.dataTable.Rows)
{
var purchase = new Purchase.ufinterface();
var body = new Purchase.entry();
purchase.purchaseapp.header.code = row["请购单号"].ToString();
purchase.purchaseapp.header.date = row["请购日"].ToString();
purchase.purchaseapp.header.departmentcode = row["部门编码"].ToString();
purchase.purchaseapp.header.personcode = row["请购人"].ToString();
purchase.purchaseapp.header.purchasetypecode = row["采购类型编号"].ToString();
purchase.purchaseapp.header.maker = row["制单人"].ToString();
var strKey = purchase.purchaseapp.header.code;
if (bomLookup.ContainsKey(strKey))
{
purchase = bomLookup[strKey];
}
else
{
bomLookup.Add(strKey, purchase);
}
body.inventorycode = row["存货编码"].ToString();
body.requiredate = purchase.purchaseapp.header.date;
body.quantity = decimal.Parse(row["数量"].ToString());
purchase.purchaseapp.body.Add(body);
}
foreach (var item in bomLookup.Values)
{
var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8);
var response = await HttpHelper.Post("", strbody);
this.textBox1.Text += response;
}
}
} }
} }

View File

@@ -9,54 +9,54 @@ namespace U8AppMain.Purchase
public class entry public class entry
{ {
public string vendorcode { get; set; } //public string vendorcode { get; set; }
public string inventorycode { get; set; } public string inventorycode { get; set; }
public int quantity { get; set; } public decimal quantity { get; set; }
public decimal price { get; set; } //public decimal price { get; set; }
public decimal taxrate { get; set; } //public decimal taxrate { get; set; }
public decimal taxprice { get; set; } //public decimal taxprice { get; set; }
public decimal money { get; set; } //public decimal money { get; set; }
public decimal tax { get; set; } //public decimal tax { get; set; }
public decimal sum { get; set; } //public decimal sum { get; set; }
public string requiredate { get; set; } public string requiredate { get; set; }
public string arrivedate { get; set; } public string arrivedate { get; set; }
public string item_class { get; set; } //public string item_class { get; set; }
public string item_code { get; set; } //public string item_code { get; set; }
public decimal btaxcost { get; set; } //public decimal btaxcost { get; set; }
public decimal num { get; set; } //public decimal num { get; set; }
public string unitid { get; set; } //public string unitid { get; set; }
public string deptcodeexec { get; set; } //public string deptcodeexec { get; set; }
public string personcodeexec { get; set; } //public string personcodeexec { get; set; }
public string currency_name { get; set; } public string currency_name { get; set; } = "人民币";
public decimal currency_rate { get; set; } public decimal currency_rate { get; set; } = 1;
public string originalprice { get; set; } //public string originalprice { get; set; }
public string originalmoney { get; set; } //public string originalmoney { get; set; }
public string originaltax { get; set; } //public string originaltax { get; set; }
public string originalsum { get; set; } //public string originalsum { get; set; }
public string ivouchrowno { get; set; } //public string ivouchrowno { get; set; }
// <vendorcode /> // <vendorcode />
//<inventorycode>107001</inventorycode> //<inventorycode>107001</inventorycode>
//<quantity>456</quantity> //<quantity>456</quantity>

View File

@@ -14,28 +14,28 @@ namespace U8AppMain.Purchase
public string personcode { get; set; } public string personcode { get; set; }
public string purchasetypecode { get; set; } public string purchasetypecode { get; set; }
public string businesstype { get; set; } public string businesstype { get; set; } = "普通采购";
public string maker { get; set; } public string maker { get; set; }
public string define1 { get; set; } //public string define1 { get; set; }
public string define2 { get; set; } //public string define2 { get; set; }
public string define3 { get; set; } //public string define3 { get; set; }
public string define4 { get; set; } //public string define4 { get; set; }
public string define5 { get; set; } //public string define5 { get; set; }
public string define6 { get; set; } //public string define6 { get; set; }
public string define7 { get; set; } //public string define7 { get; set; }
public string define8 { get; set; } //public string define8 { get; set; }
public string define9 { get; set; } //public string define9 { get; set; }
public string define10 { get; set; } //public string define10 { get; set; }
public string define11{ get; set; } //public string define11{ get; set; }
public string define12 { get; set; } //public string define12 { get; set; }
public string define13 { get; set; } //public string define13 { get; set; }
public string define14 { get; set; } //public string define14 { get; set; }
public string define15 { get; set; } //public string define15 { get; set; }
public string define16 { get; set; } //public string define16 { get; set; }
public string memory { get; set; } //public string memory { get; set; }
// <code>CGQGD2132131</code> // <code>CGQGD2132131</code>
//<date>2020-12-17</date> //<date>2020-12-17</date>

View File

@@ -8,41 +8,33 @@ namespace U8AppMain.Purchase
{ {
public class ufinterface public class ufinterface
{ {
//roottag="purchaseapp" billtype="" docid="123" receiver="u8" sender="003"
// proc="add" codeexchanged="N" exportneedexch="N" version="2.0"
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string roottag { get; set; } public string roottag { get; set; } = "purchaseapp";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string billtype { get; set; } public string billtype { get; set; } = "";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string docid { get; set; } public string docid { get; set; } = "123";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string receiver { get; set; } public string receiver { get; set; } = "u8";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string sender { get; set; } public string sender { get; set; } = "003";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string proc { get; set; } public string proc { get; set; } = "add";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string codeexchanged { get; set; } public string codeexchanged { get; set; } = "N";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string exportneedexch { get; set; } public string exportneedexch { get; set; } = "N";
[System.Xml.Serialization.XmlAttribute] [System.Xml.Serialization.XmlAttribute]
public string version { get; set; } public string version { get; set; } = "2.0";
//roottag="purchaseapp" public PurchaseEnity purchaseapp { get; set; } = new PurchaseEnity();
// billtype=""
// docid="123"
// receiver="u8"
// sender="003"
// proc="add"
// codeexchanged="N"
// exportneedexch="N"
// version="2.0"
public PurchaseEnity purchaseapp { get; set; } = new PurchaseEnity();