Browse Source

加分割品领料客户端。

master
yibo 7 years ago
parent
commit
90fe0b2337
9 changed files with 1378 additions and 0 deletions
  1. +35
    -0
      ButcherFactory.BO/Bill/SegmentPickUp.cs
  2. +2
    -0
      ButcherFactory.BO/ButcherFactory.BO.csproj
  3. +1
    -0
      ButcherFactory.BO/Enums/DriveType.cs
  4. +264
    -0
      ButcherFactory.BO/LocalBL/SegmentPickUpBL.cs
  5. +10
    -0
      ButcherFactory.Form/ButcherFactory.Form.csproj
  6. +13
    -0
      ButcherFactory.Form/SegmentPickUp_/SegmentPickUpConfig.cs
  7. +564
    -0
      ButcherFactory.Form/SegmentPickUp_/SegmentPickUpForm.Designer.cs
  8. +329
    -0
      ButcherFactory.Form/SegmentPickUp_/SegmentPickUpForm.cs
  9. +160
    -0
      ButcherFactory.Form/SegmentPickUp_/SegmentPickUpForm.resx

+ 35
- 0
ButcherFactory.BO/Bill/SegmentPickUp.cs View File

@ -0,0 +1,35 @@
using Forks.EnterpriseServices.DataDictionary;
using Forks.EnterpriseServices.DomainObjects2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.BO.Bill
{
[MapToTable("Butcher_SegmentPickUp")]
[DBIndex("IDX_Butcher_SegmentPickUp_Clustered", "BarCode", false, 0)]
[DBIndexType("IDX_Butcher_SegmentPickUp_Clustered", IndexType.Clustered)]
public class SegmentPickUp : SyncBill
{
public string BarCode { get; set; }
public long? WorkUnit_ID { get; set; }
public long? Goods_ID { get; set; }
public long? ProductBatch_ID { get; set; }
public decimal? Weight { get; set; }
[DbColumn(DefaultValue = 1)]
public int Number { get; set; }
[ReferenceTo(typeof(Goods), "Name")]
[Join("Goods_ID", "ID")]
public string Goods_Name { get; set; }
public bool Submited { get; set; }
}
}

+ 2
- 0
ButcherFactory.BO/ButcherFactory.BO.csproj View File

@ -67,6 +67,7 @@
<Compile Include="Bill\CarcassTakeOut.cs" />
<Compile Include="Bill\CarcassTakeOutWeightTemp.cs" />
<Compile Include="Bill\SegmentInStore.cs" />
<Compile Include="Bill\SegmentPickUp.cs" />
<Compile Include="Bill\SegmentProduction.cs" />
<Compile Include="Bill\SegmentSaleOut_Detail.cs" />
<Compile Include="Bill\StockUpEntity.cs" />
@ -84,6 +85,7 @@
<Compile Include="LocalBL\DialogBL.cs" />
<Compile Include="LocalBL\FormClientGoodsSetBL.cs" />
<Compile Include="LocalBL\SegmentInStoreBL.cs" />
<Compile Include="LocalBL\SegmentPickUpBL.cs" />
<Compile Include="LocalBL\SegmentProductionBL.cs" />
<Compile Include="LocalBL\SegmentSaleOutBL.cs" />
<Compile Include="LocalBL\SegmentStockUpBL.cs" />


+ 1
- 0
ButcherFactory.BO/Enums/DriveType.cs View File

@ -12,6 +12,7 @@ namespace ButcherFactory.BO
= 1,
= 2,
= 3,
= 4,
//B3从51开始
= 51,


+ 264
- 0
ButcherFactory.BO/LocalBL/SegmentPickUpBL.cs View File

