2 Commits

Author SHA1 Message Date
  robin 4ef56ada44 .. 4 years ago
  robin 17bf7561e1 add 总码 4 years ago
14 changed files with 1261 additions and 687 deletions
Split View
  1. +14
    -5
      ButcherFactory.BO/Bill/SegmentProduction.cs
  2. +30
    -0
      ButcherFactory.BO/Bill/TotalCode.cs
  3. +1
    -0
      ButcherFactory.BO/ButcherFactory.BO.csproj
  4. +104
    -16
      ButcherFactory.BO/LocalBL/SegmentProductionBL.cs
  5. +10
    -0
      ButcherFactory.Form/ButcherFactory.Form.csproj
  6. +76
    -0
      ButcherFactory.Form/Controls/CodePanel.Designer.cs
  7. +25
    -0
      ButcherFactory.Form/Controls/CodePanel.cs
  8. +120
    -0
      ButcherFactory.Form/Controls/CodePanel.resx
  9. +9
    -7
      ButcherFactory.Form/Controls/UserControl1.Designer.cs
  10. +541
    -590
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs
  11. +262
    -63
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs
  12. +0
    -6
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.resx
  13. +3
    -0
      ButcherFactory.Form/SegmentProductionAuto_/WeightView.cs
  14. +66
    -0
      ButcherFactory.Form/SegmentProduction_/SegmentSumCodePrint.cs

+ 14
- 5
ButcherFactory.BO/Bill/SegmentProduction.cs View File

@ -22,10 +22,9 @@ namespace ButcherFactory.BO
get
{
if (string.IsNullOrEmpty(BarCode))
return null;
var tag = "260912011" + DateTime.Today.Year;
if (BarCode.Contains(tag))
return BarCode.Replace(tag, "");
return null;
if (BarCode.Length > 4)
return BarCode.Substring(BarCode.Length - 4);
return BarCode;
}
}
@ -34,7 +33,17 @@ namespace ButcherFactory.BO
public long ProductBatch_ID { get; set; }
public long Goods_ID { get; set; }
public long Goods_ID { get; set; }
[DbColumn(DefaultValue = 0)]
public long TotalCode_ID { get; set; }
[NonDmoProperty]
public bool Select { get; set; }
[ReferenceTo(typeof(TotalCode), "BarCode")]
[Join("TotalCode_ID", "ID")]
public string TotalCode_Code { get; set; }
public decimal Weight { get; set; }


+ 30
- 0
ButcherFactory.BO/Bill/TotalCode.cs View File

@ -0,0 +1,30 @@
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
{
[MapToTable("Butcher_TotalCode")]
public class TotalCode : SyncBill
{
public string BarCode { get; set; }
[NonDmoProperty]
public string ShortCode
{
get
{
if (string.IsNullOrEmpty(BarCode))
return "";
if (BarCode.Length>4)
return BarCode.Substring(BarCode.Length-4);
return BarCode;
}
}
}
}

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

@ -66,6 +66,7 @@
<Compile Include="Bill\CarcassSaleOut_Detail.cs" />
<Compile Include="Bill\CarcassTakeOut.cs" />
<Compile Include="Bill\CarcassTakeOutWeightTemp.cs" />
<Compile Include="Bill\TotalCode.cs" />
<Compile Include="Bill\SegmentInStore.cs" />
<Compile Include="Bill\SegmentPickUp.cs" />
<Compile Include="Bill\SegmentProduction.cs" />


+ 104
- 16
ButcherFactory.BO/LocalBL/SegmentProductionBL.cs View File

