diff --git a/B3DealerClient/App.xaml.cs b/B3DealerClient/App.xaml.cs
index 128b6ac..326921b 100644
--- a/B3DealerClient/App.xaml.cs
+++ b/B3DealerClient/App.xaml.cs
@@ -42,14 +42,14 @@ namespace B3DealerClient
readonly string[] FOLDERS = new string[] { "Config", "Log" };
protected override void OnStartup(StartupEventArgs e)
{
- //bool createNew;
- //ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "PigButcherManageSolution.Windows", out createNew);
+ bool createNew;
+ ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "B3DealerClient", out createNew);
- //if (!createNew)
- //{
- // MessageBox.Show(@"系统已经在运行中,如果要重新启动,请从进程中关闭...", @"系统警告");
- // App.Current.Shutdown();
- //}
+ if (!createNew)
+ {
+ MessageBox.Show(@"系统已经在运行中,如果要重新启动,请从进程中关闭...", @"系统警告");
+ App.Current.Shutdown();
+ }
base.OnStartup(e);
foreach (var folder in FOLDERS)
diff --git a/B3DealerClient/B3DealerClient.csproj b/B3DealerClient/B3DealerClient.csproj
index 52621d4..832648b 100644
--- a/B3DealerClient/B3DealerClient.csproj
+++ b/B3DealerClient/B3DealerClient.csproj
@@ -76,7 +76,14 @@
App.xaml
Code
+
+
+
+
+
+
+
@@ -91,6 +98,9 @@
WeightSettingWindow.xaml
+
+ BaseInfoDialog.xaml
+
FunctionSelectDialog.xaml
@@ -103,11 +113,18 @@
+
+
+
+
CarcassInStoreWindow.xaml
+
+ RecordViewDialog.xaml
+
CarcassSaleOutWindow.xaml
@@ -145,9 +162,7 @@
-
-
-
+
Designer
@@ -161,6 +176,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -213,6 +232,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/B3DealerClient/BL/BaseInfoBL.cs b/B3DealerClient/BL/BaseInfoBL.cs
new file mode 100644
index 0000000..c844949
--- /dev/null
+++ b/B3DealerClient/BL/BaseInfoBL.cs
@@ -0,0 +1,32 @@
+using B3DealerClient.BO;
+using Forks.JsonRpc.Client;
+using Forks.JsonRpc.Client.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.BL
+{
+ public static class BaseInfoBL
+ {
+ const string BaseInfoUrl = @"/MainSystem/System/UIRpcs/GetChoiceBoxWords";
+ public static IEnumerable GetBaseInfoList(string typeName)
+ {
+ var dataKind = string.Empty;
+ switch (typeName)
+ {
+ case "Supplier":
+ dataKind = "B3Dealer_供应商";
+ break;
+ case "Store":
+ dataKind = "授权仓库";
+ break;
+ default:
+ throw new Exception(string.Format("未知的数据源类型:{0}", typeName));
+ }
+ return RpcFacade.Call>(BaseInfoUrl, dataKind, string.Empty, string.Empty).Select(x => new NameIDPair { ID = Convert.ToInt64(x.Get("Item1")), Name = x.Get("Item2") });
+ }
+ }
+}
diff --git a/B3DealerClient/BL/CarcassInStoreBL.cs b/B3DealerClient/BL/CarcassInStoreBL.cs
new file mode 100644
index 0000000..1c359d4
--- /dev/null
+++ b/B3DealerClient/BL/CarcassInStoreBL.cs
@@ -0,0 +1,90 @@
+using B3DealerClient.BO;
+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;
+using Forks.EnterpriseServices.DomainObjects2;
+
+namespace B3DealerClient.BL
+{
+ public static class CarcassInStoreBL
+ {
+ const string MethodPath = @"/MainSystem/B3Dealer/Rpcs/PayBillRpc/";
+ public static List GetDmoList(object condition)
+ {
+ var method = MethodPath + "GetPayBillList";
+ var json = RpcFacade.Call(method, JsonConvert.SerializeObject(condition));
+ return JsonConvert.DeserializeObject>(json);
+ }
+
+ public static List GetDmoDetailList(long id)
+ {
+ var method = MethodPath + "GetPayBillDetails";
+ var json = RpcFacade.Call(method, id);
+ var list= JsonConvert.DeserializeObject>(json);
+ FillAlreadyInfo(list);
+ return list;
+ }
+
+ static void FillAlreadyInfo(List details)
+ {
+ if (details.Count == 0)
+ return;
+ var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore_Receive)));
+ query.Columns.Add(DQSelectColumn.Field("DetailID"));
+ query.Columns.Add(DQSelectColumn.Sum("NetWeight"));
+ query.Columns.Add(DQSelectColumn.Sum("Pics"));
+ query.GroupBy.Expressions.Add(DQExpression.Field("DetailID"));
+ query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("MainID", details.First().PayBill_ID), DQCondition.InList(DQExpression.Field("DetailID"), details.Select(x => DQExpression.Value(x.ID)).ToArray())));
+ var list = query.EExecuteList();
+ foreach (var item in list)
+ {
+ var first = details.FirstOrDefault(x => x.ID == item.Item1);
+ first.AlreadyNumber = item.Item2;
+ first.AlreadySecondNumber = item.Item3;
+ }
+ }
+
+ public static IEnumerable GetDetailReceive(long detailID)
+ {
+ var query = new DmoQuery(typeof(CarcassInStore_Receive));
+ query.Where.Conditions.Add(DQCondition.EQ("DetailID", detailID));
+ return query.EExecuteList().Cast();
+ }
+
+ public static IEnumerable GetBillReceive(long mainID)
+ {
+ var query = new DmoQuery(typeof(CarcassInStore_Receive));
+ query.Where.Conditions.Add(DQCondition.EQ("MainID", mainID));
+ return query.EExecuteList().Cast();
+ }
+
+ public static void InsertRecord(CarcassInStore_Receive record)
+ {
+ using (var session = DmoSession.New())
+ {
+ session.Insert(record);
+ session.Commit();
+ }
+ }
+
+ public static void Delete(long id)
+ {
+ var del = new DQDeleteDom(typeof(CarcassInStore_Receive));
+ del.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ del.EExecute();
+ }
+
+ public static long FinishInStore(long id)
+ {
+ var target = GetBillReceive(id);
+
+ return RpcFacade.Call(MethodPath + "FinishInStore", JsonConvert.SerializeObject(target));
+ }
+ }
+}
diff --git a/B3DealerClient/BO/CarcassInStore.cs b/B3DealerClient/BO/CarcassInStore.cs
new file mode 100644
index 0000000..feda4ed
--- /dev/null
+++ b/B3DealerClient/BO/CarcassInStore.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.BO
+{
+ public class CarcassInStore : NotificationObject
+ {
+ private long mID;
+ public long ID
+ {
+ get { return mID; }
+ set
+ {
+ mID = value;
+ RaisePropertyChanged("ID");
+ }
+ }
+
+ private string mSupplier_Name;
+ public string Supplier_Name
+ {
+ get { return mSupplier_Name; }
+ set
+ {
+ mSupplier_Name = value;
+ RaisePropertyChanged("Supplier_Name");
+ }
+ }
+
+ private DateTime? mDate;
+ public DateTime? Date
+ {
+ get { return mDate; }
+ set
+ {
+ mDate = value;
+ RaisePropertyChanged("Date");
+ }
+ }
+
+ private DateTime? mArrivedDate;
+ public DateTime? ArrivedDate
+ {
+ get { return mArrivedDate; }
+ set
+ {
+ mArrivedDate = value;
+ RaisePropertyChanged("ArrivedDate");
+ }
+ }
+
+ private string mStore_Name;
+ public string Store_Name
+ {
+ get { return mStore_Name; }
+ set
+ {
+ mStore_Name = value;
+ RaisePropertyChanged("Store_Name");
+ }
+ }
+
+ private bool mSelected;
+ public bool Selected
+ {
+ get { return mSelected; }
+ set
+ {
+ mSelected = value;
+ RaisePropertyChanged("Selected");
+ }
+ }
+
+ private List mDetails = new List();
+ public List Details
+ {
+ get { return mDetails; }
+ set
+ {
+ mDetails = value;
+ RaisePropertyChanged("Details");
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/BO/CarcassInStore_Detail.cs b/B3DealerClient/BO/CarcassInStore_Detail.cs
new file mode 100644
index 0000000..01224df
--- /dev/null
+++ b/B3DealerClient/BO/CarcassInStore_Detail.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.BO
+{
+ public class CarcassInStore_Detail : NotificationObject
+ {
+ private long mID;
+ public long ID
+ {
+ get { return mID; }
+ set
+ {
+ mID = value;
+ RaisePropertyChanged("ID");
+ }
+ }
+
+ private long mPayBill_ID;
+ public long PayBill_ID
+ {
+ get { return mPayBill_ID; }
+ set
+ {
+ mPayBill_ID = value;
+ RaisePropertyChanged("PayBill_ID");
+ }
+ }
+
+ private string mGoods_Name;
+ public string Goods_Name
+ {
+ get { return mGoods_Name; }
+ set
+ {
+ mGoods_Name = value;
+ RaisePropertyChanged("Goods_Name");
+ }
+ }
+
+ private decimal? mNumber;
+ public decimal? Number
+ {
+ get { return mNumber; }
+ set
+ {
+ mNumber = value;
+ RaisePropertyChanged("Number");
+ }
+ }
+
+ private decimal? mSecondNumber;
+ public decimal? SecondNumber
+ {
+ get { return mSecondNumber; }
+ set
+ {
+ mSecondNumber = value;
+ RaisePropertyChanged("SecondNumber");
+ }
+ }
+
+ 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 mSelected;
+ public bool Selected
+ {
+ get { return mSelected; }
+ set
+ {
+ mSelected = value;
+ RaisePropertyChanged("Selected");
+ }
+ }
+
+ private readonly ObservableCollection mDetails=new ObservableCollection();
+ public ObservableCollection Details { get { return mDetails; } }
+ }
+}
diff --git a/B3DealerClient/BO/CarcassInStore_Receive.cs b/B3DealerClient/BO/CarcassInStore_Receive.cs
new file mode 100644
index 0000000..4067b3e
--- /dev/null
+++ b/B3DealerClient/BO/CarcassInStore_Receive.cs
@@ -0,0 +1,127 @@
+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_CarcassInStore_Receive")]
+ [KeyField("ID", KeyGenType.identity)]
+ public class CarcassInStore_Receive : NotificationObject
+ {
+ private long mID;
+ [JsonIgnore]
+ public long ID
+ {
+ get { return mID; }
+ set
+ {
+ mID = value;
+ RaisePropertyChanged("ID");
+ }
+ }
+
+ private long mDetailID;
+ public long DetailID
+ {
+ get { return mDetailID; }
+ set
+ {
+ mDetailID = value;
+ RaisePropertyChanged("DetailID");
+ }
+ }
+
+ private long mMainID;
+ public long MainID
+ {
+ get { return mMainID; }
+ set
+ {
+ mMainID = value;
+ RaisePropertyChanged("MainID");
+ }
+ }
+
+ private string mGoods_Name;
+ public string Goods_Name
+ {
+ get { return mGoods_Name; }
+ set
+ {
+ mGoods_Name = value;
+ RaisePropertyChanged("Goods_Name");
+ }
+ }
+
+ private decimal mWeight;
+ public decimal Weight
+ {
+ get { return mWeight; }
+ set
+ {
+ mWeight = value;
+ RaisePropertyChanged("Weight");
+ }
+ }
+
+ private decimal mDiscont;
+ public decimal Discont
+ {
+ get { return mDiscont; }
+ set
+ {
+ mDiscont = value;
+ RaisePropertyChanged("Discont");
+ }
+ }
+
+ private decimal mNetWeight;
+ public decimal NetWeight
+ {
+ get { return mNetWeight; }
+ set
+ {
+ mNetWeight = value;
+ RaisePropertyChanged("NetWeight");
+ }
+ }
+
+ private decimal mPics;
+ public decimal Pics
+ {
+ get { return mPics; }
+ set
+ {
+ mPics = value;
+ RaisePropertyChanged("Pics");
+ }
+ }
+
+ private DateTime mDate = DateTime.Now;
+ public DateTime Date
+ {
+ get { return mDate; }
+ set
+ {
+ mDate = value;
+ RaisePropertyChanged("Date");
+ }
+ }
+
+ private bool mSelected;
+ [NonDmoProperty]
+ public bool Selected
+ {
+ get { return mSelected; }
+ set
+ {
+ mSelected = value;
+ RaisePropertyChanged("Selected");
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/BO/NameIDPair.cs b/B3DealerClient/BO/NameIDPair.cs
new file mode 100644
index 0000000..16b3d02
--- /dev/null
+++ b/B3DealerClient/BO/NameIDPair.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.BO
+{
+ public class NameIDPair : NotificationObject
+ {
+ private long? mID;
+ public long? ID
+ {
+ get { return mID; }
+ set
+ {
+ mID = value;
+ RaisePropertyChanged("ID");
+ }
+ }
+
+ private string mName;
+ public string Name
+ {
+ get { return mName; }
+ set
+ {
+ mName = value;
+ RaisePropertyChanged("Name");
+ }
+ }
+
+ public void Clear()
+ {
+ Fill(null, null);
+ }
+
+ public void Fill(long? id, string name)
+ {
+ ID = id;
+ Name = name;
+ }
+
+ public void Fill(NameIDPair copy)
+ {
+ ID = copy.ID;
+ Name = copy.Name;
+ }
+ }
+}
diff --git a/B3DealerClient/BO/NotificationObject.cs b/B3DealerClient/BO/NotificationObject.cs
new file mode 100644
index 0000000..fde0d1d
--- /dev/null
+++ b/B3DealerClient/BO/NotificationObject.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.BO
+{
+ public class NotificationObject : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public void RaisePropertyChanged(string propertyName)
+ {
+ if (this.PropertyChanged != null)
+ {
+ this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/Control/WeightControl.xaml.cs b/B3DealerClient/Control/WeightControl.xaml.cs
index e7c5e83..9be9678 100644
--- a/B3DealerClient/Control/WeightControl.xaml.cs
+++ b/B3DealerClient/Control/WeightControl.xaml.cs
@@ -51,6 +51,7 @@ namespace B3DealerClient.Control
v -= (config.Discont ?? 0);
return v;
}
+ set { lblChengZhong.Content = value; }
}
[Browsable(false)]
diff --git a/B3DealerClient/Dialogs/BaseInfoDialog.xaml b/B3DealerClient/Dialogs/BaseInfoDialog.xaml
new file mode 100644
index 0000000..9efc983
--- /dev/null
+++ b/B3DealerClient/Dialogs/BaseInfoDialog.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Dialogs/BaseInfoDialog.xaml.cs b/B3DealerClient/Dialogs/BaseInfoDialog.xaml.cs
new file mode 100644
index 0000000..d27ca2e
--- /dev/null
+++ b/B3DealerClient/Dialogs/BaseInfoDialog.xaml.cs
@@ -0,0 +1,65 @@
+using B3DealerClient.BL;
+using B3DealerClient.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace B3DealerClient.Dialogs
+{
+ ///
+ /// BaseInfoDialog.xaml 的交互逻辑
+ ///
+ public partial class BaseInfoDialog : Window
+ {
+ public NameIDPair Result { get; private set; }
+ private string mTypeName;
+ public BaseInfoDialog(string typeName)
+ {
+ mTypeName = typeName;
+ InitializeComponent();
+ this.Loaded += BaseInfoDialog_Loaded;
+ }
+
+ void BaseInfoDialog_Loaded(object sender, RoutedEventArgs e)
+ {
+ switch (mTypeName)
+ {
+ case "Supplier":
+ this.Title = "供应商";
+ break;
+ case "Store":
+ this.Title = "仓库";
+ break;
+ default:
+ break;
+ }
+
+ var list = BaseInfoBL.GetBaseInfoList(mTypeName);
+ foreach (var item in list)
+ {
+ var content = new TextBlock() { TextWrapping = TextWrapping.Wrap };
+ content.Text = item.Name;
+ var btn = new Button() { Content = content, Tag = item };
+ btn.PreviewMouseDown += btn_PreviewMouseDown;
+ this.wrapPanel.Children.Add(btn);
+ }
+ }
+
+ void btn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var btn = sender as Button;
+ Result = btn.Tag as NameIDPair;
+ DialogResult = true;
+ }
+ }
+}
diff --git a/B3DealerClient/LoginWindow.xaml b/B3DealerClient/LoginWindow.xaml
index 96ffd24..dc74c17 100644
--- a/B3DealerClient/LoginWindow.xaml
+++ b/B3DealerClient/LoginWindow.xaml
@@ -1,7 +1,7 @@
diff --git a/B3DealerClient/Style/Button.xaml b/B3DealerClient/Style/Button.xaml
index e757331..0541122 100644
--- a/B3DealerClient/Style/Button.xaml
+++ b/B3DealerClient/Style/Button.xaml
@@ -27,5 +27,25 @@
\ No newline at end of file
diff --git a/B3DealerClient/Style/DataGrid.xaml b/B3DealerClient/Style/DataGrid.xaml
index 1fb21cc..bbbcdfd 100644
--- a/B3DealerClient/Style/DataGrid.xaml
+++ b/B3DealerClient/Style/DataGrid.xaml
@@ -17,6 +17,7 @@
+
diff --git a/B3DealerClient/Utils/Extensions.cs b/B3DealerClient/Utils/Extensions.cs
new file mode 100644
index 0000000..829ed3a
--- /dev/null
+++ b/B3DealerClient/Utils/Extensions.cs
@@ -0,0 +1,319 @@
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.Utils;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Utils
+{
+ public static class DmoSession
+ {
+ public static IDmoSessionWithTransaction New()
+ {
+ return Dmo.NewSession(AppContext.Instance.SqlConnection);
+ }
+ }
+
+ public static class Extensions
+ {
+ public static object EExecuteScalar(this DQueryDom query, IDmoSession session)
+ {
+ return session.ExecuteScalar(query);
+ }
+
+ public static object EExecuteScalar(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteScalar(session);
+ }
+ }
+
+ public static T EExecuteScalar(this DQueryDom query, IDmoSession session)
+ {
+ return (T)query.EExecuteScalar(session);
+ }
+
+ public static T EExecuteScalar(this DQueryDom query)
+ {
+ return (T)query.EExecuteScalar();
+ }
+
+ public static Tuple EExecuteScalar(this DQueryDom query, IDmoSession session)
+ {
+ var list = query.EExecuteList(session);
+ if (list.Count == 0)
+ {
+ return null;
+ }
+#if DEBUG
+ if (list.Count > 1)
+ {
+ throw new Exception(string.Format("期望返回1条记录实际返回{0}条", list.Count));
+ }
+#endif
+ return list[0];
+ }
+
+ public static Tuple EExecuteScalar(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteScalar(session);
+ }
+ }
+
+ public static Tuple EExecuteScalar(this DQueryDom query, IDmoSession session)
+ {
+ var list = query.EExecuteList(session);
+ if (list.Count == 0)
+ {
+ return null;
+ }
+#if DEBUG
+ if (list.Count > 1)
+ {
+ throw new Exception(string.Format("期望返回1条记录实际返回{0}条", list.Count));
+ }
+#endif
+ return list[0];
+ }
+
+ public static Tuple EExecuteScalar(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteScalar(session);
+ }
+ }
+
+ public static T EExecuteScalar(this DmoQuery query) where T : class
+ {
+ var result = query.EExecuteList();
+ if (result.Count == 0)
+ {
+ return default(T);
+ }
+ if (result.Count > 1)
+ {
+ throw new Exception("ExecuteScalar返回多个数据");
+ }
+ return (T)result[0];
+ }
+
+ public static List EExecuteList(this DQueryDom query, IDmoSession session)
+ {
+ var list = new List();
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ list.Add((T)reader[0]);
+ }
+ }
+ return list;
+ }
+
+ public static List EExecuteList(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteList(session);
+ }
+ }
+
+ public static List EExecuteDmoList(this DQueryDom query, IDmoSession session, params string[] fields) where TDmo : new()
+ {
+ var type = typeof(TDmo);
+ PCheck.IsTrue(query.From.RootSource.Alias.DmoSource == DmoInfo.Get(type));
+
+ var dmoInfo = DmoInfo.Get(type);
+ if (fields.Length == 0)
+ {
+
+ fields = dmoInfo.Fields
+ .Select((item) => item.Name).ToArray();
+ }
+#if DEBUG
+ else
+ {
+ foreach (var filed in fields)
+ {
+ if (!dmoInfo.Fields.Contains(filed))
+ {
+ throw new Exception(string.Format("对象{0}上不存在字段{1}的定义", type.Name, filed));
+ }
+ }
+ }
+#endif
+
+ if (query.Columns.Count == 0)
+ {
+ foreach (var filed in fields)
+ {
+ query.Columns.Add(DQSelectColumn.Field(filed));
+ }
+ }
+ else if (query.Columns.Count != fields.Length)
+ {
+ throw new Exception("查询字段数量不匹配");
+ }
+
+ var indexSetDic = fields.ToDictionary((item) => Array.IndexOf(fields, item), (item) => type.GetProperty(item).GetSetMethod());
+
+ var list = new List();
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ var dmo = new TDmo();
+ list.Add(dmo);
+ foreach (var pair in indexSetDic)
+ {
+ pair.Value.Invoke(dmo, new object[] { reader[pair.Key] });
+ }
+ }
+ }
+ return list;
+ }
+
+ public static List EExecuteDmoList(this DQueryDom query, params string[] fields) where TDmo : new()
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteDmoList(session, fields);
+ }
+ }
+
+ public static List> EExecuteList(this DQueryDom query, IDmoSession session)
+ {
+ var list = new List>();
+
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ var value = new Tuple(
+ (T1)reader[0],
+ (T2)reader[1]);
+ list.Add(value);
+ }
+ }
+ return list;
+ }
+
+ public static List> EExecuteList(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteList(session);
+ }
+ }
+
+ public static List> EExecuteList(this DQueryDom query, IDmoSession session)
+ {
+ var list = new List>();
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ var value = new Tuple(
+ (T1)reader[0],
+ (T2)reader[1],
+ (T3)reader[2]);
+ list.Add(value);
+ }
+ }
+ return list;
+ }
+
+ public static List> EExecuteList(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteList(session);
+ }
+ }
+
+ public static List> EExecuteList(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteList(session);
+ }
+ }
+
+ public static List> EExecuteList(this DQueryDom query, IDmoSession session)
+ {
+ var list = new List>();
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ var value = new Tuple(
+ (T1)reader[0],
+ (T2)reader[1],
+ (T3)reader[2], (T4)reader[3]);
+ list.Add(value);
+ }
+ }
+ return list;
+ }
+
+
+ public static List> EExecuteList(this DQueryDom query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return query.EExecuteList(session);
+ }
+ }
+
+ public static List> EExecuteList(this DQueryDom query, IDmoSession session)
+ {
+ var list = new List>();
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ var value = new Tuple(
+ (T1)reader[0],
+ (T2)reader[1],
+ (T3)reader[2], (T4)reader[3], (T5)reader[4]);
+ list.Add(value);
+ }
+ }
+ return list;
+ }
+
+ public static IList EExecuteList(this DmoQuery query)
+ {
+ using (var session = DmoSession.New())
+ {
+ return session.ExecuteList(query);
+ }
+ }
+
+ public static void EExecute(this DQUpdateDom update)
+ {
+ using (var session = DmoSession.New())
+ {
+ session.ExecuteNonQuery(update);
+ session.Commit();
+ }
+ }
+
+ public static void EExecute(this DQDeleteDom delete)
+ {
+ using (var session = DmoSession.New())
+ {
+ session.ExecuteNonQuery(delete);
+ session.Commit();
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/Utils/ValueConverter.cs b/B3DealerClient/Utils/ValueConverter.cs
new file mode 100644
index 0000000..58c7ba8
--- /dev/null
+++ b/B3DealerClient/Utils/ValueConverter.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace B3DealerClient.Utils
+{
+ public class NullToBoolConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return value != null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreConfig.cs b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreConfig.cs
new file mode 100644
index 0000000..64b4097
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreConfig.cs
@@ -0,0 +1,18 @@
+using B3DealerClient.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Windows.CarcassInStoreWindow_
+{
+ public class CarcassInStoreConfig
+ {
+ public NameIDPair Store { get; set; }
+
+ public decimal? HookWeight { get; set; }
+
+ public decimal? Pics { get; set; }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreContext.cs b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreContext.cs
new file mode 100644
index 0000000..369ec62
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreContext.cs
@@ -0,0 +1,99 @@
+using B3DealerClient.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Windows.CarcassInStoreWindow_
+{
+ public class CarcassInStoreContext : NotificationObject
+ {
+ private DateTime? mDate = DateTime.Today;
+
+ public DateTime? Date
+ {
+ get { return mDate; }
+ set
+ {
+ mDate = value;
+ RaisePropertyChanged("Date");
+ }
+ }
+
+ private DateTime? mArrivedDate;
+
+ public DateTime? ArrivedDate
+ {
+ get { return mArrivedDate; }
+ set
+ {
+ mArrivedDate = value;
+ RaisePropertyChanged("ArrivedDate");
+ }
+ }
+
+ private NameIDPair mSupplier = new NameIDPair();
+ public NameIDPair Supplier { get { return mSupplier; } }
+
+ private NameIDPair mStore = new NameIDPair();
+ public NameIDPair Store { get { return mStore; } }
+
+ private decimal? mHookWeight;
+ public decimal? HookWeight
+ {
+ get { return mHookWeight; }
+ set
+ {
+ mHookWeight = value;
+ RaisePropertyChanged("HookWeight");
+ }
+ }
+
+ private decimal? mPics;
+ public decimal? Pics
+ {
+ get { return mPics; }
+ set
+ {
+ mPics = value;
+ RaisePropertyChanged("Pics");
+ RaisePropertyChanged("CanSave");
+ }
+ }
+
+ private decimal mWeight;
+ public decimal Weight
+ {
+ get { return mWeight; }
+ set
+ {
+ mWeight = value;
+ RaisePropertyChanged("CanSave");
+ }
+ }
+
+ private CarcassInStore mDmo = null;
+ public CarcassInStore Dmo { get { return mDmo; } set { mDmo = value; RaisePropertyChanged("Dmo"); } }
+
+ private CarcassInStore_Detail mDetail = null;
+ public CarcassInStore_Detail Detail { get { return mDetail; } set { mDetail = value; RaisePropertyChanged("Detail"); RaisePropertyChanged("CanSave"); } }
+
+ private List dmoList = new List();
+
+ public List DmoList
+ {
+ get { return dmoList; }
+ set
+ {
+ dmoList = value;
+ this.RaisePropertyChanged("DmoList");
+ }
+ }
+
+ private CarcassInStore_Receive mReceive = null;
+ public CarcassInStore_Receive Receive { get { return mReceive; } set { mReceive = value; RaisePropertyChanged("Receive"); } }
+
+ public bool CanSave { get { return Pics > 0 && Weight > 0 && mDetail != null; } }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml
index 346f41a..89fe9aa 100644
--- a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml
@@ -1,16 +1,32 @@
+ xmlns:local="clr-namespace:B3DealerClient.Control"
+ xmlns:util="clr-namespace:B3DealerClient.Utils"
+ Title="白条收货" Height="700" Width="1200" FontSize="17" WindowState="Maximized">
+
+
+
+
-
@@ -22,7 +38,7 @@
-
+
@@ -31,14 +47,14 @@
-
+
-
+
-
+
@@ -48,7 +64,7 @@
-
+
@@ -69,35 +85,34 @@
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
@@ -132,16 +147,16 @@
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
@@ -221,28 +236,24 @@
-
-
-
+
+
-
-
+
-
-
+
+
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs
index 5d3d082..bc10ebb 100644
--- a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.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,233 @@ namespace B3DealerClient.Windows.CarcassInStoreWindow_
///
public partial class CarcassInStoreWindow : Window
{
+ CarcassInStoreContext context;
+ CarcassInStoreConfig config;
public CarcassInStoreWindow()
{
InitializeComponent();
+ // 全屏设置
+ Rect rc = SystemParameters.WorkArea;//获取工作区大小
+ this.Width = rc.Width;
+ this.Height = rc.Height;
+ context = new CarcassInStoreContext();
+ this.DataContext = context;
+
+ this.Loaded += CarcassInStoreWindow_Loaded;
+ this.weightControl.ReceivedValue += weightControl_ReceivedValue;
+ weightControl.weightSwitch.Click += weightSwitch_Click;
+ }
+
+ void weightSwitch_Click(object sender, RoutedEventArgs e)
+ {
+ if (!weightControl.SwitchOn)
+ context.Weight = 0;
+ }
+
+ void weightControl_ReceivedValue(decimal weight)
+ {
+ context.Weight = weight;
+ }
+
+ void CarcassInStoreWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ config = XmlUtil.DeserializeFromFile();
+ if (config.Store != null)
+ context.Store.Fill(config.Store);
+ context.HookWeight = config.HookWeight;
+ context.Pics = config.Pics;
+ }
+
+ private void NumberBox_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 "hook":
+ context.HookWeight = value;
+ config.HookWeight = value;
+ break;
+ case "pics":
+ context.Pics = value;
+ config.Pics = value;
+ break;
+ }
+ XmlUtil.SerializerObjToFile(config);
+ }
+ }
+
+ private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var tb = sender as TextBox;
+ var dig = new BaseInfoDialog(tb.Name);
+ if (dig.ShowDialog() == true)
+ {
+ switch (tb.Name)
+ {
+ case "Supplier":
+ context.Supplier.Fill(dig.Result);
+ break;
+ case "Store":
+ context.Store.Fill(dig.Result);
+ config.Store = dig.Result;
+ XmlUtil.SerializerObjToFile(config);
+ break;
+ }
+ }
+ }
+
+ private void MainGridFocus(object sender, MouseButtonEventArgs e)
+ {
+ var row = sender as DataGridRow;
+ context.Dmo = row.Item as CarcassInStore;
+ 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();
+ }
+
+ void MainSelected()
+ {
+ context.Dmo.Details = CarcassInStoreBL.GetDmoDetailList(context.Dmo.ID);
+ context.Detail = context.Dmo.Details.FirstOrDefault();
+ DetailSelected();
+ }
+
+ private void DetailGridFocus(object sender, MouseButtonEventArgs e)
+ {
+ var row = sender as DataGridRow;
+ context.Detail = row.Item as CarcassInStore_Detail;
+ DetailSelected();
+ }
+
+ void DetailSelected()
+ {
+ if (context.Detail == null)
+ return;
+
+ foreach (var item in context.Dmo.Details)
+ {
+ if (item.Selected && item.ID != context.Detail.ID)
+ item.Selected = false;
+ else if (!item.Selected && item.ID == context.Detail.ID)
+ item.Selected = true;
+ }
+
+ context.Detail.Details.Clear();
+ var details = CarcassInStoreBL.GetDetailReceive(context.Detail.ID);
+ foreach (var item in details)
+ context.Detail.Details.Add(item);
+
+ context.Receive = context.Detail.Details.FirstOrDefault();
+ RecordSelected();
+ }
+
+ private void RecordGridFocus(object sender, MouseButtonEventArgs e)
+ {
+ var row = sender as DataGridRow;
+ context.Receive = row.Item as CarcassInStore_Receive;
+ RecordSelected();
+ }
+
+ void RecordSelected()
+ {
+ if (context.Receive == null)
+ return;
+ foreach (var item in context.Dmo.Details.First(x => x.Selected).Details)
+ {
+ if (item.Selected && item.ID != context.Receive.ID)
+ item.Selected = false;
+ else if (!item.Selected && item.ID == context.Receive.ID)
+ item.Selected = true;
+ }
+ }
+
+ private void SearchBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var btnName = (sender as Button).Name;
+ switch (btnName)
+ {
+ case "cx":
+ context.DmoList = CarcassInStoreBL.GetDmoList(new
+ {
+ Date = context.Date,
+ ArrivedDate = context.ArrivedDate,
+ Supplier_ID = context.Supplier.ID,
+ Store_ID = context.Store.ID
+ });
+ context.Dmo = null;
+ context.Detail = null;
+ context.Receive = null;
+ break;
+ case "qc":
+ context.Date = null;
+ context.ArrivedDate = null;
+ context.Supplier.Clear();
+ context.Store.Clear();
+ break;
+ }
+ }
+
+ private void DeleteBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var confirm = MessageBox.Show("确定要删除选中记录吗?", "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+ if (confirm == MessageBoxResult.OK)
+ {
+ CarcassInStoreBL.Delete(context.Receive.ID);
+ context.Detail.Details.Remove(context.Receive);
+ context.Detail.AlreadyNumber = (context.Detail.AlreadyNumber ?? 0) - context.Receive.NetWeight;
+ context.Detail.AlreadySecondNumber = (context.Detail.AlreadySecondNumber ?? 0) - context.Receive.Pics;
+ context.Receive = context.Detail.Details.FirstOrDefault();
+ RecordSelected();
+ }
+ }
+
+ private void SaveBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var record = new CarcassInStore_Receive();
+ record.MainID = context.Detail.PayBill_ID;
+ record.DetailID = context.Detail.ID;
+ record.Goods_Name = context.Detail.Goods_Name;
+ record.Weight = context.Weight;
+ record.Pics = context.Pics.Value;
+ record.Discont = (context.HookWeight ?? 0) * Math.Ceiling(record.Pics);
+ record.NetWeight = record.Weight - record.Discont;
+ record.Date = DateTime.Now;
+ record.Selected = true;
+ CarcassInStoreBL.InsertRecord(record);
+ context.Detail.Details.Add(record);
+ context.Detail.AlreadyNumber = (context.Detail.AlreadyNumber ?? 0) + record.NetWeight;
+ context.Detail.AlreadySecondNumber = (context.Detail.AlreadySecondNumber ?? 0) + record.Pics;
+ context.Receive = record;
+ RecordSelected();
+ weightControl.Weight = 0;
+ context.Weight = 0;
+ }
+
+ private void ViewBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ new RecordViewDialog(context.Dmo.ID).ShowDialog();
+ }
+
+ private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var target = context.Dmo.Details.Where(x => x.AlreadyNumber > 0 && x.SecondNumber > 0);
+ if (!target.Any())
+ throw new Exception("没有收获明细!");
+
+ var id = CarcassInStoreBL.FinishInStore(context.Dmo.ID);
+ MessageBox.Show("生成采购收货单No." + id);
}
}
}
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml b/B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml
new file mode 100644
index 0000000..f2bf77f
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml.cs b/B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml.cs
new file mode 100644
index 0000000..9516bac
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml.cs
@@ -0,0 +1,37 @@
+using B3DealerClient.BL;
+using B3DealerClient.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace B3DealerClient.Windows.CarcassInStoreWindow_
+{
+ ///
+ /// RecordViewDialog.xaml 的交互逻辑
+ ///
+ public partial class RecordViewDialog : Window
+ {
+ long BillID;
+ public RecordViewDialog(long id)
+ {
+ InitializeComponent();
+ BillID = id;
+ this.Loaded += RecordViewDialog_Loaded;
+ }
+
+ void RecordViewDialog_Loaded(object sender, RoutedEventArgs e)
+ {
+ grid.ItemsSource = CarcassInStoreBL.GetBillReceive(BillID).ToList();
+ }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml
index 37c3341..95686d7 100644
--- a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml
+++ b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml
@@ -15,7 +15,6 @@
-
@@ -29,9 +28,9 @@
-
-
-
+
+
+
-
+
@@ -58,7 +57,27 @@
胡传俊
-
+
+
+
+
+
@@ -105,7 +124,7 @@
-
+
-
@@ -37,7 +36,7 @@
-
+
@@ -66,7 +65,7 @@
-
+