@ -0,0 +1,264 @@
using ButcherFactory.BO.Bill;
using ButcherFactory.BO.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.BO.LocalBL
{
public static class SegmentPickUpBL
{
const string RpcPath = @"/MainSystem/B3ClientService/Rpcs/SegmentPickUpRpc/";
public static BindingList<SegmentPickUp> GetSegmentPickUp(bool unSubmit)
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentPickUp)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("RowIndex"));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
query.Columns.Add(DQSelectColumn.Field("Number"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("CreateTime"));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
if (unSubmit)
query.Where.Conditions.Add(DQCondition.EQ("Submited", false));
else
{
query.Where.Conditions.Add(DQCondition.Between("CreateTime", DateTime.Today, DateTime.Today + new TimeSpan(23, 59, 59)));
query.Range = SelectRange.Top(20);
}
var list = new BindingList<SegmentPickUp>();
using (var session = DmoSession.New())
{
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var entity = new SegmentPickUp();
entity.ID = (long)reader[0];
entity.RowIndex = (int)reader[1];
entity.BarCode = (string)reader[2];
entity.Goods_Name = (string)reader[3];
entity.Number = (int)reader[4];
entity.Weight = (decimal?)reader[5];
if (unSubmit)
entity.CreateTime = (DateTime)reader[6];
list.Add(entity);
}
}
}
return list;
}
public static void InsertEntityByCode(SegmentPickUp entity)
{
using (var session = DmoSession.New())
{
if (CheckExist(entity.BarCode, session))
return;
try
{
var json = RpcFacade.Call<string>(RpcPath + "GetScanInfo", entity.BarCode);
if (!string.IsNullOrEmpty(json))
{
var obj = JsonConvert.DeserializeObject<ExtensionObj>(json);
entity.Goods_ID = obj.LongExt1.Value;
entity.Goods_Name = obj.StringExt1;
entity.Weight = obj.DecimalExt1;
}
}
catch
{
#if DEBUG
throw;
#endif
}
entity.Number = 1;
entity.UserID = AppContext.Worker.ID;
session.Insert(entity);
session.Commit();
}
}
static bool CheckExist(string barCode, IDmoSession session)
{
if (string.IsNullOrEmpty(barCode))
return false;
var query = new DQueryDom(new JoinAlias(typeof(SegmentPickUp)));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "c"));
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode));
return query.EExecuteScalar(session) != null;
}
public static void InsertEntityByWeight(SegmentPickUp entity)
{
using (var session = DmoSession.New())
{
entity.Number = 1;
entity.UserID = AppContext.Worker.ID;
session.Insert(entity);
session.Commit();
}
}
public static void UpdateNumber(long id, int number)
{
var update = new DQUpdateDom(typeof(SegmentPickUp));
update.Where.Conditions.Add(DQCondition.EQ("ID", id));
update.Columns.Add(new DQUpdateColumn("Number", number));
update.EExecute();
}
public static void UpdateSubmit(IEnumerable<long> ids)
{
var update = new DQUpdateDom(typeof(SegmentPickUp));
update.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), ids.Select(x => DQExpression.Value(x)).ToArray()));
update.Columns.Add(new DQUpdateColumn("Submited", true));
update.EExecute();
}
public static List<ExtensionObj> GetBeforeInfo(IEnumerable<string> codeList)
{
try
{
var json = RpcFacade.Call<string>(RpcPath + "GetBeforeInfo", codeList);
var list = JsonConvert.DeserializeObject<List<ExtensionObj>>(json);
if (list.Any())
{
using (var session = DmoSession.New())
{
foreach (var item in list)
SaveBeforeInfoInDB(item, session);
session.Commit();
}
}
return list;
}
catch
{
#if DEBUG
throw;
#endif
return new List<ExtensionObj>();
}
}
private static void SaveBeforeInfoInDB(ExtensionObj obj, IDmoSession session)
{
var update = new DQUpdateDom(typeof(SegmentPickUp));
update.Where.Conditions.Add(DQCondition.EQ("BarCode", obj.StringExt1));
update.Columns.Add(new DQUpdateColumn("Goods_ID", obj.LongExt1));
update.Columns.Add(new DQUpdateColumn("Weight", obj.DecimalExt1));
session.ExecuteNonQuery(update);
}
public static void UploadSegmentInfo()
{
try
{
using (var session = DmoSession.New())
{
var needUpload = GetUnSyncData(session);
if (needUpload.Count == 0)
return;
var method = RpcPath + "UploadSegmentInfo";
var json = JsonConvert.SerializeObject(needUpload);
RpcFacade.Call<int>(method, json);
foreach (var item in needUpload)
SetLocalAsSyncd(item, session);
session.Commit();
}
}
catch
{
#if DEBUG
throw;
#endif
}
}
static List<SegmentPickUpObj> GetUnSyncData(IDmoSession session)
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentPickUp)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("RowVersion"));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Columns.Add(DQSelectColumn.Field("UserID"));
query.Columns.Add(DQSelectColumn.Field("WorkUnit_ID"));
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID"));
query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("CreateTime"));
query.Columns.Add(DQSelectColumn.Field("Number"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Submited", true), DQCondition.EQ("Sync", false)));
query.Range = SelectRange.Top(10);
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
var upload = new List<SegmentPickUpObj>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var obj = new SegmentPickUpObj();
obj.ID = (long)reader[0];
obj.RowVersion = (int)reader[1];
obj.BarCode = (string)reader[2];
obj.TakeOutWorker_ID = (long)reader[3];
obj.WorkUnit_ID = (long?)reader[4];
if (string.IsNullOrEmpty(obj.BarCode))
{
obj.ProductBatch_ID = (long?)reader[5];
obj.Goods_ID = (long?)reader[6];
}
obj.Weight = (decimal?)reader[7];
obj.Time = (DateTime)reader[8];
obj.Number = (int)reader[9];
upload.Add(obj);
}
}
return upload;
}
static void SetLocalAsSyncd(SegmentPickUpObj obj, IDmoSession session)
{
var update = new DQUpdateDom(typeof(SegmentPickUp));
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", obj.ID), DQCondition.EQ("RowVersion", obj.RowVersion)));
update.Columns.Add(new DQUpdateColumn("Sync", true));
session.ExecuteNonQuery(update);
}
}
class SegmentPickUpObj
{
[JsonIgnore]
public long ID { get; set; }
[JsonIgnore]
public int RowVersion { get; set; }
public string BarCode { get; set; }
public long TakeOutWorker_ID { get; set; }
public long? WorkUnit_ID { get; set; }
public long? ProductBatch_ID { get; set; }
public long? Goods_ID { get; set; }
public decimal? Weight { get; set; }
public DateTime? Time { get; set; }
public int Number { get; set; }
}
}

