Browse Source

记录重量

master
robin 4 years ago
parent
commit
4f7142334d
3 changed files with 88 additions and 6 deletions
  1. +1
    -0
      ButcherFactory.Form/ButcherFactory.Form.csproj
  2. +43
    -6
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs
  3. +44
    -0
      ButcherFactory.Form/SegmentProductionAuto_/WeightDetails.cs

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

@ -213,6 +213,7 @@
<Compile Include="SegmentPickUp_\SegmentPickUpForm.Designer.cs">
<DependentUpon>SegmentPickUpForm.cs</DependentUpon>
</Compile>
<Compile Include="SegmentProductionAuto_\WeightDetails.cs" />
<Compile Include="SegmentProductionAuto_\LogForm.cs">
<SubType>Form</SubType>
</Compile>


+ 43
- 6
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -87,8 +87,8 @@ namespace ButcherFactory.SegmentProductionAuto_
uploadData.Abort();
if (checkInStoreState != null && checkInStoreState.IsAlive)
checkInStoreState.Abort();
}
}
WeightDetails mCache;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
@ -98,8 +98,27 @@ namespace ButcherFactory.SegmentProductionAuto_
checkInStoreState = new Thread(CheckInStored);
checkInStoreState.Start();
uploadData = new Thread(UpLoadLocalData);
uploadData.Start();
uploadData = new Thread(UpLoadLocalData);
uploadData.Start();
mCache = XmlUtil.DeserializeFromFile<WeightDetails>();
var del = new List<long>();
if (mCache.Cache == null)
{
mCache.Cache = new Dictionary<long, List<decimal>>();
}
foreach (var item in mCache.Cache)
{
if (item.Value == null || item.Value.Count == 0)
{
del.Add(item.Key);
}
}
foreach (var v in del)
{
mCache.Cache.Remove(v);
}
wDic = mCache.Cache;
}
void LoadBind()
@ -183,12 +202,24 @@ namespace ButcherFactory.SegmentProductionAuto_
if ((item.EachNumber ?? 0) > 0)
{
bTag.Label.MaxCount = item.EachNumber.Value;
bTag.Label.Text = string.Format("{0}-0", item.EachNumber.Value);
if (wDic.ContainsKey(item.Goods_ID))
{
var l = wDic[item.Goods_ID];
bTag.Label.Text = string.Format("{0}-{1}", item.EachNumber.Value, l.Count);
}
else
{
bTag.Label.Text = string.Format("{0}-0", item.EachNumber.Value);
}
bTag.Button.Click += delegate
{
if (batchID == null)
throw new Exception("请先选择批次");
var weight = uWeightControl1.Weight;
var weight = uWeightControl1.Weight;
//#if DEBUG
// if (weight == 0)
// weight = (item.StandardWeightLow ?? 4.0m) + 0.1m;
//#endif
if (weight == 0)
throw new Exception("重量不能为0");
if (item.StandardWeight.HasValue)
@ -217,6 +248,8 @@ namespace ButcherFactory.SegmentProductionAuto_
weight = l.Sum(x => x);
InsertSegmentProduction(item, weight);
}
mCache.Cache = wDic;
XmlUtil.SerializerObjToFile(mCache);
};
bTag.Label.Click += delegate
@ -256,6 +289,10 @@ namespace ButcherFactory.SegmentProductionAuto_
var btn = sender as ColorButton;
var detail = btn.Tag as ClientGoodsSet_Detail;
var weight = uWeightControl1.Weight;
//#if DEBUG
// if (weight == 0)
// weight = (detail.StandardWeightLow ?? 4.0m) + 0.1m;
//#endif
if (weight == 0)
throw new Exception("重量不能为0");
if (detail.StandardWeight.HasValue)


+ 44
- 0
ButcherFactory.Form/SegmentProductionAuto_/WeightDetails.cs View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace ButcherFactory.SegmentProductionAuto_
{
[XmlType("KeyValue"), XmlRoot("KeyValue")]
public class SerializableKeyValuePair<TKey, TValue>
{
public TKey Key { get; set; }
public TValue Value { get; set; }
}
public static class SerializableKeyValuePairExtensions
{
public static SerializableKeyValuePair<TKey, TValue> ToSerializablePair<TKey, TValue>(this KeyValuePair<TKey, TValue> pair)
{
return new SerializableKeyValuePair<TKey, TValue> { Key = pair.Key, Value = pair.Value };
}
}
public class WeightDetails
{
[XmlIgnore]
public Dictionary<long, List<decimal>> Cache { get; set; }
[XmlArray("Cache")]
public SerializableKeyValuePair<long, List<decimal>>[] CacheArray
{
get
{
return Cache == null ? null : Cache.Select(p => p.ToSerializablePair()).ToArray();
}
set
{
Cache = value == null ? null : value.ToDictionary(p => p.Key, p => p.Value);
}
}
}
}

Loading…
Cancel
Save