Browse Source

备货客户端添加按线路分组备货的功能

master
yibo 6 years ago
parent
commit
59f1a41616
9 changed files with 1285 additions and 859 deletions
  1. +8
    -0
      ButcherFactory.BO/Bill/StockUpEntity.cs
  2. +6
    -0
      ButcherFactory.BO/LocalBL/SegmentStockUpBL.cs
  3. +9
    -0
      ButcherFactory.Form/ButcherFactory.Form.csproj
  4. +78
    -0
      ButcherFactory.Form/SegmentStockUp_/DeliverLineGroupSelectDialog.Designer.cs
  5. +75
    -0
      ButcherFactory.Form/SegmentStockUp_/DeliverLineGroupSelectDialog.cs
  6. +120
    -0
      ButcherFactory.Form/SegmentStockUp_/DeliverLineGroupSelectDialog.resx
  7. +5
    -1
      ButcherFactory.Form/SegmentStockUp_/SegmentStockUpConfig.cs
  8. +510
    -426
      ButcherFactory.Form/SegmentStockUp_/SegmentStockUpForm.Designer.cs
  9. +474
    -432
      ButcherFactory.Form/SegmentStockUp_/SegmentStockUpForm.cs

+ 8
- 0
ButcherFactory.BO/Bill/StockUpEntity.cs View File

@ -24,6 +24,7 @@ namespace ButcherFactory.BO
public bool StandardPic { get; set; }
public bool StockUpBySecondNum { get; set; }
public bool FinishAssign { get; set; }
public long? DeliverLineGroup_ID { get; set; }
public bool Finishd
{
get
@ -92,5 +93,12 @@ namespace ButcherFactory.BO
//public bool StandardPic { get; set; }
public decimal? UnitNum { get; set; }
public decimal? SecondNumber { get; set; }
}
public class DeliverLineGroup
{
public long ID { get; set; }
public string Name { get; set; }
public int Order { get; set; }
}
}

+ 6
- 0
ButcherFactory.BO/LocalBL/SegmentStockUpBL.cs View File

@ -106,6 +106,12 @@ namespace ButcherFactory.BO.LocalBL
#endif
return new List<AlreadyStockUp>();
}
}
public static List<DeliverLineGroup> GetDeliverLineGroupList()
{
var json = RpcFacade.Call<string>(RpcPath + "SaleOutStoreRpc/GetDeliverLineGroup");
return JsonConvert.DeserializeObject<List<DeliverLineGroup>>(json);
}
}
}

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

@ -269,6 +269,12 @@
<Compile Include="SegmentSaleOut_\WeightRecordDialog.Designer.cs">
<DependentUpon>WeightRecordDialog.cs</DependentUpon>
</Compile>
<Compile Include="SegmentStockUp_\DeliverLineGroupSelectDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SegmentStockUp_\DeliverLineGroupSelectDialog.Designer.cs">
<DependentUpon>DeliverLineGroupSelectDialog.cs</DependentUpon>
</Compile>
<Compile Include="SegmentStockUp_\PrintAPI.cs" />
<Compile Include="SegmentStockUp_\SegmentStockUpConfig.cs" />
<Compile Include="SegmentStockUp_\SegmentStockUpForm.cs">
@ -402,6 +408,9 @@
<EmbeddedResource Include="SegmentSaleOut_\WeightRecordDialog.resx">
<DependentUpon>WeightRecordDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SegmentStockUp_\DeliverLineGroupSelectDialog.resx">
<DependentUpon>DeliverLineGroupSelectDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SegmentStockUp_\SegmentStockUpForm.resx">
<DependentUpon>SegmentStockUpForm.cs</DependentUpon>
</EmbeddedResource>


+ 78
- 0
ButcherFactory.Form/SegmentStockUp_/DeliverLineGroupSelectDialog.Designer.cs View File

@ -0,0 +1,78 @@
namespace ButcherFactory.SegmentStockUp_
{
partial class DeliverLineGroupSelectDialog
{
/// <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()
{
this.closeBtn = new ButcherFactory.Controls.ColorButton();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// closeBtn
//
this.closeBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.closeBtn.BackColor = System.Drawing.Color.Red;
this.closeBtn.Font = new System.Drawing.Font("宋体", 12F);
this.closeBtn.ForeColor = System.Drawing.Color.White;
this.closeBtn.Location = new System.Drawing.Point(716, 24);
this.closeBtn.Name = "closeBtn";
this.closeBtn.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(215)))), ((int)(((byte)(107)))));
this.closeBtn.Size = new System.Drawing.Size(88, 39);
this.closeBtn.TabIndex = 6;
this.closeBtn.Text = "关闭";
this.closeBtn.UseVisualStyleBackColor = false;
this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.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.flowLayoutPanel1.Location = new System.Drawing.Point(18, 84);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(789, 452);
this.flowLayoutPanel1.TabIndex = 5;
//
// DeliverLineGroupSelectDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(824, 560);
this.Controls.Add(this.closeBtn);
this.Controls.Add(this.flowLayoutPanel1);
this.Name = "DeliverLineGroupSelectDialog";
this.Text = "选择线路分组";
this.ResumeLayout(false);
}
#endregion
private Controls.ColorButton closeBtn;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
}
}