@ -34,7 +34,9 @@ namespace ButcherFactory.BO.LocalBL
query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
query.Columns.Add(DQSelectColumn.Field("ShotPrintName"));
query.Columns.Add(DQSelectColumn.Field("MainUnit"));
query.Columns.Add(DQSelectColumn.Field("MainUnit"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_ID"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_Code"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("InStored", false), DQCondition.EQ("Delete", false), DQCondition.EQ("Submited", submited)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
if (submited)
@ -52,18 +54,51 @@ namespace ButcherFactory.BO.LocalBL
var entity = new SegmentProduction();
entity.ID = (long)reader[0];
entity.RowIndex = (int?)reader[1];
entity.BarCode = (string)reader[2];
entity.Weight = (decimal)reader[3];
entity.Goods_Name = (string)reader[4];
entity.GroupID = (long?)reader[5];
entity.TrunOutID = (long?)reader[6];
entity.Goods_Spec = (string)reader[7];
entity.StandardPic = (bool)reader[8];
entity.BarCode = (string)reader[2];
entity.Weight = (decimal)reader[3];
entity.Goods_Name = (string)reader[4];
entity.GroupID = (long?)reader[5];
entity.TrunOutID = (long?)reader[6];
entity.Goods_Spec = (string)reader[7];
entity.StandardPic = (bool)reader[8];
entity.Goods_ID = (long)reader[9];
entity.Goods_Code = (string)reader[10];
entity.ShotPrintName = (string)reader[11];
entity.Submited = submited;
entity.MainUnit = (string)reader[12];
entity.ShotPrintName = (string)reader[11];
entity.Submited = submited;
entity.MainUnit = (string)reader[12];
entity.TotalCode_ID = (long)reader[13];
entity.TotalCode_Code = (string)reader[14];
list.Add(entity);
}
}
}
return list;
}
public static BindingList<TotalCode> GetTotalCode( DateTime date)
{
var query = new DQueryDom(new JoinAlias(typeof(TotalCode)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("RowIndex"));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date));
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1)));
query.Where.Conditions.Add(DQCondition.And( DQCondition.EQ("Delete", false) ));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID",true));
var list = new BindingList<TotalCode>();
using (var session = DmoSession.New())
{
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var entity = new TotalCode();
entity.ID = (long)reader[0];
entity.RowIndex = (int?)reader[1];
entity.BarCode = (string)reader[2];
list.Add(entity);
}
}
@ -120,6 +155,36 @@ namespace ButcherFactory.BO.LocalBL
session.Commit();
return entity;
}
}
public static TotalCode InsertTotalCode(TotalCode entity)
{
return InsertTotalCode(entity, DateTime.Now);
}
public static TotalCode InsertTotalCode(TotalCode entity,DateTime date )
{
using (var session = DmoSession.New())
{
entity.UserID = AppContext.Worker.ID;
entity.RowIndex = TotalCodeRowIndex(date, session);
// 年月日+2位机器号+4位顺序号
entity.BarCode = string.Format("{0:yyyyMMdd}{1}{2:0000}", date, AppContext.ConnectInfo.ClientCode, entity.RowIndex);
session.Insert(entity);
session.Commit();
return entity;
}
}
static int TotalCodeRowIndex( DateTime date, IDmoSession session)
{
var query = new DQueryDom(new JoinAlias("_main", typeof(TotalCode)));
query.Columns.Add(DQSelectColumn.Max("RowIndex"));
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date));
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1)));
return (query.EExecuteScalar<int?>(session) ?? 0) + 1;
}
static void FillGroupIDAsID(IDmoSession session, long id)
@ -331,6 +396,7 @@ namespace ButcherFactory.BO.LocalBL
query.Columns.Add(DQSelectColumn.Field("StandardPic"));
query.Columns.Add(DQSelectColumn.Field("MsgID"));
query.Columns.Add(DQSelectColumn.Field("StatisticNumber"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_Code"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Submited", true), DQCondition.EQ("Sync", false), DQCondition.EQ("Delete", false)));
//query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", DateTime.Now.AddMinutes(-1)));
query.Range = SelectRange.Top(10);
@ -353,8 +419,9 @@ namespace ButcherFactory.BO.LocalBL
obj.ProductTime = (DateTime)reader[8];
obj.Delete = (bool)reader[9];
obj.StandardPic = (bool)reader[10];
obj.MsgID = (string)reader[11];
obj.StatisticNumber = (decimal?)reader[12];
obj.MsgID = (string)reader[11];
obj.StatisticNumber = (decimal?)reader[12];
obj.TotalCode_Code = (string)reader[13];
upload.Add(obj);
}
}
@ -397,8 +464,28 @@ namespace ButcherFactory.BO.LocalBL
var log = new SegmentLog(entity.BarCode, "删除");
log.Message = string.Format("存货名称:{0} 重量:{1:#0.###}", entity.Goods_Name, entity.Weight);
InsertLog(log);
}
}
public static void DeleteTotalCode(TotalCode entity)
{
var update = new DQUpdateDom(typeof(TotalCode));
update.Where.Conditions.Add(DQCondition.EQ("ID", entity.ID));
update.Columns.Add(new DQUpdateColumn("Delete", true));
update.Columns.Add(new DQUpdateColumn("RowVersion", DQExpression.Add(DQExpression.Field("RowVersion"), DQExpression.Value(1))));
update.EExecute();
var update1 = new DQUpdateDom(typeof(SegmentProduction));
update1.Where.Conditions.Add(DQCondition.EQ("TotalCode_ID", entity.ID));
update1.Columns.Add(new DQUpdateColumn("Sync", true));
update1.Columns.Add(new DQUpdateColumn("Delete", true));
update1.Columns.Add(new DQUpdateColumn("RowVersion", DQExpression.Add(DQExpression.Field("RowVersion"), DQExpression.Value(1))));
update1.EExecute();
var log = new SegmentLog(entity.BarCode, "删除");
log.Message = string.Format("总码:删除");
InsertLog(log);
}
static bool? CheckCanDelete(string barCode)
{
try
@ -468,7 +555,8 @@ namespace ButcherFactory.BO.LocalBL
public bool Delete { get; set; }
public bool StandardPic { get; set; }
public string MsgID { get; set; }
public decimal? StatisticNumber { get; set; }
public decimal? StatisticNumber { get; set; }
public string TotalCode_Code { get; set; }
}
class TaskTemp


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

