Browse Source

鲜品发货客户端。

master
yibo 6 years ago
parent
commit
9c8eff1bdf
16 changed files with 986 additions and 224 deletions
  1. +6
    -0
      B3DealerClient/B3DealerClient.csproj
  2. +2
    -3
      B3DealerClient/BL/FreshInStoreBL.cs
  3. +104
    -0
      B3DealerClient/BL/FreshSaleOutBL.cs
  4. +73
    -0
      B3DealerClient/BO/FreshSaleOut/FreshSaleOut.cs
  5. +24
    -0
      B3DealerClient/BO/FreshSaleOut/FreshSaleOut_Record.cs
  6. +1
    -1
      B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutContext.cs
  7. +197
    -197
      B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs
  8. +0
    -2
      B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreConfig.cs
  9. +12
    -0
      B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreContext.cs
  10. +14
    -2
      B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml
  11. +21
    -15
      B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs
  12. +14
    -0
      B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutConfig.cs
  13. +88
    -0
      B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutContext.cs
  14. +207
    -3
      B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml
  15. +196
    -1
      B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs
  16. +27
    -0
      B3DealerClient/Windows/FreshSaleOutWindow_/SelfValueConvert.cs

+ 6
- 0
B3DealerClient/B3DealerClient.csproj View File

@ -80,6 +80,7 @@
<Compile Include="BL\CarcassInStoreBL.cs" /> <Compile Include="BL\CarcassInStoreBL.cs" />
<Compile Include="BL\CarcassSaleOutBL.cs" /> <Compile Include="BL\CarcassSaleOutBL.cs" />
<Compile Include="BL\FreshInStoreBL.cs" /> <Compile Include="BL\FreshInStoreBL.cs" />
<Compile Include="BL\FreshSaleOutBL.cs" />
<Compile Include="BL\LoginBL.cs" /> <Compile Include="BL\LoginBL.cs" />
<Compile Include="BO\CarcassInStore\CarcassInStore.cs" /> <Compile Include="BO\CarcassInStore\CarcassInStore.cs" />
<Compile Include="BO\CarcassInStore\CarcassInStore_Detail.cs" /> <Compile Include="BO\CarcassInStore\CarcassInStore_Detail.cs" />
@ -90,6 +91,8 @@
<Compile Include="BO\FreshInStore\FreshInStore.cs" /> <Compile Include="BO\FreshInStore\FreshInStore.cs" />
<Compile Include="BO\FreshInStore\FreshInStore_Detail.cs" /> <Compile Include="BO\FreshInStore\FreshInStore_Detail.cs" />
<Compile Include="BO\FreshInStore\FreshInStore_Record.cs" /> <Compile Include="BO\FreshInStore\FreshInStore_Record.cs" />
<Compile Include="BO\FreshSaleOut\FreshSaleOut.cs" />
<Compile Include="BO\FreshSaleOut\FreshSaleOut_Record.cs" />
<Compile Include="BO\NameIDPair.cs" /> <Compile Include="BO\NameIDPair.cs" />
<Compile Include="BO\NotificationObject.cs" /> <Compile Include="BO\NotificationObject.cs" />
<Compile Include="Control\DataFormat\DataFormat.cs" /> <Compile Include="Control\DataFormat\DataFormat.cs" />
@ -147,9 +150,12 @@
<Compile Include="Windows\FreshInStoreWindow_\FreshInStoreWindow.xaml.cs"> <Compile Include="Windows\FreshInStoreWindow_\FreshInStoreWindow.xaml.cs">
<DependentUpon>FreshInStoreWindow.xaml</DependentUpon> <DependentUpon>FreshInStoreWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Windows\FreshSaleOutWindow_\FreshSaleOutConfig.cs" />
<Compile Include="Windows\FreshSaleOutWindow_\FreshSaleOutContext.cs" />
<Compile Include="Windows\FreshSaleOutWindow_\FreshSaleOutWindow.xaml.cs"> <Compile Include="Windows\FreshSaleOutWindow_\FreshSaleOutWindow.xaml.cs">
<DependentUpon>FreshSaleOutWindow.xaml</DependentUpon> <DependentUpon>FreshSaleOutWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Windows\FreshSaleOutWindow_\SelfValueConvert.cs" />
<Compile Include="Windows\Test.xaml.cs"> <Compile Include="Windows\Test.xaml.cs">
<DependentUpon>Test.xaml</DependentUpon> <DependentUpon>Test.xaml</DependentUpon>
</Compile> </Compile>


+ 2
- 3
B3DealerClient/BL/FreshInStoreBL.cs View File

@ -38,9 +38,8 @@ namespace B3DealerClient.BL
return; return;
var query = new DQueryDom(new JoinAlias(typeof(FreshInStore_Record))); var query = new DQueryDom(new JoinAlias(typeof(FreshInStore_Record)));
query.Columns.Add(DQSelectColumn.Field("DetailID")); query.Columns.Add(DQSelectColumn.Field("DetailID"));
query.Columns.Add(DQSelectColumn.Sum("Weight"));
query.Columns.Add(DQSelectColumn.Sum("Number"));
query.GroupBy.Expressions.Add(DQExpression.Field("DetailID"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("Number"));
query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("DetailID"), details.Select(x => DQExpression.Value(x.ID)).ToArray())); query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("DetailID"), details.Select(x => DQExpression.Value(x.ID)).ToArray()));
var list = query.EExecuteList<long, decimal?, decimal?>(); var list = query.EExecuteList<long, decimal?, decimal?>();
foreach (var item in list) foreach (var item in list)


