using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using BO;
|
|
using BO.BarCodeScan;
|
|
using BO.Utils;
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
using Forks.JsonRpc.Client;
|
|
using Newtonsoft.Json;
|
|
using SegmentationInStore.Rpc;
|
|
using SegmentationInStore.Rpc.Dto;
|
|
|
|
namespace SegmentationInStore
|
|
{
|
|
public partial class SegmentationInStoreForm : Form, IAfterLogin
|
|
{
|
|
private readonly string mDropDownSetsFileName = "SegmentationInStore_DropDownSets.xml";
|
|
private DropDownSets mDropDownSets;
|
|
|
|
private static readonly object lockOjbUnScan = new object();
|
|
private static readonly object lockOjbSubmited = new object();
|
|
|
|
private BindingList<SegmentationWeightRecordDto> mUnScanList;
|
|
private BindingList<SegmentationInStoreRecord> mRecordList;
|
|
private BindingList<SegmentationInStoreRecord> mReturnRecordList;
|
|
|
|
private readonly Thread _tdSyncLocalToMiddleDb;
|
|
private readonly Thread _tdCheckNetStatus;
|
|
private readonly Thread _tdCheckSyncStatus;
|
|
private readonly Thread _tdGetUnScanRecords;
|
|
|
|
// BardCodeHooK BarCode = new BardCodeHooK();
|
|
public SegmentationInStoreForm()
|
|
{
|
|
InitializeComponent();
|
|
gridUnScan.AutoGenerateColumns = false;
|
|
gridSubmited.AutoGenerateColumns = false;
|
|
gridReturn.AutoGenerateColumns = false;
|
|
mUnScanList = new BindingList<SegmentationWeightRecordDto>();
|
|
mRecordList = new BindingList<SegmentationInStoreRecord>();
|
|
|
|
mReturnRecordList = new BindingList<SegmentationInStoreRecord>();
|
|
// Control.CheckForIllegalCrossThreadCalls = false;
|
|
// cbxStore.CheckForIllegalCrossThreadCalls = false
|
|
// BarCode.BarCodeEvent += new BardCodeHooK.BardCodeDeletegate(BarCode_BarCodeEvent);
|
|
|
|
InitCombox();
|
|
|
|
this.FormClosing += delegate
|
|
{
|
|
if (_tdSyncLocalToMiddleDb != null && _tdSyncLocalToMiddleDb.IsAlive)
|
|
{
|
|
_tdSyncLocalToMiddleDb.Abort();
|
|
}
|
|
if (_tdCheckNetStatus != null && _tdCheckNetStatus.IsAlive)
|
|
{
|
|
_tdCheckNetStatus.Abort();
|
|
}
|
|
if (_tdCheckSyncStatus != null && _tdCheckSyncStatus.IsAlive)
|
|
{
|
|
_tdCheckSyncStatus.Abort();
|
|
}
|
|
if (_tdGetUnScanRecords != null && _tdGetUnScanRecords.IsAlive)
|
|
{
|
|
_tdGetUnScanRecords.Abort();
|
|
}
|
|
};
|
|
|
|
|
|
_tdSyncLocalToMiddleDb = new Thread(SyncLocalToMiddleDb);
|
|
_tdSyncLocalToMiddleDb.Start();
|
|
|
|
_tdCheckNetStatus = new Thread(CheckNetStatus);
|
|
_tdCheckNetStatus.Start();
|
|
|
|
_tdCheckSyncStatus = new Thread(CheckSyncStatus);
|
|
_tdCheckSyncStatus.Start();
|
|
|
|
_tdGetUnScanRecords = new Thread(GetUnScanRecords);
|
|
_tdGetUnScanRecords.Start();
|
|
}
|
|
|
|
private void GetUnScanRecords()
|
|
{
|
|
while (true)
|
|
{
|
|
var listStr = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc/GetNotInStoreList");
|
|
var list = JsonConvert.DeserializeObject<List<SegmentationWeightRecordDto>>(listStr);
|
|
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
mUnScanList.Clear();
|
|
foreach (SegmentationWeightRecordDto dto in list)
|
|
{
|
|
mUnScanList.Insert(0, dto);
|
|
}
|
|
gridUnScan.DataSource = mUnScanList;
|
|
}
|
|
));
|
|
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
|
|
private void CheckSyncStatus()
|
|
{
|
|
while (true)
|
|
{
|
|
var syncSuccessed = SegmentationInStoreRpc.GetInstance().IsSyncSucessed();
|
|
var png = "stop.png";
|
|
if (syncSuccessed)
|
|
png = "working.png";
|
|
var imgPath = Path.Combine(Application.StartupPath, "BWP.WinFormControl.dll");
|
|
var s = Assembly.LoadFile(imgPath).GetManifestResourceStream("BWP.WinFormControl.Images." + png);
|
|
if (this.InvokeRequired)
|
|
{
|
|
this.BeginInvoke(new Action(() =>
|
|
{
|
|
picSyncStatus.Image = Image.FromStream(s);
|
|
picSyncStatus.Refresh();
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
picSyncStatus.Image = Image.FromStream(s);
|
|
picSyncStatus.Refresh();
|
|
}
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
|
|
private bool laseConnection = false;
|
|
|
|
private void CheckNetStatus()
|
|
{
|
|
while (true)
|
|
{
|
|
try
|
|
{
|
|
var newConnection = LoginRpcUtil.TestConnection(500);
|
|
if (newConnection && laseConnection)
|
|
{
|
|
Thread.Sleep(1000);
|
|
continue;
|
|
}
|
|
var png = "stop.png";
|
|
if (newConnection)
|
|
png = "working.png";
|
|
var imgPath = Path.Combine(Application.StartupPath, "BWP.WinFormControl.dll");
|
|
var s = Assembly.LoadFile(imgPath).GetManifestResourceStream("BWP.WinFormControl.Images." + png);
|
|
if (this.InvokeRequired)
|
|
{
|
|
this.BeginInvoke(new Action(() =>
|
|
{
|
|
picNetStatus.Image = Image.FromStream(s);
|
|
picNetStatus.Refresh();
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
picNetStatus.Image = Image.FromStream(s);
|
|
picNetStatus.Refresh();
|
|
}
|
|
laseConnection = newConnection;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//LogUtil.Error(e.ToString());
|
|
}
|
|
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
|
|
private void SyncLocalToMiddleDb()
|
|
{
|
|
while (true)
|
|
{
|
|
if (laseConnection)
|
|
{
|
|
this.BeginInvoke(new Action(() =>
|
|
{
|
|
SegmentationInStoreRpc.GetInstance().SyncToServer();
|
|
}));
|
|
|
|
}
|
|
Thread.Sleep(1000);
|
|
}
|
|
}
|
|
|
|
|
|
private void InitCombox()
|
|
{
|
|
if (LoginRpcUtil.TestConnection(500))
|
|
{
|
|
mDropDownSets = GetmDropDownSets();
|
|
XmlUtil.SerializerObjToFile(mDropDownSets, mDropDownSetsFileName);
|
|
}
|
|
else
|
|
{
|
|
mDropDownSets = XmlUtil.DeserializeFromFile<DropDownSets>(mDropDownSetsFileName);
|
|
}
|
|
var store = mDropDownSets.Details.FirstOrDefault(x => x.Name == DropDownSets.仓库);
|
|
if (store != null)
|
|
{
|
|
cbxStore.DataSource = store.Details;
|
|
cbxStore.DisplayMember = "Name";
|
|
cbxStore.ValueMember = "ID";
|
|
}
|
|
var shop = mDropDownSets.Details.FirstOrDefault(x => x.Name == DropDownSets.车间);
|
|
if (shop != null)
|
|
{
|
|
cbxWorkShop.DataSource = shop.Details;
|
|
cbxWorkShop.DisplayMember = "Name";
|
|
cbxWorkShop.ValueMember = "ID";
|
|
}
|
|
|
|
var unit = mDropDownSets.Details.FirstOrDefault(x => x.Name == DropDownSets.单元);
|
|
if (unit != null)
|
|
{
|
|
cbxWorkUnit.DataSource = unit.Details;
|
|
cbxWorkUnit.DisplayMember = "Name";
|
|
cbxWorkUnit.ValueMember = "Code";
|
|
}
|
|
|
|
}
|
|
private DropDownSets GetmDropDownSets()
|
|
{
|
|
var sets = new DropDownSets();
|
|
var storeSet = GetStoreSet();
|
|
var wrokUnitSet = GetWrokUnitSet();
|
|
var wrokShopSet = GetWrokShopSet();
|
|
sets.Details.Add(storeSet);
|
|
sets.Details.Add(wrokUnitSet);
|
|
sets.Details.Add(wrokShopSet);
|
|
return sets;
|
|
}
|
|
|
|
private DropDownSet GetWrokShopSet()
|
|
{
|
|
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BaseInfoRpc/GetWorkShopList");
|
|
var set = new DropDownSet();
|
|
set.Name = DropDownSets.车间;
|
|
foreach (var detail in JsonConvert.DeserializeObject<List<DropDownSet_Detail>>(json))
|
|
{
|
|
set.Details.Add(detail);
|
|
}
|
|
return set;
|
|
}
|
|
|
|
private DropDownSet GetWrokUnitSet()
|
|
{
|
|
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BaseInfoRpc/GetWorkUnitList");
|
|
var set = new DropDownSet();
|
|
set.Name = DropDownSets.单元;
|
|
foreach (var detail in JsonConvert.DeserializeObject<List<DropDownSet_Detail>>(json))
|
|
{
|
|
set.Details.Add(detail);
|
|
}
|
|
return set;
|
|
}
|
|
private DropDownSet GetStoreSet()
|
|
{
|
|
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BaseInfoRpc/GetStoreList");
|
|
var set = new DropDownSet();
|
|
set.Name = DropDownSets.仓库;
|
|
foreach (var detail in JsonConvert.DeserializeObject<List<DropDownSet_Detail>>(json))
|
|
{
|
|
set.Details.Add(detail);
|
|
}
|
|
return set;
|
|
}
|
|
|
|
void BarCode_BarCodeEvent(BardCodeHooK.BarCodes barCode)
|
|
{
|
|
ShowInfo(barCode);
|
|
}
|
|
private delegate void ShowInfoDelegate(BardCodeHooK.BarCodes barCode);
|
|
|
|
private void ShowInfo(BardCodeHooK.BarCodes barCode)
|
|
{
|
|
if (this.InvokeRequired)
|
|
{
|
|
this.BeginInvoke(new ShowInfoDelegate(ShowInfo), new object[] { barCode });
|
|
}
|
|
else
|
|
{
|
|
if (barCode.IsValid)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(barCode.BarCode))
|
|
{
|
|
// doInsertUnSubmit(barCode.BarCode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddException(string barcode, string error)
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
var errException = new SegmentationInStoreExceptionRecord(barcode, error);
|
|
using (var session = LocalDmoSession.New())
|
|
{
|
|
session.Insert(errException);
|
|
session.Commit();
|
|
}
|
|
richTextBox1.AppendText(errException.ToString() + Environment.NewLine);
|
|
}));
|
|
|
|
}
|
|
|
|
private void SegmentationInStoreForm_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
// var enable=BarCode.Start();
|
|
// if (!enable)
|
|
// {
|
|
// MessageBox.Show("注册扫码失败,联系管理员");
|
|
// }
|
|
|
|
// txtBarCode.Focus();
|
|
cbxStore.SelectedIndex = 0;
|
|
}
|
|
|
|
public List<string> RoleName
|
|
{
|
|
get
|
|
{
|
|
return new List<string>() { "车间业务.分割入库" };
|
|
}
|
|
}
|
|
public Form Generate()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
private void SegmentationInStoreForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
// BarCode.Stop();
|
|
}
|
|
|
|
BwpBarCodes barCodes = new BwpBarCodes();
|
|
private bool isFirstScanKey = true;//第一次扫码不判断50毫秒
|
|
private void SegmentationInStoreForm_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
gridSubmited.Focus();
|
|
if (e.KeyData == (Keys.ShiftKey | Keys.Shift))
|
|
{
|
|
return;
|
|
}
|
|
TimeSpan ts = DateTime.Now.Subtract(barCodes.Time);
|
|
var str = BwpBarCodeUtil.GetStringByKeyKeyEventArgs(e);
|
|
|
|
if (isFirstScanKey || ts.TotalMilliseconds < 50)
|
|
{
|
|
isFirstScanKey = false;
|
|
barCodes.StringBuilder.Append(str);
|
|
if (e.KeyData == Keys.Enter && barCodes.BarCode.Length > 0)
|
|
{
|
|
//回车
|
|
barCodes.IsValid = true;
|
|
barCodes.StringBuilder.Remove(barCodes.StringBuilder.Length - 1, 1);
|
|
}
|
|
}
|
|
try
|
|
{
|
|
if (barCodes.IsValid)
|
|
{
|
|
isFirstScanKey = true;
|
|
txtBarCode.Text = barCodes.BarCode;
|
|
try
|
|
{
|
|
DoEventByBarCode(barCodes.BarCode);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
MessageBox.Show(exception.ToString());
|
|
LogUtil.Error(exception);
|
|
}
|
|
finally
|
|
{
|
|
barCodes.StringBuilder = new StringBuilder();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
finally
|
|
{
|
|
barCodes.IsValid = false; //最后一定要 设置barCode无效
|
|
barCodes.Time = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
void DoEventByBarCode(string barCodesBarCode)
|
|
{
|
|
|
|
//如果是扫码汇总码
|
|
if (barCodesBarCode.ToLower().Contains("fgd"))
|
|
{
|
|
if (!LoginRpcUtil.TestConnection(1000))
|
|
{
|
|
MessageBox.Show("扫汇总码必须在线");
|
|
AddException(barCodesBarCode, "扫汇总码必须在线");
|
|
return;
|
|
}
|
|
//添加多条记录
|
|
var listStr = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc/GetWeightRecordList", barCodesBarCode.ToLower());// 转换小写 跟打印要一直
|
|
|
|
var list = JsonConvert.DeserializeObject<List<SegmentationInStoreRecord>>(listStr);
|
|
if (list.Count < 1)
|
|
{
|
|
MessageBox.Show("没有查询到该汇总码");
|
|
AddException(barCodesBarCode, "没有查询到该汇总码");
|
|
return;
|
|
|
|
}
|
|
foreach (SegmentationInStoreRecord dmo in list)
|
|
{
|
|
if (_isRetrun)
|
|
{
|
|
ReturnRecrodByCode(dmo.BarCode);
|
|
}
|
|
else
|
|
{
|
|
var recrod = doInsertAndBack(dmo);
|
|
if (recrod.ID > 0)
|
|
{
|
|
mRecordList.Insert(0, recrod);
|
|
}
|
|
RefreshRecordUi();
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
var barCode = barCodesBarCode.Replace(ButcherAppContext.Context.UrlConfig.OutAddress + "?", "");
|
|
barCode = barCodesBarCode.Replace(ButcherAppContext.Context.UrlConfig.OutAddress.ToUpper() + "?", "");
|
|
|
|
var code = UrlUtil.GetValueByKey("code", barCode);
|
|
if (string.IsNullOrWhiteSpace(code))
|
|
{
|
|
code = UrlUtil.GetValueByKey("CODE", barCode);
|
|
}
|
|
if (string.IsNullOrWhiteSpace(code))
|
|
{
|
|
code = barCodesBarCode;
|
|
}
|
|
|
|
var goodsId = UrlUtil.GetValueByKey("gid", barCode);
|
|
if (string.IsNullOrWhiteSpace(goodsId))
|
|
{
|
|
goodsId = UrlUtil.GetValueByKey("GID", barCode);
|
|
}
|
|
if (string.IsNullOrWhiteSpace(goodsId))
|
|
{
|
|
goodsId = UrlUtil.GetValueByKey("ID", barCode);
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(code))
|
|
{
|
|
MessageBox.Show("条码错误:" + barCodesBarCode);
|
|
AddException(barCodesBarCode, "条码错误");
|
|
return;
|
|
}
|
|
|
|
if (_isRetrun)
|
|
{
|
|
ReturnRecrodByCode(code);
|
|
}
|
|
else
|
|
{
|
|
var bg = new BackgroundWorker();
|
|
var record = new SegmentationInStoreRecord();
|
|
bg.DoWork += delegate
|
|
{
|
|
record = doInsertAndBack(code, goodsId);
|
|
};
|
|
bg.RunWorkerCompleted += delegate
|
|
{
|
|
if (record != null && record.ID > 0)
|
|
{
|
|
mRecordList.Insert(0, record);
|
|
RefreshRecordUi();
|
|
}
|
|
};
|
|
bg.RunWorkerAsync();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void ReturnRecrodByCode(string code)
|
|
{
|
|
using (var session = LocalDmoSession.New())
|
|
{
|
|
var record = GetLocalRecordByBarCode(session, code);
|
|
if (record != null)
|
|
{
|
|
var updateDom = new DQUpdateDom(typeof(SegmentationInStoreRecord));
|
|
updateDom.Where.Conditions.Add(DQCondition.EQ("ID", record.ID));
|
|
updateDom.Columns.Add(new DQUpdateColumn("IsDeleted", true));
|
|
updateDom.Columns.Add(new DQUpdateColumn("WillBeDeleted", true));
|
|
updateDom.Columns.Add(new DQUpdateColumn("DeleteTime", DateTime.Now));
|
|
session.ExecuteNonQuery(updateDom);
|
|
|
|
|
|
var fdrecord = mRecordList.FirstOrDefault(x => x.BarCode == code);
|
|
if (fdrecord != null)
|
|
{
|
|
mRecordList.Remove(fdrecord);
|
|
mReturnRecordList.Insert(0, fdrecord);
|
|
gridSubmited.DataSource = mRecordList;
|
|
gridReturn.DataSource = mReturnRecordList;
|
|
}
|
|
}
|
|
session.Commit();
|
|
}
|
|
|
|
}
|
|
|
|
private SegmentationInStoreRecord GetLocalRecordByBarCode(IDmoSession session, string code)
|
|
{
|
|
var query = new DmoQuery(typeof(SegmentationInStoreRecord));
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", code));
|
|
var list = session.ExecuteList(query).Cast<SegmentationInStoreRecord>().ToList();
|
|
if (list.Count > 0)
|
|
{
|
|
return list[0];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void RefreshRecordUi()
|
|
{
|
|
if (mRecordList.Count < 1)
|
|
{
|
|
return;
|
|
}
|
|
gridSubmited.DataSource = mRecordList;
|
|
}
|
|
|
|
|
|
bool IsExist(string barcode)
|
|
{
|
|
//#if DEBUG
|
|
// return false;
|
|
//#endif
|
|
using (var session = LocalDmoSession.New())
|
|
{
|
|
var query = new DQueryDom(new JoinAlias(typeof(SegmentationInStoreRecord)));
|
|
query.Columns.Add(DQSelectColumn.Field("ID"));
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barcode));
|
|
var res = session.ExecuteScalar(query);
|
|
return res != null;
|
|
}
|
|
}
|
|
|
|
void SetStoreInfo(SegmentationInStoreRecord record)
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
var storeid = Convert.ToInt64(cbxStore.SelectedValue);
|
|
var storename = cbxStore.Text;
|
|
if (!string.IsNullOrWhiteSpace(storename))
|
|
{
|
|
record.Store_ID = storeid;
|
|
record.Store_Name = storename;
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
private static readonly object _insertObj = new object();
|
|
SegmentationInStoreRecord doInsertAndBack(string code, string goodsId)
|
|
{
|
|
lock (_insertObj)
|
|
{
|
|
bool haserror = false;
|
|
|
|
var record = new SegmentationInStoreRecord();
|
|
var isExist = IsExist(code);
|
|
if (isExist)
|
|
{
|
|
AddException(code, "重复扫码");
|
|
haserror = true;
|
|
}
|
|
else
|
|
{
|
|
//添加记录
|
|
record.BarCode = code;
|
|
SetStoreInfo(record);
|
|
if (LoginRpcUtil.TestConnection(1000))
|
|
{
|
|
try
|
|
{
|
|
var weightStr = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc/GetWeightRecord", code);
|
|
if (string.IsNullOrWhiteSpace(weightStr))
|
|
{
|
|
AddException(code, "无效条码");
|
|
haserror = true;
|
|
}
|
|
else
|
|
{
|
|
var weight = JsonConvert.DeserializeObject<SegmentationWeightRecordDto>(weightStr);
|
|
record.Goods_ID = weight.Goods_ID;
|
|
record.Goods_Name = weight.Goods_Name;
|
|
record.Goods_Spec = weight.Goods_Spec;
|
|
record.Weight = weight.Weight;
|
|
record.ProductBatch = weight.ProductBatch;
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
record.BiaoShi = cbxWorkUnit.Text;
|
|
}) );
|
|
record.CardBarCode = weight.CardBarCode;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
AddException(code, e.Message);
|
|
haserror = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
record.Goods_ID = long.Parse(goodsId);
|
|
}
|
|
}
|
|
|
|
if (!haserror)
|
|
{
|
|
var id = LocalDmoSession.Insert(record);
|
|
return record;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
SegmentationInStoreRecord doInsertAndBack(SegmentationInStoreRecord dmo)
|
|
{
|
|
lock (_insertObj)
|
|
{
|
|
var record = new SegmentationInStoreRecord();
|
|
var isExist = IsExist(dmo.BarCode);
|
|
if (isExist)
|
|
{
|
|
AddException(dmo.BarCode, "重复扫码");
|
|
return record;
|
|
}
|
|
else
|
|
{
|
|
//添加记录
|
|
record.BarCode = dmo.BarCode;
|
|
SetStoreInfo(record);
|
|
record.Goods_ID = dmo.Goods_ID;
|
|
record.Goods_Name = dmo.Goods_Name;
|
|
record.Goods_Spec = dmo.Goods_Spec;
|
|
record.Weight = dmo.Weight;
|
|
record.ProductBatch = dmo.ProductBatch;
|
|
record.BiaoShi = cbxWorkUnit.Text;
|
|
record.CardBarCode = dmo.CardBarCode;
|
|
var id = LocalDmoSession.Insert(record);
|
|
return record;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
btnSubmit.Enabled = false;
|
|
Application.DoEvents();
|
|
|
|
if (LoginRpcUtil.TestConnection(1000))
|
|
{
|
|
if (SegmentationInStoreRpc.GetInstance().IsSyncSucessed())
|
|
{
|
|
var id = RpcFacade.Call<long>("/MainSystem/B3ClientService/Rpcs/BillRpc/SegmentationInStoreRecordRpc/CreateTodayB3ProductInStoreBill");
|
|
if (id > 0)
|
|
{
|
|
MessageBox.Show("同步完成,创建成品入库单:" + id);
|
|
}
|
|
else if (id == -1)
|
|
{
|
|
MessageBox.Show("同步完成");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("同步失败");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("请等待数据同步完成");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("没有网络,请通知管理员");
|
|
}
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
LogUtil.Error(exception);
|
|
MessageBox.Show(exception.ToString());
|
|
}
|
|
finally
|
|
{
|
|
btnSubmit.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private bool _isRetrun;
|
|
private void btnIsReturn_Click(object sender, EventArgs e)
|
|
{
|
|
if (_isRetrun)
|
|
{
|
|
btnIsReturn.BackColor = SystemColors.Control;
|
|
}
|
|
else
|
|
{
|
|
btnIsReturn.BackColor = Color.Green;
|
|
}
|
|
_isRetrun = !_isRetrun;
|
|
}
|
|
}
|
|
}
|