@ -78,6 +78,12 @@
<Compile Include="Controls\CircleButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\CodePanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\CodePanel.Designer.cs">
<DependentUpon>CodePanel.cs</DependentUpon>
</Compile>
<Compile Include="Controls\ColorButton.cs">
<SubType>Component</SubType>
</Compile>
@ -244,6 +250,7 @@
<Compile Include="SegmentProductionAuto_\WeightView.Designer.cs">
<DependentUpon>WeightView.cs</DependentUpon>
</Compile>
<Compile Include="SegmentProduction_\SegmentSumCodePrint.cs" />
<Compile Include="SegmentProduction_\SegmentProductionForm.cs">
<SubType>Form</SubType>
</Compile>
@ -337,6 +344,9 @@
<EmbeddedResource Include="CarcassSaleOut2_\CarcassSaleOutReadForm.resx">
<DependentUpon>CarcassSaleOutReadForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\CodePanel.resx">
<DependentUpon>CodePanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\FormTemplate.resx">
<DependentUpon>FormTemplate.cs</DependentUpon>
</EmbeddedResource>


+ 76
- 0
ButcherFactory.Form/Controls/CodePanel.Designer.cs View File

@ -0,0 +1,76 @@
namespace ButcherFactory.Controls
{
partial class CodePanel
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.Button = new ButcherFactory.Controls.ColorButton();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 46);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(101, 552);
this.flowLayoutPanel1.TabIndex = 0;
this.flowLayoutPanel1.WrapContents = false;
//
// Button
//
this.Button.BackColor = System.Drawing.Color.Violet;
this.Button.Font = new System.Drawing.Font("黑体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Button.ForeColor = System.Drawing.Color.Black;
this.Button.Location = new System.Drawing.Point(3, 3);
this.Button.Name = "Button";
this.Button.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(215)))), ((int)(((byte)(107)))));
this.Button.Size = new System.Drawing.Size(90, 40);
this.Button.TabIndex = 1;
this.Button.UseVisualStyleBackColor = false;
//
// CodePanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Controls.Add(this.Button);
this.Controls.Add(this.flowLayoutPanel1);
this.Name = "CodePanel";
this.Size = new System.Drawing.Size(101, 598);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
public ColorButton Button ;
}
}

+ 25
- 0
ButcherFactory.Form/Controls/CodePanel.cs View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ButcherFactory.Controls
{
public partial class CodePanel : UserControl
{
public CodePanel()
{
InitializeComponent();
}
public void Add(Control v)
{
flowLayoutPanel1.Controls.Add(v);
}
}
}