+ 104
- 0
B3DealerClient/BL/FreshSaleOutBL.cs View File

@ -0,0 +1,104 @@
using B3DealerClient.BO;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using B3DealerClient.Utils;
namespace B3DealerClient.BL
{
public class FreshSaleOutBL
{
const string MethodPath = @"/MainSystem/B3Dealer/Rpcs/SaleOutStoreRpc/";
public static List<FreshSaleOut> GetDmoList(object condition)
{
var method = MethodPath + "GetSaleOutStoreList";
var json = RpcFacade.Call<string>(method, JsonConvert.SerializeObject(condition));
var list = JsonConvert.DeserializeObject<List<FreshSaleOut>>(json);
FillAlreadyInfo(list);
return list;
}
private static void FillAlreadyInfo(List<FreshSaleOut> list)
{
if (list.Count == 0)
return;
var query = new DQueryDom(new JoinAlias(typeof(FreshSaleOut_Record)));
query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("DetailID"), list.Select(x => DQExpression.Value(x.ID)).ToArray()));
query.Columns.Add(DQSelectColumn.Field("DetailID"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("Number"));
var records = query.EExecuteList<long, decimal, decimal>();
foreach (var item in records)
{
var f = list.First(x => x.DetailID == item.Item1);
f.AlreadyNumber = item.Item2;
f.AlreadySecondNumber = item.Item3;
}
}
public static List<CustomerObj> GetCustomers(object condition)
{
var method = MethodPath + "GetCustomers";
var json = RpcFacade.Call<string>(method, JsonConvert.SerializeObject(condition));
return JsonConvert.DeserializeObject<List<CustomerObj>>(json);
}
public static void InsertRecord(FreshSaleOut_Record record)
{
using (var session = DmoSession.New())
{
var id = GetExistID(session, record);
if (id.HasValue)
{
record.ID = id.Value;
session.Update(record);
}
else
session.Insert(record);
session.Commit();
}
}
static long? GetExistID(IDmoSession session, FreshSaleOut_Record record)
{
var query = new DQueryDom(new JoinAlias(typeof(FreshSaleOut_Record)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Where.Conditions.Add(DQCondition.EQ("DetailID", record.DetailID));
return query.EExecuteScalar<long?>(session);
}
public static void FinishAssign(long id)
{
var target = GetBillRecords(id);
RpcFacade.Call<int>(MethodPath + "FreshFinishAssign", JsonConvert.SerializeObject(target), id);
}
static List<Tuple<long, decimal?, decimal?>> GetBillRecords(long billID)
{
var query = new DQueryDom(new JoinAlias(typeof(FreshSaleOut_Record)));
query.Where.Conditions.Add(DQCondition.EQ("BillID", billID));
query.Columns.Add(DQSelectColumn.Field("DetailID"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("Number"));
var records = new List<Tuple<long, decimal?, decimal?>>();
using (var session = DmoSession.New())
{
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
records.Add(new Tuple<long, decimal?, decimal?>((long)reader[0], (decimal?)reader[1], (decimal?)reader[2]));
}
}
}
return records;
}
}
}

+ 73
- 0
B3DealerClient/BO/FreshSaleOut/FreshSaleOut.cs View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B3DealerClient.BO
{
public class FreshSaleOut : NotificationObject
{
public long ID { get; set; }
public string Customer_Name { get; set; }
public string Driver_Name { get; set; }
public string Store_Name { get; set; }
public DateTime? LoadTime { get; set; }
public long DetailID { get; set; }
public string Goods_Name { get; set; }
public decimal? Number { get; set; }
public decimal? SecondNumber { get; set; }
private decimal? mAlreadyNumber;
public decimal? AlreadyNumber
{
get { return mAlreadyNumber; }
set
{
mAlreadyNumber = value;
RaisePropertyChanged("AlreadyNumber");
}
}
private decimal? mAlreadySecondNumber;
public decimal? AlreadySecondNumber
{
get { return mAlreadySecondNumber; }
set
{
mAlreadySecondNumber = value;
RaisePropertyChanged("AlreadySecondNumber");
}
}
private bool mAssignFinished;
public bool AssignFinished
{
get { return mAssignFinished; }
set
{
mAssignFinished = value;
RaisePropertyChanged("AssignFinished");
}
}
private bool mSelected;
public bool Selected
{
get { return mSelected; }
set
{
mSelected = value;
RaisePropertyChanged("Selected");
}
}
}
}

+ 24
- 0
B3DealerClient/BO/FreshSaleOut/FreshSaleOut_Record.cs View File

@ -0,0 +1,24 @@
using Forks.EnterpriseServices.DomainObjects2;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B3DealerClient.BO
{
[MapToTable("B3DealerClient_FreshSaleOut_Record")]
[KeyField("ID", KeyGenType.identity)]
public class FreshSaleOut_Record
{
[JsonIgnore]
public long ID { get; set; }
public long BillID { get; set; }
public long DetailID { get; set; }
public decimal? Weight { get; set; }
public decimal? Number { get; set; }
}
}

+ 1
- 1
B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutContext.cs View File

