Browse Source

配货客户端

master
luanhui 8 years ago
parent
commit
ac41e696ac
11 changed files with 390 additions and 32 deletions
  1. +7
    -0
      BO/BO.csproj
  2. +15
    -1
      BO/Utils/BillRpc/CustomerRpc.cs
  3. +15
    -1
      BO/Utils/BillRpc/DeliverGoodsLineRpc.cs
  4. +63
    -0
      BO/Utils/BillRpc/SaleOutStoreRpc.cs
  5. +4
    -0
      BWP.WinFormControl/BWP.WinFormControl.csproj
  6. +0
    -21
      BWP.WinFormControl/ComboBoxHelper.cs
  7. +204
    -0
      BWP.WinFormControl/UComboBox2.cs
  8. +31
    -0
      BWP.WinFormControl/WordPair.cs
  9. +4
    -0
      Distribution/Distribution.csproj
  10. +6
    -6
      Distribution/DistributionForm.Designer.cs
  11. +41
    -3
      Distribution/DistributionForm.cs

+ 7
- 0
BO/BO.csproj View File

@ -103,6 +103,7 @@
<Compile Include="Utils\BillRpc\GradeAndWeightRpc.cs" />
<Compile Include="Utils\BillRpc\HouseAndSanctionRpc.cs" />
<Compile Include="Utils\BillRpc\OrderDetailRpc.cs" />
<Compile Include="Utils\BillRpc\SaleOutStoreRpc.cs" />
<Compile Include="Utils\BillRpc\SecondOrderRpc.cs" />
<Compile Include="Utils\BillRpc\CarcassStateWeightRpc.cs" />
<Compile Include="Utils\ButcherAppContext.cs" />
@ -124,6 +125,12 @@
<ItemGroup>
<Folder Include="Bill\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BWP.WinFormControl\BWP.WinFormControl.csproj">
<Project>{a782b23e-be6d-4f51-b5cb-5cd259ba97cc}</Project>
<Name>BWP.WinFormControl</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.


