Browse Source

同步 automapper

master
luanhui 8 years ago
parent
commit
bd3cfd613a
14 changed files with 273 additions and 132 deletions
  1. +2
    -0
      BO/BO.csproj
  2. +16
    -0
      BO/BO/Dtos/SyncBaseDto.cs
  3. +3
    -0
      BO/BO/LocalSyncBase.cs
  4. +47
    -0
      BO/BarCodeScan/BwpBarCodeUtil.cs
  5. +2
    -0
      BO/LocalDmoSession.cs
  6. +29
    -15
      BO/SyncToServerBase.cs
  7. +4
    -0
      ButcherManageClient/ButcherManageClient.csproj
  8. +6
    -0
      ButcherManageClient/Program.cs
  9. +13
    -0
      TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs
  10. +5
    -3
      TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordDto.cs
  11. +3
    -3
      TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs
  12. +4
    -1
      TrunksIousOutInStore/TrunksIousOutInStore.csproj
  13. +101
    -84
      TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs
  14. +38
    -26
      TrunksIousOutInStore/TrunksIousOutInStoreForm.cs

+ 2
- 0
BO/BO.csproj View File

@ -64,6 +64,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="BarCodeScan\BardCodeHook.cs" /> <Compile Include="BarCodeScan\BardCodeHook.cs" />
<Compile Include="BarCodeScan\BwpBarCodes.cs" /> <Compile Include="BarCodeScan\BwpBarCodes.cs" />
<Compile Include="BarCodeScan\BwpBarCodeUtil.cs" />
<Compile Include="BO\BackRpcObj.cs" /> <Compile Include="BO\BackRpcObj.cs" />
<Compile Include="BO\BaseInfo\BodyDiscontItem.cs" /> <Compile Include="BO\BaseInfo\BodyDiscontItem.cs" />
<Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeight.cs" /> <Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeight.cs" />
@ -85,6 +86,7 @@
<Compile Include="BO\Bill\WeightBill\WeightDetail.cs" /> <Compile Include="BO\Bill\WeightBill\WeightDetail.cs" />
<Compile Include="BO\Dtos\ClientGoodsSetDto.cs" /> <Compile Include="BO\Dtos\ClientGoodsSetDto.cs" />
<Compile Include="BO\Dtos\ClientGoodsSetDtoExt.cs" /> <Compile Include="BO\Dtos\ClientGoodsSetDtoExt.cs" />
<Compile Include="BO\Dtos\SyncBaseDto.cs" />
<Compile Include="BO\LocalSyncBase.cs" /> <Compile Include="BO\LocalSyncBase.cs" />
<Compile Include="BO\SyncBase.cs" /> <Compile Include="BO\SyncBase.cs" />
<Compile Include="CTuple.cs" /> <Compile Include="CTuple.cs" />


+ 16
- 0
BO/BO/Dtos/SyncBaseDto.cs View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BO.BO.Dtos
{
public class SyncBaseDto
{
public long? Service_ID { get; set; }
public long? Client_ID { get; set; }
public long? B3_ID { get; set; }
public string CreateUserName { get; set; }
}
}

+ 3
- 0
BO/BO/LocalSyncBase.cs View File

