diff --git a/U8AppMain/App.config b/U8AppMain/App.config index 30b8937..e4f693f 100644 --- a/U8AppMain/App.config +++ b/U8AppMain/App.config @@ -6,6 +6,6 @@ - + diff --git a/U8AppMain/FrmMain.Designer.cs b/U8AppMain/FrmMain.Designer.cs index 2ee14e2..9f8ea6a 100644 --- a/U8AppMain/FrmMain.Designer.cs +++ b/U8AppMain/FrmMain.Designer.cs @@ -36,8 +36,9 @@ namespace U8AppMain this.ImportBom = new System.Windows.Forms.ToolStripMenuItem(); this.BtnPurchaseImport = new System.Windows.Forms.ToolStripMenuItem(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.领料单ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -70,7 +71,7 @@ namespace U8AppMain // BtnReadExcel // this.BtnReadExcel.Name = "BtnReadExcel"; - this.BtnReadExcel.Size = new System.Drawing.Size(180, 22); + this.BtnReadExcel.Size = new System.Drawing.Size(127, 22); this.BtnReadExcel.Text = "读取Excel"; this.BtnReadExcel.Click += new System.EventHandler(this.BtnReadExcel_Click); // @@ -78,7 +79,8 @@ namespace U8AppMain // this.导入ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ImportBom, - this.BtnPurchaseImport}); + this.BtnPurchaseImport, + this.领料单ToolStripMenuItem}); this.导入ToolStripMenuItem.Name = "导入ToolStripMenuItem"; this.导入ToolStripMenuItem.Size = new System.Drawing.Size(45, 19); this.导入ToolStripMenuItem.Text = "导入"; @@ -116,6 +118,25 @@ namespace U8AppMain 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; @@ -130,24 +151,12 @@ namespace U8AppMain this.richTextBox1.Text = ""; this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); // - // dataGridView1 + // 领料单ToolStripMenuItem // - 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, 4, 4, 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; + 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 // @@ -183,6 +192,7 @@ namespace U8AppMain private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.ToolStripMenuItem 领料单ToolStripMenuItem; } } diff --git a/U8AppMain/FrmMain.cs b/U8AppMain/FrmMain.cs index 6a8d08f..c4f176f 100644 --- a/U8AppMain/FrmMain.cs +++ b/U8AppMain/FrmMain.cs @@ -26,7 +26,7 @@ namespace U8AppMain { this.richTextBox1.SelectionColor = Color.Black; this.richTextBox1.AppendText($"单据:{info.requestroottag} 操作:{info.proc} \r\n"); - + foreach (var item in info.Items) { string tag; @@ -44,7 +44,7 @@ namespace U8AppMain } this.richTextBox1.SelectionColor = Color.Black; this.richTextBox1.AppendText($"---------------------------------------------------------------------------------------\r\n"); - + } @@ -73,6 +73,7 @@ namespace U8AppMain } private string url = ConfigurationManager.AppSettings.Get("url"); + private string connStr = ConfigurationManager.AppSettings.Get("connStr"); private DataTable dataTable; @@ -140,20 +141,20 @@ namespace U8AppMain bom.Bom.ComponentBodies.Add(comp); } } - catch (Exception err) + 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 = await this.HttpPost(strbody); - + PrintLog(response); Application.DoEvents(); } @@ -200,7 +201,7 @@ namespace U8AppMain this.richTextBox1.AppendText("读取数据出错\r\n"); return; } - + foreach (var item in bomLookup.Values) { var strbody = XmlHelper.XmlSerialize(item, Encoding.UTF8); @@ -217,5 +218,30 @@ namespace U8AppMain //滚动到光标位置 richTextBox1.ScrollToCaret(); } + + private void 领料单ToolStripMenuItem_Click(object sender, EventArgs e) + { + var a = new Voucher.VoucherDAL(connStr); + a.Add(new Voucher.Vouch() + { + DDate=DateTime.Today, + CRdCode="201", + CDepCode="5401", + CPersonCode="wx014", + CMaker="朱杰", + Vt_id="30718", + IswfControlled=0, + Vouchs=new List() { + new Voucher.Vouchs(){ + CInvCode="107001", + Iquantity=20, + CwhCode="2", + + + } + + } + });; + } } } diff --git a/U8AppMain/U8AppMain.csproj b/U8AppMain/U8AppMain.csproj index 2643e9d..08f3680 100644 --- a/U8AppMain/U8AppMain.csproj +++ b/U8AppMain/U8AppMain.csproj @@ -93,6 +93,9 @@ + + + FrmMain.cs diff --git a/U8AppMain/Voucher/Vouch.cs b/U8AppMain/Voucher/Vouch.cs new file mode 100644 index 0000000..1e8d932 --- /dev/null +++ b/U8AppMain/Voucher/Vouch.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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 IEnumerable Vouchs { get; set; } = new List(); + + + + + + } +} diff --git a/U8AppMain/Voucher/VoucherDAL.cs b/U8AppMain/Voucher/VoucherDAL.cs new file mode 100644 index 0000000..6046b29 --- /dev/null +++ b/U8AppMain/Voucher/VoucherDAL.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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 void Add(Vouch vouch) + { + + var conn = new SqlConnection(this._connStr); + conn.Open(); + var trans = conn.BeginTransaction(); + try + { + //获取ID + var idEnity = new IdEnity(); + idEnity.cAcc_Id = "003"; + idEnity.cVouchType = "mv"; + idEnity.iAmount = vouch.Vouchs.Count(); + DynamicParameters sp = new DynamicParameters(idEnity); + sp.Add("@iFatherId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output); + sp.Add("@iChildId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output); + conn.Execute("sp_GetID", sp, trans, commandType: System.Data.CommandType.StoredProcedure); + int iFatherId = sp.Get("@iFatherId"); + int iChildId = sp.Get("@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(sqlMax, new { cSeed }, trans); + 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(sqlPrefix, null, trans); + //组装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) + values(@id,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cmaker,@vt_id,@iswfcontrolled, getdate())"; + vouch.ID = iFatherId; + 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(); + 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(); + } + + + + + + + + + } + } +} diff --git a/U8AppMain/Voucher/Vouchs.cs b/U8AppMain/Voucher/Vouchs.cs new file mode 100644 index 0000000..d167ff4 --- /dev/null +++ b/U8AppMain/Voucher/Vouchs.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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; } + + 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; } + + } +}