@ -84,7 +84,7 @@ namespace B3DealerClient.Windows.CarcassSaleOutWindow_
} }
} }
public bool Finish
private bool Finish
{ {
get get
{ {


+ 197
- 197
B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs View File

@ -62,242 +62,242 @@ namespace B3DealerClient.Windows.CarcassSaleOutWindow_
pageSize = (int)customerPanel.ActualHeight / 60; pageSize = (int)customerPanel.ActualHeight / 60;
} }
private void NumberBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var numberPad = new NumberPad(this);
if (numberPad.ShowDialog() == true)
private void NumberBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
decimal value = 0;
if (!string.IsNullOrEmpty(numberPad.Result) && !decimal.TryParse(numberPad.Result, out value))
throw new Exception("输入错误");
var name = (sender as TextBox).Name;
switch (name)
var numberPad = new NumberPad(this);
if (numberPad.ShowDialog() == true)
{ {
case "hook":
context.HookWeight = value;
config.HookWeight = value;
break;
//case "number":
// context.Number = value;
// config.Number = value;
// break;
decimal value = 0;
if (!string.IsNullOrEmpty(numberPad.Result) && !decimal.TryParse(numberPad.Result, out value))
throw new Exception("输入错误");
var name = (sender as TextBox).Name;
switch (name)
{
case "hook":
context.HookWeight = value;
config.HookWeight = value;
break;
//case "number":
// context.Number = value;
// config.Number = value;
// break;
}
XmlUtil.SerializerObjToFile(config);
} }
XmlUtil.SerializerObjToFile(config);
} }
}
private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var tb = sender as FrameworkElement;
var dig = new BaseInfoDialog(tb.Name);
if (dig.ShowDialog() == true)
private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
switch (tb.Name)
var tb = sender as FrameworkElement;
var dig = new BaseInfoDialog(tb.Name);
if (dig.ShowDialog() == true)
{ {
case "DriverGoodsLine":
context.DriverGoodsLine.Fill(dig.Result);
pageIndex = 0;
BindCustomerPanel();
break;
case "Store":
context.Store.Fill(dig.Result);
config.Store = dig.Result;
XmlUtil.SerializerObjToFile(config);
break;
switch (tb.Name)
{
case "DriverGoodsLine":
context.DriverGoodsLine.Fill(dig.Result);
pageIndex = 0;
BindCustomerPanel();
break;
case "Store":
context.Store.Fill(dig.Result);
config.Store = dig.Result;
XmlUtil.SerializerObjToFile(config);
break;
}
} }
} }
}
void BindCustomerPanel()
{
context.CustomerList = CarcassSaleOutBL.GetCustomers(new
{
Date = context.Date,
Store_ID = context.Store.ID,
DeliverGoodsLine_ID = context.DriverGoodsLine.ID,
PageIndex = pageIndex,
PageSize = pageSize
});
}
private void PageBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var tag = (sender as Button).Tag.ToString();
if (tag == "0")
{
if (pageIndex == 0)
return;
pageIndex -= 1;
BindCustomerPanel();
}
else
void BindCustomerPanel()
{ {
if (context.CustomerList == null || context.CustomerList.Count < pageSize)
return;
pageIndex += 1;
BindCustomerPanel();
context.CustomerList = CarcassSaleOutBL.GetCustomers(new
{
Date = context.Date,
Store_ID = context.Store.ID,
DeliverGoodsLine_ID = context.DriverGoodsLine.ID,
PageIndex = pageIndex,
PageSize = pageSize
});
} }
}
private void NumberBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var c = (sender as Button).Content.ToString();
switch (c)
private void PageBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
case "0":
context.StrNumber = "0";
break;
case "./点":
if (string.IsNullOrEmpty(context.StrNumber))
context.StrNumber = "0.";
else if (context.StrNumber.Contains('.'))
var tag = (sender as Button).Tag.ToString();
if (tag == "0")
{
if (pageIndex == 0)
return; return;
else
context.StrNumber += ".";
break;
default:
if (context.StrNumber == "0")
context.StrNumber = c;
else
context.StrNumber += c;
break;
pageIndex -= 1;
BindCustomerPanel();
}
else
{
if (context.CustomerList == null || context.CustomerList.Count < pageSize)
return;
pageIndex += 1;
BindCustomerPanel();
}
} }
}
private void CustomerBtn_PriviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (context.Dmo != null)
context.Dmo = null;
if (context.Detail != null)
context.Detail = null;
if (context.Details.Any())
context.Details.Clear();
private void NumberBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var c = (sender as Button).Content.ToString();
switch (c)
{
case "0":
context.StrNumber = "0";
break;
case "./点":
if (string.IsNullOrEmpty(context.StrNumber))
context.StrNumber = "0.";
else if (context.StrNumber.Contains('.'))
return;
else
context.StrNumber += ".";
break;
default:
if (context.StrNumber == "0")
context.StrNumber = c;
else
context.StrNumber += c;
break;
}
}
var obj = (sender as ListBoxItem).DataContext as CustomerObj;
context.DmoList = CarcassSaleOutBL.GetDmoList(new
private void CustomerBtn_PriviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
Date = context.Date,
Customer_ID = obj.ID,
Store_ID = context.Store.ID,
AssignFinished = obj.Finished
});
if (context.Dmo != null)
context.Dmo = null;
if (context.Detail != null)
context.Detail = null;
if (context.Details.Any())
context.Details.Clear();
var obj = (sender as ListBoxItem).DataContext as CustomerObj;
context.DmoList = CarcassSaleOutBL.GetDmoList(new
{
Date = context.Date,
Customer_ID = obj.ID,
Store_ID = context.Store.ID,
AssignFinished = obj.Finished
});
foreach (var item in context.CustomerList)
foreach (var item in context.CustomerList)
{
if (item.Selected && !item.Equals(obj))
item.Selected = false;
else if (!item.Selected && item.Equals(obj))
item.Selected = true;
}
}
private void MainGridFocus(object sender, MouseButtonEventArgs e)
{ {
if (item.Selected && !item.Equals(obj))
item.Selected = false;
else if (!item.Selected && item.Equals(obj))
item.Selected = true;
var row = sender as DataGridRow;
context.Dmo = row.Item as CarcassSaleOut;
foreach (var item in context.DmoList)
{
if (item.Selected && item.ID != context.Dmo.ID)
item.Selected = false;
else if (item.Selected && item.ID == context.Dmo.ID)
context.Dmo.Selected = true;
}
MainSelected();
} }
}
private void MainGridFocus(object sender, MouseButtonEventArgs e)
{
var row = sender as DataGridRow;
context.Dmo = row.Item as CarcassSaleOut;
foreach (var item in context.DmoList)
void MainSelected()
{ {
if (item.Selected && item.ID != context.Dmo.ID)
item.Selected = false;
else if (item.Selected && item.ID == context.Dmo.ID)
context.Dmo.Selected = true;
context.Details.Clear();
var details = CarcassSaleOutBL.GetDetailRecords(context.Dmo.DetailID);
foreach (var item in details)
context.Details.Add(item);
context.Detail = context.Details.FirstOrDefault();
DetailSelected();
} }
MainSelected();
}
void MainSelected()
{
context.Details.Clear();
var details = CarcassSaleOutBL.GetDetailRecords(context.Dmo.DetailID);
foreach (var item in details)
context.Details.Add(item);
context.Detail = context.Details.FirstOrDefault();
DetailSelected();
}
private void DetailGridFocus(object sender, MouseButtonEventArgs e)
{
var row = sender as DataGridRow;
context.Detail = row.Item as CarcassSaleOut_Record;
DetailSelected();
}
private void DetailGridFocus(object sender, MouseButtonEventArgs e)
{
var row = sender as DataGridRow;
context.Detail = row.Item as CarcassSaleOut_Record;
DetailSelected();
}
void DetailSelected()
{
if (context.Detail == null)
return;
void DetailSelected()
{
if (context.Detail == null)
return;
foreach (var item in context.Details)
{
if (item.Selected && item.ID != context.Detail.ID)
item.Selected = false;
else if (!item.Selected && item.ID == context.Detail.ID)
item.Selected = true;
}
}
foreach (var item in context.Details)
private void DeleteBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
if (item.Selected && item.ID != context.Detail.ID)
item.Selected = false;
else if (!item.Selected && item.ID == context.Detail.ID)
item.Selected = true;
var confirm = MessageBox.Show("确定要删除选中记录吗?", "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (confirm == MessageBoxResult.OK)
{
CarcassSaleOutBL.Delete(context.Detail.ID);
context.Details.Remove(context.Detail);
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) - context.Detail.NetWeight;
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) - context.Detail.SecondNumber;
context.Detail = context.Details.FirstOrDefault();
DetailSelected();
}
} }
}
private void DeleteBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var confirm = MessageBox.Show("确定要删除选中记录吗?", "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (confirm == MessageBoxResult.OK)
private void SaveBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
CarcassSaleOutBL.Delete(context.Detail.ID);
context.Details.Remove(context.Detail);
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) - context.Detail.NetWeight;
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) - context.Detail.SecondNumber;
context.Detail = context.Details.FirstOrDefault();
var record = new CarcassSaleOut_Record();
record.MainID = context.Dmo.ID;
record.DetailID = context.Dmo.DetailID;
record.Goods_Name = context.Dmo.Goods_Name;
record.Weight = context.Weight;
record.SecondNumber = context.Number;
record.Discont = (context.HookWeight ?? 0) * Math.Ceiling(record.SecondNumber);
record.NetWeight = record.Weight - record.Discont;
record.Date = DateTime.Now;
record.Selected = true;
CarcassSaleOutBL.InsertRecord(record);
context.Details.Add(record);
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) + record.NetWeight;
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) + record.SecondNumber;
context.Detail = record;
DetailSelected(); DetailSelected();
weightControl.Weight = 0;
context.Weight = 0;
context.StrNumber = string.Empty;
} }
}
private void SaveBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var record = new CarcassSaleOut_Record();
record.MainID = context.Dmo.ID;
record.DetailID = context.Dmo.DetailID;
record.Goods_Name = context.Dmo.Goods_Name;
record.Weight = context.Weight;
record.SecondNumber = context.Number;
record.Discont = (context.HookWeight ?? 0) * Math.Ceiling(record.SecondNumber);
record.NetWeight = record.Weight - record.Discont;
record.Date = DateTime.Now;
record.Selected = true;
CarcassSaleOutBL.InsertRecord(record);
context.Details.Add(record);
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) + record.NetWeight;
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) + record.SecondNumber;
context.Detail = record;
DetailSelected();
weightControl.Weight = 0;
context.Weight = 0;
context.StrNumber = string.Empty;
}
private void ViewBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
new RecordViewDialog(context.Dmo.ID).ShowDialog();
}
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
private void ViewBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
new RecordViewDialog(context.Dmo.ID).ShowDialog();
}
var targets = context.DmoList.Where(x => x.ID == context.Dmo.ID);
var needConfirm = targets.Any(x => (x.AlreadyNumber ?? 0) == 0 || (x.SecondNumber ?? 0) == 0);
if (needConfirm)
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
var confirm = MessageBox.Show("存在未配货的明细,确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (confirm != MessageBoxResult.OK)
var targets = context.DmoList.Where(x => x.ID == context.Dmo.ID);
var needConfirm = targets.Any(x => (x.AlreadyNumber ?? 0) == 0 || (x.SecondNumber ?? 0) == 0);
if (needConfirm)
{
var confirm = MessageBox.Show("存在未配货的明细,确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (confirm != MessageBoxResult.OK)
return;
}
var r = MessageBox.Show("确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (r != MessageBoxResult.OK)
return; return;
CarcassSaleOutBL.FinishAssign(context.Dmo.ID);
foreach (var item in targets)
item.AssignFinished = true;
context.Dmo = context.Dmo;
MessageBox.Show("配货完成");
} }
var r = MessageBox.Show("确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (r != MessageBoxResult.OK)
return;
CarcassSaleOutBL.FinishAssign(context.Dmo.ID);
foreach (var item in targets)
item.AssignFinished = true;
context.Finish = true;
MessageBox.Show("配货完成");
}
} }
} }