+ 10
- 0
ButcherFactory.Form/ButcherFactory.Form.csproj View File

@ -189,6 +189,13 @@
<DependentUpon>SegmentInStoreForm.cs</DependentUpon>
</Compile>
<Compile Include="SegmentInStore_\SegmentInStoreFormConfig.cs" />
<Compile Include="SegmentPickUp_\SegmentPickUpConfig.cs" />
<Compile Include="SegmentPickUp_\SegmentPickUpForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SegmentPickUp_\SegmentPickUpForm.Designer.cs">
<DependentUpon>SegmentPickUpForm.cs</DependentUpon>
</Compile>
<Compile Include="SegmentProductionAuto_\SegmentProductionAutoForm.cs">
<SubType>Form</SubType>
</Compile>
@ -308,6 +315,9 @@
<EmbeddedResource Include="SegmentInStore_\SegmentInStoreForm.resx">
<DependentUpon>SegmentInStoreForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SegmentPickUp_\SegmentPickUpForm.resx">
<DependentUpon>SegmentPickUpForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SegmentProductionAuto_\SegmentProductionAutoForm.resx">
<DependentUpon>SegmentProductionAutoForm.cs</DependentUpon>
</EmbeddedResource>


+ 13
- 0
ButcherFactory.Form/SegmentPickUp_/SegmentPickUpConfig.cs View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.SegmentPickUp_
{
public class SegmentPickUpConfig
{
public long? WorkUnitID { get; set; }
}
}

+ 564
- 0
ButcherFactory.Form/SegmentPickUp_/SegmentPickUpForm.Designer.cs View File

