diff --git a/B3DealerClient/B3DealerClient.csproj b/B3DealerClient/B3DealerClient.csproj
index d0cfdfa..9095425 100644
--- a/B3DealerClient/B3DealerClient.csproj
+++ b/B3DealerClient/B3DealerClient.csproj
@@ -80,6 +80,7 @@
+
@@ -90,6 +91,8 @@
+
+
@@ -147,9 +150,12 @@
FreshInStoreWindow.xaml
+
+
FreshSaleOutWindow.xaml
+
Test.xaml
diff --git a/B3DealerClient/BL/FreshInStoreBL.cs b/B3DealerClient/BL/FreshInStoreBL.cs
index a317a31..3074385 100644
--- a/B3DealerClient/BL/FreshInStoreBL.cs
+++ b/B3DealerClient/BL/FreshInStoreBL.cs
@@ -38,9 +38,8 @@ namespace B3DealerClient.BL
return;
var query = new DQueryDom(new JoinAlias(typeof(FreshInStore_Record)));
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()));
var list = query.EExecuteList();
foreach (var item in list)
diff --git a/B3DealerClient/BL/FreshSaleOutBL.cs b/B3DealerClient/BL/FreshSaleOutBL.cs
new file mode 100644
index 0000000..10f6aca
--- /dev/null
+++ b/B3DealerClient/BL/FreshSaleOutBL.cs
@@ -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 GetDmoList(object condition)
+ {
+ var method = MethodPath + "GetSaleOutStoreList";
+ var json = RpcFacade.Call(method, JsonConvert.SerializeObject(condition));
+ var list = JsonConvert.DeserializeObject>(json);
+ FillAlreadyInfo(list);
+ return list;
+ }
+
+ private static void FillAlreadyInfo(List 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();
+ 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 GetCustomers(object condition)
+ {
+ var method = MethodPath + "GetCustomers";
+ var json = RpcFacade.Call(method, JsonConvert.SerializeObject(condition));
+ return JsonConvert.DeserializeObject>(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(session);
+ }
+
+ public static void FinishAssign(long id)
+ {
+ var target = GetBillRecords(id);
+
+ RpcFacade.Call(MethodPath + "FreshFinishAssign", JsonConvert.SerializeObject(target), id);
+ }
+
+ static List> 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>();
+ using (var session = DmoSession.New())
+ {
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ records.Add(new Tuple((long)reader[0], (decimal?)reader[1], (decimal?)reader[2]));
+ }
+ }
+ }
+ return records;
+ }
+ }
+}
diff --git a/B3DealerClient/BO/FreshSaleOut/FreshSaleOut.cs b/B3DealerClient/BO/FreshSaleOut/FreshSaleOut.cs
new file mode 100644
index 0000000..b9781a4
--- /dev/null
+++ b/B3DealerClient/BO/FreshSaleOut/FreshSaleOut.cs
@@ -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");
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/BO/FreshSaleOut/FreshSaleOut_Record.cs b/B3DealerClient/BO/FreshSaleOut/FreshSaleOut_Record.cs
new file mode 100644
index 0000000..4d27211
--- /dev/null
+++ b/B3DealerClient/BO/FreshSaleOut/FreshSaleOut_Record.cs
@@ -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; }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutContext.cs b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutContext.cs
index 9c20082..8d3b61e 100644
--- a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutContext.cs
+++ b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutContext.cs
@@ -84,7 +84,7 @@ namespace B3DealerClient.Windows.CarcassSaleOutWindow_
}
}
- public bool Finish
+ private bool Finish
{
get
{
diff --git a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs
index 8769843..97b507e 100644
--- a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs
+++ b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs
@@ -62,242 +62,242 @@ namespace B3DealerClient.Windows.CarcassSaleOutWindow_
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;
- 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();
+ 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;
+ 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("配货完成");
- }
}
}
diff --git a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreConfig.cs b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreConfig.cs
index 86fa6da..fb21002 100644
--- a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreConfig.cs
+++ b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreConfig.cs
@@ -10,7 +10,5 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
public class FreshInStoreConfig
{
public NameIDPair Store { get; set; }
-
- public decimal? Pics { get; set; }
}
}
diff --git a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreContext.cs b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreContext.cs
index 628047e..bb1aa3f 100644
--- a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreContext.cs
+++ b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreContext.cs
@@ -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;
public FreshInStore Dmo { get { return mDmo; } set { mDmo = value; RaisePropertyChanged("Dmo"); } }
diff --git a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml
index 14a6b65..5cbd3b1 100644
--- a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml
+++ b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml
@@ -178,9 +178,21 @@
+
+
+
-
-
+
+
+
+
diff --git a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs
index e2c2d46..9603c02 100644
--- a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs
+++ b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs
@@ -43,7 +43,6 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
config = XmlUtil.DeserializeFromFile();
if (config.Store != null)
context.Store.Fill(config.Store);
- context.Pics = config.Pics;
}
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);
if (numberPad.ShowDialog() == true)
@@ -78,19 +77,27 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
var name = (sender as TextBox).Name;
switch (name)
{
- //case "hook":
- // context.HookWeight = value;
- // config.HookWeight = value;
- // break;
case "pics":
context.Pics = value;
- config.Pics = value;
+ NumberToWeight();
+ break;
+ case "weight":
+ context.Weight = value;
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)
{
var btnName = (sender as Button).Name;
@@ -166,7 +173,7 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
record.DetailID = item.ID;
record.Number = item.SecondNumber;
record.Weight = item.Number;
- InsertRecord(record, false);
+ InsertRecord(record);
}
}
@@ -176,7 +183,7 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
record.DetailID = context.Detail.ID;
record.Number = context.Detail.SecondNumber;
record.Weight = context.Detail.Number;
- InsertRecord(record, false);
+ InsertRecord(record);
}
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
@@ -193,15 +200,14 @@ namespace B3DealerClient.Windows.FreshInStoreWindow_
{
var record = new FreshInStore_Record();
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;
- if (convert && context.Detail.SecondNumber != 0)
- record.Weight = context.Detail.Number / context.Detail.SecondNumber * record.Number;
FreshInStoreBL.InsertRecord(record);
context.Detail.AlreadyNumber = record.Weight;
context.Detail.AlreadySecondNumber = record.Number;
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutConfig.cs b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutConfig.cs
new file mode 100644
index 0000000..e655e8d
--- /dev/null
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutConfig.cs
@@ -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; }
+ }
+}
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutContext.cs b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutContext.cs
new file mode 100644
index 0000000..1370e14
--- /dev/null
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutContext.cs
@@ -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 mDmoList = null;
+ public List DmoList { get { return mDmoList; } set { mDmoList = value; RaisePropertyChanged("DmoList"); } }
+
+ private List mCustomerList = null;
+ public List CustomerList { get { return mCustomerList; } set { mCustomerList = value; RaisePropertyChanged("CustomerList"); } }
+
+ public bool CanSave { get { return Number > 0 && Weight > 0 && mDmo != null && !Finish; } }
+
+ }
+}
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml
index 6d10e61..4498745 100644
--- a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml
@@ -1,8 +1,212 @@
-
-
+ xmlns:self="clr-namespace:B3DealerClient.Windows.FreshSaleOutWindow_"
+ Title="鲜品发货" Height="800" Width="1200" FontSize="17" WindowState="Maximized">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs
index 517281b..bccd0e1 100644
--- a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs
@@ -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.Linq;
using System.Text;
@@ -19,9 +24,199 @@ namespace B3DealerClient.Windows.FreshSaleOutWindow_
///
public partial class FreshSaleOutWindow : Window
{
+ FreshSaleOutContext context;
+ FreshSaleOutConfig config;
+ int pageSize;
+ int pageIndex;
public FreshSaleOutWindow()
{
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();
+ 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("配货完成");
}
}
}
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/SelfValueConvert.cs b/B3DealerClient/Windows/FreshSaleOutWindow_/SelfValueConvert.cs
new file mode 100644
index 0000000..74b291a
--- /dev/null
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/SelfValueConvert.cs
@@ -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();
+ }
+ }
+}