+ 0
- 2
B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreConfig.cs View File

@ -10,7 +10,5 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
public class FreshInStoreConfig public class FreshInStoreConfig
{ {
public NameIDPair Store { get; set; } public NameIDPair Store { get; set; }
public decimal? Pics { get; set; }
} }
} }

+ 12
- 0
B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreContext.cs View File

@ -51,6 +51,18 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
} }
} }
private decimal? mWeight;
public decimal? Weight
{
get { return mWeight; }
set
{
mWeight = value;
RaisePropertyChanged("Weight");
RaisePropertyChanged("CanSave");
}
}
private FreshInStore mDmo = null; private FreshInStore mDmo = null;
public FreshInStore Dmo { get { return mDmo; } set { mDmo = value; RaisePropertyChanged("Dmo"); } } public FreshInStore Dmo { get { return mDmo; } set { mDmo = value; RaisePropertyChanged("Dmo"); } }


+ 14
- 2
B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml View File

@ -178,9 +178,21 @@
</WrapPanel> </WrapPanel>
<WrapPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right"> <WrapPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right">
<WrapPanel.Resources>
<Style TargetType="TextBox">
<Setter Property="Width" Value="90"/>
<Setter Property="Height" Value="35"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Margin" Value="10,0"/>
<EventSetter Event="PreviewMouseDown" Handler="InputBox_PreviewMouseDown"/>
</Style>
</WrapPanel.Resources>
<Button Content="按装货入库" IsEnabled="{Binding Detail, Converter={StaticResource NullIsFalseConverter}}" PreviewMouseDown="FillByDetailBtn_PreviewMouseDown"/> <Button Content="按装货入库" IsEnabled="{Binding Detail, Converter={StaticResource NullIsFalseConverter}}" PreviewMouseDown="FillByDetailBtn_PreviewMouseDown"/>
<TextBlock Text="件数录入"/>
<TextBox x:Name="pics" Text="{Binding Pics,StringFormat=\{0:0.######\}}" Margin="10,0" PreviewMouseDown="NumberBox_PreviewMouseDown"/>
<TextBlock Text="件数"/>
<TextBox x:Name="pics" Text="{Binding Pics,StringFormat=\{0:0.######\}}"/>
<TextBlock Text="重量"/>
<TextBox x:Name="weight" Text="{Binding Weight,StringFormat=\{0:0.######\}}"/>
<Button Content="确认" IsEnabled="{Binding CanSave}" PreviewMouseDown="SaveBtn_PreviewMouseDown"/> <Button Content="确认" IsEnabled="{Binding CanSave}" PreviewMouseDown="SaveBtn_PreviewMouseDown"/>
</WrapPanel> </WrapPanel>
</Grid> </Grid>