@ -11,6 +11,9 @@ namespace BO.BO
[KeyField("ID", KeyGenType.identity)] [KeyField("ID", KeyGenType.identity)]
public abstract class LocalSyncBase public abstract class LocalSyncBase
{ {
public abstract string GetDtoJson();
/// <summary> /// <summary>
/// 本地自增ID /// 本地自增ID
/// </summary> /// </summary>


+ 47
- 0
BO/BarCodeScan/BwpBarCodeUtil.cs View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BO.BarCodeScan
{
public class BwpBarCodeUtil
{
/// <summary>
/// 根据按键获取字符串
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
public static string GetStringByKeyKeyEventArgs(KeyEventArgs e)
{
if (e.KeyData == (Keys.D7 | Keys.Shift))
{
return "&";
}
if (e.KeyData == (Keys.ProcessKey | Keys.Shift))
{
return "&";
}
if (e.KeyData == (Keys.Oem2))
{
return "/";
}
if (e.KeyData == (Keys.Oem2 | Keys.Shift))
{
return "?";
}
if (e.KeyData == (Keys.Oemplus))
{
return "=";
}
char keyvalue = (char)e.KeyValue;
var str = keyvalue.ToString();
return str;
}
}
}

+ 2
- 0
BO/LocalDmoSession.cs View File

@ -146,6 +146,8 @@ namespace BO
// detail.Sync = false; // detail.Sync = false;
update.Columns.Add(new DQUpdateColumn(p, type.GetProperty(p).GetValue(detail))); update.Columns.Add(new DQUpdateColumn(p, type.GetProperty(p).GetValue(detail)));
} }
update.Columns.Add(new DQUpdateColumn("WillBeUpdated", true));
session.ExecuteNonQuery(update); session.ExecuteNonQuery(update);
session.Commit(); session.Commit();
} }


+ 29
- 15
BO/SyncToServerBase.cs View File