+ 120
- 0
ButcherFactory.Form/Controls/CodePanel.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>

+ 9
- 7
ButcherFactory.Form/Controls/UserControl1.Designer.cs View File

@ -32,15 +32,18 @@
this.Button = new ButcherFactory.Controls.ColorButton();
this.SuspendLayout();
//
// Tag
//
// Label
//
this.Label.BackColor = System.Drawing.Color.DeepSkyBlue;
this.Label.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Label.Font = new System.Drawing.Font("黑体", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Label.ForeColor = System.Drawing.Color.White;
this.Label.Location = new System.Drawing.Point(111, 0);
this.Label.Name = "Tag";
this.Label.Size = new System.Drawing.Size(36, 33);
this.Label.MaxCount = 1;
this.Label.MinCount = 0;
this.Label.Name = "Label";
this.Label.Size = new System.Drawing.Size(64, 56);
this.Label.TabIndex = 1;
this.Label.Text = "1-0";
this.Label.UseVisualStyleBackColor = false;
//
// Button
@ -61,9 +64,8 @@
this.Controls.Add(this.Label);
this.Controls.Add(this.Button);
this.Name = "ButtonTag";
this.Size = new System.Drawing.Size(147, 90);
this.Size = new System.Drawing.Size(178, 90);
this.ResumeLayout(false);
this.PerformLayout();
}


+ 541
- 590
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs
File diff suppressed because it is too large
View File