+ 75
- 0
ButcherFactory.Form/SegmentStockUp_/DeliverLineGroupSelectDialog.cs View File

@ -0,0 +1,75 @@
using ButcherFactory.BO;
using ButcherFactory.BO.LocalBL;
using ButcherFactory.BO.Utils;
using ButcherFactory.Controls;
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 ButcherFactory.SegmentStockUp_
{
public partial class DeliverLineGroupSelectDialog : Form
{
Color color = Color.FromArgb(105, 105, 105);
Color selectColor = Color.FromArgb(250, 120, 24);
SegmentStockUpConfig config;
public DeliverLineGroupSelectDialog()
{
InitializeComponent();
this.FormClosing += DeliverLineGroupSelectDialog_FormClosing;
}
void DeliverLineGroupSelectDialog_FormClosing(object sender, FormClosingEventArgs e)
{
XmlUtil.SerializerObjToFile(config);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
config = XmlUtil.DeserializeFromFile<SegmentStockUpConfig>();
BindList();
}
void BindList()
{
flowLayoutPanel1.Controls.Clear();
var list = SegmentStockUpBL.GetDeliverLineGroupList();
foreach (var item in list)
{
var btn = new ColorButton() { Width = 150, Height = 60, Text = item.Name, Tag = item, Font = new Font("宋体", 14), Margin = new Padding(30) };
btn.BackColor = config.LineGroup.Any(x => x.ID == item.ID) ? selectColor : color;
btn.Click += ItemClick;
flowLayoutPanel1.Controls.Add(btn);
}
}
private void ItemClick(object sender, EventArgs e)
{
var btn = sender as ColorButton;
var item = (DeliverLineGroup)btn.Tag;
var first = config.LineGroup.FirstOrDefault(x => x.ID == item.ID);
if (first == null)
{
config.LineGroup.Add(item);
btn.BackColor = selectColor;
}
else
{
config.LineGroup.Remove(first);
btn.BackColor = color;
}
}
private void closeBtn_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

+ 120
- 0
ButcherFactory.Form/SegmentStockUp_/DeliverLineGroupSelectDialog.resx View File

@ -0,0 +1,120 @@
<?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>
</root>

+ 5
- 1
ButcherFactory.Form/SegmentStockUp_/SegmentStockUpConfig.cs View File

@ -1,4 +1,5 @@
using System;
using ButcherFactory.BO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -9,5 +10,8 @@ namespace ButcherFactory.SegmentStockUp_
public class SegmentStockUpConfig
{
public decimal? AllowDownWeight { get; set; }
private List<DeliverLineGroup> mLineGroup = new List<DeliverLineGroup>();
public List<DeliverLineGroup> LineGroup { get { return mLineGroup; } }
}
}

+ 510
- 426
ButcherFactory.Form/SegmentStockUp_/SegmentStockUpForm.Designer.cs
File diff suppressed because it is too large
View File


+ 474
- 432
ButcherFactory.Form/SegmentStockUp_/SegmentStockUpForm.cs View File

@ -1,428 +1,430 @@
using ButcherFactory.BO;
using ButcherFactory.BO.LocalBL;
using ButcherFactory.BO.Utils;
using ButcherFactory.Controls;
using ButcherFactory.Dialogs;
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 ButcherFactory.BO;
using ButcherFactory.BO.LocalBL;
using ButcherFactory.BO.Utils;
using ButcherFactory.Controls;
using ButcherFactory.Dialogs;
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 WinFormControl;
namespace ButcherFactory.SegmentStockUp_
{
public partial class SegmentStockUpForm : FormTemplate, IWithRoleForm
{
#region IWithRoleForm
public List<short> RoleName
{
get { return new List<short> { (short). }; }
}
public Form Generate()
{
return this;
}
using WinFormControl;
namespace ButcherFactory.SegmentStockUp_
{
public partial class SegmentStockUpForm : FormTemplate, IWithRoleForm
{
#region IWithRoleForm
public List<short> RoleName
{
get { return new List<short> { (short). }; }
}
public Form Generate()
{
return this;
}
#endregion
Tuple<string, long> selectedCustomer;
Tuple<string, long> selectedCustomer;
DateTime sendTime = DateTime.Today;
SegmentStockUpConfig config;
BindingList<SaleOutStoreInfo> mainList;
BindingList<SegmentStockUp> detailList;
BindingList<DeliverGoodsLineTemp> finishList;
List<SaleOutStoreInfo> allMain;
List<SegmentStockUp> allDetail;
List<AlreadyStockUp> alreadyList;
Thread syncStockdNumber;
Thread refreshFromServer;
Thread loadBindTask;//onetime
public SegmentStockUpForm()
SegmentStockUpConfig config;
BindingList<SaleOutStoreInfo> mainList;
BindingList<SegmentStockUp> detailList;
BindingList<DeliverGoodsLineTemp> finishList;
List<SaleOutStoreInfo> allMain;
List<SegmentStockUp> allDetail;
List<AlreadyStockUp> alreadyList;
Thread syncStockdNumber;
Thread refreshFromServer;
Thread loadBindTask;//onetime
List<long> mLineGroupIds = new List<long>();
public SegmentStockUpForm()
{
config = XmlUtil.DeserializeFromFile<SegmentStockUpConfig>();
InitializeComponent();
finishList = new BindingList<DeliverGoodsLineTemp>();
allMain = new List<SaleOutStoreInfo>();
allDetail = new List<SegmentStockUp>();
alreadyList = new List<AlreadyStockUp>();
// dataPicker.Text = sendTime.ToString("yyyy-MM-dd");
uScanPanel1.AfterScan += uScanPanel1_AfterScan;
this.FormClosing += delegate
{
AbortTask();
};
}
void AbortTask()
{
if (loadBindTask != null && loadBindTask.IsAlive)
loadBindTask.Abort();
if (syncStockdNumber != null && syncStockdNumber.IsAlive)
syncStockdNumber.Abort();
if (refreshFromServer != null && refreshFromServer.IsAlive)
refreshFromServer.Abort();
}
protected override void OnLoad(EventArgs e)
{
BindDeliverLineGroup(false);
downWeightBox.Text = string.Format("{0:#0.######}", config.AllowDownWeight);
StartTask();
base.OnLoad(e);
}
void StartTask()
{
allDetail = SegmentStockUpBL.GetLocalList(sendTime);
loadBindTask = new Thread(LoadBind);
loadBindTask.Start();
syncStockdNumber = new Thread(SyncStockdNumber);
syncStockdNumber.Start();
refreshFromServer = new Thread(RefreshFromServer);
refreshFromServer.Start();
}
private void LoadBind()
{
config = XmlUtil.DeserializeFromFile<SegmentStockUpConfig>();
InitializeComponent();
finishList = new BindingList<DeliverGoodsLineTemp>();
allMain = new List<SaleOutStoreInfo>();
allDetail = new List<SegmentStockUp>();
alreadyList = new List<AlreadyStockUp>();
// dataPicker.Text = sendTime.ToString("yyyy-MM-dd");
uScanPanel1.AfterScan += uScanPanel1_AfterScan;
this.FormClosing += delegate
{
AbortTask();
};
}
void AbortTask()
{
if (loadBindTask != null && loadBindTask.IsAlive)
loadBindTask.Abort();
if (syncStockdNumber != null && syncStockdNumber.IsAlive)
syncStockdNumber.Abort();
if (refreshFromServer != null && refreshFromServer.IsAlive)
refreshFromServer.Abort();
}
protected override void OnLoad(EventArgs e)
var mainList = SegmentStockUpBL.GetSaleOutStoreList(sendTime);
var appendAlready = SegmentStockUpBL.SyncAlreadyNumber(mainList.Select(x => x.DetailID), null);
ReBind(mainList, appendAlready);
}
object _lock = new object();
//loadBind,Refresh, taskMain,taskAlready,Scan
void ReBind(List<SaleOutStoreInfo> mainList, List<AlreadyStockUp> appendAlready)
{
lock (_lock)
{
AppendData(mainList, appendAlready);
var needRefresh = PrepareFinishList();
if (needRefresh)
BindFinishGrid();
}
}
void AppendData(List<SaleOutStoreInfo> mainList, List<AlreadyStockUp> appendAlready)
{
if (mainList.Any())
allMain = mainList;
foreach (var item in appendAlready)
{
var first = alreadyList.FirstOrDefault(x => x.DetailID == item.DetailID);
if (first == null)
{
first = item;
alreadyList.Add(item);
}
else if (first.MaxID < item.MaxID)
{
first.MaxID = item.MaxID;
first.UnitNum = (first.UnitNum ?? 0) + (item.UnitNum ?? 0);
first.SecondNumber = (first.SecondNumber ?? 0) + (item.SecondNumber ?? 0);
}
else
continue;
//局部更新
if (!mainList.Any())
UpdateMainInfo(first);
}
//全量更新
if (mainList.Any())
{
foreach (var item in alreadyList)
UpdateMainInfo(item);
}
}
void UpdateMainInfo(AlreadyStockUp item)
{
downWeightBox.Text = string.Format("{0:#0.######}", config.AllowDownWeight);
StartTask();
base.OnLoad(e);
}
void StartTask()
{
allDetail = SegmentStockUpBL.GetLocalList(sendTime);
loadBindTask = new Thread(LoadBind);
loadBindTask.Start();
syncStockdNumber = new Thread(SyncStockdNumber);
syncStockdNumber.Start();
refreshFromServer = new Thread(RefreshFromServer);
refreshFromServer.Start();
}
private void LoadBind()
{
var mainList = SegmentStockUpBL.GetSaleOutStoreList(sendTime);
var appendAlready = SegmentStockUpBL.SyncAlreadyNumber(mainList.Select(x => x.DetailID), null);
ReBind(mainList, appendAlready);
}
object _lock = new object();
//loadBind,Refresh, taskMain,taskAlready,Scan
void ReBind(List<SaleOutStoreInfo> mainList, List<AlreadyStockUp> appendAlready)
{
lock (_lock)
{
AppendData(mainList, appendAlready);
var needRefresh = PrepareFinishList();
if (needRefresh)
BindFinishGrid();
}
}
void AppendData(List<SaleOutStoreInfo> mainList, List<AlreadyStockUp> appendAlready)
{
if (mainList.Any())
allMain = mainList;
foreach (var item in appendAlready)
{
var first = alreadyList.FirstOrDefault(x => x.DetailID == item.DetailID);
if (first == null)
{
first = item;
alreadyList.Add(item);
}
else if (first.MaxID < item.MaxID)
{
first.MaxID = item.MaxID;
first.UnitNum = (first.UnitNum ?? 0) + (item.UnitNum ?? 0);
first.SecondNumber = (first.SecondNumber ?? 0) + (item.SecondNumber ?? 0);
}
else
continue;
//局部更新
if (!mainList.Any())
UpdateMainInfo(first);
}
//全量更新
if (mainList.Any())
{
foreach (var item in alreadyList)
UpdateMainInfo(item);
}
}
void UpdateMainInfo(AlreadyStockUp item)
{
var mainFirst = allMain.FirstOrDefault(x => x.DetailID == item.DetailID);
if (mainFirst != null)
var mainFirst = allMain.FirstOrDefault(x => x.DetailID == item.DetailID);
if (mainFirst != null)
{
mainFirst.StandardPic = false;// item.StandardPic;
mainFirst.SUnitNum = item.UnitNum;
mainFirst.StandardPic = false;// item.StandardPic;
mainFirst.SUnitNum = item.UnitNum;
mainFirst.SSecondNumber = item.SecondNumber;
mainFirst.DownFloat = config.AllowDownWeight;
}
}
//返回是否需要更新Grid;
bool PrepareFinishList()
{
var old = finishList.ToList();
var append = new List<DeliverGoodsLineTemp>();
finishList = new BindingList<DeliverGoodsLineTemp>();
var idx = 0;
foreach (var item in allMain.GroupBy(x => x.Customer_Name).Where(x => x.All(y => y.Finishd)))
{
var detail = new DeliverGoodsLineTemp();
detail.RowIndex = ++idx;
detail.Name = item.Key;
detail.UnitNum = item.Sum(x => x.UnitNum ?? 0);
detail.SecondNumber = item.Sum(x => x.SecondNumber ?? 0);
detail.SUnitNum = item.Sum(x => x.SUnitNum ?? 0);
detail.SSecondNumber = item.Sum(x => x.SSecondNumber ?? 0);
if (!old.Any(x => x.Name == item.Key))
{
idx--;
append.Add(detail);
}
else
finishList.Insert(0, detail);
}
foreach (var item in append)
{
item.RowIndex = ++idx;
finishList.Insert(0, item);
}
if (old.Count != finishList.Count)
return true;
return old.Except(finishList).Count() != 0;
}
void BindFinishGrid()
{
this.Invoke(new Action(() =>
{
finishGrid.DataSource = finishList;
if (finishList.Any())
finishGrid.Rows[0].Selected = true;
finishGrid.Refresh();
}));
}
private void SyncStockdNumber()
{
while (true)
{
Thread.Sleep(2000);
IEnumerable<long> tags = new List<long>();
long? maxID = null;
if (alreadyList.Any())
maxID = alreadyList.Max(x => x.MaxID);
else
tags = allMain.Select(x => x.DetailID);
if (maxID.HasValue || tags.Any())
{
var temp = SegmentStockUpBL.SyncAlreadyNumber(tags, maxID);
if (temp.Any())
{
ReBind(new List<SaleOutStoreInfo>(), temp);
}
}
}
}
private void RefreshFromServer()
{
while (true)
{
Thread.Sleep(2 * 60 * 1000);
var temp = SegmentStockUpBL.GetSaleOutStoreList(sendTime);
if (temp.Any())
{
ReBind(temp, new List<AlreadyStockUp>());
}
}
}
void uScanPanel1_AfterScan()
{
var code = uScanPanel1.TextBox.Text;
if (string.IsNullOrEmpty(code))
return;
if (allDetail.Any(x => x.BarCode == code))
{
InfoBox.Show("错误", "条码已使用过", Color.Green, 1, this);
return;
}
var info = SegmentStockUpBL.StockUpScan(code);
if (info == null)
{
InfoBox.Show("错误", "条码未入库", Color.Blue, 1, this);
return;
}
InsertDetail(info);
}
void InsertDetail(Tuple<string, decimal?, bool> scan)
mainFirst.DownFloat = config.AllowDownWeight;
}
}
//返回是否需要更新Grid;
bool PrepareFinishList()
{
var old = finishList.ToList();
var append = new List<DeliverGoodsLineTemp>();
finishList = new BindingList<DeliverGoodsLineTemp>();
var idx = 0;
foreach (var item in allMain.GroupBy(x => x.Customer_Name).Where(x => x.All(y => y.Finishd)))
{
var detail = new DeliverGoodsLineTemp();
detail.RowIndex = ++idx;
detail.Name = item.Key;
detail.UnitNum = item.Sum(x => x.UnitNum ?? 0);
detail.SecondNumber = item.Sum(x => x.SecondNumber ?? 0);
detail.SUnitNum = item.Sum(x => x.SUnitNum ?? 0);
detail.SSecondNumber = item.Sum(x => x.SSecondNumber ?? 0);
if (!old.Any(x => x.Name == item.Key))
{
idx--;
append.Add(detail);
}
else
finishList.Insert(0, detail);
}
foreach (var item in append)
{
item.RowIndex = ++idx;
finishList.Insert(0, item);
}
if (old.Count != finishList.Count)
return true;
return old.Except(finishList).Count() != 0;
}
void BindFinishGrid()
{
this.Invoke(new Action(() =>
{
finishGrid.DataSource = finishList;
if (finishList.Any())
finishGrid.Rows[0].Selected = true;
finishGrid.Refresh();
}));
}
private void SyncStockdNumber()
{
SaleOutStoreInfo saleOutStore;
while (true)
{
Thread.Sleep(2000);
IEnumerable<long> tags = new List<long>();
long? maxID = null;
if (alreadyList.Any())
maxID = alreadyList.Max(x => x.MaxID);
else
tags = allMain.Select(x => x.DetailID);
if (maxID.HasValue || tags.Any())
{
var temp = SegmentStockUpBL.SyncAlreadyNumber(tags, maxID);
if (temp.Any())
{
ReBind(new List<SaleOutStoreInfo>(), temp);
}
}
}
}
private void RefreshFromServer()
{
while (true)
{
Thread.Sleep(2 * 60 * 1000);
var temp = SegmentStockUpBL.GetSaleOutStoreList(sendTime);
if (temp.Any())
{
ReBind(temp, new List<AlreadyStockUp>());
}
}
}
void uScanPanel1_AfterScan()
{
var code = uScanPanel1.TextBox.Text;
if (string.IsNullOrEmpty(code))
return;
if (allDetail.Any(x => x.BarCode == code))
{
InfoBox.Show("错误", "条码已使用过", Color.Green, 1, this);
return;
}
var info = SegmentStockUpBL.StockUpScan(code);
if (info == null)
{
InfoBox.Show("错误", "条码未入库", Color.Blue, 1, this);
return;
}
InsertDetail(info);
}
void InsertDetail(Tuple<string, decimal?, bool> scan)
{
SaleOutStoreInfo saleOutStore;
if (selectedCustomer != null)
saleOutStore = allMain.FirstOrDefault(x => x.Customer_Name == selectedCustomer.Item1 && !x.Finishd && x.Goods_Code == scan.Item1);
saleOutStore = allMain.FirstOrDefault(x => x.Customer_Name == selectedCustomer.Item1 && !x.Finishd && x.Goods_Code == scan.Item1);
else
saleOutStore = allMain.FirstOrDefault(x => !x.Finishd && x.Goods_Code == scan.Item1);
if (saleOutStore == null)
{
InfoBox.Show("提示", "没有订单", Color.Red, 1, this);
return;
}
var detail = new SegmentStockUp();
detail.BarCode = uScanPanel1.TextBox.Text;
detail.Date = sendTime;
detail.DetailID = saleOutStore.DetailID;
detail.DeliverGoodsLine_Name = saleOutStore.DeliverGoodsLine_Name;
detail.Goods_Name = saleOutStore.Goods_Name;
saleOutStore = allMain.FirstOrDefault(x => mLineGroupIds.Contains(x.DeliverLineGroup_ID ?? 0) && !x.Finishd && x.Goods_Code == scan.Item1);
if (saleOutStore == null)
{
InfoBox.Show("提示", "没有订单", Color.Red, 1, this);
return;
}
var detail = new SegmentStockUp();
detail.BarCode = uScanPanel1.TextBox.Text;
detail.Date = sendTime;
detail.DetailID = saleOutStore.DetailID;
detail.DeliverGoodsLine_Name = saleOutStore.DeliverGoodsLine_Name;
detail.Goods_Name = saleOutStore.Goods_Name;
//detail.BillID = saleOutStore.BillID;
detail.Customer_Name = saleOutStore.Customer_Name;
detail.UnitNumber = scan.Item2;
detail.StandardPic = scan.Item3;
//if (detail.UnitNumber.HasValue && saleOutStore.Rate.HasValue)
// detail.SecondNumber = detail.UnitNumber * saleOutStore.Rate;
//else
detail.SecondNumber = 1;
var number = 0m;
if (saleOutStore.StockUpBySecondNum)
number = saleOutStore.SecondNumber ?? 0;
else
number = (saleOutStore.UnitNum ?? 0) - (config.AllowDownWeight ?? 0);
detail.Customer_Name = saleOutStore.Customer_Name;
detail.UnitNumber = scan.Item2;
detail.StandardPic = scan.Item3;
//if (detail.UnitNumber.HasValue && saleOutStore.Rate.HasValue)
// detail.SecondNumber = detail.UnitNumber * saleOutStore.Rate;
//else
detail.SecondNumber = 1;
var number = 0m;
if (saleOutStore.StockUpBySecondNum)
number = saleOutStore.SecondNumber ?? 0;
else
number = (saleOutStore.UnitNum ?? 0) - (config.AllowDownWeight ?? 0);
//if (!detail.StandardPic)
// number = saleOutStore.SecondNumber;
// number = saleOutStore.SecondNumber;
var already = alreadyList.FirstOrDefault(x => x.DetailID == detail.DetailID);
if (already == null)
already = new AlreadyStockUp() { DetailID = detail.DetailID };//StandardPic = detail.StandardPic
var back = SegmentStockUpBL.Insert(detail, already, number,saleOutStore.StockUpBySecondNum);
if (back == null)
{
InfoBox.Show("提示", "网络错误!", Color.Red, 1, this);
return;
}
if (back.State == -1)
{
InfoBox.Show("提示", "条码已使用过", Color.Green, 1, this);
return;
}
//back.StandardPic = detail.StandardPic;
back.DetailID = detail.DetailID;
if (back.State == 0)
{
ReBind(new List<SaleOutStoreInfo>(), new List<AlreadyStockUp> { back });
InsertDetail(scan);
return;
}
if (back.State != 1)
{
InfoBox.Show("提示", "未知状态" + back.State, Color.Green, 1, this);
return;
}
ReBind(new List<SaleOutStoreInfo>(), new List<AlreadyStockUp> { back });
allDetail.Add(detail);
if (printCk.Checked)
var back = SegmentStockUpBL.Insert(detail, already, number, saleOutStore.StockUpBySecondNum);
if (back == null)
{
InfoBox.Show("提示", "网络错误!", Color.Red, 1, this);
return;
}
if (back.State == -1)
{
InfoBox.Show("提示", "条码已使用过", Color.Green, 1, this);
return;
}
//back.StandardPic = detail.StandardPic;
back.DetailID = detail.DetailID;
if (back.State == 0)
{
ReBind(new List<SaleOutStoreInfo>(), new List<AlreadyStockUp> { back });
InsertDetail(scan);
return;
}
if (back.State != 1)
{
var last = 0m;
// allMain.Where(x => x.Goods_Name == saleOutStore.Goods_Name && x.DeliverGoodsLine_Name == saleOutStore.DeliverGoodsLine_Name)
// .Sum(x => ((x.UnitNum ?? 0) - (x.SUnitNum ?? 0)) < 0 ? 0 : ((x.UnitNum ?? 0) - (x.SUnitNum ?? 0)));
//if (last < 0)
InfoBox.Show("提示", "未知状态" + back.State, Color.Green, 1, this);
return;
}
ReBind(new List<SaleOutStoreInfo>(), new List<AlreadyStockUp> { back });
allDetail.Add(detail);
if (printCk.Checked)
{
var last = 0m;
// allMain.Where(x => x.Goods_Name == saleOutStore.Goods_Name && x.DeliverGoodsLine_Name == saleOutStore.DeliverGoodsLine_Name)
// .Sum(x => ((x.UnitNum ?? 0) - (x.SUnitNum ?? 0)) < 0 ? 0 : ((x.UnitNum ?? 0) - (x.SUnitNum ?? 0)));
//if (last < 0)
// last = 0;
SegmentStockUpPrint.Print(detail, last, saleOutStore);
SegmentStockUpPrint.Print(detail, last, saleOutStore);
}
var hasUnFinish = allMain.Where(x => x.Customer_Name == saleOutStore.Customer_Name).Any(x => !x.Finishd);
if (!hasUnFinish)
InfoBox.Show("提示", string.Format("{0} 备货完成", saleOutStore.Customer_Name), Color.Green, 1, this);
BindMainGrid(saleOutStore);
}
void BindMainGrid(SaleOutStoreInfo saleOutStore)
{
var main = new List<SaleOutStoreInfo>();
foreach (var g in allMain.Where(x => x.Goods_Name == saleOutStore.Goods_Name).GroupBy(x => x.Customer_Name))
{
var item = new SaleOutStoreInfo();
var f = g.First();
main.Add(item);
item.Customer_Name = g.Key;
item.Goods_Name = f.Goods_Name;
item.Goods_Spec = f.Goods_Spec;
item.SecondNumber = g.Sum(x => x.SecondNumber ?? 0);
item.UnitNum = g.Sum(x => x.UnitNum ?? 0);
item.SSecondNumber = g.Sum(x => x.SSecondNumber ?? 0);
InfoBox.Show("提示", string.Format("{0} 备货完成", saleOutStore.Customer_Name), Color.Green, 1, this);
BindMainGrid(saleOutStore);
}
void BindMainGrid(SaleOutStoreInfo saleOutStore)
{
var main = new List<SaleOutStoreInfo>();
foreach (var g in allMain.Where(x => x.Goods_Name == saleOutStore.Goods_Name).GroupBy(x => x.Customer_Name))
{
var item = new SaleOutStoreInfo();
var f = g.First();
main.Add(item);
item.Customer_Name = g.Key;
item.Goods_Name = f.Goods_Name;
item.Goods_Spec = f.Goods_Spec;
item.SecondNumber = g.Sum(x => x.SecondNumber ?? 0);
item.UnitNum = g.Sum(x => x.UnitNum ?? 0);
item.SSecondNumber = g.Sum(x => x.SSecondNumber ?? 0);
item.SUnitNum = g.Sum(x => x.SUnitNum ?? 0);
item.DownFloat = config.AllowDownWeight;
item.StockUpBySecondNum = f.StockUpBySecondNum;
item.FinishAssign = f.FinishAssign;
}
mainList = new BindingList<SaleOutStoreInfo>(main.OrderBy(x => x.Finishd).ToList());
mainGridView.DataSource = mainList;
mainGridView.Refresh();
BindDetail(main.Where(x => x.Customer_Name == saleOutStore.Customer_Name).First());
}
void BindDetail(SaleOutStoreInfo first)
{
//if (first != null)
//{
driveLineLbl.Text = first.DeliverGoodsLine_Name;
goodsLbl.Text = first.Goods_Name;
dhNumberLbl.Text = string.Format("{0:#0.##}", first.SecondNumber);
dhUnitNumLbl.Text = string.Format("{0:#0.##}", first.UnitNum);
bhNumberLbl.Text = string.Format("{0:#0.##}", first.SSecondNumber);
item.FinishAssign = f.FinishAssign;
}
mainList = new BindingList<SaleOutStoreInfo>(main.OrderBy(x => x.Finishd).ToList());
mainGridView.DataSource = mainList;
mainGridView.Refresh();
BindDetail(main.Where(x => x.Customer_Name == saleOutStore.Customer_Name).First());
}
void BindDetail(SaleOutStoreInfo first)
{
//if (first != null)
//{
driveLineLbl.Text = first.DeliverGoodsLine_Name;
goodsLbl.Text = first.Goods_Name;
dhNumberLbl.Text = string.Format("{0:#0.##}", first.SecondNumber);
dhUnitNumLbl.Text = string.Format("{0:#0.##}", first.UnitNum);
bhNumberLbl.Text = string.Format("{0:#0.##}", first.SSecondNumber);
bhUnitNumLbl.Text = string.Format("{0:#0.##}", first.SUnitNum);
var detail = allDetail.Where(x => x.Customer_Name == first.Customer_Name && x.Goods_Name == first.Goods_Name).OrderByDescending(x => x.ID);
detailList = new BindingList<SegmentStockUp>(detail.ToList());
//}
//else
//{
// driveLineLbl.Text = string.Empty;
// goodsLbl.Text = string.Empty;
// dhNumberLbl.Text = string.Empty;
// dhUnitNumLbl.Text = string.Empty;
// bhNumberLbl.Text = string.Empty;
// bhUnitNumLbl.Text = string.Empty;
// detailList = new BindingList<SegmentStockUp>();
//}
detailGridView.DataSource = detailList;
detailGridView.Refresh();
}
private void refresh_Click(object sender, EventArgs e)
{
AbortTask();
StartTask();
}
private void mainGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
return;
var item = mainGridView.CurrentRow.DataBoundItem as SaleOutStoreInfo;
BindDetail(item);
}
private void mainGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
DataGridViewRow dgrSingle = mainGridView.Rows[e.RowIndex];
var v = (bool)dgrSingle.Cells["D_Finishd"].Value;
if (v)
{
dgrSingle.DefaultCellStyle.BackColor = Color.YellowGreen;
}
var detail = allDetail.Where(x => x.Customer_Name == first.Customer_Name && x.Goods_Name == first.Goods_Name).OrderByDescending(x => x.ID);
detailList = new BindingList<SegmentStockUp>(detail.ToList());
//}
//else
//{
// driveLineLbl.Text = string.Empty;
// goodsLbl.Text = string.Empty;
// dhNumberLbl.Text = string.Empty;
// dhUnitNumLbl.Text = string.Empty;
// bhNumberLbl.Text = string.Empty;
// bhUnitNumLbl.Text = string.Empty;
// detailList = new BindingList<SegmentStockUp>();
//}
detailGridView.DataSource = detailList;
detailGridView.Refresh();
}
private void refresh_Click(object sender, EventArgs e)
{
AbortTask();
StartTask();
}
private void mainGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
return;
var item = mainGridView.CurrentRow.DataBoundItem as SaleOutStoreInfo;
BindDetail(item);
}
private void mainGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
DataGridViewRow dgrSingle = mainGridView.Rows[e.RowIndex];
var v = (bool)dgrSingle.Cells["D_Finishd"].Value;
if (v)
{
dgrSingle.DefaultCellStyle.BackColor = Color.YellowGreen;
}
}
private void colorButton1_Click(object sender, EventArgs e)
{
var detail = new SegmentStockUp() { DeliverGoodsLine_Name = "青岛龙钰聚祥万福批发部", Date = DateTime.Today, BarCode="260912011201905120100005" };
var detail = new SegmentStockUp() { DeliverGoodsLine_Name = "青岛龙钰聚祥万福批发部", Date = DateTime.Today, BarCode = "260912011201905120100005" };
var last = 5.234m;
var saleOutStore = new SaleOutStoreInfo() { Customer_Name = "青岛市大客户", SendQueue = 51 };
SegmentStockUpPrint.Print(detail, last, saleOutStore);
@ -446,7 +448,7 @@ namespace ButcherFactory.SegmentStockUp_
var pad = new NumberPad();
if (pad.ShowDialog() == true)
{
decimal? weight=null;
decimal? weight = null;
if (!string.IsNullOrEmpty(pad.Result))
{
decimal v;
@ -459,38 +461,78 @@ namespace ButcherFactory.SegmentStockUp_
config.AllowDownWeight = weight;
XmlUtil.SerializerObjToFile(config);
}
}
}
class DeliverGoodsLineTemp
{
public string Name { get; set; }
public int RowIndex { get; set; }
public decimal? SecondNumber { get; set; }
public decimal? UnitNum { get; set; }
public decimal? SSecondNumber { get; set; }
public decimal? SUnitNum { get; set; }
public override bool Equals(object obj)
{
var tag = obj as DeliverGoodsLineTemp;
return tag.Name == this.Name
&& tag.UnitNum == this.UnitNum
&& tag.SecondNumber == this.SecondNumber
&& tag.SUnitNum == this.SUnitNum
&& tag.SSecondNumber == this.SSecondNumber;
}
public override int GetHashCode()
{
var hc1 = Name.GetHashCode();
var hc2 = UnitNum.GetHashCode();
var hc3 = SecondNumber.GetHashCode();
var hc4 = SUnitNum.GetHashCode();
var hc5 = SSecondNumber.GetHashCode();
return hc1 ^ hc2 ^ hc3 ^ hc4 ^ hc5;
}
}
}
}
private void lineGroupSetBtn_Click(object sender, EventArgs e)
{
new DeliverLineGroupSelectDialog().ShowDialog();
BindDeliverLineGroup(true);
}
Color color = Color.FromArgb(105, 105, 105);
Color selectColor = Color.FromArgb(250, 120, 24);
void BindDeliverLineGroup(bool loadNew)
{
flowLayoutPanel1.Controls.Clear();
mLineGroupIds.Clear();
if (loadNew)
config = XmlUtil.DeserializeFromFile<SegmentStockUpConfig>();
foreach (var item in config.LineGroup)
{
var btn = new ColorButton() { Width = 150, Height = 60, Text = item.Name, Tag = item, Font = new Font("宋体", 14), Margin = new Padding(30) };
btn.BackColor = color;
btn.Click += DeliverLineBtn_Click;
flowLayoutPanel1.Controls.Add(btn);
}
}
private void DeliverLineBtn_Click(object sender, EventArgs e)
{
var btn = sender as ColorButton;
var item = (DeliverLineGroup)btn.Tag;
var first = mLineGroupIds.FirstOrDefault(x => x == item.ID);
if (first == 0)
{
mLineGroupIds.Add(item.ID);
btn.BackColor = selectColor;
}
else
{
mLineGroupIds.Remove(item.ID);
btn.BackColor = color;
}
}
}
class DeliverGoodsLineTemp
{
public string Name { get; set; }
public int RowIndex { get; set; }
public decimal? SecondNumber { get; set; }
public decimal? UnitNum { get; set; }
public decimal? SSecondNumber { get; set; }
public decimal? SUnitNum { get; set; }
public override bool Equals(object obj)
{
var tag = obj as DeliverGoodsLineTemp;
return tag.Name == this.Name
&& tag.UnitNum == this.UnitNum
&& tag.SecondNumber == this.SecondNumber
&& tag.SUnitNum == this.SUnitNum
&& tag.SSecondNumber == this.SSecondNumber;
}
public override int GetHashCode()
{
var hc1 = Name.GetHashCode();
var hc2 = UnitNum.GetHashCode();
var hc3 = SecondNumber.GetHashCode();
var hc4 = SUnitNum.GetHashCode();
var hc5 = SSecondNumber.GetHashCode();
return hc1 ^ hc2 ^ hc3 ^ hc4 ^ hc5;
}
}
}

Loading…
Cancel
Save