Browse Source

白条收货客户端开发。

master
yibo 6 years ago
parent
commit
6391418133
25 changed files with 1495 additions and 87 deletions
  1. +7
    -7
      B3DealerClient/App.xaml.cs
  2. +26
    -3
      B3DealerClient/B3DealerClient.csproj
  3. +32
    -0
      B3DealerClient/BL/BaseInfoBL.cs
  4. +90
    -0
      B3DealerClient/BL/CarcassInStoreBL.cs
  5. +88
    -0
      B3DealerClient/BO/CarcassInStore.cs
  6. +103
    -0
      B3DealerClient/BO/CarcassInStore_Detail.cs
  7. +127
    -0
      B3DealerClient/BO/CarcassInStore_Receive.cs
  8. +50
    -0
      B3DealerClient/BO/NameIDPair.cs
  9. +22
    -0
      B3DealerClient/BO/NotificationObject.cs
  10. +1
    -0
      B3DealerClient/Control/WeightControl.xaml.cs
  11. +16
    -0
      B3DealerClient/Dialogs/BaseInfoDialog.xaml
  12. +65
    -0
      B3DealerClient/Dialogs/BaseInfoDialog.xaml.cs
  13. +1
    -1
      B3DealerClient/LoginWindow.xaml
  14. +20
    -0
      B3DealerClient/Style/Button.xaml
  15. +1
    -0
      B3DealerClient/Style/DataGrid.xaml
  16. +319
    -0
      B3DealerClient/Utils/Extensions.cs
  17. +22
    -0
      B3DealerClient/Utils/ValueConverter.cs
  18. +18
    -0
      B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreConfig.cs
  19. +99
    -0
      B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreContext.cs
  20. +73
    -62
      B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml
  21. +230
    -1
      B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs
  22. +17
    -0
      B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml
  23. +37
    -0
      B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml.cs
  24. +27
    -8
      B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml
  25. +4
    -5
      B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml

+ 7
- 7
B3DealerClient/App.xaml.cs View File

@ -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)


+ 26
- 3
B3DealerClient/B3DealerClient.csproj View File

@ -76,7 +76,14 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="BL\BaseInfoBL.cs" />
<Compile Include="BL\CarcassInStoreBL.cs" />
<Compile Include="BL\LoginBL.cs" />
<Compile Include="BO\CarcassInStore.cs" />
<Compile Include="BO\CarcassInStore_Detail.cs" />
<Compile Include="BO\CarcassInStore_Receive.cs" />
<Compile Include="BO\NameIDPair.cs" />
<Compile Include="BO\NotificationObject.cs" />
<Compile Include="Control\DataFormat\DataFormat.cs" />
<Compile Include="Control\DataFormat\IND560DataFormat.cs" />
<Compile Include="Control\DataFormat\Xk3124DataFormat.cs" />
@ -91,6 +98,9 @@
<Compile Include="Control\WeightSettingWindow.xaml.cs">
<DependentUpon>WeightSettingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\BaseInfoDialog.xaml.cs">
<DependentUpon>BaseInfoDialog.xaml</DependentUpon>
</Compile>
<Compile Include="FunctionSelectDialog.xaml.cs">
<DependentUpon>FunctionSelectDialog.xaml</DependentUpon>
</Compile>
@ -103,11 +113,18 @@
<Compile Include="Utils\AppContext.cs" />
<Compile Include="Utils\ControlAttachProperty.cs" />
<Compile Include="Utils\DbUtil.cs" />
<Compile Include="Utils\Extensions.cs" />
<Compile Include="Utils\ValueConverter.cs" />
<Compile Include="Utils\WindowUtil.cs" />
<Compile Include="Utils\XmlUtil.cs" />
<Compile Include="Windows\CarcassInStoreWindow_\CarcassInStoreConfig.cs" />
<Compile Include="Windows\CarcassInStoreWindow_\CarcassInStoreContext.cs" />
<Compile Include="Windows\CarcassInStoreWindow_\CarcassInStoreWindow.xaml.cs">
<DependentUpon>CarcassInStoreWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\CarcassInStoreWindow_\RecordViewDialog.xaml.cs">
<DependentUpon>RecordViewDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\CarcassSaleOutWindow_\CarcassSaleOutWindow.xaml.cs">
<DependentUpon>CarcassSaleOutWindow.xaml</DependentUpon>
</Compile>
@ -145,9 +162,7 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="BO\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Control\NumberPad.xaml">
<SubType>Designer</SubType>
@ -161,6 +176,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialogs\BaseInfoDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="FunctionSelectDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -213,6 +232,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\CarcassInStoreWindow_\RecordViewDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\CarcassSaleOutWindow_\CarcassSaleOutWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>