+ 262
- 63
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -36,7 +36,8 @@ namespace ButcherFactory.SegmentProductionAuto_
Thread uploadData;
Thread checkInStoreState;
Thread initTask;
BindingList<SegmentProduction> historyList;
BindingList<SegmentProduction> historyList;
BindingList<TotalCode> allCode;
Dictionary<string, List<ClientGoodsSet_Detail>> goodsSetDic;
long? batchID;
DateTime? batchDate;
@ -88,7 +89,7 @@ namespace ButcherFactory.SegmentProductionAuto_
if (checkInStoreState != null && checkInStoreState.IsAlive)
checkInStoreState.Abort();
}
WeightDetails mCache;
public WeightDetails mCache;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
@ -215,11 +216,15 @@ namespace ButcherFactory.SegmentProductionAuto_
{
if (batchID == null)
throw new Exception("请先选择批次");
if (_totalCode == null || _codePanel == null)
{
throw new Exception(string.Format("请先选择总码!"));
}
var weight = uWeightControl1.Weight;
//#if DEBUG
// if (weight == 0)
// weight = (item.StandardWeightLow ?? 4.0m) + 0.1m;
//#endif
#if DEBUG
if (weight == 0)
weight = (item.StandardWeightLow ?? 4.0m) + 0.1m;
#endif
if (weight == 0)
throw new Exception("重量不能为0");
if (item.StandardWeight.HasValue)
@ -289,12 +294,13 @@ 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 DEBUG
if (weight == 0)
weight = (detail.StandardWeightLow ?? 4.0m) + 0.1m;
#endif
if (weight == 0)
throw new Exception("重量不能为0");
if (detail.StandardWeight.HasValue)
{
if (weight < (detail.StandardWeightLow ?? 0) || weight > (detail.StandardWeightUp ?? 0))
@ -322,14 +328,22 @@ namespace ButcherFactory.SegmentProductionAuto_
entity.StandardPic = detail.StandardPic;
if (!string.IsNullOrEmpty(statisticNumberBox.Text))
entity.StatisticNumber = decimal.Parse(statisticNumberBox.Text);
if (_totalCode == null || _codePanel==null)
{
throw new Exception(string.Format("请先选择总码!" ));
}
entity.TotalCode_ID = _totalCode.ID;
SegmentProductionBL.InsertAndSetGroupID(entity, batchDate.Value);
entity.Goods_Code = detail.Goods_Code;
entity.Goods_Name = detail.Goods_Name;
entity.Goods_Spec = detail.Goods_Spec;
entity.MainUnit = detail.MainUnit;
entity.ShotPrintName = detail.ShotPrintName;
_codePanel.Add(initSegmentBt(entity));
historyList.Insert(0, entity);
if (historyList.Count > 30)
historyList.RemoveAt(30);
if (barPrintCheck.Checked)
@ -344,33 +358,99 @@ namespace ButcherFactory.SegmentProductionAuto_
}
}
GoodsLabel.Text = detail.Goods_Name;
historyDataGrid.FirstDisplayedScrollingRowIndex = 0;
historyDataGrid.ClearSelection();
historyDataGrid.Refresh();
var thd = new Thread(new ParameterizedThreadStart(RefreshTask));
thd.Start(entity);
}
void RefreshTask(object obj)
{
var entity = obj as SegmentProduction;
var list = SegmentProductionBL.GetProductTask(batchDate ?? DateTime.Today, entity);
this.Invoke(new Action(() =>
{
taskDataGrid.DataSource = list;
taskDataGrid.Refresh();
}));
}
}
SegmentProduction current;
ColorButton _labelBt;
private ColorButton initSegmentBt(SegmentProduction entity)
{
var bt = new ColorButton() { Text = entity.ShortCode };
bt.Tag = entity;
bt.Width = 90;
bt.Height = 35;
bt.Font = new Font("黑体", 13, FontStyle.Bold);
bt.BackColor = Color.DarkCyan;
bt.SelectedColor = Color.DarkOrange;
bt.Click += delegate
{
bt.Selected = !bt.Selected;
if (bt.Selected)
{
current = entity;
_labelBt = bt;
GoodsLabel.Text = entity.Goods_Name;
if (_codePanel != null)
{
_codePanel.Button.Selected = false;
_codePanel.Button.Invalidate();
}
_totalCode = null;
_codePanel = null;
}
else
{
_labelBt = null;
current = null;
GoodsLabel.Text = "";
}
foreach (var bt2 in segmentButtons)
{
if (bt2.Text != entity.ShortCode && bt2.Selected)
{
bt2.Selected = false;
bt2.Invalidate();
}
}
};
segmentButtons.Add(bt);
return bt;
}
void RefreshTask(object obj)
{
var entity = obj as SegmentProduction;
var list = SegmentProductionBL.GetProductTask(batchDate ?? DateTime.Today, entity);
this.Invoke(new Action(() =>
{
taskDataGrid.DataSource = list;
taskDataGrid.Refresh();
}));
}
List<ColorButton> codeButtons = new List<ColorButton>(0);
List<ColorButton> segmentButtons = new List<ColorButton>(0);
void BindGrid()
{
historyList = SegmentProductionBL.GetListByState(true);
historyDataGrid.DataSource = historyList;
historyDataGrid.Refresh();
historyList = SegmentProductionBL.GetListByState(true);
allCode = SegmentProductionBL.GetTotalCode(DateTime.Now);
RefreshCodePanel();
var first = historyList.FirstOrDefault();
if (first != null)
GoodsLabel.Text = first.Goods_Name;
}
private void RefreshCodePanel()
{
flowLayoutPanel3.Controls.Clear();
codeButtons.Clear();
foreach (var item in allCode)
{
var details = historyList.Where(x => x.TotalCode_ID == item.ID);
var n = new CodePanel();
AddCodeButton(n, item);
foreach (var seg in details)
{
n.Add(initSegmentBt(seg));
}
flowLayoutPanel3.Controls.Add(n);
}
}
void UpLoadLocalData()
@ -410,8 +490,8 @@ namespace ButcherFactory.SegmentProductionAuto_
{
foreach (var item in tag)
historyList.Remove(item);
historyDataGrid.ClearSelection();
historyDataGrid.Refresh();
//historyDataGrid.ClearSelection();
//historyDataGrid.Refresh();
}));
}
}
@ -439,13 +519,13 @@ namespace ButcherFactory.SegmentProductionAuto_
{
if (historyList.Count == 0)
throw new Exception("请先选择要补打的记录");
SegmentProduction item;
var row = historyDataGrid.SelectedRows;
if (row.Count > 0)
item = row[0].DataBoundItem as SegmentProduction;
else
item = historyList.First();
var template = config.Template;
SegmentProduction item;
if (current != null)
item = current;
else
item = historyList.First();
var template = config.Template;
var goodsType = SegmentProductionBL.GetGoodsType(item.Goods_ID);
if (goodsType.HasValue)
template = goodsType == 0 ? "SegmentProductionPrint.html" : "SegmentProductionPrint1.html";
@ -459,30 +539,68 @@ namespace ButcherFactory.SegmentProductionAuto_
private void templateBtn_Click(object sender, EventArgs e)
{
new TemplateSelector(config).ShowDialog();
}
private void deleteBtn_Click(object sender, EventArgs e)
{
var row = historyDataGrid.SelectedRows;
if (row.Count == 0)
return;
if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK)
return;
var tag = historyDataGrid.SelectedRows[0].DataBoundItem as SegmentProduction;
if (tag.CreateTime.AddMinutes(1) < DateTime.Now)
{
MessageBox.Show("已超出可删除时间范围");
return;
}
SegmentProductionBL.Delete(tag);
//SegmentProductionBL.SetAsDelete(tag.ID, tag.BarCode);
historyList.Remove(tag);
historyDataGrid.DataSource = historyList;
historyDataGrid.ClearSelection();
historyDataGrid.Refresh();
var thd = new Thread(new ParameterizedThreadStart(RefreshTask));
thd.Start(tag);
}
private void deleteBtn_Click(object sender, EventArgs e)
{
if (_totalCode == null || _codePanel == null)
{
if (current == null)
return;
if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK)
return;
//var tag = historyDataGrid.SelectedRows[0].DataBoundItem as SegmentProduction;
if (current.CreateTime.AddMinutes(1) < DateTime.Now)
{
MessageBox.Show("已超出可删除时间范围");
return;
}
SegmentProduction d = current;
SegmentProductionBL.Delete(d);
historyList.Remove(d);
if (_labelBt != null)
{
var parent=_labelBt.Parent;
parent.Controls.Remove(_labelBt);
}
//RefreshCodePanel();
var thd = new Thread(new ParameterizedThreadStart(RefreshTask));
thd.Start(d);
current = null;
}
else
{
var deleteList = historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToList();
SegmentProductionBL.DeleteTotalCode(_totalCode);
allCode.Remove(_totalCode);
codeButtons.Remove(_codePanel.Button);
foreach (var item in deleteList)
{
historyList.Remove(item);
var thd = new Thread(new ParameterizedThreadStart(RefreshTask));
thd.Start(item);
}
flowLayoutPanel3.Controls.Remove(_codePanel);
// RefreshCodePanel();
current = null;
if (allCode.Count > 0)
{
_totalCode = allCode[0];
_codePanel = (CodePanel)flowLayoutPanel3.Controls[0];
_codePanel.Button.Selected = true;
_codePanel.Button.Invalidate();
}
else
{
_totalCode = null;
_codePanel = null;
}
}
}
private void logBtn_Click(object sender, EventArgs e)
@ -545,5 +663,86 @@ namespace ButcherFactory.SegmentProductionAuto_
}
}
}
CodePanel _codePanel;
TotalCode _totalCode;
private void colorButton1_Click(object sender, EventArgs e)
{
var n = new CodePanel();
var tCode = SegmentProductionBL.InsertTotalCode(new TotalCode());
allCode.Insert(0, tCode);
AddCodeButton(n, tCode,true);
flowLayoutPanel3.Controls.Add(n);
flowLayoutPanel3.Controls.SetChildIndex(n, 0);
}
private void AddCodeButton(CodePanel n, TotalCode tCode,bool add=false)
{
n.Button.Tag = tCode;
n.Button.Text = tCode.ShortCode;
n.Button.Click += delegate
{
current = null;
n.Button.Selected = !n.Button.Selected;
if (n.Button.Selected)
{
_codePanel = n;
_totalCode = tCode;
if (_labelBt != null)
{
_labelBt.Selected = false;
_labelBt.Invalidate();
}
_labelBt = null;
}
else
{
_codePanel = null;
_totalCode = null;
}
foreach (var bt in codeButtons)
{
if (bt.Text != n.Button.Text && bt.Selected)
{
bt.Selected = false;
bt.Invalidate();
}
}
};
if (add)
{
_codePanel = n;
n.Button.Selected = true;
_totalCode = tCode;
foreach (var bt in codeButtons)
{
if (bt.Selected)
{
bt.Selected = false;
bt.Invalidate();
}
}
}
codeButtons.Add(n.Button);
}
private void colorButton2_Click(object sender, EventArgs e)
{
if (_totalCode == null || _codePanel == null)
{
throw new Exception(string.Format("请先选择总码!"));
}
var dmos= historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToArray();
if (dmos.Length == 0)
{
throw new Exception(string.Format("此码不包含任何产品!"));
}
NotAuto.SegmentSumCodePrint.Print(dmos, "SegmentSumCode.html");
var log = new SegmentLog(dmos[0].TotalCode_Code, "总码");
log.Message = string.Format("总码:{0} ", dmos[0].TotalCode_Code);
SegmentProductionBL.InsertLog(log);
}
}
}