@ -0,0 +1,564 @@
namespace ButcherFactory.SegmentPickUp_
{
partial class SegmentPickUpForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SegmentPickUpForm));
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = 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();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
this.submitBtn = new WinFormControl.UButton();
this.uLabel4 = new WinFormControl.ULabel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.needSubmitGrid = new WinFormControl.UDataGridView();
this.numFlowPanel = new System.Windows.Forms.FlowLayoutPanel();
this.uLabel3 = new WinFormControl.ULabel();
this.workUnitSelect = new System.Windows.Forms.ComboBox();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.numSetBtn = new WinFormControl.UButton();
this.productBatchSelect = new System.Windows.Forms.ComboBox();
this.uLabel2 = new WinFormControl.ULabel();
this.closeBtn = new WinFormControl.UButton();
this.uTimerLabel1 = new WinFormControl.UTimerLabel();
this.uScanPanel1 = new WinFormControl.UScanPanel();
this.netStateWatch1 = new WinFormControl.NetStateWatch();
this.uWeightControl1 = new WinFormControl.UWeightControl();
this.uLabel1 = new WinFormControl.ULabel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.historyDataGrid = new WinFormControl.UDataGridView();
this.U_ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.U_RowIndex = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.U_BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.U_Goods_Name = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.U_Number = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.U_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.H_ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.H_RowIndex = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.H_BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.H_Goods_Name = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.H_Number = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.H_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.needSubmitGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.historyDataGrid)).BeginInit();
this.SuspendLayout();
//
// submitBtn
//
this.submitBtn.AsClicked = false;
this.submitBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("submitBtn.BackgroundImage")));
this.submitBtn.EnableGroup = false;
this.submitBtn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.submitBtn.FlatAppearance.BorderSize = 0;
this.submitBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.submitBtn.Font = new System.Drawing.Font("宋体", 15F);
this.submitBtn.ForeColor = System.Drawing.Color.Black;
this.submitBtn.Location = new System.Drawing.Point(11, 20);
this.submitBtn.Name = "submitBtn";
this.submitBtn.PlaySound = false;
this.submitBtn.SelfControlEnable = false;
this.submitBtn.Size = new System.Drawing.Size(111, 34);
this.submitBtn.SoundType = WinFormControl.SoundType.Click;
this.submitBtn.TabIndex = 11;
this.submitBtn.Text = "提 交";
this.submitBtn.UseVisualStyleBackColor = true;
this.submitBtn.WithStataHode = false;
this.submitBtn.Click += new System.EventHandler(this.submitBtn_Click);
//
// uLabel4
//
this.uLabel4.AutoSize = true;
this.uLabel4.BackColor = System.Drawing.Color.White;
this.uLabel4.Font = new System.Drawing.Font("宋体", 13F);
this.uLabel4.Location = new System.Drawing.Point(8, -1);
this.uLabel4.Name = "uLabel4";
this.uLabel4.Size = new System.Drawing.Size(80, 18);
this.uLabel4.TabIndex = 1;
this.uLabel4.Text = "历史领料";
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.needSubmitGrid);
this.groupBox1.Controls.Add(this.numFlowPanel);
this.groupBox1.Controls.Add(this.submitBtn);
this.groupBox1.Controls.Add(this.uLabel3);
this.groupBox1.Location = new System.Drawing.Point(11, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(5);
this.groupBox1.Size = new System.Drawing.Size(776, 265);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
//
// needSubmitGrid
//
this.needSubmitGrid.AllowUserToAddRows = false;
this.needSubmitGrid.AllowUserToDeleteRows = false;
this.needSubmitGrid.AllowUserToResizeColumns = false;
this.needSubmitGrid.AllowUserToResizeRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235)))));
this.needSubmitGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.needSubmitGrid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.needSubmitGrid.BackgroundColor = System.Drawing.Color.White;
this.needSubmitGrid.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.needSubmitGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.needSubmitGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.needSubmitGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.U_ID,
this.U_RowIndex,
this.U_BarCode,
this.U_Goods_Name,
this.U_Number,
this.U_Weight});
this.needSubmitGrid.Location = new System.Drawing.Point(5, 57);
this.needSubmitGrid.MultiSelect = false;
this.needSubmitGrid.Name = "needSubmitGrid";
this.needSubmitGrid.ReadOnly = true;
this.needSubmitGrid.RowHeadersVisible = false;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218)))));
this.needSubmitGrid.RowsDefaultCellStyle = dataGridViewCellStyle3;
this.needSubmitGrid.RowTemplate.Height = 30;
this.needSubmitGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.needSubmitGrid.Size = new System.Drawing.Size(766, 248);
this.needSubmitGrid.TabIndex = 16;
//
// numFlowPanel
//
this.numFlowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.numFlowPanel.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.numFlowPanel.Location = new System.Drawing.Point(143, 14);
this.numFlowPanel.Name = "numFlowPanel";
this.numFlowPanel.Size = new System.Drawing.Size(628, 41);
this.numFlowPanel.TabIndex = 15;
//
// uLabel3
//
this.uLabel3.AutoSize = true;
this.uLabel3.BackColor = System.Drawing.Color.White;
this.uLabel3.Font = new System.Drawing.Font("宋体", 13F);
this.uLabel3.Location = new System.Drawing.Point(8, 0);
this.uLabel3.Name = "uLabel3";
this.uLabel3.Size = new System.Drawing.Size(80, 18);
this.uLabel3.TabIndex = 0;
this.uLabel3.Text = "领料明细";
//
// workUnitSelect
//
this.workUnitSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.workUnitSelect.Font = new System.Drawing.Font("宋体", 15F);
this.workUnitSelect.FormattingEnabled = true;
this.workUnitSelect.Location = new System.Drawing.Point(984, 11);
this.workUnitSelect.Name = "workUnitSelect";
this.workUnitSelect.Size = new System.Drawing.Size(170, 28);
this.workUnitSelect.TabIndex = 7;
//
// splitContainer1
//
this.splitContainer1.BackColor = System.Drawing.Color.Transparent;
this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.BackColor = System.Drawing.Color.Transparent;
this.splitContainer1.Panel1.Controls.Add(this.numSetBtn);
this.splitContainer1.Panel1.Controls.Add(this.productBatchSelect);
this.splitContainer1.Panel1.Controls.Add(this.uLabel2);
this.splitContainer1.Panel1.Controls.Add(this.closeBtn);
this.splitContainer1.Panel1.Controls.Add(this.uTimerLabel1);
this.splitContainer1.Panel1.Controls.Add(this.workUnitSelect);
this.splitContainer1.Panel1.Controls.Add(this.uScanPanel1);
this.splitContainer1.Panel1.Controls.Add(this.netStateWatch1);
this.splitContainer1.Panel1.Controls.Add(this.uWeightControl1);
this.splitContainer1.Panel1.Controls.Add(this.uLabel1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.flowLayoutPanel1);
this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
this.splitContainer1.Panel2.Controls.Add(this.groupBox1);
this.splitContainer1.Size = new System.Drawing.Size(1305, 611);
this.splitContainer1.SplitterDistance = 86;
this.splitContainer1.TabIndex = 2;
//
// numSetBtn
//
this.numSetBtn.AsClicked = false;
this.numSetBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("numSetBtn.BackgroundImage")));
this.numSetBtn.EnableGroup = false;
this.numSetBtn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.numSetBtn.FlatAppearance.BorderSize = 0;
this.numSetBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.numSetBtn.Font = new System.Drawing.Font("宋体", 15F);
this.numSetBtn.ForeColor = System.Drawing.Color.Black;
this.numSetBtn.Location = new System.Drawing.Point(358, 46);
this.numSetBtn.Name = "numSetBtn";
this.numSetBtn.PlaySound = false;
this.numSetBtn.SelfControlEnable = false;
this.numSetBtn.Size = new System.Drawing.Size(111, 34);
this.numSetBtn.SoundType = WinFormControl.SoundType.Click;
this.numSetBtn.TabIndex = 21;
this.numSetBtn.Text = "数量设置";
this.numSetBtn.UseVisualStyleBackColor = true;
this.numSetBtn.WithStataHode = false;
this.numSetBtn.Click += new System.EventHandler(this.numSetBtn_Click);
//
// productBatchSelect
//
this.productBatchSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.productBatchSelect.Font = new System.Drawing.Font("宋体", 15F);
this.productBatchSelect.FormattingEnabled = true;
this.productBatchSelect.Location = new System.Drawing.Point(984, 50);
this.productBatchSelect.Name = "productBatchSelect";
this.productBatchSelect.Size = new System.Drawing.Size(170, 28);
this.productBatchSelect.TabIndex = 18;
//
// uLabel2
//
this.uLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.uLabel2.AutoSize = true;
this.uLabel2.BackColor = System.Drawing.Color.Transparent;
this.uLabel2.Font = new System.Drawing.Font("宋体", 15F);
this.uLabel2.Location = new System.Drawing.Point(883, 53);
this.uLabel2.Name = "uLabel2";
this.uLabel2.Size = new System.Drawing.Size(109, 20);
this.uLabel2.TabIndex = 16;
this.uLabel2.Text = "生产批次:";
//
// closeBtn
//
this.closeBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.closeBtn.AsClicked = false;
this.closeBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("closeBtn.BackgroundImage")));
this.closeBtn.EnableGroup = false;
this.closeBtn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.closeBtn.FlatAppearance.BorderSize = 0;
this.closeBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.closeBtn.Font = new System.Drawing.Font("宋体", 15F);
this.closeBtn.ForeColor = System.Drawing.Color.Black;
this.closeBtn.Location = new System.Drawing.Point(1187, 7);
this.closeBtn.Name = "closeBtn";
this.closeBtn.PlaySound = false;
this.closeBtn.SelfControlEnable = false;
this.closeBtn.Size = new System.Drawing.Size(111, 34);
this.closeBtn.SoundType = WinFormControl.SoundType.Click;
this.closeBtn.TabIndex = 10;
this.closeBtn.Text = "关 闭";
this.closeBtn.UseVisualStyleBackColor = true;
this.closeBtn.WithStataHode = false;
this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click);
//
// uTimerLabel1
//
this.uTimerLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.uTimerLabel1.AutoSize = true;
this.uTimerLabel1.BackColor = System.Drawing.Color.Transparent;
this.uTimerLabel1.Font = new System.Drawing.Font("黑体", 12F);
this.uTimerLabel1.Format = "M月d日 H:mm:ss";
this.uTimerLabel1.Location = new System.Drawing.Point(1165, 53);
this.uTimerLabel1.Name = "uTimerLabel1";
this.uTimerLabel1.Size = new System.Drawing.Size(128, 16);
this.uTimerLabel1.TabIndex = 8;
this.uTimerLabel1.Text = "3月30日 8:54:07";
//
// uScanPanel1
//
this.uScanPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.uScanPanel1.BackColor = System.Drawing.Color.Transparent;
this.uScanPanel1.Location = new System.Drawing.Point(580, 9);
this.uScanPanel1.Name = "uScanPanel1";
this.uScanPanel1.Size = new System.Drawing.Size(303, 32);
this.uScanPanel1.TabIndex = 3;
//
// netStateWatch1
//
this.netStateWatch1.BackColor = System.Drawing.Color.Transparent;
this.netStateWatch1.Location = new System.Drawing.Point(354, 4);
this.netStateWatch1.Name = "netStateWatch1";
this.netStateWatch1.Size = new System.Drawing.Size(90, 39);
this.netStateWatch1.TabIndex = 1;
//
// uWeightControl1
//
this.uWeightControl1.BackColor = System.Drawing.Color.Transparent;
this.uWeightControl1.Location = new System.Drawing.Point(3, 3);
this.uWeightControl1.Name = "uWeightControl1";
this.uWeightControl1.Size = new System.Drawing.Size(349, 78);
this.uWeightControl1.TabIndex = 0;
this.uWeightControl1.WeightFalg = null;
//
// uLabel1
//
this.uLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.uLabel1.AutoSize = true;
this.uLabel1.BackColor = System.Drawing.Color.Transparent;
this.uLabel1.Font = new System.Drawing.Font("宋体", 15F);
this.uLabel1.Location = new System.Drawing.Point(883, 14);
this.uLabel1.Name = "uLabel1";
this.uLabel1.Size = new System.Drawing.Size(109, 20);
this.uLabel1.TabIndex = 5;
this.uLabel1.Text = "工作单元:";
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowLayoutPanel1.Location = new System.Drawing.Point(793, -1);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(514, 521);
this.flowLayoutPanel1.TabIndex = 4;
//
// groupBox2
//
this.groupBox2.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.groupBox2.Controls.Add(this.historyDataGrid);
this.groupBox2.Controls.Add(this.uLabel4);
this.groupBox2.Location = new System.Drawing.Point(11, 324);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(5);
this.groupBox2.Size = new System.Drawing.Size(776, 182);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
//
// historyDataGrid
//
this.historyDataGrid.AllowUserToAddRows = false;
this.historyDataGrid.AllowUserToDeleteRows = false;
this.historyDataGrid.AllowUserToResizeColumns = false;
this.historyDataGrid.AllowUserToResizeRows = false;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235)))));
this.historyDataGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4;
this.historyDataGrid.BackgroundColor = System.Drawing.Color.White;
this.historyDataGrid.BorderStyle = System.Windows.Forms.BorderStyle.None;
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F);
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.historyDataGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
this.historyDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.historyDataGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.H_ID,
this.H_RowIndex,
this.H_BarCode,
this.H_Goods_Name,
this.H_Number,
this.H_Weight});
this.historyDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.historyDataGrid.Location = new System.Drawing.Point(5, 19);
this.historyDataGrid.MultiSelect = false;
this.historyDataGrid.Name = "historyDataGrid";
this.historyDataGrid.ReadOnly = true;
this.historyDataGrid.RowHeadersVisible = false;
dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218)))));
this.historyDataGrid.RowsDefaultCellStyle = dataGridViewCellStyle7;
this.historyDataGrid.RowTemplate.Height = 23;
this.historyDataGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.historyDataGrid.Size = new System.Drawing.Size(766, 158);
this.historyDataGrid.TabIndex = 2;
//
// U_ID
//
this.U_ID.DataPropertyName = "ID";
this.U_ID.HeaderText = "ID";
this.U_ID.Name = "U_ID";
this.U_ID.ReadOnly = true;
this.U_ID.Visible = false;
//
// U_RowIndex
//
this.U_RowIndex.DataPropertyName = "RowIndex";
this.U_RowIndex.HeaderText = "序号";
this.U_RowIndex.Name = "U_RowIndex";
this.U_RowIndex.ReadOnly = true;
//
// U_BarCode
//
this.U_BarCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.U_BarCode.DataPropertyName = "BarCode";
this.U_BarCode.HeaderText = "条码";
this.U_BarCode.Name = "U_BarCode";
this.U_BarCode.ReadOnly = true;
//
// U_Goods_Name
//
this.U_Goods_Name.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.U_Goods_Name.DataPropertyName = "Goods_Name";
this.U_Goods_Name.HeaderText = "产品名称";
this.U_Goods_Name.Name = "U_Goods_Name";
this.U_Goods_Name.ReadOnly = true;
//
// U_Number
//
this.U_Number.DataPropertyName = "Number";
this.U_Number.HeaderText = "数量";
this.U_Number.Name = "U_Number";
this.U_Number.ReadOnly = true;
//
// U_Weight
//
this.U_Weight.DataPropertyName = "Weight";
this.U_Weight.HeaderText = "重量";
this.U_Weight.Name = "U_Weight";
this.U_Weight.ReadOnly = true;
//
// H_ID
//
this.H_ID.DataPropertyName = "ID";
this.H_ID.HeaderText = "ID";
this.H_ID.Name = "H_ID";
this.H_ID.ReadOnly = true;
this.H_ID.Visible = false;
//
// H_RowIndex
//
this.H_RowIndex.DataPropertyName = "RowIndex";
this.H_RowIndex.HeaderText = "序号";
this.H_RowIndex.Name = "H_RowIndex";
this.H_RowIndex.ReadOnly = true;
//
// H_BarCode
//
this.H_BarCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.H_BarCode.DataPropertyName = "BarCode";
this.H_BarCode.HeaderText = "条码";
this.H_BarCode.Name = "H_BarCode";
this.H_BarCode.ReadOnly = true;
//
// H_Goods_Name
//
this.H_Goods_Name.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.H_Goods_Name.DataPropertyName = "Goods_Name";
this.H_Goods_Name.HeaderText = "产品名称";
this.H_Goods_Name.Name = "H_Goods_Name";
this.H_Goods_Name.ReadOnly = true;
//
// H_Number
//
this.H_Number.DataPropertyName = "Number";
this.H_Number.HeaderText = "数量";
this.H_Number.Name = "H_Number";
this.H_Number.ReadOnly = true;
//
// H_Weight
//
this.H_Weight.DataPropertyName = "Weight";
dataGridViewCellStyle6.Format = "#0.######";
this.H_Weight.DefaultCellStyle = dataGridViewCellStyle6;
this.H_Weight.HeaderText = "重量";
this.H_Weight.Name = "H_Weight";
this.H_Weight.ReadOnly = true;
//
// SegmentPickUpForm
//
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(1305, 611);
this.Controls.Add(this.splitContainer1);
this.MinimumSize = new System.Drawing.Size(1321, 650);
this.Name = "SegmentPickUpForm";
this.Text = "分割领用";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.needSubmitGrid)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.historyDataGrid)).EndInit();
this.ResumeLayout(false);
}
#endregion
private WinFormControl.UButton submitBtn;
private WinFormControl.ULabel uLabel4;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.FlowLayoutPanel numFlowPanel;
private WinFormControl.ULabel uLabel3;
private System.Windows.Forms.ComboBox workUnitSelect;
private System.Windows.Forms.SplitContainer splitContainer1;
private WinFormControl.UButton numSetBtn;
private System.Windows.Forms.ComboBox productBatchSelect;
private WinFormControl.ULabel uLabel2;
private WinFormControl.UButton closeBtn;
private WinFormControl.UTimerLabel uTimerLabel1;
private WinFormControl.UScanPanel uScanPanel1;
private WinFormControl.NetStateWatch netStateWatch1;
private WinFormControl.UWeightControl uWeightControl1;
private WinFormControl.ULabel uLabel1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.GroupBox groupBox2;
private WinFormControl.UDataGridView historyDataGrid;
private WinFormControl.UDataGridView needSubmitGrid;
private System.Windows.Forms.DataGridViewTextBoxColumn U_ID;
private System.Windows.Forms.DataGridViewTextBoxColumn U_RowIndex;
private System.Windows.Forms.DataGridViewTextBoxColumn U_BarCode;
private System.Windows.Forms.DataGridViewTextBoxColumn U_Goods_Name;
private System.Windows.Forms.DataGridViewTextBoxColumn U_Number;
private System.Windows.Forms.DataGridViewTextBoxColumn U_Weight;
private System.Windows.Forms.DataGridViewTextBoxColumn H_ID;
private System.Windows.Forms.DataGridViewTextBoxColumn H_RowIndex;
private System.Windows.Forms.DataGridViewTextBoxColumn H_BarCode;
private System.Windows.Forms.DataGridViewTextBoxColumn H_Goods_Name;
private System.Windows.Forms.DataGridViewTextBoxColumn H_Number;
private System.Windows.Forms.DataGridViewTextBoxColumn H_Weight;
}
}

