修正项目

This commit is contained in:
admin
2021-01-05 11:11:28 +08:00
parent 56d6cc89e9
commit e9b4b307c9
93 changed files with 2524 additions and 156 deletions

18
NX.ERP.U8.App/App.config Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
</startup>
<appSettings>
<!--修改账套请修改这里的配置-->
<add key="url" value="http://192.168.0.242/U8EAI/import.asp"/>
<add key="connStr" value="Server=192.168.0.242 ;DataBase=UFDATA_003_2019;Uid=sa;Pwd=!@#qwe123;"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
<runtime>
</runtime>
<system.web>
</system.web>
</configuration>

57
NX.ERP.U8.App/Bom/Bom.cs Normal file
View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace U8AppMain.Bom
{
public class BomEnity
{
public VersionEnity Version { get; set; } = new VersionEnity();
public ParentEnity Parent { get; set; } = new ParentEnity();
[XmlElement(Type = typeof(ComponentEnity))]
public List<ComponentEnity> Component
{
get
{
return this._componentBodies.ConvertAll(m => { return m.Component; });
}
}
[XmlElement(Type = typeof(ComponentOptEnity))]
public List<ComponentOptEnity> ComponentOpt
{
get
{
return this.ComponentBodies.ConvertAll(m => { return m.ComponentOpt; });
}
}
[XmlElement(Type = typeof(ComponentRmkEnity))]
public List<ComponentRmkEnity> ComponentRmk
{
get
{
return this.ComponentBodies.ConvertAll(m => { return m.componentRmk; });
}
}
[XmlIgnore]
public List<ComponentBody> ComponentBodies { get => _componentBodies; set => _componentBodies = value; }
private List<ComponentBody> _componentBodies = new List<ComponentBody>();
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace U8AppMain.Bom
{
public class ComponentBody
{
public ComponentEnity Component { get; set; } = new ComponentEnity();
public ComponentOptEnity ComponentOpt { get; set; } = new ComponentOptEnity();
public ComponentRmkEnity componentRmk { get; set; } = new ComponentRmkEnity();
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Bom
{
//<OpComponentId>10</OpComponentId>
// <BomId>4</BomId>
// <SortSeq>10</SortSeq>
// <OpSeq>0000</OpSeq>
// <InvCode>107001</InvCode>
// <EffBegDate>2000-01-07T00:00:00+08:00</EffBegDate>
// <EffEndDate>2099-12-31T00:00:00+08:00</EffEndDate>
// <FVFlag>1</FVFlag>
// <BaseQtyN>1.000000</BaseQtyN>
// <BaseQtyD>1.000000</BaseQtyD>
// <CompScrap>0.000</CompScrap>
// <ByproductFlag>false</ByproductFlag>
// <OptionsId>10</OptionsId>
public class ComponentEnity
{
public int OpComponentId { get; set; }
public int BomId { get; set; }
public string SortSeq { get; set; }
public string OpSeq { get; set; } = "000";
public string InvCode { get; set; }
public DateTime EffBegDate { get; set; } = DateTime.Today;
public DateTime EffEndDate { get; set; } = DateTime.Now.AddYears(50);
public int FVFlag { get; set; } = 1;
public decimal BaseQtyN { get; set; }
public decimal BaseQtyD { get; set; }
public decimal CompScrap { get; set; }
public bool ByproductFlag { get; set; }
public int OptionsId { get; set; }
//<OpComponentId>11</OpComponentId>
// <BomId>4</BomId>
// <SortSeq>20</SortSeq>
// <OpSeq>0000</OpSeq>
// <InvCode>502006</InvCode>
// <EffBegDate>2000-01-07T00:00:00+08:00</EffBegDate>
// <EffEndDate>2099-12-31T00:00:00+08:00</EffEndDate>
// <FVFlag>1</FVFlag>
// <BaseQtyN>1.000000</BaseQtyN>
// <BaseQtyD>1.000000</BaseQtyD>
// <CompScrap>0.000</CompScrap>
// <ByproductFlag>false</ByproductFlag>
// <OptionsId>11</OptionsId>
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Bom
{
public class ComponentOptEnity
{
public string WIPType { get; set; }
public int OptionsId { get; set; }
public int Offset { get; set; }
public bool AccuCostFlag { get; set; } = true;
public string DrawDeptCode { get; set; } = "";
public string Whcode { get; set; } = "";
public bool OptionalFlag { get; set; } = false;
public int MutexRule { get; set; } = 2;
public decimal PlanFactor { get; set; } = 100;
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Bom
{
public class ComponentRmkEnity
{
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Bom
{
public class ParentEnity
{
public int BomId { get; set; }
public string InvCode { get; set; } = "";
public string InvName { get; set; } = "";
public decimal ParentScrap { get; set; }
//<BomId>4</BomId>
// <InvCode>1001002</InvCode>
// <InvName>环球普通PC</InvName>
// <ParentScrap>0.000</ParentScrap>
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Bom
{
public class VersionEnity
{
public int BomId { get; set; } = 0;
public string BomType { get; set; } = "1";
public int Version { get; set; }
public string VersionDesc { get; set; }
public DateTime VersionEffDate { get; set; } = DateTime.Now;
public int Status { get; set; } = 3;
public string Define12 { get; set; }
//<BomType>1</BomType>
// <Version>70</Version>
// <VersionDesc>环球普通PC</VersionDesc>
// <VersionEffDate>2000-01-07T00:00:00+08:00</VersionEffDate>
// <Status>3</Status>
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace U8AppMain.Bom
{
public class ufinterface
{
//sender="003" receiver="u8" roottag="Bom" docid="971742630" proc="add" codeexchanged="N" exportneedexch="N" paginate="0" display="物料清单" family="生产制造" timestamp="0x000000000027B6E6"
[System.Xml.Serialization.XmlAttribute]
public string sender { get; set; } = "003";
[System.Xml.Serialization.XmlAttribute]
public string receiver { get; set; } = "u8";
[System.Xml.Serialization.XmlAttribute]
public string roottag { get; set; } = "Bom";
[System.Xml.Serialization.XmlAttribute]
public string docid { get; set; } = "971742630";
[System.Xml.Serialization.XmlAttribute]
public string proc { get; set; } = "add";
[System.Xml.Serialization.XmlAttribute]
public string codeexchanged { get; set; } = "N";
[System.Xml.Serialization.XmlAttribute]
public string exportneedexch { get; set; } = "N";
[System.Xml.Serialization.XmlAttribute]
public string paginate { get; set; } = "0";
[System.Xml.Serialization.XmlAttribute]
public string display { get; set; } = "物料清单";
[System.Xml.Serialization.XmlAttribute]
public string family { get; set; } = "生产制造";
[System.Xml.Serialization.XmlAttribute]
public string timestamp { get; set; } = "0x000000000027B6E6";
public BomEnity Bom { get; set; } = new BomEnity();
}
}

View File

@@ -0,0 +1,93 @@
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
namespace U8AppMain
{
/// <summary>
///
/// </summary>
public static class ExcelHelper
{
public static DataTable ExcelToDataTable(Stream steam, string sheetName = null, Dictionary<string, string> fieldName = null,
bool isFirstRowColumn = true)
{
DataTable data = new DataTable();
try
{
var workbook = WorkbookFactory.Create(steam);
ISheet sheet;
if (sheetName != null)
{
sheet = workbook.GetSheet(sheetName);
if (sheet == null) sheet = workbook.GetSheetAt(0);
}
else
{
sheet = workbook.GetSheetAt(0);
}
if (sheet != null)
{
IRow firstRow = sheet.GetRow(0);
int cellCount = firstRow.LastCellNum; //一行最后一个cell的编号 即总的列数
int startRow;
if (isFirstRowColumn)
{
for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
{
ICell cell = firstRow.GetCell(i);
if (cell != null)
{
string cellValue = cell.StringCellValue.Trim();
if (fieldName != null)
{
if (fieldName.ContainsKey(cellValue))
{
cellValue = fieldName[cellValue];
}
}
if (cellValue != null)
{
DataColumn column = new DataColumn(cellValue);
data.Columns.Add(column);
}
}
}
startRow = sheet.FirstRowNum + 1;
}
else
{
startRow = sheet.FirstRowNum;
}
//最后一列的标号
int rowCount = sheet.LastRowNum;
for (int i = startRow; i <= rowCount; ++i)
{
IRow row = sheet.GetRow(i);
if (row == null) continue; //没有数据的行默认是null       
DataRow dataRow = data.NewRow();
for (int j = row.FirstCellNum; j < cellCount; ++j)
{
if (row.GetCell(j) != null) //同理,没有数据的单元格都默认是null
dataRow[j] = row.GetCell(j).ToString().Trim();
}
data.Rows.Add(dataRow);
}
}
return data;
}
catch (Exception ex)
{
throw ex;
}
}
}
}

228
NX.ERP.U8.App/FrmMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,228 @@
namespace U8AppMain
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.操作ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BtnReadExcel = new System.Windows.Forms.ToolStripMenuItem();
this.导入ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ImportBom = new System.Windows.Forms.ToolStripMenuItem();
this.BtnPurchaseImport = new System.Windows.Forms.ToolStripMenuItem();
this.领料单ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.打印ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.打印ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.登录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Font = new System.Drawing.Font("Segoe UI", 9F);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.操作ToolStripMenuItem,
this.导入ToolStripMenuItem,
this.打印ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(9, 4, 0, 4);
this.menuStrip1.Size = new System.Drawing.Size(1200, 27);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// 操作ToolStripMenuItem
//
this.操作ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.BtnReadExcel,
this.登录ToolStripMenuItem});
this.操作ToolStripMenuItem.Name = "操作ToolStripMenuItem";
this.操作ToolStripMenuItem.Size = new System.Drawing.Size(45, 19);
this.操作ToolStripMenuItem.Text = "文件";
//
// BtnReadExcel
//
this.BtnReadExcel.Name = "BtnReadExcel";
this.BtnReadExcel.Size = new System.Drawing.Size(180, 22);
this.BtnReadExcel.Text = "读取Excel";
this.BtnReadExcel.Click += new System.EventHandler(this.BtnReadExcel_Click);
//
// 导入ToolStripMenuItem
//
this.导入ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ImportBom,
this.BtnPurchaseImport,
this.领料单ToolStripMenuItem});
this.导入ToolStripMenuItem.Name = "导入ToolStripMenuItem";
this.导入ToolStripMenuItem.Size = new System.Drawing.Size(45, 19);
this.导入ToolStripMenuItem.Text = "导入";
//
// ImportBom
//
this.ImportBom.Name = "ImportBom";
this.ImportBom.Size = new System.Drawing.Size(113, 22);
this.ImportBom.Text = "BOM";
this.ImportBom.Click += new System.EventHandler(this.ImportBom_Click);
//
// BtnPurchaseImport
//
this.BtnPurchaseImport.Name = "BtnPurchaseImport";
this.BtnPurchaseImport.Size = new System.Drawing.Size(113, 22);
this.BtnPurchaseImport.Text = "请购单";
this.BtnPurchaseImport.Click += new System.EventHandler(this.BtnPurchaseImport_Click);
//
// 领料单ToolStripMenuItem
//
this.领料单ToolStripMenuItem.Name = "领料单ToolStripMenuItem";
this.领料单ToolStripMenuItem.Size = new System.Drawing.Size(113, 22);
this.领料单ToolStripMenuItem.Text = "领料单";
this.领料单ToolStripMenuItem.Click += new System.EventHandler(this.领料单ToolStripMenuItem_Click);
//
// 打印ToolStripMenuItem
//
this.打印ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.打印ToolStripMenuItem1});
this.打印ToolStripMenuItem.Name = "打印ToolStripMenuItem";
this.打印ToolStripMenuItem.Size = new System.Drawing.Size(45, 19);
this.打印ToolStripMenuItem.Text = "打印";
//
// 打印ToolStripMenuItem1
//
this.打印ToolStripMenuItem1.Name = "打印ToolStripMenuItem1";
this.打印ToolStripMenuItem1.Size = new System.Drawing.Size(100, 22);
this.打印ToolStripMenuItem1.Text = "打印";
this.打印ToolStripMenuItem1.Click += new System.EventHandler(this.打印ToolStripMenuItem1_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 27);
this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.dataGridView1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.richTextBox1);
this.splitContainer1.Size = new System.Drawing.Size(1200, 722);
this.splitContainer1.SplitterDistance = 450;
this.splitContainer1.TabIndex = 0;
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToOrderColumns = true;
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.GridColor = System.Drawing.SystemColors.ActiveBorder;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Margin = new System.Windows.Forms.Padding(4);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(1200, 450);
this.dataGridView1.TabIndex = 0;
//
// richTextBox1
//
this.richTextBox1.BackColor = System.Drawing.Color.White;
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
this.richTextBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(1200, 268);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// 登录ToolStripMenuItem
//
this.登录ToolStripMenuItem.Name = "登录ToolStripMenuItem";
this.登录ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.登录ToolStripMenuItem.Text = "登录";
this.登录ToolStripMenuItem.Click += new System.EventHandler(this.登录ToolStripMenuItem_Click);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1200, 749);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FrmMain";
this.Text = "U8导入";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem 操作ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem BtnReadExcel;
private System.Windows.Forms.ToolStripMenuItem 导入ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ImportBom;
private System.Windows.Forms.ToolStripMenuItem BtnPurchaseImport;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.ToolStripMenuItem 领料单ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 打印ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 打印ToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem 登录ToolStripMenuItem;
}
}

294
NX.ERP.U8.App/FrmMain.cs Normal file
View File

@@ -0,0 +1,294 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.IO;
using System.Configuration;
namespace U8AppMain
{
public partial class FrmMain : Form
{
public FrmMain()
{
InitializeComponent();
}
private NX.ERP.U8.U8LoginContext u8LoginContext = null;
private void PrintLog(ResultEnity.ufinterface info)
{
this.richTextBox1.SelectionColor = Color.Black;
this.richTextBox1.AppendText($"单据:{info.requestroottag} 操作:{info.proc} \r\n");
foreach (var item in info.Items)
{
string tag;
if (item.succeed == "0")
{
this.richTextBox1.SelectionColor = Color.Green;
tag = "成功";
}
else
{
this.richTextBox1.SelectionColor = Color.Red;
tag = "出错";
}
this.richTextBox1.AppendText($"[{tag}] 单号:({item.key}),信息:{item.dsc} \r\n");
}
this.richTextBox1.SelectionColor = Color.Black;
this.richTextBox1.AppendText($"---------------------------------------------------------------------------------------\r\n");
}
private ResultEnity.ufinterface HttpPost(string body)
{
try
{
var response = HttpHelper.HttpPost(url, body);
return XmlHelper.XmlDeserialize<ResultEnity.ufinterface>(response, Encoding.UTF8);
// var strResult = $"单据:{result.requestroottag} 操作:{result.proc} \r\n";
//foreach (var item in result.Items)
//{
// strResult += $" 单号:{item.key} 单号:{item.u8key} ------------执行结果: {item.dsc} \r\n";
//}
// return strResult;
}
catch (Exception err)
{
this.richTextBox1.Text = err.Message;
return null;
//return err.Message;
}
}
private string url = ConfigurationManager.AppSettings.Get("url");
private string connStr = ConfigurationManager.AppSettings.Get("connStr");
private DataTable dataTable;
private void BtnReadExcel_Click(object sender, EventArgs e)
{
var opentFileDlg = new OpenFileDialog
{
Filter = "EXCEL文件(*.xls;*.xlsx)|*.xls;*.xlsx"
};
if (opentFileDlg.ShowDialog() == DialogResult.OK)
{
using (var file = new FileStream(opentFileDlg.FileName, FileMode.Open))
{
dataTable = ExcelHelper.ExcelToDataTable(file);
this.dataGridView1.DataSource = dataTable;
}
}
return;
}
private void ImportBom_Click(object sender, EventArgs e)
{
if (this.dataTable == null || this.dataTable.Rows.Count == 0)
{
return;
}
var bomLookup = new Dictionary<string, Bom.ufinterface>();
try
{
foreach (DataRow row in this.dataTable.Rows)
{
var bom = new Bom.ufinterface();
var comp = new Bom.ComponentBody();
bom.Bom.Version.Version = Convert.ToInt32(row["版本号"]);
bom.Bom.Version.VersionDesc = row.Field<string>("版本说明");
bom.Bom.Version.Define12 = row.Field<string>("母件编码") + row.Field<string>("版本说明");
bom.Bom.Parent.InvCode = row.Field<string>("母件编码");
bom.Bom.Version.VersionEffDate = DateTime.Parse(row["版本生效日"].ToString());
bom.Bom.Parent.ParentScrap = decimal.Parse(row["母件损耗率"].ToString());
var strKey = $"{bom.Bom.Parent.InvCode}-{bom.Bom.Version.Version}";
if (bomLookup.ContainsKey(strKey))
{
bom = bomLookup[strKey];
}
else
{
bomLookup.Add(strKey, bom);
}
comp.Component.OpComponentId = bom.Bom.ComponentBodies.Count;
comp.Component.EffBegDate = bom.Bom.Version.VersionEffDate;
comp.Component.InvCode = row.Field<string>("子件编码");
comp.Component.SortSeq = row.Field<string>("行号");
comp.Component.OptionsId = bom.Bom.ComponentBodies.Count;
comp.Component.BaseQtyN = decimal.Parse(row["基本用量分子"].ToString());
comp.Component.BaseQtyD = decimal.Parse(row["基础数量分母"].ToString());
comp.Component.CompScrap = decimal.Parse(row["子件损耗率"].ToString());
comp.ComponentOpt.WIPType = row["供应类型"].ToString();
comp.ComponentOpt.OptionsId = bom.Bom.ComponentBodies.Count;
bom.Bom.ComponentBodies.Add(comp);
}
}
catch (Exception)
{
this.richTextBox1.SelectionColor = Color.Red;
this.richTextBox1.AppendText("读取数据出错\r\n");
return;
}
foreach (var item in bomLookup.Values)
{
var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8);
var response = this.HttpPost(strbody);
PrintLog(response);
Application.DoEvents();
}
}
private void BtnPurchaseImport_Click(object sender, EventArgs e)
{
if (this.dataTable == null || this.dataTable.Rows.Count == 0)
{
return;
}
var bomLookup = new Dictionary<string, Purchase.ufinterface>();
try
{
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();
purchase.purchaseapp.header.define12 = 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);
}
}
catch (Exception)
{
this.richTextBox1.SelectionColor = Color.Red;
this.richTextBox1.AppendText("读取数据出错\r\n");
return;
}
foreach (var item in bomLookup.Values)
{
var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8);
var response = this.HttpPost(strbody);
PrintLog(response);
Application.DoEvents();
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
richTextBox1.SelectionStart = richTextBox1.Text.Length;
//滚动到光标位置
richTextBox1.ScrollToCaret();
}
private void 领料单ToolStripMenuItem_Click(object sender, EventArgs e)
{
//单据号 日期 部门编码 业务员 制单人 存货编码 数量
if (this.dataTable == null || this.dataTable.Rows.Count == 0)
{
return;
}
var bomLookup = new Dictionary<string, Voucher.Vouch>();
try
{
foreach (DataRow row in this.dataTable.Rows)
{
var Vouch = new Voucher.Vouch();
var Vouchs = new Voucher.Vouchs();
Vouch.CCode = row["单据号"].ToString();
Vouch.DDate = DateTime.Parse(row["日期"].ToString());
Vouch.CDepCode = row["部门编码"].ToString();
Vouch.CPersonCode = row["业务员"].ToString();
Vouch.CMaker = row["制单人"].ToString();
Vouch.CRdCode = "201";
Vouch.Vt_id = "30718";
Vouch.IswfControlled = 0;
var strKey = Vouch.CCode;
if (bomLookup.ContainsKey(strKey))
{
Vouch = bomLookup[strKey];
}
else
{
bomLookup.Add(strKey, Vouch);
}
Vouchs.CInvCode = row["存货编码"].ToString();
Vouchs.Iquantity = int.Parse(row["数量"].ToString());
Vouch.Vouchs.Add(Vouchs);
}
foreach (var item in bomLookup.Values)
{
var a = new Voucher.VoucherDAL(this.u8LoginContext.Constr4Net);
if (a.Add(item))
{
this.richTextBox1.SelectionColor = Color.Green;
this.richTextBox1.AppendText($" {item.cDefine12} 导入成功 ,实际U8单号: {item.CCode} \r\n");
}
else
{
this.richTextBox1.SelectionColor = Color.Red;
this.richTextBox1.AppendText($"{item.CCode} 导入出错\r\n");
}
}
this.richTextBox1.AppendText($"--------------------------------------------------------------------------------------------\r\n");
}
catch (Exception err)
{
this.richTextBox1.SelectionColor = Color.Red;
this.richTextBox1.AppendText($"{err.Message}读取数据出错\r\n");
return;
}
}
private void 打印ToolStripMenuItem1_Click(object sender, EventArgs e)
{
}
private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
{
u8LoginContext = new NX.ERP.U8.U8LoginContext();
u8LoginContext.Login(true);
}
}
}

123
NX.ERP.U8.App/FrmMain.resx Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
namespace U8AppMain
{
public static class HttpHelper
{
/// <summary>
/// HTTP POST方式请求数据
/// </summary>
/// <param name="url">URL.</param>
/// <param name="param">POST的数据</param>
/// <returns></returns>
public static string HttpPost(string url, string param = null)
{
var request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.Timeout = 15000;
request.AllowAutoRedirect = false;
StreamWriter requestStream = null;
WebResponse response = null;
string responseStr = null;
try
{
requestStream = new StreamWriter(request.GetRequestStream());
requestStream.Write(param);
requestStream.Close();
response = request.GetResponse();
if (response != null)
{
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
responseStr = reader.ReadToEnd();
reader.Close();
}
}
catch (Exception)
{
throw;
}
finally
{
request = null;
requestStream = null;
response = null;
}
return responseStr;
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace U8AppMain
{
public class MessageFilter : IMessageFilter
{
private Timer timer = new Timer();
private int _lastTick = Environment.TickCount;
public MessageFilter(int closeInterval = 60)
{
this._closeInterval = closeInterval * 1000;
this.timer.Interval = 10000;
this.timer.Tick += Timer_Tick;
this.timer.Start();
}
private int _closeInterval;
private void Timer_Tick(object sender, EventArgs e)
{
if (Environment.TickCount - _closeInterval > Environment.TickCount)
{
Application.Exit();
}
}
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == (int)WindowsMessages.WM_MOUSEMOVE || m.Msg == (int)WindowsMessages.WM_KEYUP)
{
this._lastTick = Environment.TickCount;
}
return false;
}
}
}

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8A6603B0-444A-49C7-80C9-195638129068}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>NX.ERP.U8.App</RootNamespace>
<AssemblyName>NX.ERP.U8.App</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.1.42\lib\net35\Dapper.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="NPOI, Version=2.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.2.1\lib\net20\NPOI.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML, Version=2.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.2.1\lib\net20\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net, Version=2.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.2.1\lib\net20\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats, Version=2.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<HintPath>..\packages\NPOI.2.2.1\lib\net20\NPOI.OpenXmlFormats.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Security" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="Bom\Bom.cs" />
<Compile Include="Bom\ComponentBody.cs" />
<Compile Include="Bom\ComponentEnity.cs" />
<Compile Include="Bom\ComponentOptEnity.cs" />
<Compile Include="Bom\ComponentRmkEnity.cs" />
<Compile Include="Bom\ParentEnity.cs" />
<Compile Include="Bom\ufinterface.cs" />
<Compile Include="Bom\Version.cs" />
<Compile Include="ExcelHelper.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="HttpHelper.cs" />
<Compile Include="MessageFilter.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Purchase\BodyEnity.cs" />
<Compile Include="Purchase\EntryEnity.cs" />
<Compile Include="Purchase\HeaderEnity.cs" />
<Compile Include="Purchase\PurchaseEnity.cs" />
<Compile Include="Purchase\ufinterface.cs" />
<Compile Include="ResultEnity\Item.cs" />
<Compile Include="ResultEnity\ufinterface.cs" />
<Compile Include="Voucher\Vouch.cs" />
<Compile Include="Voucher\VoucherDAL.cs" />
<Compile Include="Voucher\Vouchs.cs" />
<Compile Include="WindowsMessages.cs" />
<Compile Include="XmlHelper.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NX.ERP.Model\NX.ERP.Model.csproj">
<Project>{5d012e0a-afed-474e-81a9-5820890b1b29}</Project>
<Name>NX.ERP.Model</Name>
</ProjectReference>
<ProjectReference Include="..\NX.ERP.U8\NX.ERP.U8.csproj">
<Project>{bd673da9-0606-4bcf-a016-fb5c4e7b5d59}</Project>
<Name>NX.ERP.U8</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

23
NX.ERP.U8.App/Program.cs Normal file
View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace U8AppMain
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.AddMessageFilter(new MessageFilter());
Application.Run(new FrmMain());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("U8AppMain")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("U8AppMain")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("8a6603b0-444a-49c7-80c9-195638129068")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace NX.ERP.U8.App.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NX.ERP.U8.App.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace NX.ERP.U8.App.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Purchase
{
public class BodyEnity
{
[System.Xml.Serialization.XmlElement(Type =typeof(entry),ElementName = "entry")]
public List<entry> entries { get; set; } = new List<entry>();
}
}

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Purchase
{
public class entry
{
//public string vendorcode { get; set; }
public string inventorycode { get; set; }
public decimal quantity { get; set; }
//public decimal price { get; set; }
//public decimal taxrate { get; set; }
//public decimal taxprice { get; set; }
//public decimal money { get; set; }
//public decimal tax { get; set; }
//public decimal sum { get; set; }
public string requiredate { get; set; }
public string arrivedate { get; set; }
//public string item_class { get; set; }
//public string item_code { get; set; }
//public decimal btaxcost { get; set; }
public string num { get; set; } = "";
//public string unitid { get; set; }
//public string deptcodeexec { get; set; }
//public string personcodeexec { get; set; }
public string currency_name { get; set; } = "人民币";
public decimal currency_rate { get; set; } = 1;
//public string originalprice { get; set; }
//public string originalmoney { get; set; }
//public string originaltax { get; set; }
//public string originalsum { get; set; }
public int ivouchrowno { get; set; }
// <vendorcode />
//<inventorycode>107001</inventorycode>
//<quantity>456</quantity>
//<price />
//<taxrate />
//<taxprice />
//<money />
//<tax />
//<sum />
//<requiredate>2020-12-17</requiredate>
//<arrivedate />
//<item_class />
//<item_code />
//<item_name />
//<btaxcost />
//<num />
//<unitid />
//<deptcodeexec />
//<personcodeexec />
//<currency_name>人民币</currency_name>
//<currency_rate>1</currency_rate>
//<originalprice />
//<originaltaxedprice />
//<originalmoney />
//<originaltax />
//<originalsum />
//<ivouchrowno />
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Purchase
{
public class HeaderEnity
{
public string code { get; set; }
public string date { get; set; }
public string departmentcode { get; set; }
public string personcode { get; set; }
public string purchasetypecode { get; set; }
public string businesstype { get; set; } = "普通采购";
public string maker { get; set; }
//public string define1 { get; set; }
//public string define2 { get; set; }
//public string define3 { get; set; }
//public string define4 { get; set; }
//public string define5 { get; set; }
//public string define6 { get; set; }
//public string define7 { get; set; }
//public string define8 { get; set; }
//public string define9 { get; set; }
//public string define10 { get; set; }
//public string define11{ get; set; }
public string define12 { get; set; }
//public string define13 { get; set; }
//public string define14 { get; set; }
//public string define15 { get; set; }
//public string define16 { get; set; }
//public string memory { get; set; }
// <code>CGQGD2132131</code>
//<date>2020-12-17</date>
//<departmentcode>51</departmentcode>
//<personcode>0031</personcode>
//<purchasetypecode>01</purchasetypecode>
//<businesstype>普通采购</businesstype>
//<maker>苏青红</maker>
//<define1 />
//<define2 />
//<define3 />
//<define4 />
//<define5 />
//<define6 />
//<define7 />
//<define8 />
//<define9 />
//<define10 />
//<define11 />
//<define12 />
//<define13 />
//<define14 />
//<define15 />
//<define16 />
//<memory />
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Purchase
{
public class PurchaseEnity
{
public HeaderEnity header { get; set; } = new HeaderEnity();
//public BodyEnity body { get; set; } = new BodyEnity();
public List<entry> body { get; set; } = new List<entry>();
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Purchase
{
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]
public string roottag { get; set; } = "purchaseapp";
[System.Xml.Serialization.XmlAttribute]
public string billtype { get; set; } = "";
[System.Xml.Serialization.XmlAttribute]
public string docid { get; set; } = "123";
[System.Xml.Serialization.XmlAttribute]
public string receiver { get; set; } = "u8";
[System.Xml.Serialization.XmlAttribute]
public string sender { get; set; } = "003";
[System.Xml.Serialization.XmlAttribute]
public string proc { get; set; } = "add";
[System.Xml.Serialization.XmlAttribute]
public string codeexchanged { get; set; } = "N";
[System.Xml.Serialization.XmlAttribute]
public string exportneedexch { get; set; } = "N";
[System.Xml.Serialization.XmlAttribute]
public string version { get; set; } = "2.0";
public PurchaseEnity purchaseapp { get; set; } = new PurchaseEnity();
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace U8AppMain.ResultEnity
{
public class Item
{
// <item key = "CGQGD2132133" succeed="0" dsc="ok" u8key="CGQGD2132133"></item>
[XmlAttribute]
public string key { get; set; }
[XmlAttribute]
public string succeed { get; set; }
[XmlAttribute]
public string dsc { get; set; }
[XmlAttribute]
public string u8key { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace U8AppMain.ResultEnity
{
public class ufinterface
{
// <ufinterface roottag = "return" docid="123" proc="add" sender="u8" receiver="003" 
// request-roottag="purchaseapp">
//    <item key = "CGQGD2132133" succeed="0" dsc="ok" u8key="CGQGD2132133"></item>
//</ufinterface>
[XmlAttribute]
public string roottag { get; set; }
[XmlAttribute]
public string docid { get; set; }
[XmlAttribute]
public string proc { get; set; }
[XmlAttribute]
public string receiver { get; set; }
[XmlAttribute(attributeName: "request-roottag")]
public string requestroottag { get; set; }
[XmlElement(Type = typeof(Item),ElementName ="item")]
public List<Item> Items { get; set; } = new List<Item>();
}
}

View File

@@ -0,0 +1,97 @@
using System;
using U8Login;
namespace U8ApiInterface
{
public class U8LoginContext : IDisposable
{
private static U8LoginContext _u8LoginContext;
public static U8LoginContext Instance
{
get
{
if (_u8LoginContext == null)
{
_u8LoginContext = new U8LoginContext();
}
return _u8LoginContext;
}
}
private UFSoft.U8.Framework.Login.UI.clsLogin clsLogin;
private clsLogin _clslogin;
private U8LoginContext()
{
clsLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();
}
public clsLogin ClsLogin
{
get
{
if (this._clslogin == null)
{
this.Login();
}
return this._clslogin;
}
}
public void Dispose()
{
if (clsLogin != null)
{
clsLogin.SubLogout(AccID);
clsLogin.ShutDown();
clsLogin = null;
}
}
public string UserId { get; set; } = "003";
public string PassWord { get; set; } = "123456";
public string Server { get; set; } = "192.168.0.242";
public string AccID { get; set; } = "u8@889";
public string Serial { get; set; }
public void Login()
{
var a = clsLogin.GetDataSource("192.168.0.250");
if (!clsLogin.login("DP", "wx998", "nx123456", "192.168.0.250","2020-12-31", AccID, Serial))
{
throw new Exception(clsLogin.ErrDescript);
}
if (clsLogin.SubLogin("ST") == null)
{
throw new Exception(clsLogin.ErrDescript);
}
this._clslogin = new clsLoginClass();
if (!_clslogin.ConstructLogin(clsLogin.userToken))
{
throw new Exception(_clslogin.ShareString);
}
_clslogin.set_TaskId(clsLogin.GetTaskID("ST"));
//U8EnvContext u8EnvContext = new U8EnvContext
//{
// U8Login = this._clslogin
//};
//return true;
}
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Voucher
{
public class Vouch
{
//id,ddate,ccode,crdcode,cdepcode,cpersoncode,cmaker,vt_id,iswfcontrolled,
//dnmaketime,dnmodifytime,dnverifytime
public int ID { get; set; }
public DateTime DDate { get; set; }
public string CCode { get; set; }
public string CRdCode { get; set; }
public string CDepCode { get; set; }
public string CPersonCode { get; set; }
public string CMaker { get; set; }
public string Vt_id { get; set; }
public int IswfControlled { get; set; }
public DateTime dnmaketime { get; set; }
public DateTime dnmodifytime { get; set; }
public DateTime dnverifytime { get; set; }
public ICollection<Vouchs> Vouchs { get; set; } = new List<Vouchs>();
public string cDefine12 { get; set; }
}
}

View File

@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
using System.Data.SqlClient;
namespace U8AppMain.Voucher
{
public class IdEnity
{
public string cAcc_Id { get; set; }
public string cVouchType { get; set; }
public int iAmount { get; set; }
//public int iFatherId { get; set; }
//public int iChildId { get; set; }
public bool bEnableNewRule { get; set; } = true;
}
public class VoucherDAL
{
private string _connStr;
public VoucherDAL(string connStr)
{
_connStr = connStr;
}
public bool Add(Vouch vouch)
{
var conn = new SqlConnection(this._connStr);
conn.Open();
var trans = conn.BeginTransaction();
try
{
//获取ID
var idEnity = new IdEnity
{
cAcc_Id = "003",
cVouchType = "mv",
iAmount = vouch.Vouchs.Count()
};
DynamicParameters sp = new DynamicParameters(idEnity);
sp.Add("@iFatherId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output,0);
sp.Add("@iChildId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output,0);
conn.Execute("sp_GetID", sp, trans, commandType: System.Data.CommandType.StoredProcedure);
int iFatherId = sp.Get<int>("@iFatherId");
int iChildId = sp.Get<int>("@iChildId");
//获取最大值
var cSeed = DateTime.Today.ToString("yyyyMM");
var sqlMax = $@"select cNumber as Maxnumber From VoucherHistory with (ROWLOCK) Where CardNumber='0413' and cContent='日期' and cSeed=@cSeed";
var maxCode = conn.ExecuteScalar<int>(sqlMax, new { cSeed }, trans,200,System.Data.CommandType.Text);
maxCode++;
//更新最大之
var sqlUpdate = "update VoucherHistory set cNumber=@cNumber Where CardNumber='0413' and cContent='日期' and cSeed=@cSeed ";
conn.Execute(sqlUpdate, new { cNumber = maxCode, cSeed }, trans);
//获取前缀
var sqlPrefix = " Select Prefix1Rule From VoucherNumber Where CardNumber = '0413'";
var prefix = conn.ExecuteScalar<string>(sqlPrefix, null, trans,200,System.Data.CommandType.Text);
//组装Code
var cCode = prefix + cSeed.Substring(2, cSeed.Length - 2) + maxCode.ToString().PadLeft(5, '0');
//主表
var sql = @"insert into MaterialAppVouch(id,ddate,ccode,crdcode,cdepcode,cpersoncode,cmaker,vt_id,iswfcontrolled,dnmaketime,cDefine12)
values(@id,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cmaker,@vt_id,@iswfcontrolled, getdate(),@cDefine12)";
vouch.ID = iFatherId;
vouch.cDefine12 = vouch.CCode;
vouch.CCode = cCode;
conn.Execute(sql, vouch, trans);
sql = @"INSERT INTO MaterialAppVouchs (autoid, id, cinvcode, inum, iquantity , cwhcode, iexpiratdatecalcu, irowno, iordertype, isotype , ipesotype)
VALUES (@autoid, @id, @cinvcode, @inum, @iquantity , @cwhcode, @iexpiratdatecalcu, @irowno, @iordertype, @isotype , @ipesotype)";
//明细
var n = vouch.Vouchs.Count() - 1;
foreach (var item in vouch.Vouchs)
{
item.autoid = iChildId - n;
item.id = iFatherId;
n--;
item.IRowNO = n;
}
conn.Execute(sql, vouch.Vouchs, trans);
trans.Commit();
}
catch (Exception err)
{
trans.Rollback();
throw err;
}
finally
{
conn.Close();
}
return true;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain.Voucher
{
//autoid, id, cinvcode, inum, iquantity, cwhcode, iexpiratdatecalcu, irowno, iordertype, isotype, ipesotype
public class Vouchs
{
public int autoid { get; set; }
public int id { get; set; }
public string CInvCode { get; set; }
public int Inum { get; set; }
public int Iquantity { get; set; }
public string CwhCode { get; set; } = "2";
public int IExpiratdatecalcu { get; set; }
public int IRowNO { get; set; }
public int IorderType { get; set; }
public int ISotype { get; set; }
public int IPesotype { get; set; }
}
}

View File

@@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace U8AppMain
{
public enum WindowsMessages
{
WM_ACTIVATE = 0x6,
WM_ACTIVATEAPP = 0x1C,
WM_AFXFIRST = 0x360,
WM_AFXLAST = 0x37F,
WM_APP = 0x8000,
WM_ASKCBFORMATNAME = 0x30C,
WM_CANCELJOURNAL = 0x4B,
WM_CANCELMODE = 0x1F,
WM_CAPTURECHANGED = 0x215,
WM_CHANGECBCHAIN = 0x30D,
WM_CHAR = 0x102,
WM_CHARTOITEM = 0x2F,
WM_CHILDACTIVATE = 0x22,
WM_CLEAR = 0x303,
WM_CLOSE = 0x10,
WM_COMMAND = 0x111,
WM_COMPACTING = 0x41,
WM_COMPAREITEM = 0x39,
WM_CONTEXTMENU = 0x7B,
WM_COPY = 0x301,
WM_COPYDATA = 0x4A,
WM_CREATE = 0x1,
WM_CTLCOLORBTN = 0x135,
WM_CTLCOLORDLG = 0x136,
WM_CTLCOLOREDIT = 0x133,
WM_CTLCOLORLISTBOX = 0x134,
WM_CTLCOLORMSGBOX = 0x132,
WM_CTLCOLORSCROLLBAR = 0x137,
WM_CTLCOLORSTATIC = 0x138,
WM_CUT = 0x300,
WM_DEADCHAR = 0x103,
WM_DELETEITEM = 0x2D,
WM_DESTROY = 0x2,
WM_DESTROYCLIPBOARD = 0x307,
WM_DEVICECHANGE = 0x219,
WM_DEVMODECHANGE = 0x1B,
WM_DISPLAYCHANGE = 0x7E,
WM_DRAWCLIPBOARD = 0x308,
WM_DRAWITEM = 0x2B,
WM_DROPFILES = 0x233,
WM_ENABLE = 0xA,
WM_ENDSESSION = 0x16,
WM_ENTERIDLE = 0x121,
WM_ENTERMENULOOP = 0x211,
WM_ENTERSIZEMOVE = 0x231,
WM_ERASEBKGND = 0x14,
WM_EXITMENULOOP = 0x212,
WM_EXITSIZEMOVE = 0x232,
WM_FONTCHANGE = 0x1D,
WM_GETDLGCODE = 0x87,
WM_GETFONT = 0x31,
WM_GETHOTKEY = 0x33,
WM_GETICON = 0x7F,
WM_GETMINMAXINFO = 0x24,
WM_GETOBJECT = 0x3D,
WM_GETTEXT = 0xD,
WM_GETTEXTLENGTH = 0xE,
WM_HANDHELDFIRST = 0x358,
WM_HANDHELDLAST = 0x35F,
WM_HELP = 0x53,
WM_HOTKEY = 0x312,
WM_HSCROLL = 0x114,
WM_HSCROLLCLIPBOARD = 0x30E,
WM_ICONERASEBKGND = 0x27,
WM_IME_CHAR = 0x286,
WM_IME_COMPOSITION = 0x10F,
WM_IME_COMPOSITIONFULL = 0x284,
WM_IME_CONTROL = 0x283,
WM_IME_ENDCOMPOSITION = 0x10E,
WM_IME_KEYDOWN = 0x290,
WM_IME_KEYLAST = 0x10F,
WM_IME_KEYUP = 0x291,
WM_IME_NOTIFY = 0x282,
WM_IME_REQUEST = 0x288,
WM_IME_SELECT = 0x285,
WM_IME_SETCONTEXT = 0x281,
WM_IME_STARTCOMPOSITION = 0x10D,
WM_INITDIALOG = 0x110,
WM_INITMENU = 0x116,
WM_INITMENUPOPUP = 0x117,
WM_INPUTLANGCHANGE = 0x51,
WM_INPUTLANGCHANGEREQUEST = 0x50,
WM_KEYDOWN = 0x100,
WM_KEYFIRST = 0x100,
WM_KEYLAST = 0x108,
WM_KEYUP = 0x101,
WM_KILLFOCUS = 0x8,
WM_LBUTTONDBLCLK = 0x203,
WM_LBUTTONDOWN = 0x201,
WM_LBUTTONUP = 0x202,
WM_MBUTTONDBLCLK = 0x209,
WM_MBUTTONDOWN = 0x207,
WM_MBUTTONUP = 0x208,
WM_MDIACTIVATE = 0x222,
WM_MDICASCADE = 0x227,
WM_MDICREATE = 0x220,
WM_MDIDESTROY = 0x221,
WM_MDIGETACTIVE = 0x229,
WM_MDIICONARRANGE = 0x228,
WM_MDIMAXIMIZE = 0x225,
WM_MDINEXT = 0x224,
WM_MDIREFRESHMENU = 0x234,
WM_MDIRESTORE = 0x223,
WM_MDISETMENU = 0x230,
WM_MDITILE = 0x226,
WM_MEASUREITEM = 0x2C,
WM_MENUCHAR = 0x120,
WM_MENUCOMMAND = 0x126,
WM_MENUDRAG = 0x123,
WM_MENUGETOBJECT = 0x124,
WM_MENURBUTTONUP = 0x122,
WM_MENUSELECT = 0x11F,
WM_MOUSEACTIVATE = 0x21,
WM_MOUSEFIRST = 0x200,
WM_MOUSEHOVER = 0x2A1,
WM_MOUSELAST = 0x20A,
WM_MOUSELEAVE = 0x2A3,
WM_MOUSEMOVE = 0x200,
WM_MOUSEWHEEL = 0x20A,
WM_MOVE = 0x3,
WM_MOVING = 0x216,
WM_NCACTIVATE = 0x86,
WM_NCCALCSIZE = 0x83,
WM_NCCREATE = 0x81,
WM_NCDESTROY = 0x82,
WM_NCHITTEST = 0x84,
WM_NCLBUTTONDBLCLK = 0xA3,
WM_NCLBUTTONDOWN = 0xA1,
WM_NCLBUTTONUP = 0xA2,
WM_NCMBUTTONDBLCLK = 0xA9,
WM_NCMBUTTONDOWN = 0xA7,
WM_NCMBUTTONUP = 0xA8,
WM_NCMOUSEHOVER = 0x2A0,
WM_NCMOUSELEAVE = 0x2A2,
WM_NCMOUSEMOVE = 0xA0,
WM_NCPAINT = 0x85,
WM_NCRBUTTONDBLCLK = 0xA6,
WM_NCRBUTTONDOWN = 0xA4,
WM_NCRBUTTONUP = 0xA5,
WM_NEXTDLGCTL = 0x28,
WM_NEXTMENU = 0x213,
WM_NOTIFY = 0x4E,
WM_NOTIFYFORMAT = 0x55,
WM_NULL = 0x0,
WM_PAINT = 0xF,
WM_PAINTCLIPBOARD = 0x309,
WM_PAINTICON = 0x26,
WM_PALETTECHANGED = 0x311,
WM_PALETTEISCHANGING = 0x310,
WM_PARENTNOTIFY = 0x210,
WM_PASTE = 0x302,
WM_PENWINFIRST = 0x380,
WM_PENWINLAST = 0x38F,
WM_POWER = 0x48,
WM_PRINT = 0x317,
WM_PRINTCLIENT = 0x318,
WM_QUERYDRAGICON = 0x37,
WM_QUERYENDSESSION = 0x11,
WM_QUERYNEWPALETTE = 0x30F,
WM_QUERYOPEN = 0x13,
WM_QUEUESYNC = 0x23,
WM_QUIT = 0x12,
WM_RBUTTONDBLCLK = 0x206,
WM_RBUTTONDOWN = 0x204,
WM_RBUTTONUP = 0x205,
WM_RENDERALLFORMATS = 0x306,
WM_RENDERFORMAT = 0x305,
WM_SETCURSOR = 0x20,
WM_SETFOCUS = 0x7,
WM_SETFONT = 0x30,
WM_SETHOTKEY = 0x32,
WM_SETICON = 0x80,
WM_SETREDRAW = 0xB,
WM_SETTEXT = 0xC,
WM_SETTINGCHANGE = 0x1A,
WM_SHOWWINDOW = 0x18,
WM_SIZE = 0x5,
WM_SIZECLIPBOARD = 0x30B,
WM_SIZING = 0x214,
WM_SPOOLERSTATUS = 0x2A,
WM_STYLECHANGED = 0x7D,
WM_STYLECHANGING = 0x7C,
WM_SYNCPAINT = 0x88,
WM_SYSCHAR = 0x106,
WM_SYSCOLORCHANGE = 0x15,
WM_SYSCOMMAND = 0x112,
WM_SYSDEADCHAR = 0x107,
WM_SYSKEYDOWN = 0x104,
WM_SYSKEYUP = 0x105,
WM_TCARD = 0x52,
WM_TIMECHANGE = 0x1E,
WM_TIMER = 0x113,
WM_UNDO = 0x304,
WM_UNINITMENUPOPUP = 0x125,
WM_USER = 0x400,
WM_USERCHANGED = 0x54,
WM_VKEYTOITEM = 0x2E,
WM_VSCROLL = 0x115,
WM_VSCROLLCLIPBOARD = 0x30A,
WM_WINDOWPOSCHANGED = 0x47,
WM_WINDOWPOSCHANGING = 0x46,
WM_WININICHANGE = 0x1A
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace U8AppMain
{
/// <summary>
/// XML转化对象
/// </summary>
public static class XmlHelper
{
private static void XmlSerializeInternal(Stream stream, object o, Encoding encoding)
{
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
XmlSerializer serializer = new XmlSerializer(o.GetType());
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineChars = "\r\n";
settings.Encoding = encoding;
settings.IndentChars = " ";
//settings.NamespaceHandling = NamespaceHandling.OmitDuplicates;
using (XmlWriter writer = XmlWriter.Create(stream, settings))
{
serializer.Serialize(writer, o, ns);
writer.Close();
}
}
/// <summary>
/// 将一个对象序列化为XML字符串
/// </summary>
/// <param name="o">要序列化的对象</param>
/// <param name="encoding">编码方式</param>
/// <returns>序列化产生的XML字符串</returns>
public static string XmlSerialize(object o, Encoding encoding)
{
using (MemoryStream stream = new MemoryStream())
{
XmlSerializeInternal(stream, o, encoding);
stream.Position = 0;
using (StreamReader reader = new StreamReader(stream, encoding))
{
return reader.ReadToEnd();
}
}
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="s"></param>
/// <param name="encoding"></param>
/// <returns></returns>
public static T XmlDeserialize<T>(string s, Encoding encoding)
{
if (string.IsNullOrEmpty(s))
throw new ArgumentNullException("s");
if (encoding == null)
throw new ArgumentNullException("encoding");
XmlSerializer mySerializer = new XmlSerializer(typeof(T));
s = s.Replace(" ", " ");
using (MemoryStream ms = new MemoryStream(encoding.GetBytes(s)))
{
using (StreamReader sr = new StreamReader(ms, encoding))
{
return (T)mySerializer.Deserialize(sr);
}
}
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dapper" version="1.42" targetFramework="net35" />
<package id="NPOI" version="2.2.1" targetFramework="net35" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net35" />
</packages>