+ 21
- 15
B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs View File

@ -43,7 +43,6 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
config = XmlUtil.DeserializeFromFile<FreshInStoreConfig>(); config = XmlUtil.DeserializeFromFile<FreshInStoreConfig>();
if (config.Store != null) if (config.Store != null)
context.Store.Fill(config.Store); context.Store.Fill(config.Store);
context.Pics = config.Pics;
} }
private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
@ -66,7 +65,7 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
} }
} }
private void NumberBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
private void InputBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
var numberPad = new NumberPad(this); var numberPad = new NumberPad(this);
if (numberPad.ShowDialog() == true) if (numberPad.ShowDialog() == true)
@ -78,19 +77,27 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
var name = (sender as TextBox).Name; var name = (sender as TextBox).Name;
switch (name) switch (name)
{ {
//case "hook":
// context.HookWeight = value;
// config.HookWeight = value;
// break;
case "pics": case "pics":
context.Pics = value; context.Pics = value;
config.Pics = value;
NumberToWeight();
break;
case "weight":
context.Weight = value;
break; break;
} }
XmlUtil.SerializerObjToFile(config);
} }
} }
void NumberToWeight()
{
if (context.Detail == null)
return;
if (context.Detail.SecondNumber == 0)
context.Weight = null;
else
context.Weight = context.Detail.Number / context.Detail.SecondNumber * context.Pics;
}
private void SearchBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) private void SearchBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{ {
var btnName = (sender as Button).Name; var btnName = (sender as Button).Name;
@ -166,7 +173,7 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
record.DetailID = item.ID; record.DetailID = item.ID;
record.Number = item.SecondNumber; record.Number = item.SecondNumber;
record.Weight = item.Number; record.Weight = item.Number;
InsertRecord(record, false);
InsertRecord(record);
} }
} }
@ -176,7 +183,7 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
record.DetailID = context.Detail.ID; record.DetailID = context.Detail.ID;
record.Number = context.Detail.SecondNumber; record.Number = context.Detail.SecondNumber;
record.Weight = context.Detail.Number; record.Weight = context.Detail.Number;
InsertRecord(record, false);
InsertRecord(record);
} }
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
@ -193,15 +200,14 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
{ {
var record = new FreshInStore_Record(); var record = new FreshInStore_Record();
record.DetailID = context.Detail.ID; record.DetailID = context.Detail.ID;
record.Number = context.Pics.Value;
InsertRecord(record, true);
record.Number = context.Pics;
record.Weight = context.Weight;
InsertRecord(record);
} }
void InsertRecord(FreshInStore_Record record, bool convert)
void InsertRecord(FreshInStore_Record record)
{ {
record.BillID = context.Dmo.ID; record.BillID = context.Dmo.ID;
if (convert && context.Detail.SecondNumber != 0)
record.Weight = context.Detail.Number / context.Detail.SecondNumber * record.Number;
FreshInStoreBL.InsertRecord(record); FreshInStoreBL.InsertRecord(record);
context.Detail.AlreadyNumber = record.Weight; context.Detail.AlreadyNumber = record.Weight;
context.Detail.AlreadySecondNumber = record.Number; context.Detail.AlreadySecondNumber = record.Number;


+ 14
- 0
B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutConfig.cs View File

@ -0,0 +1,14 @@
using B3DealerClient.BO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B3DealerClient.Windows.FreshSaleOutWindow_
{
public class FreshSaleOutConfig
{
public NameIDPair Store { get; set; }
}
}

+ 88
- 0
B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutContext.cs View File

@ -0,0 +1,88 @@
using B3DealerClient.BO;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B3DealerClient.Windows.FreshSaleOutWindow_
{
public class FreshSaleOutContext : NotificationObject
{
private DateTime? mDate = DateTime.Today;
public DateTime? Date
{
get { return mDate; }
set
{
mDate = value;
RaisePropertyChanged("Date");
}
}
private NameIDPair mDriverGoodsLine = new NameIDPair() { Name = "请选择" };
public NameIDPair DriverGoodsLine { get { return mDriverGoodsLine; } }
private NameIDPair mStore = new NameIDPair();
public NameIDPair Store { get { return mStore; } }
private decimal mNumber;
public decimal Number
{
get { return mNumber; }
set
{
mNumber = value;
RaisePropertyChanged("Number");
RaisePropertyChanged("CanSave");
}
}
private decimal? mWeight;
public decimal? Weight
{
get { return mWeight; }
set
{
mWeight = value;
RaisePropertyChanged("Weight");
RaisePropertyChanged("CanSave");
}
}
private bool Finish
{
get
{
return mDmo == null ? true : mDmo.AssignFinished;
}
set
{
RaisePropertyChanged("CanSave");
}
}
private FreshSaleOut mDmo = null;
public FreshSaleOut Dmo
{
get { return mDmo; }
set
{
mDmo = value;
RaisePropertyChanged("Dmo");
RaisePropertyChanged("CanSave");
}
}
private List<FreshSaleOut> mDmoList = null;
public List<FreshSaleOut> DmoList { get { return mDmoList; } set { mDmoList = value; RaisePropertyChanged("DmoList"); } }
private List<CustomerObj> mCustomerList = null;
public List<CustomerObj> CustomerList { get { return mCustomerList; } set { mCustomerList = value; RaisePropertyChanged("CustomerList"); } }
public bool CanSave { get { return Number > 0 && Weight > 0 && mDmo != null && !Finish; } }
}
}

+ 207
- 3
B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml View File

@ -1,8 +1,212 @@
<Window x:Class="B3DealerClient.Windows.FreshSaleOutWindow_.FreshSaleOutWindow" <Window x:Class="B3DealerClient.Windows.FreshSaleOutWindow_.FreshSaleOutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FreshSaleOutWindow" Height="300" Width="300">
<Grid>
xmlns:self="clr-namespace:B3DealerClient.Windows.FreshSaleOutWindow_"
Title="鲜品发货" Height="800" Width="1200" FontSize="17" WindowState="Maximized">
<Window.Resources>
<self:TrueToFalseConverter x:Key="TrueToFalseConverter"/>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="5,20"/>
<Setter Property="Width" Value="80"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
</Style>
<Style x:Key="textBox" TargetType="TextBox">
<Setter Property="Width" Value="150"/>
<Setter Property="Height" Value="40"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<Style x:Key="deleteBtn" TargetType="Button" BasedOn="{StaticResource RedButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="55"/>
<Setter Property="Margin" Value="10,0"/>
</Style>
</Window.Resources>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="165"/>
<ColumnDefinition/>
<ColumnDefinition Width="320"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="0.8*"/>
<RowDefinition/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Border Grid.RowSpan="3" Margin="0,2" Style="{StaticResource DefaultBorder}">
<ListBox x:Name="customerPanel" ItemsSource="{Binding CustomerList}" ScrollViewer.HorizontalScrollBarVisibility="Hidden" BorderThickness="0">
<ListBox.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<EventSetter Event="PreviewMouseDown" Handler="CustomerBtn_PriviewMouseDown"/>
</Style>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Margin" Value="0,5"/>
<Setter Property="Width" Value="150"/>
<Setter Property="Height" Value="50"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Selected}" Value="False" />
<Condition Binding="{Binding Finished}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="DarkGreen"/>
</MultiDataTrigger>
<DataTrigger Binding="{Binding Selected}" Value="True">
<Setter Property="Background" Value="Orange"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<Button>
<Button.Content>
<TextBlock Text="{Binding Name}"/>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
<WrapPanel Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Margin" Value="2,0"/>
<Setter Property="Width" Value="75"/>
<Setter Property="Height" Value="40"/>
<EventSetter Event="PreviewMouseDown" Handler="PageBtn_PreviewMouseDown"/>
</Style>
</WrapPanel.Resources>
<Button Content="上一页" Tag="0"/>
<Button Content="下一页" Tag="1"/>
</WrapPanel>
<Grid Grid.Column="1">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.6*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="1" Text="客户:"/>
<TextBlock Grid.Column="2" Text="{Binding Dmo.Customer_Name}"/>
<TextBlock Grid.Column="3" Text="司机:"/>
<TextBlock Grid.Column="4" Text="{Binding Dmo.Driver_Name}"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="仓库:"/>
<TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding Dmo.Store_Name}"/>
</Grid> </Grid>
<Border Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Margin="2" Style="{StaticResource DefaultBorder}">
<DataGrid Margin="5" ItemsSource="{Binding DmoList}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">
<EventSetter Event="PreviewMouseDown" Handler="MainGridFocus"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Selected}" Value="False" />
<Condition Binding="{Binding AssignFinished}" Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Offset="0.0" Color="#9ACD32"/>
<GradientStop Offset="1.0" Color="White"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"/>
</MultiDataTrigger>
<DataTrigger Binding="{Binding Selected}" Value="True">
<Setter Property="Background" Value="#1581ED"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding ID}" Header="单号" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Goods_Name}" Header="存货名称" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding LoadTime ,StringFormat=\{0:yyyy-MM-dd\}}" Header="出库时间" Width="0.8*"/>
<DataGridTextColumn Binding="{Binding Number, StringFormat=\{0:0.######\}}" Header="主数量" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding SecondNumber, StringFormat=\{0:0.######\}}" Header="辅数量" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding AlreadyNumber ,StringFormat=\{0:0.######\}}" Header="已配主数量" Width="0.8*"/>
<DataGridTextColumn Binding="{Binding AlreadySecondNumber,StringFormat=\{0:0.######\}}" Header="已配辅数量" Width="0.8*"/>
</DataGrid.Columns>
</DataGrid>
</Border>
<StackPanel Grid.Row="1" Grid.Column="2" HorizontalAlignment="Center">
<WrapPanel>
<TextBlock Text="发货日期"/>
<DatePicker SelectedDate="{Binding Date}" Width="150" Height="40" Margin="-0.2,0,0,0"/>
</WrapPanel>
<WrapPanel>
<TextBlock Text="仓库"/>
<TextBox x:Name="Store" Style="{StaticResource textBox}" Text="{Binding Store.Name}" PreviewMouseDown="BaseInfoBox_PreviewMouseDown"/>
</WrapPanel>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="2">
<StackPanel.Resources>
<Style TargetType="TextBox" BasedOn="{StaticResource textBox}">
<EventSetter Event="PreviewMouseDown" Handler="InputBox_PreviewMouseDown"/>
</Style>
</StackPanel.Resources>
<Button Content="按备货发货" Width="160" Height="55" Margin="0,20" IsEnabled="{Binding Dmo ,Converter={StaticResource TrueToFalseConverter}}" PreviewMouseDown="SendAsDmo_PreviewMouseDown"/>
<WrapPanel HorizontalAlignment="Center">
<TextBlock Text="件数"/>
<TextBox x:Name="number" Text="{Binding Number}"/>
</WrapPanel>
<WrapPanel HorizontalAlignment="Center">
<TextBlock Text="重量"/>
<TextBox x:Name="weight" Text="{Binding Weight}"/>
</WrapPanel>
<Button Content="确认" Width="160" Height="55" Margin="0,20" IsEnabled="{Binding CanSave}" PreviewMouseDown="SaveBtn_PreviewMouseDown"/>
</StackPanel>
<WrapPanel Grid.Row="3" Grid.Column="1" VerticalAlignment="Center">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="55"/>
</Style>
</WrapPanel.Resources>
<TextBlock Text="送货线路" VerticalAlignment="Center" Margin="20,0,10,0"/>
<Button x:Name="DriverGoodsLine" PreviewMouseDown="BaseInfoBox_PreviewMouseDown">
<Button.Content>
<TextBlock Text="{Binding DriverGoodsLine.Name}" Style="{x:Null}"/>
</Button.Content>
</Button>
</WrapPanel>
<WrapPanel Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="55"/>
<Setter Property="Margin" Value="10,0"/>
</Style>
</WrapPanel.Resources>
<Button Content="配货完成" IsEnabled="{Binding Dmo ,Converter={StaticResource TrueToFalseConverter}}" PreviewMouseDown="FinishBtn_PreviewMouseDown"/>
</WrapPanel>
</Grid>
</Window> </Window>

+ 196
- 1
B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs View File

@ -1,4 +1,9 @@
using System;
using B3DealerClient.BL;
using B3DealerClient.BO;
using B3DealerClient.Control;
using B3DealerClient.Dialogs;
using B3DealerClient.Utils;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -19,9 +24,199 @@ namespace B3DealerClient.Windows.FreshSaleOutWindow_
/// </summary> /// </summary>
public partial class FreshSaleOutWindow : Window public partial class FreshSaleOutWindow : Window
{ {
FreshSaleOutContext context;
FreshSaleOutConfig config;
int pageSize;
int pageIndex;
public FreshSaleOutWindow() public FreshSaleOutWindow()
{ {
InitializeComponent(); InitializeComponent();
Rect rc = SystemParameters.WorkArea;//获取工作区大小
this.Width = rc.Width;
this.Height = rc.Height;
context = new FreshSaleOutContext();
this.DataContext = context;
this.Loaded += FreshSaleOutWindow_Loaded;
}
void FreshSaleOutWindow_Loaded(object sender, RoutedEventArgs e)
{
config = XmlUtil.DeserializeFromFile<FreshSaleOutConfig>();
if (config.Store != null)
context.Store.Fill(config.Store);
pageSize = (int)customerPanel.ActualHeight / 60;
}
private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var tb = sender as FrameworkElement;
var dig = new BaseInfoDialog(tb.Name);
if (dig.ShowDialog() == true)
{
switch (tb.Name)
{
case "DriverGoodsLine":
context.DriverGoodsLine.Fill(dig.Result);
pageIndex = 0;
BindCustomerPanel();
break;
case "Store":
context.Store.Fill(dig.Result);
config.Store = dig.Result;
XmlUtil.SerializerObjToFile(config);
break;
}
}
}
private void InputBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var numberPad = new NumberPad(this);
if (numberPad.ShowDialog() == true)
{
decimal value = 0;
if (!string.IsNullOrEmpty(numberPad.Result) && !decimal.TryParse(numberPad.Result, out value))
throw new Exception("输入错误");
var name = (sender as TextBox).Name;
switch (name)
{
case "number":
context.Number = value;
NumberToWeight();
break;
case "weight":
context.Weight = value;
break;
}
}
}
void NumberToWeight()
{
if (context.Dmo == null)
return;
if (context.Dmo.SecondNumber == 0)
context.Weight = null;
else
context.Weight = context.Dmo.Number / context.Dmo.SecondNumber * context.Number;
}
void BindCustomerPanel()
{
context.CustomerList = FreshSaleOutBL.GetCustomers(new
{
Date = context.Date,
Store_ID = context.Store.ID,
DeliverGoodsLine_ID = context.DriverGoodsLine.ID,
PageIndex = pageIndex,
PageSize = pageSize
});
context.Dmo = null;
context.DmoList = null;
}
private void PageBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var tag = (sender as Button).Tag.ToString();
if (tag == "0")
{
if (pageIndex == 0)
return;
pageIndex -= 1;
BindCustomerPanel();
}
else
{
if (context.CustomerList == null || context.CustomerList.Count < pageSize)
return;
pageIndex += 1;
BindCustomerPanel();
}
}
private void CustomerBtn_PriviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (context.Dmo != null)
context.Dmo = null;
var obj = (sender as ListBoxItem).DataContext as CustomerObj;
context.DmoList = FreshSaleOutBL.GetDmoList(new
{
Date = context.Date,
Customer_ID = obj.ID,
Store_ID = context.Store.ID,
AssignFinished = obj.Finished
});
foreach (var item in context.CustomerList)
{
if (item.Selected && !item.Equals(obj))
item.Selected = false;
else if (!item.Selected && item.Equals(obj))
item.Selected = true;
}
}
private void MainGridFocus(object sender, MouseButtonEventArgs e)
{
var row = sender as DataGridRow;
context.Dmo = row.Item as FreshSaleOut;
foreach (var item in context.DmoList)
{
if (item.Selected && item.ID != context.Dmo.ID)
item.Selected = false;
else if (item.Selected && item.ID == context.Dmo.ID)
context.Dmo.Selected = true;
}
}
private void SendAsDmo_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var record = new FreshSaleOut_Record();
record.Number = context.Dmo.SecondNumber;
record.Weight = context.Dmo.Number;
InsertRecord(record);
}
private void SaveBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var record = new FreshSaleOut_Record();
record.Number = context.Number;
record.Weight = context.Weight;
InsertRecord(record);
context.Weight = 0;
context.Number = 0;
}
void InsertRecord(FreshSaleOut_Record record)
{
record.BillID = context.Dmo.ID;
record.DetailID = context.Dmo.DetailID;
FreshSaleOutBL.InsertRecord(record);
context.Dmo.AlreadyNumber = record.Weight;
context.Dmo.AlreadySecondNumber = record.Number;
}
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var targets = context.DmoList.Where(x => x.ID == context.Dmo.ID);
var needConfirm = targets.Any(x => (x.AlreadyNumber ?? 0) == 0 || (x.SecondNumber ?? 0) == 0);
if (needConfirm)
{
var confirm = MessageBox.Show("存在未配货的明细,确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (confirm != MessageBoxResult.OK)
return;
}
var r = MessageBox.Show("确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (r != MessageBoxResult.OK)
return;
FreshSaleOutBL.FinishAssign(context.Dmo.ID);
foreach (var item in targets)
item.AssignFinished = true;
context.Dmo = context.Dmo;
MessageBox.Show("配货完成");
} }
} }
} }

+ 27
- 0
B3DealerClient/Windows/FreshSaleOutWindow_/SelfValueConvert.cs View File

@ -0,0 +1,27 @@
using B3DealerClient.BO;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace B3DealerClient.Windows.FreshSaleOutWindow_
{
public class TrueToFalseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return false;
var v = (FreshSaleOut)value;
return !v.AssignFinished;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

Loading…
Cancel
Save