+ 32
- 0
B3DealerClient/BL/BaseInfoBL.cs View File

@ -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<NameIDPair> 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<List<RpcObject>>(BaseInfoUrl, dataKind, string.Empty, string.Empty).Select(x => new NameIDPair { ID = Convert.ToInt64(x.Get<string>("Item1")), Name = x.Get<string>("Item2") });
}
}
}

+ 90
- 0
B3DealerClient/BL/CarcassInStoreBL.cs View File

@ -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<CarcassInStore> GetDmoList(object condition)
{
var method = MethodPath + "GetPayBillList";
var json = RpcFacade.Call<string>(method, JsonConvert.SerializeObject(condition));
return JsonConvert.DeserializeObject<List<CarcassInStore>>(json);
}
public static List<CarcassInStore_Detail> GetDmoDetailList(long id)
{
var method = MethodPath + "GetPayBillDetails";
var json = RpcFacade.Call<string>(method, id);
var list= JsonConvert.DeserializeObject<List<CarcassInStore_Detail>>(json);
FillAlreadyInfo(list);
return list;
}
static void FillAlreadyInfo(List<CarcassInStore_Detail> 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<long, decimal, decimal>();
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<CarcassInStore_Receive> GetDetailReceive(long detailID)
{
var query = new DmoQuery(typeof(CarcassInStore_Receive));
query.Where.Conditions.Add(DQCondition.EQ("DetailID", detailID));
return query.EExecuteList().Cast<CarcassInStore_Receive>();
}
public static IEnumerable<CarcassInStore_Receive> GetBillReceive(long mainID)
{
var query = new DmoQuery(typeof(CarcassInStore_Receive));
query.Where.Conditions.Add(DQCondition.EQ("MainID", mainID));
return query.EExecuteList().Cast<CarcassInStore_Receive>();
}
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<long>(MethodPath + "FinishInStore", JsonConvert.SerializeObject(target));
}
}
}

+ 88
- 0
B3DealerClient/BO/CarcassInStore.cs View File

@ -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<CarcassInStore_Detail> mDetails = new List<CarcassInStore_Detail>();
public List<CarcassInStore_Detail> Details
{
get { return mDetails; }
set
{
mDetails = value;
RaisePropertyChanged("Details");
}
}
}
}

+ 103
- 0
B3DealerClient/BO/CarcassInStore_Detail.cs View File

@ -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<CarcassInStore_Receive> mDetails=new ObservableCollection<CarcassInStore_Receive>();
public ObservableCollection<CarcassInStore_Receive> Details { get { return mDetails; } }
}
}

+ 127
- 0
B3DealerClient/BO/CarcassInStore_Receive.cs View File

@ -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");
}
}
}
}

+ 50
- 0
B3DealerClient/BO/NameIDPair.cs View File

@ -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;
}
}
}

+ 22
- 0
B3DealerClient/BO/NotificationObject.cs View File

@ -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));
}
}
}
}

+ 1
- 0
B3DealerClient/Control/WeightControl.xaml.cs View File

@ -51,6 +51,7 @@ namespace B3DealerClient.Control
v -= (config.Discont ?? 0);
return v;
}
set { lblChengZhong.Content = value; }
}
[Browsable(false)]


+ 16
- 0
B3DealerClient/Dialogs/BaseInfoDialog.xaml View File

@ -0,0 +1,16 @@
<Window x:Class="B3DealerClient.Dialogs.BaseInfoDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BaseInfoDialog" Height="500" Width="880" FontSize="17">
<Window.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="130"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Margin" Value="20"/>
</Style>
</Window.Resources>
<Border Margin="10" Style="{StaticResource DefaultBorder}">
<WrapPanel x:Name="wrapPanel">
</WrapPanel>
</Border>
</Window>

+ 65
- 0
B3DealerClient/Dialogs/BaseInfoDialog.xaml.cs View File

@ -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
{
/// <summary>
/// BaseInfoDialog.xaml 的交互逻辑
/// </summary>
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;
}
}
}

+ 1
- 1
B3DealerClient/LoginWindow.xaml View File

