diff --git a/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs b/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs index 06b917d..f360a69 100644 --- a/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs +++ b/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutForm.cs @@ -9,6 +9,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using WinFormControl; @@ -32,6 +33,9 @@ namespace ButcherFactory.CarcassSaleOut_ BindingList saleOutStoreList; BindingList details; BindingList weightRecord; + Thread checkWeight; + string strErrorWeight = ""; + List errorWeight = new List(); internal DateTime sendTime = DateTime.Today; internal long? deliverGoodsLineID; internal long? customerID; @@ -43,6 +47,11 @@ namespace ButcherFactory.CarcassSaleOut_ { InitializeComponent(); this.Resize += CarcassSaleOutForm_Resize; + this.FormClosing += delegate + { + if (checkWeight != null && checkWeight.IsAlive) + checkWeight.Abort(); + }; uWeightControl1.ReceivedValue += uWeightControl1_ReceivedValue; uScanPanel1.AfterScan += uScanPanel1_AfterScan; @@ -81,7 +90,12 @@ namespace ButcherFactory.CarcassSaleOut_ storeBox.Text = config.Store_Name; storeID = config.Store_ID; } - + if (!string.IsNullOrEmpty(config.Weight)) + { + strErrorWeight = config.Weight; + var arr = strErrorWeight.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).OrderBy(x => x); + errorWeight.AddRange(arr); + } this.mainGridView.BorderStyle = BorderStyle.FixedSingle; BindWeightRecord(); BindProductBatch(); @@ -134,10 +148,20 @@ namespace ButcherFactory.CarcassSaleOut_ AfterScan("G8536"); else sendGridView.Refresh(); + checkWeight = new Thread(new ParameterizedThreadStart(CheckWeight)); + checkWeight.Start(weight); })); } } + void CheckWeight(object objWeight) + { + decimal weight = (decimal)objWeight; + var first = errorWeight.FirstOrDefault(x => x > weight); + if (first != 0) + SoundPalyUtil.PlaySound(string.Format("Sounds\\l{0}.wav", first)); + } + void uScanPanel1_AfterScan() { var barCode = uScanPanel1.TextBox.Text.Trim(); @@ -293,7 +317,7 @@ namespace ButcherFactory.CarcassSaleOut_ { textBox.Text = sb.Result.Item1; storeID = sb.Result.Item2; - XmlUtil.SerializerObjToFile(new CarcassSaleOutFormConfig { Store_ID = storeID, Store_Name = textBox.Text }); + XmlUtil.SerializerObjToFile(new CarcassSaleOutFormConfig { Weight = strErrorWeight, Store_ID = storeID, Store_Name = textBox.Text }); } break; } diff --git a/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutFormConfig.cs b/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutFormConfig.cs index d684b18..d475895 100644 --- a/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutFormConfig.cs +++ b/ButcherFactory.Form/CarcassSaleOut_/CarcassSaleOutFormConfig.cs @@ -11,5 +11,7 @@ namespace ButcherFactory.CarcassSaleOut_ public long? Store_ID { get; set; } public string Store_Name { get; set; } + + public string Weight { get; set; } } } diff --git a/ButcherFactorySolution.sln b/ButcherFactorySolution.sln index 2a1fa65..11c412a 100644 --- a/ButcherFactorySolution.sln +++ b/ButcherFactorySolution.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ButcherFactory.Login", "But EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ButcherFactory.Tools", "ButcherFactory.Tools\ButcherFactory.Tools.csproj", "{788A10A5-154A-4590-9DDA-60AA22FBC42F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SelfHelpClient", "SelfHelpClient\SelfHelpClient.csproj", "{51EF4E9D-1148-4055-8B1A-9A9DBCA12A03}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -37,6 +39,10 @@ Global {788A10A5-154A-4590-9DDA-60AA22FBC42F}.Debug|Any CPU.Build.0 = Debug|Any CPU {788A10A5-154A-4590-9DDA-60AA22FBC42F}.Release|Any CPU.ActiveCfg = Release|Any CPU {788A10A5-154A-4590-9DDA-60AA22FBC42F}.Release|Any CPU.Build.0 = Release|Any CPU + {51EF4E9D-1148-4055-8B1A-9A9DBCA12A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51EF4E9D-1148-4055-8B1A-9A9DBCA12A03}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51EF4E9D-1148-4055-8B1A-9A9DBCA12A03}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51EF4E9D-1148-4055-8B1A-9A9DBCA12A03}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SelfHelpClient/BL/WeightBillBL.cs b/SelfHelpClient/BL/WeightBillBL.cs new file mode 100644 index 0000000..eab832d --- /dev/null +++ b/SelfHelpClient/BL/WeightBillBL.cs @@ -0,0 +1,52 @@ +using Newtonsoft.Json; +using SelfHelpClient.BO; +using SelfHelpClient.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SelfHelpClient.BL +{ + public static class WeightBillBL + { + public static string ServerUrl; + static string MethodHead = "/MainSystem/B3ClientService/Rpcs/SelfHelpRpc/"; + + private static ClientRpc mRpc; + public static ClientRpc Rpc + { + get + { + if (mRpc == null) + mRpc = new ClientRpc(ServerUrl); + return mRpc; + } + } + + public static List GetViewEntity(string idCard) + { + var json = Rpc.Call(MethodHead + "GetViewEntity", idCard); + return JsonConvert.DeserializeObject>(json); + } + + public static WeightBill CreateWeightBill(long id) + { + var json = Rpc.Call(MethodHead + "CreateWeightBill", id); + return JsonConvert.DeserializeObject(json); + } + + public static WeightBill GetWeightBill(long id) + { + var json = Rpc.Call(MethodHead + "GetWeightBill", id); + return JsonConvert.DeserializeObject(json); + } + + public static List GetWeightDetail(long id) + { + var json = Rpc.Call(MethodHead + "GetWeightDetail", id); + return JsonConvert.DeserializeObject>(json); + } + } +} diff --git a/SelfHelpClient/BO/ViewEntity.cs b/SelfHelpClient/BO/ViewEntity.cs new file mode 100644 index 0000000..71a764f --- /dev/null +++ b/SelfHelpClient/BO/ViewEntity.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SelfHelpClient.BO +{ + public class ViewEntity + { + public long ID { get; set; } + + public int BillType { get; set; } + + public string CarNumber { get; set; } + + public int Number { get; set; } + + public DateTime Date { get; set; } + } +} diff --git a/SelfHelpClient/BO/WeightBill.cs b/SelfHelpClient/BO/WeightBill.cs new file mode 100644 index 0000000..2358b3c --- /dev/null +++ b/SelfHelpClient/BO/WeightBill.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SelfHelpClient.BO +{ + public class WeightBill + { + public long ID { get; set; } + public string Supplier_Name { get; set; } + + public string PurchaseType_Name { get; set; } + + public DateTime WeighTime { get; set; } + + public string Car_Name { get; set; } + + public string Employee_Name { get; set; } + + public decimal? JingJianFee { get; set; } + + public decimal? DiscontMoney { get; set; } + + public decimal? ShackWeight { get; set; } + + public decimal? ShackPrice { get; set; } + + public decimal? ShackMoney { get; set; } + + public string AnimalTestMan { get; set; } + + public string AnimalTestNumber { get; set; } + + public DateTime? AnimalTestDate { get; set; } + + public List FarmerDetails { get; set; } + + public List Details { get; set; } + } +} diff --git a/SelfHelpClient/BO/WeightBill_FarmerDetail.cs b/SelfHelpClient/BO/WeightBill_FarmerDetail.cs new file mode 100644 index 0000000..04aa9a7 --- /dev/null +++ b/SelfHelpClient/BO/WeightBill_FarmerDetail.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SelfHelpClient.BO +{ + public class WeightBill_FarmerDetail + { + public int Index { get; set; } + + public string Farmer_Name { get; set; } + + public int? Number { get; set; } + + public decimal? Weight { get; set; } + + public decimal? Money { get; set; } + + public string Farmer_IDCard { get; set; } + + public string Farmer_BankAccount { get; set; } + + public string Farmer_Tel { get; set; } + + public string Farmer_Address { get; set; } + } +} diff --git a/SelfHelpClient/BO/WeightBill_WeightDetail.cs b/SelfHelpClient/BO/WeightBill_WeightDetail.cs new file mode 100644 index 0000000..65c22c5 --- /dev/null +++ b/SelfHelpClient/BO/WeightBill_WeightDetail.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SelfHelpClient.BO +{ + public class WeightBill_WeightDetail + { + public string Index { get; set; } + + public int? Number { get; set; } + + public decimal? PiWeight { get; set; } + + public decimal? MaoWeight { get; set; } + + public decimal? Weight { get; set; } + } +} diff --git a/SelfHelpClient/DialogForm.Designer.cs b/SelfHelpClient/DialogForm.Designer.cs new file mode 100644 index 0000000..a2b6918 --- /dev/null +++ b/SelfHelpClient/DialogForm.Designer.cs @@ -0,0 +1,86 @@ +namespace SelfHelpClient +{ + partial class DialogForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.msgLbl = new WinFormControl.ULabel(); + this.okBtn = new WinFormControl.NButton(); + this.SuspendLayout(); + // + // msgLbl + // + this.msgLbl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.msgLbl.BackColor = System.Drawing.Color.Transparent; + this.msgLbl.Font = new System.Drawing.Font("宋体", 18F); + this.msgLbl.ForeColor = System.Drawing.Color.Red; + this.msgLbl.Location = new System.Drawing.Point(64, 43); + this.msgLbl.Name = "msgLbl"; + this.msgLbl.Size = new System.Drawing.Size(286, 97); + this.msgLbl.TabIndex = 0; + this.msgLbl.Text = "uLabel1"; + this.msgLbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // okBtn + // + this.okBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.okBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.okBtn.Font = new System.Drawing.Font("宋体", 18F); + this.okBtn.ForeColor = System.Drawing.Color.White; + this.okBtn.Location = new System.Drawing.Point(124, 156); + this.okBtn.Name = "okBtn"; + this.okBtn.PlaySound = false; + this.okBtn.Size = new System.Drawing.Size(158, 63); + this.okBtn.SoundType = WinFormControl.SoundType.Click; + this.okBtn.TabIndex = 1; + this.okBtn.Text = "nButton1"; + this.okBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.okBtn.UseVisualStyleBackColor = false; + this.okBtn.Click += new System.EventHandler(this.okBtn_Click); + // + // DialogForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(417, 251); + this.Controls.Add(this.okBtn); + this.Controls.Add(this.msgLbl); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "DialogForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "DialogForm"; + this.ResumeLayout(false); + + } + + #endregion + + private WinFormControl.ULabel msgLbl; + private WinFormControl.NButton okBtn; + } +} \ No newline at end of file diff --git a/SelfHelpClient/DialogForm.cs b/SelfHelpClient/DialogForm.cs new file mode 100644 index 0000000..1e04b08 --- /dev/null +++ b/SelfHelpClient/DialogForm.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + public partial class DialogForm : Form + { + + System.Timers.Timer timer; + int sec = 0; + private DialogForm(string msg, int closeSec) + { + InitializeComponent(); + msgLbl.Text = msg; + okBtn.Text = "确定"; + if (closeSec > 0) + { + sec = closeSec; + timer = new System.Timers.Timer(); + timer.Interval = 1000; + timer.Elapsed += timer_Elapsed; + timer.Start(); + } + this.FormClosing += DialogForm_FormClosing; + } + + void DialogForm_FormClosing(object sender, FormClosingEventArgs e) + { + if (timer != null) + { + if (timer.Enabled) + timer.Enabled = false; + timer.Dispose(); + } + } + + void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + this.Invoke(new Action(() => + { + if (sec > 0) + { + this.okBtn.Text = string.Format("确定({0}秒)", sec); + sec--; + } + else + { + timer.Enabled = false; + this.Close(); + } + })); + } + + public static void ShowDialog(string msg, int closeSec = 0) + { + var d = new DialogForm(msg, closeSec); + d.ShowDialog(); + } + + private void okBtn_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/SelfHelpClient/DialogForm.resx b/SelfHelpClient/DialogForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SelfHelpClient/DialogForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SelfHelpClient/ItemSelect.Designer.cs b/SelfHelpClient/ItemSelect.Designer.cs new file mode 100644 index 0000000..a67277d --- /dev/null +++ b/SelfHelpClient/ItemSelect.Designer.cs @@ -0,0 +1,173 @@ +namespace SelfHelpClient +{ + partial class ItemSelect + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + this.uDataGridView1 = new WinFormControl.UDataGridView(); + this.R_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.R_CarNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.R_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.R_Date = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.uLabel1 = new WinFormControl.ULabel(); + this.backBtn = new WinFormControl.NButton(); + ((System.ComponentModel.ISupportInitialize)(this.uDataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // uDataGridView1 + // + this.uDataGridView1.AllowUserToAddRows = false; + this.uDataGridView1.AllowUserToDeleteRows = false; + this.uDataGridView1.AllowUserToResizeColumns = false; + this.uDataGridView1.AllowUserToResizeRows = false; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.uDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.uDataGridView1.BackgroundColor = System.Drawing.Color.White; + this.uDataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 23F); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.uDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.uDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.uDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.R_ID, + this.R_CarNumber, + this.R_Number, + this.R_Date}); + this.uDataGridView1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.uDataGridView1.Location = new System.Drawing.Point(0, 68); + this.uDataGridView1.MultiSelect = false; + this.uDataGridView1.Name = "uDataGridView1"; + this.uDataGridView1.ReadOnly = true; + this.uDataGridView1.RowHeadersVisible = false; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 18F); + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.uDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle4; + this.uDataGridView1.RowTemplate.Height = 80; + this.uDataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.uDataGridView1.Size = new System.Drawing.Size(650, 332); + this.uDataGridView1.TabIndex = 0; + this.uDataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.uDataGridView1_CellClick); + // + // R_ID + // + this.R_ID.HeaderText = "ID"; + this.R_ID.Name = "R_ID"; + this.R_ID.ReadOnly = true; + this.R_ID.Visible = false; + // + // R_CarNumber + // + this.R_CarNumber.DataPropertyName = "CarNumber"; + this.R_CarNumber.HeaderText = "车辆"; + this.R_CarNumber.Name = "R_CarNumber"; + this.R_CarNumber.ReadOnly = true; + this.R_CarNumber.Width = 220; + // + // R_Number + // + this.R_Number.DataPropertyName = "Number"; + this.R_Number.HeaderText = "头数"; + this.R_Number.Name = "R_Number"; + this.R_Number.ReadOnly = true; + this.R_Number.Width = 150; + // + // R_Date + // + this.R_Date.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.R_Date.DataPropertyName = "Date"; + dataGridViewCellStyle3.Format = "yyyy-MM-dd HH:mm:ss"; + this.R_Date.DefaultCellStyle = dataGridViewCellStyle3; + this.R_Date.HeaderText = "时间"; + this.R_Date.Name = "R_Date"; + this.R_Date.ReadOnly = true; + // + // uLabel1 + // + this.uLabel1.AutoSize = true; + this.uLabel1.BackColor = System.Drawing.Color.Transparent; + this.uLabel1.Font = new System.Drawing.Font("宋体", 18F); + this.uLabel1.ForeColor = System.Drawing.Color.Red; + this.uLabel1.Location = new System.Drawing.Point(12, 19); + this.uLabel1.Name = "uLabel1"; + this.uLabel1.Size = new System.Drawing.Size(298, 24); + this.uLabel1.TabIndex = 1; + this.uLabel1.Text = "请选择要办理的送猪信息单"; + // + // backBtn + // + this.backBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.backBtn.Font = new System.Drawing.Font("宋体", 18F); + this.backBtn.ForeColor = System.Drawing.Color.White; + this.backBtn.Location = new System.Drawing.Point(533, 3); + this.backBtn.Name = "backBtn"; + this.backBtn.PlaySound = false; + this.backBtn.Size = new System.Drawing.Size(113, 63); + this.backBtn.SoundType = WinFormControl.SoundType.Click; + this.backBtn.TabIndex = 2; + this.backBtn.TabStop = false; + this.backBtn.Text = "返回"; + this.backBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.UseVisualStyleBackColor = false; + this.backBtn.Click += new System.EventHandler(this.backBtn_Click); + // + // ItemSelect + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Control; + this.ClientSize = new System.Drawing.Size(650, 400); + this.Controls.Add(this.backBtn); + this.Controls.Add(this.uLabel1); + this.Controls.Add(this.uDataGridView1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "ItemSelect"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ItemSelect"; + ((System.ComponentModel.ISupportInitialize)(this.uDataGridView1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private WinFormControl.UDataGridView uDataGridView1; + private WinFormControl.ULabel uLabel1; + private WinFormControl.NButton backBtn; + private System.Windows.Forms.DataGridViewTextBoxColumn R_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn R_CarNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn R_Number; + private System.Windows.Forms.DataGridViewTextBoxColumn R_Date; + } +} \ No newline at end of file diff --git a/SelfHelpClient/ItemSelect.cs b/SelfHelpClient/ItemSelect.cs new file mode 100644 index 0000000..ca8954b --- /dev/null +++ b/SelfHelpClient/ItemSelect.cs @@ -0,0 +1,45 @@ +using SelfHelpClient.BO; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + public partial class ItemSelect : Form + { + List list; + ReadCardForm form; + public ItemSelect(List mlist, ReadCardForm mForm) + { + InitializeComponent(); + form = mForm; + list = mlist; + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + uDataGridView1.DataSource = list; + uDataGridView1.Refresh(); + } + + private void uDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex < 0) + return; + form.VEntity = uDataGridView1.CurrentRow.DataBoundItem as ViewEntity; + DialogResult = DialogResult.OK; + } + + private void backBtn_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/SelfHelpClient/ItemSelect.resx b/SelfHelpClient/ItemSelect.resx new file mode 100644 index 0000000..bae4ac0 --- /dev/null +++ b/SelfHelpClient/ItemSelect.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/SelfHelpClient/MainForm.Designer.cs b/SelfHelpClient/MainForm.Designer.cs new file mode 100644 index 0000000..cd35800 --- /dev/null +++ b/SelfHelpClient/MainForm.Designer.cs @@ -0,0 +1,125 @@ +namespace SelfHelpClient +{ + partial class MainForm + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.weightBtn = new WinFormControl.NButton(); + this.selfBtn = new WinFormControl.NButton(); + this.testClose = new WinFormControl.NButton(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.panel1.Controls.Add(this.weightBtn); + this.panel1.Controls.Add(this.selfBtn); + this.panel1.Location = new System.Drawing.Point(136, 137); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(644, 271); + this.panel1.TabIndex = 0; + // + // weightBtn + // + this.weightBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.weightBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.weightBtn.Font = new System.Drawing.Font("宋体", 23F); + this.weightBtn.ForeColor = System.Drawing.Color.White; + this.weightBtn.Location = new System.Drawing.Point(392, 64); + this.weightBtn.Name = "weightBtn"; + this.weightBtn.PlaySound = true; + this.weightBtn.Size = new System.Drawing.Size(235, 128); + this.weightBtn.SoundType = WinFormControl.SoundType.Click; + this.weightBtn.TabIndex = 1; + this.weightBtn.Text = "送猪过磅"; + this.weightBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.weightBtn.UseVisualStyleBackColor = false; + this.weightBtn.Click += new System.EventHandler(this.weightBtn_Click); + // + // selfBtn + // + this.selfBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.selfBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.selfBtn.Font = new System.Drawing.Font("宋体", 23F); + this.selfBtn.ForeColor = System.Drawing.Color.White; + this.selfBtn.Location = new System.Drawing.Point(23, 64); + this.selfBtn.Name = "selfBtn"; + this.selfBtn.PlaySound = true; + this.selfBtn.Size = new System.Drawing.Size(235, 128); + this.selfBtn.SoundType = WinFormControl.SoundType.Click; + this.selfBtn.TabIndex = 0; + this.selfBtn.Text = "自助服务"; + this.selfBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.selfBtn.UseVisualStyleBackColor = false; + this.selfBtn.Click += new System.EventHandler(this.selfBtn_Click); + // + // testClose + // + this.testClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.testClose.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.testClose.ClickColor = System.Drawing.Color.YellowGreen; + this.testClose.Font = new System.Drawing.Font("宋体", 12F); + this.testClose.ForeColor = System.Drawing.Color.White; + this.testClose.Location = new System.Drawing.Point(798, 12); + this.testClose.Name = "testClose"; + this.testClose.PlaySound = false; + this.testClose.Size = new System.Drawing.Size(99, 59); + this.testClose.SoundType = WinFormControl.SoundType.Click; + this.testClose.TabIndex = 1; + this.testClose.Text = "测试用"; + this.testClose.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.testClose.UseVisualStyleBackColor = false; + this.testClose.Click += new System.EventHandler(this.testClose_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.LightGray; + this.ClientSize = new System.Drawing.Size(928, 521); + this.Controls.Add(this.testClose); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "MainForm"; + this.Text = "Form1"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private WinFormControl.NButton selfBtn; + private WinFormControl.NButton weightBtn; + private WinFormControl.NButton testClose; + } +} + diff --git a/SelfHelpClient/MainForm.cs b/SelfHelpClient/MainForm.cs new file mode 100644 index 0000000..ba7dfea --- /dev/null +++ b/SelfHelpClient/MainForm.cs @@ -0,0 +1,67 @@ +using SelfHelpClient.BL; +using SelfHelpClient.BO; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + public partial class MainForm : Form + { + private static MainForm mForm; + public static MainForm Form + { + get { return mForm; } + } + public MainForm() + { + if (!File.Exists("AppConfig.cfg")) + { + MessageBox.Show("请先配置服务器地址"); + this.Close(); + } + WeightBillBL.ServerUrl = File.ReadAllText("AppConfig.cfg"); + mForm = this; + InitializeComponent(); + } + + private void selfBtn_Click(object sender, EventArgs e) + { + var entity = ReadCard(); + if (entity == null) + return; + if (entity.BillType == 0) + return; + new SelfHelpForm(entity.ID).Show(); + this.Hide(); + } + + private void weightBtn_Click(object sender, EventArgs e) + { + var entity = ReadCard(); + if (entity == null) + return; + new WeightForm(entity).Show(); + this.Hide(); + } + + ViewEntity ReadCard() + { + var reader = new ReadCardForm(); + if (reader.ShowDialog() == DialogResult.OK) + return reader.VEntity; + return null; ; + } + + private void testClose_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/SelfHelpClient/MainForm.resx b/SelfHelpClient/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SelfHelpClient/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SelfHelpClient/Program.cs b/SelfHelpClient/Program.cs new file mode 100644 index 0000000..075d091 --- /dev/null +++ b/SelfHelpClient/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/SelfHelpClient/Properties/AssemblyInfo.cs b/SelfHelpClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c631dc7 --- /dev/null +++ b/SelfHelpClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SelfHelpClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SelfHelpClient")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("d68a4767-63a5-414c-af38-9111ad6b3e03")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SelfHelpClient/Properties/Resources.Designer.cs b/SelfHelpClient/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9b8580d --- /dev/null +++ b/SelfHelpClient/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace SelfHelpClient.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [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("SelfHelpClient.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 使用此强类型资源类,为所有资源查找 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/SelfHelpClient/Properties/Resources.resx b/SelfHelpClient/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/SelfHelpClient/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SelfHelpClient/Properties/Settings.Designer.cs b/SelfHelpClient/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d169858 --- /dev/null +++ b/SelfHelpClient/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace SelfHelpClient.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.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; + } + } + } +} diff --git a/SelfHelpClient/Properties/Settings.settings b/SelfHelpClient/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/SelfHelpClient/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SelfHelpClient/ReadCardForm.Designer.cs b/SelfHelpClient/ReadCardForm.Designer.cs new file mode 100644 index 0000000..e938951 --- /dev/null +++ b/SelfHelpClient/ReadCardForm.Designer.cs @@ -0,0 +1,88 @@ +namespace SelfHelpClient +{ + partial class ReadCardForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.uLabel1 = new WinFormControl.ULabel(); + this.backBtn = new WinFormControl.NButton(); + this.SuspendLayout(); + // + // uLabel1 + // + this.uLabel1.AutoSize = true; + this.uLabel1.BackColor = System.Drawing.Color.Transparent; + this.uLabel1.Font = new System.Drawing.Font("宋体", 23F); + this.uLabel1.ForeColor = System.Drawing.Color.Red; + this.uLabel1.Location = new System.Drawing.Point(222, 147); + this.uLabel1.Name = "uLabel1"; + this.uLabel1.Size = new System.Drawing.Size(200, 31); + this.uLabel1.TabIndex = 0; + this.uLabel1.Text = "请扫描身份证"; + // + // backBtn + // + this.backBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.backBtn.Font = new System.Drawing.Font("宋体", 18F); + this.backBtn.ForeColor = System.Drawing.Color.White; + this.backBtn.Location = new System.Drawing.Point(529, 12); + this.backBtn.Name = "backBtn"; + this.backBtn.PlaySound = false; + this.backBtn.Size = new System.Drawing.Size(113, 63); + this.backBtn.SoundType = WinFormControl.SoundType.Click; + this.backBtn.TabIndex = 1; + this.backBtn.TabStop = false; + this.backBtn.Text = "返回"; + this.backBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.UseVisualStyleBackColor = false; + this.backBtn.Click += new System.EventHandler(this.backBtn_Click); + // + // ReadCardForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(650, 355); + this.Controls.Add(this.backBtn); + this.Controls.Add(this.uLabel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.ImeMode = System.Windows.Forms.ImeMode.Disable; + this.KeyPreview = true; + this.Name = "ReadCardForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private WinFormControl.ULabel uLabel1; + private WinFormControl.NButton backBtn; + } +} \ No newline at end of file diff --git a/SelfHelpClient/ReadCardForm.cs b/SelfHelpClient/ReadCardForm.cs new file mode 100644 index 0000000..3be9270 --- /dev/null +++ b/SelfHelpClient/ReadCardForm.cs @@ -0,0 +1,58 @@ +using SelfHelpClient.BL; +using SelfHelpClient.BO; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + public partial class ReadCardForm : Form + { + string _cardNumber = ""; + public ViewEntity VEntity { get; set; } + public ReadCardForm() + { + InitializeComponent(); + this.KeyPress += ReadCardForm_KeyPress; + } + + void ReadCardForm_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == (char)Keys.Tab) + { + FillViewEntity(_cardNumber); + DialogResult = DialogResult.OK; + } + else + _cardNumber += e.KeyChar.ToString(); + } + + private void FillViewEntity(string idCard) + { + var list = WeightBillBL.GetViewEntity(idCard); + if (list.Count == 0) + { + DialogForm.ShowDialog("没有待办理业务", 5); + this.Close(); + } + else if (list.Count == 1) + VEntity = list.First(); + else + { + new ItemSelect(list, this).ShowDialog(); + } + } + + private void backBtn_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/SelfHelpClient/ReadCardForm.resx b/SelfHelpClient/ReadCardForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SelfHelpClient/ReadCardForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SelfHelpClient/SelfHelpClient.csproj b/SelfHelpClient/SelfHelpClient.csproj new file mode 100644 index 0000000..f9f6024 --- /dev/null +++ b/SelfHelpClient/SelfHelpClient.csproj @@ -0,0 +1,149 @@ + + + + + Debug + AnyCPU + {51EF4E9D-1148-4055-8B1A-9A9DBCA12A03} + WinExe + Properties + SelfHelpClient + SelfHelpClient + v4.5 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + False + ..\..\..\tsref\release\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + Form + + + DialogForm.cs + + + Form + + + ItemSelect.cs + + + Form + + + MainForm.cs + + + + + Form + + + ReadCardForm.cs + + + Form + + + SelfHelpForm.cs + + + + + + + Form + + + WeightForm.cs + + + DialogForm.cs + + + ItemSelect.cs + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + ReadCardForm.cs + + + SelfHelpForm.cs + + + WeightForm.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/SelfHelpClient/SelfHelpForm.Designer.cs b/SelfHelpClient/SelfHelpForm.Designer.cs new file mode 100644 index 0000000..a51acb8 --- /dev/null +++ b/SelfHelpClient/SelfHelpForm.Designer.cs @@ -0,0 +1,123 @@ +namespace SelfHelpClient +{ + partial class SelfHelpForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.weightPrintBtn = new WinFormControl.NButton(); + this.washCarBtn = new WinFormControl.NButton(); + this.backBtn = new WinFormControl.NButton(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.panel1.Controls.Add(this.weightPrintBtn); + this.panel1.Controls.Add(this.washCarBtn); + this.panel1.Location = new System.Drawing.Point(136, 137); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(644, 271); + this.panel1.TabIndex = 1; + // + // weightPrintBtn + // + this.weightPrintBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.weightPrintBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.weightPrintBtn.Font = new System.Drawing.Font("宋体", 23F); + this.weightPrintBtn.ForeColor = System.Drawing.Color.White; + this.weightPrintBtn.Location = new System.Drawing.Point(392, 64); + this.weightPrintBtn.Name = "weightPrintBtn"; + this.weightPrintBtn.PlaySound = true; + this.weightPrintBtn.Size = new System.Drawing.Size(235, 128); + this.weightPrintBtn.SoundType = WinFormControl.SoundType.Click; + this.weightPrintBtn.TabIndex = 1; + this.weightPrintBtn.Text = "打印过磅单"; + this.weightPrintBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.weightPrintBtn.UseVisualStyleBackColor = false; + // + // washCarBtn + // + this.washCarBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.washCarBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.washCarBtn.Font = new System.Drawing.Font("宋体", 23F); + this.washCarBtn.ForeColor = System.Drawing.Color.White; + this.washCarBtn.Location = new System.Drawing.Point(23, 64); + this.washCarBtn.Name = "washCarBtn"; + this.washCarBtn.PlaySound = true; + this.washCarBtn.Size = new System.Drawing.Size(235, 128); + this.washCarBtn.SoundType = WinFormControl.SoundType.Click; + this.washCarBtn.TabIndex = 0; + this.washCarBtn.Text = "打印洗车单"; + this.washCarBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.washCarBtn.UseVisualStyleBackColor = false; + // + // backBtn + // + this.backBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.backBtn.Font = new System.Drawing.Font("宋体", 18F); + this.backBtn.ForeColor = System.Drawing.Color.White; + this.backBtn.Location = new System.Drawing.Point(798, 12); + this.backBtn.Name = "backBtn"; + this.backBtn.PlaySound = false; + this.backBtn.Size = new System.Drawing.Size(113, 63); + this.backBtn.SoundType = WinFormControl.SoundType.Click; + this.backBtn.TabIndex = 3; + this.backBtn.TabStop = false; + this.backBtn.Text = "返回"; + this.backBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.UseVisualStyleBackColor = false; + this.backBtn.Click += new System.EventHandler(this.backBtn_Click); + // + // SelfHelpForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.LightGray; + this.ClientSize = new System.Drawing.Size(923, 507); + this.Controls.Add(this.backBtn); + this.Controls.Add(this.panel1); + this.ForeColor = System.Drawing.SystemColors.ControlText; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "SelfHelpForm"; + this.Text = "SelfHelpForm"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private WinFormControl.NButton weightPrintBtn; + private WinFormControl.NButton washCarBtn; + private WinFormControl.NButton backBtn; + } +} \ No newline at end of file diff --git a/SelfHelpClient/SelfHelpForm.cs b/SelfHelpClient/SelfHelpForm.cs new file mode 100644 index 0000000..8de6b05 --- /dev/null +++ b/SelfHelpClient/SelfHelpForm.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + public partial class SelfHelpForm : Form + { + public SelfHelpForm(long id) + { + InitializeComponent(); + } + + private void backBtn_Click(object sender, EventArgs e) + { + MainForm.Form.Show(); + this.Close(); + } + } +} diff --git a/SelfHelpClient/SelfHelpForm.resx b/SelfHelpClient/SelfHelpForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SelfHelpClient/SelfHelpForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SelfHelpClient/Utils/ClientRpc.cs b/SelfHelpClient/Utils/ClientRpc.cs new file mode 100644 index 0000000..3a9f36b --- /dev/null +++ b/SelfHelpClient/Utils/ClientRpc.cs @@ -0,0 +1,124 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace SelfHelpClient.Utils +{ + public class ClientRpc + { + public ClientRpc(string url) + { + mUrl = url; + } + + class _Error + { + public int? code { get; set; } + public string message { get; set; } + } + class _ErrorResposne + { + public _Error error { get; set; } + } + + string mUrl; + + public string Url + { + get + { + return mUrl; + } + } + + public T Call(string method, params object[] args) + { + var resp = DoCall(method, args); + + if (resp.error != null) + { + throw new Exception(string.Format("{0}:{1}", resp.error.code, resp.error.message)); + } + + return resp.result; + } + + LRestClientReponse DoCall(string method, object[] args) + { + var request = (HttpWebRequest)WebRequest.Create(mUrl); + request.Method = "POST"; + request.ContentType = "application/json"; + var dic = new Dictionary(); + dic.Add("method", method); + dic.Add("id", 1); + dic.Add("params", args); + + var json = JsonConvert.SerializeObject(dic); + + var buffer = Encoding.UTF8.GetBytes(json); + + var requestStream = request.GetRequestStream(); + requestStream.Write(buffer, 0, buffer.Length); + + var responseJson = GetResponseJSON(request); + + try + { + var result = JsonConvert.DeserializeObject>(responseJson); + return result; + } + catch + { + try + { + var errorResponse = JsonConvert.DeserializeObject<_ErrorResposne>(responseJson); + if (errorResponse.error != null) + { + throw new Exception(errorResponse.error.message); + } + } + catch + { + throw new Exception("JSON反序列化失败:" + responseJson); + } + throw new Exception("JSON反序列化失败:" + responseJson); + } + + } + + public class LRestClientReponseError + { + public string code { get; set; } + public string message { get; set; } + + public override string ToString() + { + return string.Format("{0}:{1}", code, message); + } + } + + public class LRestClientReponse + { + public long id { get; set; } + public LRestClientReponseError error { get; set; } + public T result { get; set; } + } + + private static string GetResponseJSON(HttpWebRequest request) + { + var response = request.GetResponse(); + using (var stream = response.GetResponseStream()) + { + using (var reader = new StreamReader(stream, Encoding.UTF8)) + { + return reader.ReadToEnd(); + } + } + } + } +} diff --git a/SelfHelpClient/WeightForm.Designer.cs b/SelfHelpClient/WeightForm.Designer.cs new file mode 100644 index 0000000..391297c --- /dev/null +++ b/SelfHelpClient/WeightForm.Designer.cs @@ -0,0 +1,400 @@ +namespace SelfHelpClient +{ + partial class WeightForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + this.panel1 = new System.Windows.Forms.Panel(); + this.backBtn = new WinFormControl.NButton(); + this.okBtn = new WinFormControl.NButton(); + this.panel2 = new System.Windows.Forms.Panel(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.weightGrid = new WinFormControl.UDataGridView(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.farmerGrid = new WinFormControl.UDataGridView(); + this.F_Index = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Money = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_IDCard = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_BankAccount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_Tel = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_Address = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.D_Index = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.D_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.D_MaoWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.D_PiWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.D_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.weightGrid)).BeginInit(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.farmerGrid)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.panel1.Controls.Add(this.backBtn); + this.panel1.Controls.Add(this.okBtn); + this.panel1.Location = new System.Drawing.Point(168, 394); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(614, 100); + this.panel1.TabIndex = 0; + // + // backBtn + // + this.backBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.backBtn.Font = new System.Drawing.Font("宋体", 23F); + this.backBtn.ForeColor = System.Drawing.Color.White; + this.backBtn.Location = new System.Drawing.Point(352, 3); + this.backBtn.Name = "backBtn"; + this.backBtn.PlaySound = false; + this.backBtn.Size = new System.Drawing.Size(162, 94); + this.backBtn.SoundType = WinFormControl.SoundType.Click; + this.backBtn.TabIndex = 1; + this.backBtn.Text = "返回"; + this.backBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.backBtn.UseVisualStyleBackColor = false; + this.backBtn.Click += new System.EventHandler(this.backBtn_Click); + // + // okBtn + // + this.okBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.okBtn.ClickColor = System.Drawing.Color.YellowGreen; + this.okBtn.Font = new System.Drawing.Font("宋体", 23F); + this.okBtn.ForeColor = System.Drawing.Color.White; + this.okBtn.Location = new System.Drawing.Point(71, 3); + this.okBtn.Name = "okBtn"; + this.okBtn.PlaySound = false; + this.okBtn.Size = new System.Drawing.Size(162, 94); + this.okBtn.SoundType = WinFormControl.SoundType.Click; + this.okBtn.TabIndex = 0; + this.okBtn.Text = "确定"; + this.okBtn.ToColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(136)))), ((int)(((byte)(255))))); + this.okBtn.UseVisualStyleBackColor = false; + // + // panel2 + // + this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel2.Controls.Add(this.groupBox2); + this.panel2.Controls.Add(this.groupBox1); + this.panel2.Location = new System.Drawing.Point(0, 12); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(926, 362); + this.panel2.TabIndex = 1; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.weightGrid); + this.groupBox2.Location = new System.Drawing.Point(4, 230); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(919, 108); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "过磅信息"; + // + // weightGrid + // + this.weightGrid.AllowUserToAddRows = false; + this.weightGrid.AllowUserToDeleteRows = false; + this.weightGrid.AllowUserToResizeColumns = false; + this.weightGrid.AllowUserToResizeRows = false; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.weightGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + this.weightGrid.BackgroundColor = System.Drawing.Color.White; + this.weightGrid.BorderStyle = System.Windows.Forms.BorderStyle.None; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.weightGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.weightGrid.ColumnHeadersHeight = 40; + this.weightGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.weightGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.D_Index, + this.D_Number, + this.D_MaoWeight, + this.D_PiWeight, + this.D_Weight}); + this.weightGrid.Dock = System.Windows.Forms.DockStyle.Fill; + this.weightGrid.Location = new System.Drawing.Point(3, 17); + this.weightGrid.MultiSelect = false; + this.weightGrid.Name = "weightGrid"; + this.weightGrid.ReadOnly = true; + this.weightGrid.RowHeadersVisible = false; + dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.weightGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; + this.weightGrid.RowTemplate.Height = 30; + this.weightGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.weightGrid.Size = new System.Drawing.Size(913, 88); + this.weightGrid.TabIndex = 0; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.farmerGrid); + this.groupBox1.Location = new System.Drawing.Point(4, 78); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(920, 109); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "养殖户信息"; + // + // farmerGrid + // + this.farmerGrid.AllowUserToAddRows = false; + this.farmerGrid.AllowUserToDeleteRows = false; + this.farmerGrid.AllowUserToResizeColumns = false; + this.farmerGrid.AllowUserToResizeRows = false; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.farmerGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; + this.farmerGrid.BackgroundColor = System.Drawing.Color.White; + this.farmerGrid.BorderStyle = System.Windows.Forms.BorderStyle.None; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.farmerGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; + this.farmerGrid.ColumnHeadersHeight = 40; + this.farmerGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + this.farmerGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.F_Index, + this.F_Farmer_Name, + this.F_Number, + this.F_Weight, + this.F_Money, + this.F_Farmer_IDCard, + this.F_Farmer_BankAccount, + this.F_Farmer_Tel, + this.F_Farmer_Address}); + this.farmerGrid.Dock = System.Windows.Forms.DockStyle.Fill; + this.farmerGrid.Location = new System.Drawing.Point(3, 17); + this.farmerGrid.MultiSelect = false; + this.farmerGrid.Name = "farmerGrid"; + this.farmerGrid.ReadOnly = true; + this.farmerGrid.RowHeadersVisible = false; + dataGridViewCellStyle11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.farmerGrid.RowsDefaultCellStyle = dataGridViewCellStyle11; + this.farmerGrid.RowTemplate.Height = 30; + this.farmerGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.farmerGrid.Size = new System.Drawing.Size(914, 89); + this.farmerGrid.TabIndex = 0; + // + // F_Index + // + this.F_Index.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.F_Index.DataPropertyName = "Index"; + this.F_Index.HeaderText = "序号"; + this.F_Index.MinimumWidth = 70; + this.F_Index.Name = "F_Index"; + this.F_Index.ReadOnly = true; + this.F_Index.Width = 70; + // + // F_Farmer_Name + // + this.F_Farmer_Name.DataPropertyName = "Farmer_Name"; + this.F_Farmer_Name.HeaderText = "养殖户"; + this.F_Farmer_Name.Name = "F_Farmer_Name"; + this.F_Farmer_Name.ReadOnly = true; + this.F_Farmer_Name.Width = 150; + // + // F_Number + // + this.F_Number.DataPropertyName = "Number"; + this.F_Number.HeaderText = "头数"; + this.F_Number.Name = "F_Number"; + this.F_Number.ReadOnly = true; + this.F_Number.Width = 80; + // + // F_Weight + // + this.F_Weight.DataPropertyName = "Weight"; + dataGridViewCellStyle9.Format = "#0.######"; + this.F_Weight.DefaultCellStyle = dataGridViewCellStyle9; + this.F_Weight.HeaderText = "重量"; + this.F_Weight.Name = "F_Weight"; + this.F_Weight.ReadOnly = true; + // + // F_Money + // + this.F_Money.DataPropertyName = "Money"; + dataGridViewCellStyle10.Format = "#0.######"; + this.F_Money.DefaultCellStyle = dataGridViewCellStyle10; + this.F_Money.HeaderText = "棚前金额"; + this.F_Money.Name = "F_Money"; + this.F_Money.ReadOnly = true; + this.F_Money.Width = 120; + // + // F_Farmer_IDCard + // + this.F_Farmer_IDCard.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.F_Farmer_IDCard.DataPropertyName = "Farmer_IDCard"; + this.F_Farmer_IDCard.HeaderText = "身份证号"; + this.F_Farmer_IDCard.MinimumWidth = 150; + this.F_Farmer_IDCard.Name = "F_Farmer_IDCard"; + this.F_Farmer_IDCard.ReadOnly = true; + this.F_Farmer_IDCard.Width = 150; + // + // F_Farmer_BankAccount + // + this.F_Farmer_BankAccount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.F_Farmer_BankAccount.DataPropertyName = "Farmer_BankAccount"; + this.F_Farmer_BankAccount.HeaderText = "银行卡号"; + this.F_Farmer_BankAccount.MinimumWidth = 150; + this.F_Farmer_BankAccount.Name = "F_Farmer_BankAccount"; + this.F_Farmer_BankAccount.ReadOnly = true; + this.F_Farmer_BankAccount.Width = 150; + // + // F_Farmer_Tel + // + this.F_Farmer_Tel.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.F_Farmer_Tel.DataPropertyName = "Farmer_Tel"; + this.F_Farmer_Tel.HeaderText = "手机"; + this.F_Farmer_Tel.MinimumWidth = 150; + this.F_Farmer_Tel.Name = "F_Farmer_Tel"; + this.F_Farmer_Tel.ReadOnly = true; + this.F_Farmer_Tel.Width = 150; + // + // F_Farmer_Address + // + this.F_Farmer_Address.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.F_Farmer_Address.DataPropertyName = "Farmer_Address"; + this.F_Farmer_Address.HeaderText = "地址"; + this.F_Farmer_Address.MinimumWidth = 150; + this.F_Farmer_Address.Name = "F_Farmer_Address"; + this.F_Farmer_Address.ReadOnly = true; + // + // D_Index + // + this.D_Index.DataPropertyName = "Index"; + this.D_Index.HeaderText = "序号"; + this.D_Index.Name = "D_Index"; + this.D_Index.ReadOnly = true; + // + // D_Number + // + this.D_Number.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.D_Number.DataPropertyName = "Number"; + this.D_Number.HeaderText = "头数"; + this.D_Number.Name = "D_Number"; + this.D_Number.ReadOnly = true; + // + // D_MaoWeight + // + this.D_MaoWeight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.D_MaoWeight.DataPropertyName = "MaoWeight"; + dataGridViewCellStyle3.Format = "#0.######"; + this.D_MaoWeight.DefaultCellStyle = dataGridViewCellStyle3; + this.D_MaoWeight.HeaderText = "毛重"; + this.D_MaoWeight.Name = "D_MaoWeight"; + this.D_MaoWeight.ReadOnly = true; + // + // D_PiWeight + // + this.D_PiWeight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.D_PiWeight.DataPropertyName = "PiWeight"; + dataGridViewCellStyle4.Format = "#0.######"; + this.D_PiWeight.DefaultCellStyle = dataGridViewCellStyle4; + this.D_PiWeight.HeaderText = "皮重"; + this.D_PiWeight.Name = "D_PiWeight"; + this.D_PiWeight.ReadOnly = true; + // + // D_Weight + // + this.D_Weight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.D_Weight.DataPropertyName = "Weight"; + dataGridViewCellStyle5.Format = "#0.######"; + this.D_Weight.DefaultCellStyle = dataGridViewCellStyle5; + this.D_Weight.HeaderText = "重量"; + this.D_Weight.Name = "D_Weight"; + this.D_Weight.ReadOnly = true; + // + // WeightForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(926, 514); + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "WeightForm"; + this.Text = "WeightForm"; + this.WindowState = System.Windows.Forms.FormWindowState.Maximized; + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.weightGrid)).EndInit(); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.farmerGrid)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private WinFormControl.NButton backBtn; + private WinFormControl.NButton okBtn; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private WinFormControl.UDataGridView farmerGrid; + private WinFormControl.UDataGridView weightGrid; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Index; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Farmer_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Number; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Weight; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Money; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Farmer_IDCard; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Farmer_BankAccount; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Farmer_Tel; + private System.Windows.Forms.DataGridViewTextBoxColumn F_Farmer_Address; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Index; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Number; + private System.Windows.Forms.DataGridViewTextBoxColumn D_MaoWeight; + private System.Windows.Forms.DataGridViewTextBoxColumn D_PiWeight; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Weight; + } +} \ No newline at end of file diff --git a/SelfHelpClient/WeightForm.cs b/SelfHelpClient/WeightForm.cs new file mode 100644 index 0000000..39a9de9 --- /dev/null +++ b/SelfHelpClient/WeightForm.cs @@ -0,0 +1,190 @@ +using SelfHelpClient.BL; +using SelfHelpClient.BO; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SelfHelpClient +{ + public partial class WeightForm : Form + { + WeightBill entity; + Thread refersh; + public WeightForm(ViewEntity view) + { + InitializeComponent(); + if (view.BillType == 0) + entity = WeightBillBL.CreateWeightBill(view.ID); + else + entity = WeightBillBL.GetWeightBill(view.ID); + var tableHeight = InitTableLayoutPanel(); + BuildGridPanel(tableHeight); + this.FormClosing += delegate + { + if (refersh != null && refersh.IsAlive) + refersh.Abort(); + }; + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + farmerGrid.DataSource = entity.FarmerDetails; + farmerGrid.Refresh(); + + weightGrid.DataSource = entity.Details; + weightGrid.Refresh(); + + refersh = new Thread(RefershDetail); + refersh.Start(); + } + + private void RefershDetail() + { + while (true) + { + Thread.Sleep(2000); + if (this.IsHandleCreated) + { + this.Invoke(new Action(() => + { + var detail = WeightBillBL.GetWeightDetail(entity.ID); + if (detail.Any()) + { + weightGrid.DataSource = detail; + weightGrid.Refresh(); + } + })); + } + } + } + + private void BuildGridPanel(int tableHeight) + { + groupBox1.Location = new Point(0, tableHeight + 10); + groupBox1.Width = Screen.PrimaryScreen.Bounds.Width; + groupBox1.Height = 200; + + groupBox2.Location = new Point(0, tableHeight + groupBox1.Height + 10); + groupBox2.Width = Screen.PrimaryScreen.Bounds.Width; + groupBox2.Height = 150; + } + + private int InitTableLayoutPanel() + { + TableLayoutPanel tablePanel = new TableLayoutPanel(); + tablePanel.Width = Screen.PrimaryScreen.Bounds.Width; + panel2.Controls.Add(tablePanel); + var dic = BuildFields(); + var table = ComputeColAndRow(dic.Count); + tablePanel.Height = 60 * table.Rows + 5; + DynamicLayout(tablePanel, table); + var type = typeof(WeightBill); + var r = 0; + var c = 0; + foreach (var item in dic) + { + Label title = BuildLabel(item.Value + ":"); + tablePanel.Controls.Add(title); + tablePanel.SetRow(title, r); + tablePanel.SetColumn(title, c); + c++; + + var v = type.GetProperty(item.Key).GetValue(entity); + var lbl = string.Empty; + switch (item.Key) + { + case "WeighTime": + lbl = string.Format("{0:yyyy-MM-dd HH:mm:ss}", v); + break; + case "JingJianFee": + case "DiscontMoney": + case "ShackWeight": + case "ShackPrice": + case "ShackMoney": + lbl = string.Format("{0:#0.######}", v); + break; + case "AnimalTestDate": + lbl = string.Format("{0:yyyy-MM-dd}", v); + break; + default: + lbl = string.Format("{0}", v); + break; + } + Label content = BuildLabel(lbl); + tablePanel.Controls.Add(content); + tablePanel.SetRow(content, r); + tablePanel.SetColumn(content, c); + c++; + + if (c % table.Cols == 0) + { + c = 0; + r++; + } + } + + return tablePanel.Height; + } + + TableSturct ComputeColAndRow(int fileCount) + { + var screenWidth = Screen.PrimaryScreen.Bounds.Width; + var col = Math.Floor((decimal)screenWidth / (160 + 280)); + var row = Math.Ceiling(fileCount / col); + return new TableSturct() { Rows = (int)row, Cols = (int)col * 2 }; + } + + private void DynamicLayout(TableLayoutPanel layoutPanel, TableSturct table) + { + layoutPanel.RowCount = table.Rows; //设置分成几行 + for (int i = 0; i < table.Rows; i++) + { + layoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 60)); + } + layoutPanel.ColumnCount = table.Cols; //设置分成几列 + for (int i = 0; i < table.Cols; i++) + { + var precent = i % 2 == 0 ? 30F : 70F; + layoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, precent)); + } + } + + Dictionary BuildFields() + { + var dic = new Dictionary() { + {"Supplier_Name","供应商"},{"PurchaseType_Name","收购类型"},{"WeighTime","过磅时间"},{"Car_Name","车辆"},{"Employee_Name","业务员"},{"JingJianFee","经检费"},{"DiscontMoney","猪场扣款"},{"ShackWeight","棚前重量"},{"ShackPrice","棚前单价"},{"ShackMoney","棚前金额"},{"AnimalTestMan","动检人"},{"AnimalTestNumber","动检证号"},{"AnimalTestDate","动检日期"}, + }; + return dic; + } + + Label BuildLabel(string content) + { + Label label = new Label(); + label.Text = content; + label.Font = new System.Drawing.Font("宋体", 18); + label.Dock = DockStyle.Fill; + label.TextAlign = ContentAlignment.MiddleLeft; + return label; + } + + private void backBtn_Click(object sender, EventArgs e) + { + MainForm.Form.Show(); + this.Close(); + } + } + + struct TableSturct + { + public int Rows { get; set; } + public int Cols { get; set; } + } +} diff --git a/SelfHelpClient/WeightForm.resx b/SelfHelpClient/WeightForm.resx new file mode 100644 index 0000000..f088455 --- /dev/null +++ b/SelfHelpClient/WeightForm.resx @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file