@ -27,9 +27,16 @@ namespace BO
{ {
lock (lockSucessedObj) lock (lockSucessedObj)
{ {
var forList = LocalDmoSession.GetNeedSyncList<T>();
//所有集合长度为0时
return forList.WillInsertList.Count == 0 && forList.WillUpdateList.Count == 0 &&forList.WillDeleteList.Count == 0;
try
{
var forList = LocalDmoSession.GetNeedSyncList<T>();
//所有集合长度为0时
return forList.WillInsertList.Count == 0 && forList.WillUpdateList.Count == 0 && forList.WillDeleteList.Count == 0;
}
catch (Exception e)
{
return false;
}
} }
} }
@ -37,27 +44,34 @@ namespace BO
{ {
lock (lockObj) lock (lockObj)
{ {
var forList = LocalDmoSession.GetNeedSyncList<T>();
foreach (T record in forList.WillInsertList)
try
{ {
Insert(record);
}
var forList = LocalDmoSession.GetNeedSyncList<T>();
foreach (T record in forList.WillInsertList)
{
Insert(record);
}
foreach (T record in forList.WillUpdateList)
{
Update(record);
}
foreach (T record in forList.WillUpdateList)
{
Update(record);
}
foreach (T record in forList.WillDeleteList)
foreach (T record in forList.WillDeleteList)
{
Delete(record);
}
}
catch (Exception e)
{ {
Delete(record);
} }
} }
} }
private long Insert(T record) private long Insert(T record)
{ {
var json = JsonConvert.SerializeObject(record);
var json = record.GetDtoJson();
var serviceid = RpcFacade.Call<long>(InsertRpcUrl, json); var serviceid = RpcFacade.Call<long>(InsertRpcUrl, json);
LocalDmoSession.UpdateAfterInsertSynced<T>(record.ID, serviceid); LocalDmoSession.UpdateAfterInsertSynced<T>(record.ID, serviceid);
return serviceid; return serviceid;
@ -65,7 +79,7 @@ namespace BO
private void Update(T record) private void Update(T record)
{ {
var json = JsonConvert.SerializeObject(record);
var json = record.GetDtoJson();
RpcFacade.Call<int>(UpdateRpcUrl, json); RpcFacade.Call<int>(UpdateRpcUrl, json);
LocalDmoSession.UpdateAfterUpdateSynced<T>(record.ID); LocalDmoSession.UpdateAfterUpdateSynced<T>(record.ID);
} }


+ 4
- 0
ButcherManageClient/ButcherManageClient.csproj View File

@ -35,6 +35,10 @@
<ApplicationIcon>pig [128x128].ico</ApplicationIcon> <ApplicationIcon>pig [128x128].ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AutoMapper, Version=6.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="Forks.JsonRpc.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL"> <Reference Include="Forks.JsonRpc.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\BwpB3Project\tsref\Debug\Forks.JsonRpc.Client.dll</HintPath> <HintPath>..\..\..\..\BwpB3Project\tsref\Debug\Forks.JsonRpc.Client.dll</HintPath>


+ 6
- 0
ButcherManageClient/Program.cs View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using AutoMapper;
namespace ButcherManageClient namespace ButcherManageClient
{ {
@ -32,6 +33,11 @@ namespace ButcherManageClient
} }
else else
{ {
// Mapper.Initialize(cfg => {
// cfg.AddProfile<AppProfile>();
// cfg.CreateMap<Source, Dest>();
// });
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login()); Application.Run(new Login());


+ 13
- 0
TrunksIousOutInStore/LocalSyncBO/TrunksIousOutInStoreRecord.cs View File

@ -1,6 +1,9 @@
using System; using System;
using AutoMapper;
using BO.BO; using BO.BO;
using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2;
using Newtonsoft.Json;
using TrunksIousOutInStore.Rpc;
namespace TrunksIousOutInStore.LocalSyncBO namespace TrunksIousOutInStore.LocalSyncBO
{ {
@ -23,6 +26,16 @@ namespace TrunksIousOutInStore.LocalSyncBO
public decimal? Weight { get; set; } public decimal? Weight { get; set; }
public string CarcassStatus{ get; set; }// 胴体状态 public string CarcassStatus{ get; set; }// 胴体状态
public override string GetDtoJson()
{
var config = new MapperConfiguration(cfg => {
cfg.CreateMap<TrunksIousOutInStoreRecord, TrunksIousOutInStoreRecordDto>();
});
var mapper = config.CreateMapper();
var dto = mapper.Map<TrunksIousOutInStoreRecordDto>(this);
dto.Client_ID = this.ID;
return JsonConvert.SerializeObject(dto);
}
} }
public class CarcassStatus public class CarcassStatus


TrunksIousOutInStore/Rpc/TrunksIousOutInStoreFormDto.cs → TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordDto.cs View File

@ -1,8 +1,10 @@
namespace TrunksIousOutInStore.Rpc
using BO.BO.Dtos;
namespace TrunksIousOutInStore.Rpc
{ {
public class TrunksIousOutInStoreFormDto
public class TrunksIousOutInStoreRecordDto: SyncBaseDto
{ {
public long ID { get; set; }
public string BarCode { get; set; } public string BarCode { get; set; }
public string Goods_Name { get; set; } public string Goods_Name { get; set; }
public string Goods_Spec { get; set; } public string Goods_Spec { get; set; }

+ 3
- 3
TrunksIousOutInStore/Rpc/TrunksIousOutInStoreRecordRpc.cs View File

@ -45,17 +45,17 @@ namespace TrunksIousOutInStore.Rpc
protected override string InsertRpcUrl { protected override string InsertRpcUrl {
get { return ""; }
get { return "/MainSystem/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc/Insert"; }
} }
protected override string UpdateRpcUrl protected override string UpdateRpcUrl
{ {
get { return ""; }
get { return "/MainSystem/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc/Update"; }
} }
protected override string DeleteRpcUrl protected override string DeleteRpcUrl
{ {
get { return ""; }
get { return "/MainSystem/B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc/Delete"; }
} }
} }


+ 4
- 1
TrunksIousOutInStore/TrunksIousOutInStore.csproj View File

@ -33,6 +33,9 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AutoMapper">
<HintPath>..\ButcherManageClient\bin\Debug\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="Forks.EnterpriseServices, Version=3.1.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL"> <Reference Include="Forks.EnterpriseServices, Version=3.1.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.EnterpriseServices.dll</HintPath> <HintPath>..\..\..\tsref\Debug\Forks.EnterpriseServices.dll</HintPath>
@ -62,7 +65,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Rpc\TrunksIousOutInStoreRecordRpc.cs" /> <Compile Include="Rpc\TrunksIousOutInStoreRecordRpc.cs" />
<Compile Include="LocalSyncBO\TrunksIousOutInStoreRecord.cs" /> <Compile Include="LocalSyncBO\TrunksIousOutInStoreRecord.cs" />
<Compile Include="Rpc\TrunksIousOutInStoreFormDto.cs" />
<Compile Include="Rpc\TrunksIousOutInStoreRecordDto.cs" />
<Compile Include="TrunksIousOutInStoreClientGoodsSet.cs" /> <Compile Include="TrunksIousOutInStoreClientGoodsSet.cs" />
<Compile Include="TrunksIousOutInStoreContext.cs" /> <Compile Include="TrunksIousOutInStoreContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />


+ 101
- 84
TrunksIousOutInStore/TrunksIousOutInStoreForm.Designer.cs View File

@ -51,23 +51,24 @@
this.splitContainer3 = new System.Windows.Forms.SplitContainer(); this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.gridChecked = new BWP.WinFormControl.UDataGridView(); this.gridChecked = new BWP.WinFormControl.UDataGridView();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.gridUnCheck = new System.Windows.Forms.DataGridView();
this.flpGoods = new System.Windows.Forms.FlowLayoutPanel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timerChectNetStatus = new System.Windows.Forms.Timer(this.components);
this.timerSyncToService = new System.Windows.Forms.Timer(this.components);
this.timerCheckSyncSucessed = new System.Windows.Forms.Timer(this.components);
this. = new System.Windows.Forms.DataGridViewTextBoxColumn(); this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn(); this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn(); this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn(); this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn(); this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.gridUnCheck = new System.Windows.Forms.DataGridView();
this.uncheck序号 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck序号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck条码 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck条码 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck产品名称 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck数量 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck数量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uncheck重量 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uncheck重量 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.flpClass = new System.Windows.Forms.FlowLayoutPanel();
this.flpGoods = new System.Windows.Forms.FlowLayoutPanel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timerChectNetStatus = new System.Windows.Forms.Timer(this.components);
this.timerSyncToService = new System.Windows.Forms.Timer(this.components);
this.timerCheckSyncSucessed = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@ -116,8 +117,6 @@
this.panel1.Controls.Add(this.enableWeight); this.panel1.Controls.Add(this.enableWeight);
this.panel1.Controls.Add(this.panel2); this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.btnWeightSet); this.panel1.Controls.Add(this.btnWeightSet);
this.panel1.Controls.Add(this.btnSycnStatus);
this.panel1.Controls.Add(this.btnNetStatus);
this.panel1.Location = new System.Drawing.Point(11, 3); this.panel1.Location = new System.Drawing.Point(11, 3);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1251, 100); this.panel1.Size = new System.Drawing.Size(1251, 100);
@ -171,9 +170,9 @@
// //
this.btnSycnStatus.Enabled = false; this.btnSycnStatus.Enabled = false;
this.btnSycnStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnSycnStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSycnStatus.Location = new System.Drawing.Point(655, 28);
this.btnSycnStatus.Location = new System.Drawing.Point(61, 83);
this.btnSycnStatus.Name = "btnSycnStatus"; this.btnSycnStatus.Name = "btnSycnStatus";
this.btnSycnStatus.Size = new System.Drawing.Size(114, 46);
this.btnSycnStatus.Size = new System.Drawing.Size(120, 46);
this.btnSycnStatus.TabIndex = 0; this.btnSycnStatus.TabIndex = 0;
this.btnSycnStatus.Text = "同步完成"; this.btnSycnStatus.Text = "同步完成";
this.btnSycnStatus.UseVisualStyleBackColor = true; this.btnSycnStatus.UseVisualStyleBackColor = true;
@ -182,7 +181,7 @@
// //
this.btnNetStatus.Enabled = false; this.btnNetStatus.Enabled = false;
this.btnNetStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnNetStatus.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnNetStatus.Location = new System.Drawing.Point(450, 28);
this.btnNetStatus.Location = new System.Drawing.Point(61, 14);
this.btnNetStatus.Name = "btnNetStatus"; this.btnNetStatus.Name = "btnNetStatus";
this.btnNetStatus.Size = new System.Drawing.Size(120, 46); this.btnNetStatus.Size = new System.Drawing.Size(120, 46);
this.btnNetStatus.TabIndex = 0; this.btnNetStatus.TabIndex = 0;
@ -201,7 +200,9 @@
this.splitContainer2.Panel1.Controls.Add(this.cbxBaiTiaoStatus); this.splitContainer2.Panel1.Controls.Add(this.cbxBaiTiaoStatus);
this.splitContainer2.Panel1.Controls.Add(this.label2); this.splitContainer2.Panel1.Controls.Add(this.label2);
this.splitContainer2.Panel1.Controls.Add(this.btnCreateBill); this.splitContainer2.Panel1.Controls.Add(this.btnCreateBill);
this.splitContainer2.Panel1.Controls.Add(this.btnSycnStatus);
this.splitContainer2.Panel1.Controls.Add(this.btnSubmit); this.splitContainer2.Panel1.Controls.Add(this.btnSubmit);
this.splitContainer2.Panel1.Controls.Add(this.btnNetStatus);
// //
// splitContainer2.Panel2 // splitContainer2.Panel2
// //
@ -221,7 +222,7 @@
"分割领用", "分割领用",
"入销售库", "入销售库",
"销售出库"}); "销售出库"});
this.cbxBaiTiaoStatus.Location = new System.Drawing.Point(45, 144);
this.cbxBaiTiaoStatus.Location = new System.Drawing.Point(41, 197);
this.cbxBaiTiaoStatus.Name = "cbxBaiTiaoStatus"; this.cbxBaiTiaoStatus.Name = "cbxBaiTiaoStatus";
this.cbxBaiTiaoStatus.Size = new System.Drawing.Size(167, 35); this.cbxBaiTiaoStatus.Size = new System.Drawing.Size(167, 35);
this.cbxBaiTiaoStatus.TabIndex = 34; this.cbxBaiTiaoStatus.TabIndex = 34;
@ -230,7 +231,7 @@
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(45, 117);
this.label2.Location = new System.Drawing.Point(41, 170);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(106, 24); this.label2.Size = new System.Drawing.Size(106, 24);
this.label2.TabIndex = 1; this.label2.TabIndex = 1;
@ -239,7 +240,7 @@
// btnCreateBill // btnCreateBill
// //
this.btnCreateBill.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnCreateBill.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCreateBill.Location = new System.Drawing.Point(45, 368);
this.btnCreateBill.Location = new System.Drawing.Point(41, 275);
this.btnCreateBill.Name = "btnCreateBill"; this.btnCreateBill.Name = "btnCreateBill";
this.btnCreateBill.Size = new System.Drawing.Size(156, 46); this.btnCreateBill.Size = new System.Drawing.Size(156, 46);
this.btnCreateBill.TabIndex = 0; this.btnCreateBill.TabIndex = 0;
@ -250,7 +251,7 @@
// btnSubmit // btnSubmit
// //
this.btnSubmit.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnSubmit.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSubmit.Location = new System.Drawing.Point(45, 259);
this.btnSubmit.Location = new System.Drawing.Point(45, 451);
this.btnSubmit.Name = "btnSubmit"; this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(156, 46); this.btnSubmit.Size = new System.Drawing.Size(156, 46);
this.btnSubmit.TabIndex = 0; this.btnSubmit.TabIndex = 0;
@ -272,6 +273,7 @@
// //
// splitContainer3.Panel2 // splitContainer3.Panel2
// //
this.splitContainer3.Panel2.Controls.Add(this.flpClass);
this.splitContainer3.Panel2.Controls.Add(this.flpGoods); this.splitContainer3.Panel2.Controls.Add(this.flpGoods);
this.splitContainer3.Size = new System.Drawing.Size(1015, 610); this.splitContainer3.Size = new System.Drawing.Size(1015, 610);
this.splitContainer3.SplitterDistance = 726; this.splitContainer3.SplitterDistance = 726;
@ -329,6 +331,43 @@
this.gridChecked.Size = new System.Drawing.Size(693, 320); this.gridChecked.Size = new System.Drawing.Size(693, 320);
this.gridChecked.TabIndex = 4; this.gridChecked.TabIndex = 4;
// //
// 序号
//
this..DataPropertyName = "ID";
this..HeaderText = "序号";
this..Name = "序号";
this..ReadOnly = true;
//
// 条码
//
this..AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this..DataPropertyName = "BarCode";
this..HeaderText = "条码";
this..Name = "条码";
this..ReadOnly = true;
//
// 产品名称
//
this..DataPropertyName = "Goods_Name";
this..HeaderText = "产品名称";
this..Name = "产品名称";
this..ReadOnly = true;
this..Width = 120;
//
// 数量
//
this..DataPropertyName = "Number";
this..HeaderText = "数量";
this..Name = "数量";
this..ReadOnly = true;
//
// 重量
//
this..DataPropertyName = "Weight";
this..HeaderText = "重量";
this..Name = "重量";
this..ReadOnly = true;
//
// groupBox1 // groupBox1
// //
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@ -379,74 +418,6 @@
this.gridUnCheck.Size = new System.Drawing.Size(699, 200); this.gridUnCheck.Size = new System.Drawing.Size(699, 200);
this.gridUnCheck.TabIndex = 3; this.gridUnCheck.TabIndex = 3;
// //
// flpGoods
//
this.flpGoods.Dock = System.Windows.Forms.DockStyle.Fill;
this.flpGoods.Location = new System.Drawing.Point(0, 0);
this.flpGoods.Name = "flpGoods";
this.flpGoods.Size = new System.Drawing.Size(286, 608);
this.flpGoods.TabIndex = 0;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 3000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timerChectNetStatus
//
this.timerChectNetStatus.Enabled = true;
this.timerChectNetStatus.Interval = 2000;
this.timerChectNetStatus.Tick += new System.EventHandler(this.timerChectNetStatus_Tick);
//
// timerSyncToService
//
this.timerSyncToService.Interval = 5000;
this.timerSyncToService.Tick += new System.EventHandler(this.timerSyncToService_Tick);
//
// timerCheckSyncSucessed
//
this.timerCheckSyncSucessed.Enabled = true;
this.timerCheckSyncSucessed.Interval = 4000;
this.timerCheckSyncSucessed.Tick += new System.EventHandler(this.timerCheckSyncSucessed_Tick);
//
// 序号
//
this..DataPropertyName = "ID";
this..HeaderText = "序号";
this..Name = "序号";
this..ReadOnly = true;
//
// 条码
//
this..AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this..DataPropertyName = "BarCode";
this..HeaderText = "条码";
this..Name = "条码";
this..ReadOnly = true;
//
// 产品名称
//
this..DataPropertyName = "Goods_Name";
this..HeaderText = "产品名称";
this..Name = "产品名称";
this..ReadOnly = true;
this..Width = 120;
//
// 数量
//
this..DataPropertyName = "Number";
this..HeaderText = "数量";
this..Name = "数量";
this..ReadOnly = true;
//
// 重量
//
this..DataPropertyName = "Weight";
this..HeaderText = "重量";
this..Name = "重量";
this..ReadOnly = true;
//
// uncheck序号 // uncheck序号
// //
this.uncheck序号.DataPropertyName = "ID"; this.uncheck序号.DataPropertyName = "ID";
@ -485,6 +456,51 @@
this.uncheck重量.Name = "uncheck重量"; this.uncheck重量.Name = "uncheck重量";
this.uncheck重量.ReadOnly = true; this.uncheck重量.ReadOnly = true;
// //
// flpClass
//
this.flpClass.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flpClass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flpClass.Location = new System.Drawing.Point(3, 11);
this.flpClass.Name = "flpClass";
this.flpClass.Size = new System.Drawing.Size(283, 76);
this.flpClass.TabIndex = 1;
//
// flpGoods
//
this.flpGoods.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.flpGoods.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flpGoods.Location = new System.Drawing.Point(0, 117);
this.flpGoods.Name = "flpGoods";
this.flpGoods.Size = new System.Drawing.Size(289, 491);
this.flpGoods.TabIndex = 0;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 3000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timerChectNetStatus
//
this.timerChectNetStatus.Enabled = true;
this.timerChectNetStatus.Interval = 2000;
this.timerChectNetStatus.Tick += new System.EventHandler(this.timerChectNetStatus_Tick);
//
// timerSyncToService
//
this.timerSyncToService.Enabled = true;
this.timerSyncToService.Interval = 5000;
this.timerSyncToService.Tick += new System.EventHandler(this.timerSyncToService_Tick);
//
// timerCheckSyncSucessed
//
this.timerCheckSyncSucessed.Enabled = true;
this.timerCheckSyncSucessed.Interval = 4000;
this.timerCheckSyncSucessed.Tick += new System.EventHandler(this.timerCheckSyncSucessed_Tick);
//
// TrunksIousOutInStoreForm // TrunksIousOutInStoreForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -561,5 +577,6 @@
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck产品名称; private System.Windows.Forms.DataGridViewTextBoxColumn uncheck产品名称;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck数量; private System.Windows.Forms.DataGridViewTextBoxColumn uncheck数量;
private System.Windows.Forms.DataGridViewTextBoxColumn uncheck重量; private System.Windows.Forms.DataGridViewTextBoxColumn uncheck重量;
private System.Windows.Forms.FlowLayoutPanel flpClass;
} }
} }