+ 15
- 1
BO/Utils/BillRpc/CustomerRpc.cs View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BO.BO.BaseInfo;
using BWP.WinFormControl;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
@ -21,7 +22,7 @@ namespace BO.Utils.BillRpc
/// <returns></returns>
public static List<Customer> SyncList(string input="", bool updateLocalDb=true)
{
if (LoginRpcUtil.TestConnection(1000))
if (LoginRpcUtil.TestConnection(100))
{
//在线
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/BaseInfoRpc/SyncCustomer",input);
@ -31,6 +32,8 @@ namespace BO.Utils.BillRpc
{
using (var session = LocalDmoSession.New())
{
var sql1 = @"truncate table [Customer];";
session.ExecuteSqlNonQuery(sql1);
foreach (Customer dmo in list)
{
session.Insert(dmo);
@ -42,10 +45,21 @@ namespace BO.Utils.BillRpc
}
var dmoquery = new DmoQuery(typeof(Customer));
if (!string.IsNullOrWhiteSpace(input))
{
dmoquery.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name", input), DQCondition.Like("Spell", input)));
}
using (var session = LocalDmoSession.New())
{
return session.ExecuteList(dmoquery).Cast<Customer>().ToList();
}
}
public static List<WordPair> SyncListForDropDown(string input = "", bool updateLocalDb = true)
{
var list = SyncList(input, updateLocalDb);
return list.Select(x => new WordPair(x.Name, x.ID.ToString())).ToList();
}
}
}

+ 15
- 1
BO/Utils/BillRpc/DeliverGoodsLineRpc.cs View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BO.BO.BaseInfo;
using BWP.WinFormControl;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
@ -20,7 +21,7 @@ namespace BO.Utils.BillRpc
/// <returns></returns>
public static List<DeliverGoodsLine> SyncList(string input = "", bool updateLocalDb = true)
{
if (LoginRpcUtil.TestConnection(1000))
if (LoginRpcUtil.TestConnection(100))
{
//在线
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/BaseInfoRpc/SyncDeliverGoodsLine", input);
@ -30,6 +31,8 @@ namespace BO.Utils.BillRpc
{
using (var session = LocalDmoSession.New())
{
var sql1 = @"truncate table [DeliverGoodsLine];";
session.ExecuteSqlNonQuery(sql1);
foreach (DeliverGoodsLine dmo in list)
{
session.Insert(dmo);
@ -42,10 +45,21 @@ namespace BO.Utils.BillRpc
var dmoquery = new DmoQuery(typeof(DeliverGoodsLine));
if (!string.IsNullOrWhiteSpace(input))
{
dmoquery.Where.Conditions.Add(DQCondition.Or(DQCondition.Like("Name", input), DQCondition.Like("Spell", input)));
}
using (var session = LocalDmoSession.New())
{
return session.ExecuteList(dmoquery).Cast<DeliverGoodsLine>().ToList();
}
}
public static List<WordPair> SyncListForDropDown(string input = "", bool updateLocalDb = true)
{
var list = SyncList(input, updateLocalDb);
return list.Select(x => new WordPair(x.Name, x.ID.ToString())).ToList();
}
}
}

+ 63
- 0
BO/Utils/BillRpc/SaleOutStoreRpc.cs View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BWP.B3ClientService.BO;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
using Customer = BO.BO.BaseInfo.Customer;
namespace BO.Utils.BillRpc
{
public class SaleOutStoreRpc
{
public static BindingList<SaleOutStore> SyncList(DateTime date, string customerName,string sendLineName,string billstate,bool updateLocalDb)
{
var resList=new BindingList<SaleOutStore>();
if (LoginRpcUtil.TestConnection(100))
{
var json = RpcFacade.Call<string>("/MainSystem/B3ClientService/Rpcs/BillRpc/SaleOutStoreRpc/SyncList", date,customerName,sendLineName,billstate);
var list = JsonConvert.DeserializeObject<List<SaleOutStore>>(json);
if (updateLocalDb)
{
// AddLocalSaleOutStore(list);
}
foreach (SaleOutStore store in list)
{
resList.Add(store);
}
}
else
{
var dmoquery = new DmoQuery(typeof(SaleOutStore));
dmoquery.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("LoadTime", date));
dmoquery.Where.Conditions.Add(DQCondition.LessThan("LoadTime", date.AddDays(1)));
if (!string.IsNullOrWhiteSpace(customerName))
{
dmoquery.Where.Conditions.Add(DQCondition.EQ("Customer_Name", customerName));
}
if (!string.IsNullOrWhiteSpace(sendLineName))
{
dmoquery.Where.Conditions.Add(DQCondition.EQ("DeliverGoodsLine_Name", sendLineName));
}
if (!string.IsNullOrWhiteSpace(sendLineName))
{
dmoquery.Where.Conditions.Add(DQCondition.EQ("BillState", billstate));
}
var list = new List<SaleOutStore>();
using (var session=LocalDmoSession.New())
{
list =session.ExecuteList(dmoquery).Cast<SaleOutStore>().ToList();
}
foreach (SaleOutStore store in list)
{
resList.Add(store);
}
}
return resList;
}
}
}

+ 4
- 0
BWP.WinFormControl/BWP.WinFormControl.csproj View File

@ -56,6 +56,9 @@
<Compile Include="ComboBoxHelper.cs" />
<Compile Include="ComponentUtil.cs" />
<Compile Include="PrintAPI.cs" />
<Compile Include="UComboBox2.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UMessageBox.cs">
<SubType>Form</SubType>
</Compile>
@ -96,6 +99,7 @@
<DependentUpon>WeightControl.cs</DependentUpon>
</Compile>
<Compile Include="User32ClassUtil.cs" />
<Compile Include="WordPair.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="Calendar.xaml">


+ 0
- 21
BWP.WinFormControl/ComboBoxHelper.cs View File

@ -22,26 +22,5 @@ namespace BWP.WinFormControl
}
}
public sealed class WordPair
{
public string DisplayName { get; private set; }
public string PhyName { get; private set; }
public WordPair()
{ }
public WordPair(string display)
{
DisplayName = display;
}
public WordPair(string display, string phy)
{
DisplayName = display;
PhyName = phy;
}
public override string ToString()
{
return DisplayName;
}
}
}

+ 204
- 0
BWP.WinFormControl/UComboBox2.cs View File