+ 0
- 6
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.resx View File

@ -120,10 +120,4 @@
<metadata name="T_Last.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="H_ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="H_Weight.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

+ 3
- 0
ButcherFactory.Form/SegmentProductionAuto_/WeightView.cs View File

@ -1,4 +1,5 @@
using ButcherFactory.BO;
using ButcherFactory.BO.Utils;
using ButcherFactory.Controls;
using System;
using System.Collections.Generic;
@ -106,6 +107,8 @@ namespace ButcherFactory.SegmentProductionAuto_
var l = form.wDic[goods.Goods_ID];
l.RemoveAt(tag.No - 1);
bTag.Label.MinCount = l.Count;
form.mCache.Cache = form.wDic;
XmlUtil.SerializerObjToFile( form.mCache);
}
list.Remove(tag);
int i = 1;


+ 66
- 0
ButcherFactory.Form/SegmentProduction_/SegmentSumCodePrint.cs View File

@ -0,0 +1,66 @@
using ButcherFactory.BO;
using ButcherFactory.BO.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.SegmentProduction_
{
public static class SegmentSumCodePrint
{
static int id = 1;
const string PRINTFILE = @"PrintTemplate\";
const string ENDFILE = @"PrintTemplate\SegmentProductionPrintEnd.html";
const string IMGFILE = @"TempImg\_sum_img{0}.png";
public static void Print(SegmentProduction[] entitys, string template)
{
if (AppContext.ConnectInfo.TraceBackUrl == "default")
throw new Exception("请先配置追溯服务器地址");
var dic = new Dictionary<string, string>();
var entity = entitys.FirstOrDefault();
var groupByGoods = entitys.GroupBy(x => x.Goods_ID);
var info = string.Empty;
foreach (var item in groupByGoods)
{
var f = item.FirstOrDefault();
info += string.Format("<p class='g_name'>{0}</p>", f.Goods_Name);
info += string.Format("<p class='g_number'>件数:{0}</p>", item.Count());
}
dic.Add("$Goods_Name", info);
dic.Add("$Date", DateTime.Now.ToString("yyyy/MM/dd HH:mm"));
var code = entity.TotalCode_Code;
dic.Add("$Code", code);
var imgUrl = string.Format(IMGFILE, id);
var url = string.Format(AppContext.ConnectInfo.TraceBackUrl + "?code={0}",entity.TotalCode_Code);
BwpClientPrint.BwpClientWebPrint.Create2DPic(url, imgUrl, 120);
dic.Add("$ImageUrl", imgUrl);
BwpClientPrint.BwpClientWebPrint.Print(PRINTFILE + template, dic);
AfterPrint();
}
static DirectoryInfo TempImage = null;
private static void AfterPrint()
{
if (id == 100)
id = 0;
id++;
if (TempImage == null)
TempImage = new DirectoryInfo("TempImg");
var files = TempImage.GetFiles();
while (files.Length > 100)
{
var last = files.OrderBy(x => x.CreationTime).First().FullName;
File.Delete(last);
files = TempImage.GetFiles();
}
}
}
}

Loading…
Cancel
Save