+ 38
- 26
TrunksIousOutInStore/TrunksIousOutInStoreForm.cs View File

@ -28,7 +28,7 @@ namespace TrunksIousOutInStore
private readonly string ClientGoodsSetApplyClient = "白条出入库"; private readonly string ClientGoodsSetApplyClient = "白条出入库";
public const string DATA_PATH = "LocalData/TrunksIousOutInStore"; public const string DATA_PATH = "LocalData/TrunksIousOutInStore";
// BardCodeHooK BarCode = new BardCodeHooK();
// BardCodeHooK BarCode = new BardCodeHooK();
#region weightNeed #region weightNeed
SerialPort weightPort; SerialPort weightPort;
@ -57,7 +57,7 @@ namespace TrunksIousOutInStore
// syncToServer.Abort(); // syncToServer.Abort();
}; };
// BarCode.BarCodeEvent += new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent);
// BarCode.BarCodeEvent += new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent);
if (!Directory.Exists(DATA_PATH)) if (!Directory.Exists(DATA_PATH))
{ {
@ -80,15 +80,10 @@ namespace TrunksIousOutInStore
{ {
if (barCode.IsValid) if (barCode.IsValid)
{ {
// using (var sw=new StreamWriter("d:\\1122.txt",true))
// {
// sw.Write(barCode.BarCode);
// }
// MessageBox.Show(barCode.BarCode);
// MessageBox.Show(barCode.OriginalBarCode);
var code = UrlUtil.GetBarCode(barCode.BarCode.Trim());
var goodsName = UrlUtil.GetGoodsName(barCode.BarCode);
doInsertUnSubmit(code, goodsName, null);
// var code = UrlUtil.GetBarCode(barCode.BarCode.Trim());
// var goodsName = UrlUtil.GetGoodsName(barCode.BarCode);
var code = barCode.BarCode.Trim();
doInsertUnSubmit(code, "", null);
} }
} }
} }
@ -391,7 +386,7 @@ namespace TrunksIousOutInStore
private void TrunksIousOutInStoreForm_Load(object sender, EventArgs e) private void TrunksIousOutInStoreForm_Load(object sender, EventArgs e)
{ {
// BarCode.Start();
// BarCode.Start();
InitLocalList(); InitLocalList();
@ -402,12 +397,34 @@ namespace TrunksIousOutInStore
private void InitGoodsControl() private void InitGoodsControl()
{ {
flpClass.Controls.Clear();
foreach (IGrouping<string, TrunksIousOutInStoreClientGoodsSet> grouping in mLocaList.Where(x=>!string.IsNullOrWhiteSpace(x.Name)).GroupBy(x=>x.Name))
{
var btn = CreateClassButton(grouping.Key);
flpClass.Controls.Add(btn);
}
}
private Button CreateClassButton(string text)
{
var btn = new Button(){Text = text};
btn.Width = 100;
btn.Height = 60;
btn.Click += BtnClass_Click;
return btn;
}
private void BtnClass_Click(object sender, EventArgs e)
{
var btnClass = sender as Button;
flpGoods.Controls.Clear(); flpGoods.Controls.Clear();
foreach (TrunksIousOutInStoreClientGoodsSet set in mLocaList)
foreach (TrunksIousOutInStoreClientGoodsSet set in mLocaList.Where(x=>x.Name== btnClass.Text))
{ {
var btn = CreateGoodsSetButton(set); var btn = CreateGoodsSetButton(set);
flpGoods.Controls.Add(btn); flpGoods.Controls.Add(btn);
} }
GridUnCheckFocus();
Application.DoEvents();
} }
private Button CreateGoodsSetButton(TrunksIousOutInStoreClientGoodsSet set) private Button CreateGoodsSetButton(TrunksIousOutInStoreClientGoodsSet set)
@ -529,11 +546,10 @@ namespace TrunksIousOutInStore
private void TrunksIousOutInStoreForm_FormClosed(object sender, FormClosedEventArgs e) private void TrunksIousOutInStoreForm_FormClosed(object sender, FormClosedEventArgs e)
{ {
// BarCode.Stop();
// BarCode.Stop();
} }
#region 检查网络畅通 #region 检查网络畅通
private void timerChectNetStatus_Tick(object sender, EventArgs e) private void timerChectNetStatus_Tick(object sender, EventArgs e)
{ {
@ -600,20 +616,15 @@ namespace TrunksIousOutInStore
} }
BwpBarCodes barCodes = new BwpBarCodes(); BwpBarCodes barCodes = new BwpBarCodes();
private void TrunksIousOutInStoreForm_KeyDown(object sender, KeyEventArgs e) private void TrunksIousOutInStoreForm_KeyDown(object sender, KeyEventArgs e)
{ {
TimeSpan ts = DateTime.Now.Subtract(barCodes.Time);
char keyvalue = (char) e.KeyValue;
var str = keyvalue.ToString();
if (e.Shift)
if (e.KeyData == (Keys.ShiftKey | Keys.Shift))
{ {
if (e.KeyValue == 16)
{
str = ":";
}
return;
} }
TimeSpan ts = DateTime.Now.Subtract(barCodes.Time);
var str = BwpBarCodeUtil.GetStringByKeyKeyEventArgs(e);
barCodes.StringBuilder.Append(str); barCodes.StringBuilder.Append(str);
if (ts.TotalMilliseconds < 50) if (ts.TotalMilliseconds < 50)
@ -631,7 +642,8 @@ namespace TrunksIousOutInStore
{ {
MessageBox.Show(barCodes.BarCode);
// MessageBox.Show(barCodes.BarCode);
doInsertUnSubmit(barCodes.BarCode, "", null);
barCodes.StringBuilder = new StringBuilder(); barCodes.StringBuilder = new StringBuilder();
} }
} }


Loading…
Cancel
Save