@ -1,7 +1,7 @@
<Window x:Class="B3DealerClient.LoginWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="LoginWindow" Height="433" Width="622" WindowStyle="None" AllowsTransparency="True"
Title="青花瓷登录" Height="433" Width="622" WindowStyle="None" AllowsTransparency="True"
ResizeMode="NoResize" BorderThickness="40" MouseLeftButtonDown="Window_MouseLeftButtonDown"
Loaded="Window_Loaded">
<Window.Background>


+ 20
- 0
B3DealerClient/Style/Button.xaml View File

@ -27,5 +27,25 @@
<Style x:Key="RedButton" TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Background" Value="Red"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Control.Background" Value="OrangeRed"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Control.Background" Value="Black"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Control.Background" Value="#BABABA"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

+ 1
- 0
B3DealerClient/Style/DataGrid.xaml View File

@ -17,6 +17,7 @@
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>


+ 319
- 0
B3DealerClient/Utils/Extensions.cs View File

@ -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<T>(this DQueryDom query, IDmoSession session)
{
return (T)query.EExecuteScalar(session);
}
public static T EExecuteScalar<T>(this DQueryDom query)
{
return (T)query.EExecuteScalar();
}
public static Tuple<T1, T2> EExecuteScalar<T1, T2>(this DQueryDom query, IDmoSession session)
{
var list = query.EExecuteList<T1, T2>(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<T1, T2> EExecuteScalar<T1, T2>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteScalar<T1, T2>(session);
}
}
public static Tuple<T1, T2, T3> EExecuteScalar<T1, T2, T3>(this DQueryDom query, IDmoSession session)
{
var list = query.EExecuteList<T1, T2, T3>(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<T1, T2, T3> EExecuteScalar<T1, T2, T3>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteScalar<T1, T2, T3>(session);
}
}
public static T EExecuteScalar<T>(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<T> EExecuteList<T>(this DQueryDom query, IDmoSession session)
{
var list = new List<T>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
list.Add((T)reader[0]);
}
}
return list;
}
public static List<T> EExecuteList<T>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteList<T>(session);
}
}
public static List<TDmo> EExecuteDmoList<TDmo>(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<string>(fields, item), (item) => type.GetProperty(item).GetSetMethod());
var list = new List<TDmo>();
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<TDmo> EExecuteDmoList<TDmo>(this DQueryDom query, params string[] fields) where TDmo : new()
{
using (var session = DmoSession.New())
{
return query.EExecuteDmoList<TDmo>(session, fields);
}
}
public static List<Tuple<T1, T2>> EExecuteList<T1, T2>(this DQueryDom query, IDmoSession session)
{
var list = new List<Tuple<T1, T2>>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var value = new Tuple<T1, T2>(
(T1)reader[0],
(T2)reader[1]);
list.Add(value);
}
}
return list;
}
public static List<Tuple<T1, T2>> EExecuteList<T1, T2>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteList<T1, T2>(session);
}
}
public static List<Tuple<T1, T2, T3>> EExecuteList<T1, T2, T3>(this DQueryDom query, IDmoSession session)
{
var list = new List<Tuple<T1, T2, T3>>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var value = new Tuple<T1, T2, T3>(
(T1)reader[0],
(T2)reader[1],
(T3)reader[2]);
list.Add(value);
}
}
return list;
}
public static List<Tuple<T1, T2, T3>> EExecuteList<T1, T2, T3>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteList<T1, T2, T3>(session);
}
}
public static List<Tuple<T1, T2, T3, T4>> EExecuteList<T1, T2, T3, T4>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteList<T1, T2, T3, T4>(session);
}
}
public static List<Tuple<T1, T2, T3, T4>> EExecuteList<T1, T2, T3, T4>(this DQueryDom query, IDmoSession session)
{
var list = new List<Tuple<T1, T2, T3, T4>>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var value = new Tuple<T1, T2, T3, T4>(
(T1)reader[0],
(T2)reader[1],
(T3)reader[2], (T4)reader[3]);
list.Add(value);
}
}
return list;
}
public static List<Tuple<T1, T2, T3, T4, T5>> EExecuteList<T1, T2, T3, T4, T5>(this DQueryDom query)
{
using (var session = DmoSession.New())
{
return query.EExecuteList<T1, T2, T3, T4, T5>(session);
}
}
public static List<Tuple<T1, T2, T3, T4, T5>> EExecuteList<T1, T2, T3, T4, T5>(this DQueryDom query, IDmoSession session)
{
var list = new List<Tuple<T1, T2, T3, T4, T5>>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var value = new Tuple<T1, T2, T3, T4, T5>(
(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();
}
}
}
}

