From 536e86930674915b504fac6817e18eb7252e6481 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Sat, 20 Apr 2019 15:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=8D=95No.143137=20?= =?UTF-8?q?=E7=99=BD=E6=9D=A1=E5=8F=91=E8=B4=A7=E3=80=81=E7=99=BD=E6=9D=A1?= =?UTF-8?q?=E6=94=B6=E8=B4=A7=E5=AE=A2=E6=88=B7=E7=AB=AF=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3DealerClient/App.xaml | 1 + B3DealerClient/B3DealerClient.csproj | 7 ++ B3DealerClient/Control/SwitchCheckBox.xaml | 70 ++++++++++++++++++ B3DealerClient/Control/SwitchCheckBox.xaml.cs | 72 +++++++++++++++++++ .../CarcassInStoreWindow.xaml | 14 ++-- .../CarcassInStoreWindow.xaml.cs | 5 +- .../CarcassSaleOutWindow.xaml | 3 + B3DealerClient/Windows/Test.xaml | 39 +--------- B3DealerClient/Windows/Test.xaml.cs | 18 +---- 9 files changed, 169 insertions(+), 60 deletions(-) create mode 100644 B3DealerClient/Control/SwitchCheckBox.xaml create mode 100644 B3DealerClient/Control/SwitchCheckBox.xaml.cs diff --git a/B3DealerClient/App.xaml b/B3DealerClient/App.xaml index 725a37f..70cfaaf 100644 --- a/B3DealerClient/App.xaml +++ b/B3DealerClient/App.xaml @@ -13,6 +13,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/B3DealerClient/Control/SwitchCheckBox.xaml.cs b/B3DealerClient/Control/SwitchCheckBox.xaml.cs new file mode 100644 index 0000000..3419c54 --- /dev/null +++ b/B3DealerClient/Control/SwitchCheckBox.xaml.cs @@ -0,0 +1,72 @@ +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.Navigation; +using System.Windows.Shapes; + +namespace B3DealerClient.Control +{ + /// + /// SwitchCheckBox.xaml 的交互逻辑 + /// + public partial class SwitchCheckBox : CheckBox + { + public static readonly DependencyProperty TextProperty = DependencyProperty.Register( + "Text", typeof(string), typeof(SwitchCheckBox), new PropertyMetadata("Off")); + /// + /// 默认文本(未选中) + /// + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public static readonly DependencyProperty CheckedTextProperty = DependencyProperty.Register( + "CheckedText", typeof(string), typeof(SwitchCheckBox), new PropertyMetadata("On")); + /// + /// 选中状态文本 + /// + public string CheckedText + { + get { return (string)GetValue(CheckedTextProperty); } + set { SetValue(CheckedTextProperty, value); } + } + + public static readonly DependencyProperty CheckedForegroundProperty = + DependencyProperty.Register("CheckedForeground", typeof(Brush), typeof(SwitchCheckBox), new PropertyMetadata(Brushes.WhiteSmoke)); + /// + /// 选中状态前景样式 + /// + public Brush CheckedForeground + { + get { return (Brush)GetValue(CheckedForegroundProperty); } + set { SetValue(CheckedForegroundProperty, value); } + } + + public static readonly DependencyProperty CheckedBackgroundProperty = + DependencyProperty.Register("CheckedBackground", typeof(Brush), typeof(SwitchCheckBox), new PropertyMetadata(Brushes.LimeGreen)); + /// + /// 选中状态背景色 + /// + public Brush CheckedBackground + { + get { return (Brush)GetValue(CheckedBackgroundProperty); } + set { SetValue(CheckedBackgroundProperty, value); } + } + + static SwitchCheckBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(SwitchCheckBox), new FrameworkPropertyMetadata(typeof(SwitchCheckBox))); + } + } +} diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml index 23fc34d..a4b8914 100644 --- a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml +++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml @@ -47,13 +47,17 @@ - - + + + + + + - - - + + + diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs index 0feacdf..9950c5f 100644 --- a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs +++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs @@ -235,7 +235,10 @@ namespace B3DealerClient.Windows.CarcassInStoreWindow_ record.Weight = context.Weight; record.Pics = context.Pics.Value; record.Discont = (context.HookWeight ?? 0) * Math.Ceiling(record.Pics); - record.NetWeight = record.Weight - record.Discont; + if (weightUnit.IsChecked == true) + record.NetWeight = Math.Ceiling(record.Pics / 2) * (context.HookWeight ?? 0); + else + record.NetWeight = record.Weight - record.Discont; record.Date = DateTime.Now; record.Selected = true; CarcassInStoreBL.InsertRecord(record); diff --git a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml index e7cf85a..db63692 100644 --- a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml +++ b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml @@ -236,6 +236,9 @@ - - - - + + diff --git a/B3DealerClient/Windows/Test.xaml.cs b/B3DealerClient/Windows/Test.xaml.cs index e2d61e1..61080df 100644 --- a/B3DealerClient/Windows/Test.xaml.cs +++ b/B3DealerClient/Windows/Test.xaml.cs @@ -20,25 +20,9 @@ namespace B3DealerClient.Windows /// public partial class Test : Window { - List Items; public Test() - { + { InitializeComponent(); - Items = new List(); - Items.Add(new NameIDPair() { ID = 1, Name = "张三" }); - Items.Add(new NameIDPair() { ID = 2, Name = "张1" }); - Items.Add(new NameIDPair() { ID = 3, Name = "张2" }); - Items.Add(new NameIDPair() { ID = 4, Name = "张4" }); - Items.Add(new NameIDPair() { ID = 5, Name = "张5" }); - Items.Add(new NameIDPair() { ID = 6, Name = "张6" }); - lb .ItemsSource = Items; - } - - private void BtnClick(object sender, MouseButtonEventArgs e) - { - var btn = sender as Button; - var tag = btn.Tag as NameIDPair; - MessageBox.Show(tag.ID.ToString()); } } }