@ -0,0 +1,204 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BWP.WinFormControl
{
public class UComboBox2 : ComboBox
{
ToolTip itemTip = null;
public UComboBox2()
{
this.DropDown += (sender, de) =>
{
CRefreshItems();
//if (string.IsNullOrEmpty(this.Text))
// return;
//if (_enableTopItem && Items.Count > 1)
// this.SelectedIndex = 1;
//else if (!_enableTopItem && Items.Count > 0)
// this.SelectedIndex = 0;
SelectionStart = Text.Length;
};
this.SelectedIndexChanged += (sender, e) =>
{
var item = SelectedItem as WordPair;
if (item == null)
{
_selectedObj = null;
return;
}
if (item.DisplayName == string.Empty)
_selectedObj = null;
else
_selectedObj = item;
};
this.DrawMode = DrawMode.OwnerDrawFixed;
this.DrawItem += new DrawItemEventHandler(cb_DrawItem);
this.DropDownClosed += new EventHandler(cb_DropDownClosed);
itemTip = new ToolTip();
itemTip.SetToolTip(this, "");
}
void cb_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
// 绘制背景
e.DrawBackground();
//绘制列表项目
e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, System.Drawing.Brushes.Black, e.Bounds);
//将高亮的列表项目的文字传递到toolTip1(之前建立ToolTip的一个实例)
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
itemTip.Show(this.Items[e.Index].ToString(), this, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + e.Bounds.Height);
e.DrawFocusRectangle();
}
void cb_DropDownClosed(object sender, EventArgs e)
{
itemTip.Hide(this);
}
private bool _enableTopItem = true;
public bool EnableTopItem
{
get { return _enableTopItem; }
set { _enableTopItem = value; }
}
private int range = 10;
public int Range
{
get { return range; }
set { range = value; }
}
private Func<string,List<WordPair>> mFunc;
public void Init(Func<string,List<WordPair>> func)
{
if (func == null)
{
return;
}
mFunc = func;
}
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if (e.KeyCode == System.Windows.Forms.Keys.Enter)
{
this.FindForm().Cursor = Cursors.Default;
if (string.IsNullOrEmpty(this.Text) || this.DisplayValue != this.Text || string.IsNullOrEmpty(this.SelectedText))
{
if (!this.DroppedDown)
this.DroppedDown = true;
}
}
}
void CRefreshItems()
{
var inputArgs = string.Empty;
if (this.SelectedItem == null)
inputArgs = this.Text;
var list = mFunc(inputArgs);
if (_enableTopItem)
list.Insert(0, new WordPair(string.Empty));
this.Items.Clear();
foreach (var item in list)
this.Items.Add(item);
this.DisplayMember = "DisplayName";
this.ValueMember = "PhyName";
}
public void Clear()
{
_selectedObj = null;
this.Text = string.Empty;
}
public void Fill(string display, string value)
{
if (string.IsNullOrEmpty(display))
{
Clear();
return;
}
_selectedObj = new WordPair(display, value);
this.Text = display == null ? string.Empty : display;
}
public bool IsEmpty { get { return _selectedObj == null; } }
public string DisplayValue { get { if (IsEmpty) return null; return _selectedObj.DisplayName; } }
public string Value { get { if (IsEmpty) return null; return _selectedObj.PhyName; } }
public long? LongValue
{
get
{
if (IsEmpty)
return null;
long v;
if (long.TryParse(_selectedObj.PhyName, out v))
return v;
return null;
}
}
private WordPair _selectedObj = null;
protected override void OnDropDown(EventArgs e)
{
base.OnDropDown(e);
AdjustComboBoxDropDownListWidth(); //调整comboBox的下拉列表的大小
}
private void AdjustComboBoxDropDownListWidth()
{
Graphics g = null;
Font font = null;
try
{
int width = this.Width;
g = this.CreateGraphics();
font = this.Font;
//checks if a scrollbar will be displayed.
//If yes, then get its width to adjust the size of the drop down list.
int vertScrollBarWidth =
(this.Items.Count > this.MaxDropDownItems)
? SystemInformation.VerticalScrollBarWidth : 0;
int newWidth;
foreach (object s in this.Items) //Loop through list items and check size of each items.
{
if (s != null)
{
newWidth = (int)g.MeasureString(s.ToString().Trim(), font).Width
+ vertScrollBarWidth;
if (width < newWidth)
width = newWidth; //set the width of the drop down list to the width of the largest item.
}
}
this.DropDownWidth = width;
}
catch
{ }
finally
{
if (g != null)
g.Dispose();
}
}
}
}

+ 31
- 0
BWP.WinFormControl/WordPair.cs View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BWP.WinFormControl
{
public sealed class WordPair
{
public string DisplayName { get; private set; }
public string PhyName { get; private set; }
public WordPair()
{ }
public WordPair(string display)
{
DisplayName = display;
}
public WordPair(string display, string phy)
{
DisplayName = display;
PhyName = phy;
}
public override string ToString()
{
return DisplayName;
}
}
}

+ 4
- 0
Distribution/Distribution.csproj View File