+ 22
- 0
B3DealerClient/Utils/ValueConverter.cs View File

@ -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();
}
}
}

+ 18
- 0
B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreConfig.cs View File

@ -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; }
}
}

+ 99
- 0
B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreContext.cs View File

@ -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<CarcassInStore> dmoList = new List<CarcassInStore>();
public List<CarcassInStore> 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; } }
}
}

+ 73
- 62
B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml View File

@ -1,16 +1,32 @@
<Window x:Class="B3DealerClient.Windows.CarcassInStoreWindow_.CarcassInStoreWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:B3DealerClient.Control"
Title="白条收货" Height="700" Width="1100" FontSize="17">
xmlns:local="clr-namespace:B3DealerClient.Control"
xmlns:util="clr-namespace:B3DealerClient.Utils"
Title="白条收货" Height="700" Width="1200" FontSize="17" WindowState="Maximized">
<Window.Resources>
<util:NullToBoolConverter x:Key="NullIsFalseConverter"/>
<Style TargetType="TextBox">
<Setter Property="Width" Value="120"/>
<Setter Property="Width" Value="130"/>
<Setter Property="Height" Value="35"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="Cursor" Value="Hand"/>
</Style>
<Style TargetType="DatePicker" BasedOn="{StaticResource DatePickerStyle1}">
<Setter Property="Width" Value="130"/>
<Setter Property="Height" Value="35"/>
</Style>
<Style x:Key="simpleBtn" TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="50"/>
</Style>
<Style x:Key="deleteBtn" TargetType="Button" BasedOn="{StaticResource RedButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="50"/>
<Setter Property="Margin" Value="30,12"/>
</Style>
<Style TargetType="Border" BasedOn="{StaticResource DefaultBorder}"/>
</Window.Resources>
<Grid Margin="5">
<Grid.RowDefinitions>
@ -22,7 +38,7 @@
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2" Margin="2">
<Border Grid.ColumnSpan="2" Margin="2" Style="{StaticResource DefaultBorder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.8*"/>
@ -31,14 +47,14 @@
<local:WeightControl x:Name="weightControl" HorizontalAlignment="Left" Width="250" Margin="2,5,0,5"/>
<WrapPanel HorizontalAlignment="Right" Margin="0,10,10,0">
<TextBlock Text="扣钩重:"/>
<TextBox Margin="0,-5,0,0" Text="2.5"/>
<TextBox x:Name="hook" Margin="0,-5,0,0" Text="{Binding HookWeight,StringFormat=\{0:0.######\}}" PreviewMouseDown="NumberBox_PreviewMouseDown"/>
</WrapPanel>
<WrapPanel Grid.Column="1" HorizontalAlignment="Center" Margin="0,10">
<TextBlock Text="供应商:"/>
<TextBlock Text="龙达肉食" MinWidth="120"/>
<TextBlock Text="{Binding Dmo.Supplier_Name}" Width="200" TextWrapping="Wrap" Margin="0,0,10,0" Foreground="Red"/>
<TextBlock Text="仓库:"/>
<TextBlock Text="白条库" MinWidth="120"/>
<TextBlock Text="{Binding Dmo.Store_Name}" Width="120" TextWrapping="Wrap" Foreground="Red"/>
</WrapPanel>
</Grid>
</Border>
@ -48,7 +64,7 @@
<RowDefinition Height="180"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Margin="2">
<Border Margin="2" Style="{StaticResource DefaultBorder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.9*"/>
@ -69,35 +85,34 @@
</Style>
</Grid.Resources>
<TextBlock Text="装货日期"/>
<TextBox Grid.Column="1" Text="2019/01/25"/>
<DatePicker Grid.Column="1" SelectedDate="{Binding Date}"/>
<TextBlock Grid.Column="2" Text="供应商"/>
<TextBox Grid.Column="3" Text="龙达肉食"/>
<TextBox x:Name="Supplier" Grid.Column="3" Text="{Binding Supplier.Name}" PreviewMouseDown="BaseInfoBox_PreviewMouseDown"/>
<TextBlock Grid.Row="1" Text="计划到货日期"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="2019/01/25"/>
<DatePicker Grid.Row="1" Grid.Column="1" SelectedDate="{Binding ArrivedDate}"/>
<TextBlock Grid.Row="1" Grid.Column="2" Text="仓库"/>
<TextBox Grid.Row="1" Grid.Column="3" Text="白条库"/>
<TextBox x:Name="Store" Grid.Row="1" Grid.Column="3" Text="{Binding Store.Name}" PreviewMouseDown="BaseInfoBox_PreviewMouseDown"/>
<WrapPanel Grid.Row="2" Grid.ColumnSpan="4" HorizontalAlignment="Center" VerticalAlignment="Center">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="50"/>
<Style TargetType="Button" BasedOn="{StaticResource simpleBtn}">
<Setter Property="Margin" Value="20,0"/>
<EventSetter Event="PreviewMouseDown" Handler="SearchBtn_PreviewMouseDown"/>
</Style>
</WrapPanel.Resources>
<Button Content="查询"/>
<Button Content="清除条件"/>
<Button x:Name="cx" Content="查询"/>
<Button x:Name="qc" Content="清除条件"/>
</WrapPanel>
</Grid>
</Border>
<Border Grid.Row="1" Margin="2">
<DataGrid Margin="5">
<Border Grid.Row="1" Margin="2" Style="{StaticResource DefaultBorder}">
<DataGrid Margin="5" ItemsSource="{Binding DmoList}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">
<!--<EventSetter Event="PreviewMouseDown" Handler="TangGridFocus"/>-->
<EventSetter Event="PreviewMouseDown" Handler="MainGridFocus"/>
<Style.Triggers>
<MultiDataTrigger>
<!--<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Selected}" Value="False" />
<Condition Binding="{Binding Finish}" Value="True" />
@ -111,7 +126,7 @@
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"/>
</MultiDataTrigger>
</MultiDataTrigger>-->
<DataTrigger Binding="{Binding Selected}" Value="True">
<Setter Property="Background" Value="#1581ED"/>
<Setter Property="Foreground" Value="White"/>
@ -120,10 +135,10 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding WeightID}" Header="单号" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Order}" Header="供应商" Width="1.2*"/>
<DataGridTextColumn Binding="{Binding Number ,StringFormat=\{0:yyyy/MM/dd\}}" Header="装货日期" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding Already,StringFormat=\{0:yyyy/MM/dd\}}" Header="预计到货日期" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding ID}" Header="单号" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Supplier_Name}" Header="供应商" Width="1.2*"/>
<DataGridTextColumn Binding="{Binding Date ,StringFormat=\{0:yyyy/MM/dd\}}" Header="装货日期" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding ArrivedDate,StringFormat=\{0:yyyy/MM/dd\}}" Header="预计到货日期" Width="1.0*"/>
<!--<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="重量" Width="1*"/>-->
</DataGrid.Columns>
</DataGrid>
@ -132,16 +147,16 @@
<Grid Grid.Row="1" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="0.4*"/>
<RowDefinition Height="0.6*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<GroupBox Header="装车明细">
<DataGrid>
<DataGrid ItemsSource="{Binding Dmo.Details}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">
<!--<EventSetter Event="PreviewMouseDown" Handler="TangGridFocus"/>-->
<EventSetter Event="PreviewMouseDown" Handler="DetailGridFocus"/>
<Style.Triggers>
<MultiDataTrigger>
<!--<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Selected}" Value="False" />
<Condition Binding="{Binding Finish}" Value="True" />
@ -155,7 +170,7 @@
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"/>
</MultiDataTrigger>
</MultiDataTrigger>-->
<DataTrigger Binding="{Binding Selected}" Value="True">
<Setter Property="Background" Value="#1581ED"/>
<Setter Property="Foreground" Value="White"/>
@ -164,22 +179,22 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding WeightID}" Header="单号" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Order}" Header="存货" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="重量" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="件数" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Number ,StringFormat=\{0:0.######\}}" Header="已入库重量" Width="0.8*"/>
<DataGridTextColumn Binding="{Binding Already,StringFormat=\{0:0.######\}}" Header="已入库件数" Width="0.8*"/>
<DataGridTextColumn Binding="{Binding PayBill_ID}" Header="单号" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Goods_Name}" Header="存货" Width="1.0*"/>
<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>
</GroupBox>
<GroupBox Header="收货明细" Grid.Row="1" Margin="0,0,0,1">
<DataGrid>
<DataGrid ItemsSource="{Binding Detail.Details}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">
<!--<EventSetter Event="PreviewMouseDown" Handler="TangGridFocus"/>-->
<EventSetter Event="PreviewMouseDown" Handler="RecordGridFocus"/>
<Style.Triggers>
<MultiDataTrigger>
<!--<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Selected}" Value="False" />
<Condition Binding="{Binding Finish}" Value="True" />
@ -193,7 +208,7 @@
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Black"/>
</MultiDataTrigger>
</MultiDataTrigger>-->
<DataTrigger Binding="{Binding Selected}" Value="True">
<Setter Property="Background" Value="#1581ED"/>
<Setter Property="Foreground" Value="White"/>
@ -202,18 +217,18 @@
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding WeightID}" Header="" Width="0.4*"/>
<DataGridTextColumn Binding="{Binding Order}" Header="存货" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="重量" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="扣重" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="净重" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="件数" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Number ,StringFormat=\{0:HH:mm:ss\}}" Header="确认时间" Width="0.8*"/>
<!--<DataGridCheckBoxColumn Binding="{Binding WeightID}" Header="" Width="0.4*"/>-->
<DataGridTextColumn Binding="{Binding Goods_Name}" Header="存货" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding Weight, StringFormat=\{0:0.######\}}" Header="重量" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Discont, StringFormat=\{0:0.######\}}" Header="扣重" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding NetWeight, StringFormat=\{0:0.######\}}" Header="净重" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Pics, StringFormat=\{0:0.######\}}" Header="件数" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Date ,StringFormat=\{0:HH:mm:ss\}}" Header="确认时间" Width="0.8*"/>
</DataGrid.Columns>
</DataGrid>
</GroupBox>
</Grid>
<Border Grid.Row="2" Grid.ColumnSpan="2" Margin="2">
<Border Grid.Row="2" Grid.ColumnSpan="2" Margin="2" Style="{StaticResource DefaultBorder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.8*"/>
@ -221,28 +236,24 @@
</Grid.ColumnDefinitions>
<WrapPanel HorizontalAlignment="Right">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="50"/>
<Style TargetType="Button" BasedOn="{StaticResource simpleBtn}">
<Setter Property="Margin" Value="30,12"/>
</Style>
</WrapPanel.Resources>
<Button Content="称重记录"/>
<Button Content="入库完成"/>
<Button Content="称重记录" IsEnabled="{Binding Dmo, Converter={StaticResource NullIsFalseConverter}}" PreviewMouseDown="ViewBtn_PreviewMouseDown"/>
<Button Content="入库完成" IsEnabled="{Binding Dmo, Converter={StaticResource NullIsFalseConverter}}" PreviewMouseDown="FinishBtn_PreviewMouseDown"/>
</WrapPanel>
<WrapPanel Grid.Column="1" HorizontalAlignment="Right">
<WrapPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Width" Value="120"/>
<Setter Property="Height" Value="50"/>
<Style TargetType="Button" BasedOn="{StaticResource simpleBtn}">
<Setter Property="Margin" Value="30,12"/>
</Style>
</WrapPanel.Resources>
<Button Content="删除选中" Background="Red"/>
<Button Content="删除选中" Style="{StaticResource deleteBtn}" IsEnabled="{Binding Receive ,Converter={StaticResource NullIsFalseConverter}}" PreviewMouseDown="DeleteBtn_PreviewMouseDown"/>
<TextBlock Text="件数录入:" VerticalAlignment="Center"/>
<TextBox Text="2.5" Margin="10,0"/>
<Button Content="确认"/>
<TextBox x:Name="pics" Text="{Binding Pics,StringFormat=\{0:0.######\}}" Margin="10,0" PreviewMouseDown="NumberBox_PreviewMouseDown"/>
<Button Content="确认" IsEnabled="{Binding CanSave}" PreviewMouseDown="SaveBtn_PreviewMouseDown"/>
</WrapPanel>
</Grid>
</Border>


+ 230
- 1
B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.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.Linq;
using System.Text;
@ -19,9 +24,233 @@ namespace B3DealerClient.Windows.CarcassInStoreWindow_
/// </summary>
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<CarcassInStoreConfig>();
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);
}
}
}