+ 329
- 0
ButcherFactory.Form/SegmentPickUp_/SegmentPickUpForm.cs View File

@ -0,0 +1,329 @@
using ButcherFactory.BO;
using ButcherFactory.BO.Rpcs;
using ButcherFactory.BO.Utils;
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;
using ButcherFactory.Utils;
using WinFormControl;
using ButcherFactory.BO.LocalBL;
using ButcherFactory.Dialogs;
using ButcherFactory.BO.Bill;
namespace ButcherFactory.SegmentPickUp_
{
public partial class SegmentPickUpForm : Form, IWithRoleForm
{
#region IWithRoleForm
public List<short> RoleName
{
get { return new List<short> { (short). }; }
}
public Form Generate()
{
return this;
}
#endregion
const string FilePatch = @"Config\NumberSetDialog.cfg";
Thread syncBeforeInfo;
Thread uploadData;
BindingList<SegmentPickUp> needSubmitedList;
BindingList<SegmentPickUp> historyList;
long? workUnitID;
long? batchID;
public SegmentPickUpForm()
{
InitializeComponent();
BuildNumberPanel();
netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500);
uScanPanel1.AfterScan += uScanPanel1_AfterScan;
workUnitSelect.SelectedIndexChanged += delegate
{
if (workUnitSelect.SelectedValue == null)
workUnitID = null;
else
workUnitID = (long)workUnitSelect.SelectedValue;
XmlUtil.SerializerObjToFile(new SegmentPickUpConfig { WorkUnitID = workUnitID });
};
productBatchSelect.SelectedIndexChanged += delegate
{
if (productBatchSelect.SelectedValue == null)
batchID = null;
else
batchID = (long)productBatchSelect.SelectedValue;
};
this.FormClosing += delegate
{
if (syncBeforeInfo != null && syncBeforeInfo.IsAlive)
syncBeforeInfo.Abort();
if (uploadData != null && uploadData.IsAlive)
uploadData.Abort();
};
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var initTask = new Thread(LoadBind);
initTask.Start();
syncBeforeInfo = new Thread(GetBeforeInfo);
syncBeforeInfo.Start();
uploadData = new Thread(UpLoadLocalData);
uploadData.Start();
}
private void LoadBind()
{
this.Invoke(new Action(() =>
{
if (netStateWatch1.NetState)
{
BaseInfoSyncRpc.SyncGoodsByTag(ApplyClient.);
BaseInfoSyncRpc.SyncBaseInfo<WorkUnit>();
BaseInfoSyncRpc.SyncBaseInfo<ProductBatch>();
}
productBatchSelect.EBindComboBox<ProductBatch>(x => x.Date == DateTime.Today, 6, "Date");
var config = XmlUtil.DeserializeFromFile<SegmentPickUpConfig>();
workUnitSelect.EBindComboBox<WorkUnit>(x => x.ID == config.WorkUnitID);
BindGoods();
BindGrid();
}));
}
List<UButton> goodsBtns = new List<UButton>();
void BindGoods()
{
var goods = FormClientGoodsSetBL.GetGoodsList();
foreach (var item in goods)
{
var btn = new UButton() { Width = 120, Height = 75, Text = item.Goods_Name, Tag = item.Goods_ID, Font = new Font("宋体", 15), Margin = new Padding(22, 10, 22, 30), PlaySound = true };
btn.Click += GoodsBtnClick;
goodsBtns.Add(btn);
flowLayoutPanel1.Controls.Add(btn);
}
}
void GoodsBtnClick(object sender, EventArgs e)
{
if (batchID == null)
throw new Exception("请先选择批次");
if (uWeightControl1.Weight == 0)
throw new Exception("重量不能为0!");
var c = sender as UButton;
var entity = new SegmentPickUp();
entity.RowIndex = GetRowIndex();
entity.Weight = uWeightControl1.Weight;
entity.Goods_ID = (long)c.Tag;
entity.Goods_Name = c.Text;
entity.ProductBatch_ID = batchID;
entity.WorkUnit_ID = workUnitID;
SegmentPickUpBL.InsertEntityByWeight(entity);
needSubmitedList.Insert(0, entity);
AfterInsert();
}
void BindGrid()
{
needSubmitedList = SegmentPickUpBL.GetSegmentPickUp(true);
needSubmitGrid.DataSource = needSubmitedList;
needSubmitGrid.Refresh();
historyList = SegmentPickUpBL.GetSegmentPickUp(false);
historyDataGrid.DataSource = historyList;
historyDataGrid.Refresh();
}
private void GetBeforeInfo()
{
while (true)
{
if (this.IsHandleCreated)
{
this.Invoke(new Action(() =>
{
if (netStateWatch1.NetState)
{
bool ff = true;
var list = needSubmitedList.Where(x => x.Weight == null).Take(5);
if (!list.Any())
{
list = historyList.Where(x => x.Weight == null).Take(5);
ff = false;
}
if (list.Any())
{
var back = SegmentPickUpBL.GetBeforeInfo(list.Select(x => x.BarCode));
if (back.Any())
{
foreach (var item in back)
{
var f = list.First(x => x.BarCode == item.StringExt1);
f.Weight = item.DecimalExt1;
f.Goods_Name = item.StringExt2;
}
if (ff)
needSubmitGrid.Refresh();
else
historyDataGrid.Refresh();
}
}
}
}));
}
Thread.Sleep(2000);
}
}
private void UpLoadLocalData()
{
while (true)
{
if (this.IsHandleCreated)
{
this.Invoke(new Action(() =>
{
if (netStateWatch1.NetState)
SegmentPickUpBL.UploadSegmentInfo();
}));
}
Thread.Sleep(2000);
}
}
void uScanPanel1_AfterScan()
{
var barCode = uScanPanel1.TextBox.Text.Trim();
if (string.IsNullOrEmpty(barCode))
throw new Exception("请先扫码");
if (barCode.Length != 24)
throw new Exception("条码格式不正确");
if (needSubmitedList.Any(x => x.BarCode == barCode) || historyList.Any(x => x.BarCode == barCode))
return;
var entity = new SegmentPickUp();
entity.BarCode = barCode;
entity.WorkUnit_ID = workUnitID;
entity.RowIndex = GetRowIndex();
SegmentPickUpBL.InsertEntityByCode(entity);
needSubmitedList.Insert(0, entity);
AfterInsert();
uScanPanel1.TextBox.Clear();
}
void AfterInsert()
{
needSubmitGrid.FirstDisplayedScrollingRowIndex = 0;
needSubmitGrid.Rows[0].Selected = true;
needSubmitGrid.Refresh();
}
int GetRowIndex()
{
var f = needSubmitedList.FirstOrDefault(x => x.CreateTime.Date == DateTime.Today);
if (f != null)
return f.RowIndex.Value + 1;
else if (historyList.Any())
return historyList.First().RowIndex.Value + 1;
else
return 1;
}
private void closeBtn_Click(object sender, EventArgs e)
{
Close();
}
private void submitBtn_Click(object sender, EventArgs e)
{
if (needSubmitedList.Count == 0)
throw new Exception("没有待提交记录");
var arr = needSubmitedList.ToList();
SegmentPickUpBL.UpdateSubmit(needSubmitedList.Select(x => x.ID));
foreach (var item in arr)
{
historyList.Add(item);
if (historyList.Count > 50)
historyList.RemoveAt(50);
needSubmitedList.Remove(item);
}
historyDataGrid.FirstDisplayedScrollingRowIndex = 0;
historyDataGrid.Refresh();
needSubmitGrid.Refresh();
}
private void numSetBtn_Click(object sender, EventArgs e)
{
new NumberSetDialog().ShowDialog();
BuildNumberPanel();
}
void BuildNumberPanel()
{
numFlowPanel.Controls.Clear();
if (!System.IO.File.Exists(FilePatch))
return;
var simpBtn = new UButton() { Width = 100, Height = 34, Text = "自定义", Font = new Font("宋体", 15), Margin = new Padding(6, 2, 6, 0), WithStataHode = true, EnableGroup = true };
simpBtn.Click += delegate
{
var cr = GetCurrentRowEntity();
if (cr == null)
return;
var keyBoard = new NumberPad();
if (keyBoard.ShowDialog() == true)
{
var v = 0;
if (int.TryParse(keyBoard.Result, out v) && v > 0)
{
cr.Number = v;
SegmentPickUpBL.UpdateNumber(cr.ID, cr.Number);
needSubmitGrid.Refresh();
}
else
throw new Exception("输入数量有误!");
}
};
numFlowPanel.Controls.Add(simpBtn);
var arr = System.IO.File.ReadAllText(FilePatch).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Reverse();
foreach (var item in arr)
{
var btn = new UButton() { Width = 100, Height = 34, Text = item, Font = new Font("宋体", 15), Margin = new Padding(6, 2, 6, 0), WithStataHode = true, EnableGroup = true };
btn.Click += (sender, e) =>
{
var row = GetCurrentRowEntity();
if (row == null)
return;
var b = sender as UButton;
row.Number = int.Parse(b.Text);
SegmentPickUpBL.UpdateNumber(row.ID, row.Number);
needSubmitGrid.Refresh();
};
numFlowPanel.Controls.Add(btn);
}
}
SegmentPickUp GetCurrentRowEntity()
{
if (needSubmitGrid.CurrentRow == null)
return null;
var row = needSubmitGrid.CurrentRow.DataBoundItem as SegmentPickUp;
if (string.IsNullOrEmpty(row.BarCode))
return row;
return null;
}
}
}

+ 160
- 0
ButcherFactory.Form/SegmentPickUp_/SegmentPickUpForm.resx View File

@ -0,0 +1,160 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="submitBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
<metadata name="U_RowIndex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="U_Number.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="U_Weight.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="numSetBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
<data name="closeBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
<metadata name="H_RowIndex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="H_Number.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

Loading…
Cancel
Save