@ -73,6 +73,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BO\BO.csproj">
<Project>{8968f14a-c7c7-4751-96ce-b114fbfd65ef}</Project>
<Name>BO</Name>
</ProjectReference>
<ProjectReference Include="..\BWP.WinFormControl\BWP.WinFormControl.csproj">
<Project>{A782B23E-BE6D-4F51-B5CB-5CD259BA97CC}</Project>
<Name>BWP.WinFormControl</Name>


+ 6
- 6
Distribution/DistributionForm.Designer.cs View File

@ -45,8 +45,8 @@
this.btnRead = new System.Windows.Forms.Button();
this.dataGridViewSaleOutStore = new BWP.WinFormControl.UDataGridView();
this.panel4 = new System.Windows.Forms.Panel();
this.cbxSelectCustomer = new BWP.WinFormControl.UComboBox();
this.cbxSelectXianLu = new BWP.WinFormControl.UComboBox();
this.cbxSelectCustomer = new BWP.WinFormControl.UComboBox2();
this.cbxSelectXianLu = new BWP.WinFormControl.UComboBox2();
this.dateInput = new BWP.WinFormControl.UDatePicker();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
@ -245,7 +245,7 @@
//
// cbxSelectCustomer
//
this.cbxSelectCustomer.CodeArgs = null;
this.cbxSelectCustomer.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.cbxSelectCustomer.EnableTopItem = true;
this.cbxSelectCustomer.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@ -258,7 +258,7 @@
//
// cbxSelectXianLu
//
this.cbxSelectXianLu.CodeArgs = null;
this.cbxSelectXianLu.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.cbxSelectXianLu.EnableTopItem = true;
this.cbxSelectXianLu.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@ -736,8 +736,8 @@
private System.Windows.Forms.Label label1;
private BWP.WinFormControl.UDatePicker dateInput;
private System.Windows.Forms.Label label2;
private BWP.WinFormControl.UComboBox cbxSelectXianLu;
private BWP.WinFormControl.UComboBox cbxSelectCustomer;
private BWP.WinFormControl.UComboBox2 cbxSelectXianLu;
private BWP.WinFormControl.UComboBox2 cbxSelectCustomer;
private System.Windows.Forms.Label label3;
private BWP.WinFormControl.UDataGridView dataGridViewSaleOutStore;
private System.Windows.Forms.Button btnRead;


+ 41
- 3
Distribution/DistributionForm.cs View File

@ -7,19 +7,55 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BO.Utils;
using BO.Utils.BillRpc;
using BWP.WinFormControl;
using Distribution.LocalBo;
namespace Distribution
{
public partial class DistributionForm : Form
public partial class DistributionForm : Form,IAfterLogin
{
private bool mIsCustomerSynced,mIs;
public string RoleName { get { return "配货员"; } }
public Form Generate()
{
return this;
}
private bool mIsCustomerSynced, mIsDeliverGoodsLineSynced;
private BackgroundWorker mBackgroundWorkerSyncBaseInfo;
private BindingList<SaleOutStore> mSaleOutStoreList;
public DistributionForm()
{
InitializeComponent();
dataGridViewSaleOutStore.AutoGenerateColumns = false;
dataGridViewDingHuo.AutoGenerateColumns = false;
dataGridViewFaHuo.AutoGenerateColumns = false;
cbxSelectCustomer.Init(x => CustomerRpc.SyncListForDropDown(x,!mIsCustomerSynced));
cbxSelectXianLu.Init(x => DeliverGoodsLineRpc.SyncListForDropDown(x,!mIsDeliverGoodsLineSynced));
mBackgroundWorkerSyncBaseInfo =new BackgroundWorker();
mBackgroundWorkerSyncBaseInfo.DoWork += backgroundWorkerSyncBaseInfo_DoWork;
mBackgroundWorkerSyncBaseInfo.RunWorkerCompleted += backgroundWorkerSyncBaseInfo_RunWorkerCompleted;
mBackgroundWorkerSyncBaseInfo.RunWorkerAsync();
}
private void backgroundWorkerSyncBaseInfo_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
mIsCustomerSynced = true;
mIsDeliverGoodsLineSynced = true;
}
private void backgroundWorkerSyncBaseInfo_DoWork(object sender, DoWorkEventArgs e)
{
CustomerRpc.SyncList();
DeliverGoodsLineRpc.SyncList();
}
private void DistributionForm_Load(object sender, EventArgs e)
@ -29,7 +65,9 @@ namespace Distribution
private void btnSearch_Click(object sender, EventArgs e)
{
}
}
}

Loading…
Cancel
Save