+ 17
- 0
B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml View File

@ -0,0 +1,17 @@
<Window x:Class="B3DealerClient.Windows.CarcassInStoreWindow_.RecordViewDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="称重记录" Height="500" Width="800" FontSize="17">
<Border Margin="5" Style="{StaticResource DefaultBorder}">
<DataGrid x:Name="grid" Margin="5">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Goods_Name}" Header="存货" Width="1.0*"/>
<DataGridTextColumn Binding="{Binding Weight, StringFormat=\{0:0.######\}}" Header="重量" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Discont, StringFormat=\{0:0.######\}}" Header="扣重" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding NetWeight, StringFormat=\{0:0.######\}}" Header="净重" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Pics, StringFormat=\{0:0.######\}}" Header="件数" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding Date ,StringFormat=\{0:HH:mm:ss\}}" Header="确认时间" Width="0.8*"/>
</DataGrid.Columns>
</DataGrid>
</Border>
</Window>

+ 37
- 0
B3DealerClient/Windows/CarcassInStoreWindow_/RecordViewDialog.xaml.cs View File

@ -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_
{
/// <summary>
/// RecordViewDialog.xaml 的交互逻辑
/// </summary>
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();
}
}
}

+ 27
- 8
B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml View File

@ -15,7 +15,6 @@
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="Border" BasedOn="{StaticResource DefaultBorder}"/>
</Window.Resources>
<Grid Margin="5">
<Grid.ColumnDefinitions>
@ -29,9 +28,9 @@
<RowDefinition/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<Border Grid.RowSpan="3" Margin="0,2">
<WrapPanel Orientation="Vertical">
<WrapPanel.Resources>
<Border Grid.RowSpan="3" Margin="0,2" Style="{StaticResource DefaultBorder}">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource DefaultButton}">
<Setter Property="Margin" Value="5"/>
<Setter Property="Width" Value="150"/>
@ -40,7 +39,7 @@
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</WrapPanel.Resources>
</StackPanel.Resources>
<Button Content="东台五烈"/>
<Button Content="东台五烈"/>
<Button Content="郭涛"/>
@ -58,7 +57,27 @@
<TextBlock>胡传俊</TextBlock>
</Button.Content>
</Button>
</WrapPanel>
<Button>
<Button.Content>
<TextBlock>胡传俊</TextBlock>
</Button.Content>
</Button>
<Button>
<Button.Content>
<TextBlock>胡传俊</TextBlock>
</Button.Content>
</Button>
<Button>
<Button.Content>
<TextBlock>胡传俊</TextBlock>
</Button.Content>
</Button>
<Button>
<Button.Content>
<TextBlock>胡传俊</TextBlock>
</Button.Content>
</Button>
</StackPanel>
</Border>
<WrapPanel Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center">
@ -105,7 +124,7 @@
</Grid>
</Grid>
<Border Grid.Row="1" Grid.Column="1" Margin="2">
<Border Grid.Row="1" Grid.Column="1" Margin="2" Style="{StaticResource DefaultBorder}">
<DataGrid Margin="5">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">
@ -145,7 +164,7 @@
</DataGrid>
</Border>
<Border Grid.Row="2" Grid.Column="1" Margin="2">
<Border Grid.Row="2" Grid.Column="1" Margin="2" Style="{StaticResource DefaultBorder}">
<DataGrid Margin="5">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">


+ 4
- 5
B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml View File

@ -20,7 +20,6 @@
<Setter Property="Height" Value="50"/>
<Setter Property="Margin" Value="20,0"/>
</Style>
<Style TargetType="Border" BasedOn="{StaticResource DefaultBorder}"/>
</Window.Resources>
<Grid Margin="5">
<Grid.RowDefinitions>
@ -37,7 +36,7 @@
<RowDefinition Height="180"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Margin="2">
<Border Margin="2" Style="{StaticResource DefaultBorder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.9*"/>
@ -66,7 +65,7 @@
</WrapPanel>
</Grid>
</Border>
<Border Grid.Row="1" Margin="2">
<Border Grid.Row="1" Margin="2" Style="{StaticResource DefaultBorder}">
<DataGrid Margin="5">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRow}">
@ -107,10 +106,10 @@
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="50"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Margin="2">
<Border Margin="2" Style="{StaticResource DefaultBorder}">
<WrapPanel HorizontalAlignment="Center" Margin="0,10">
<TextBlock Text="供应商:"/>
<TextBlock Text="龙达肉食" MinWidth="120"/>


Loading…
Cancel
Save