chr
2024-08-21 9ee7d3bd9c58a204b1efe38e6be61155bbb15c16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using PdmSwPlugin.Common.Entity;
using PdmSwPlugin.PriceCheck.Param;
using System.Collections.ObjectModel;
 
namespace PdmSwPlugin.PriceCheck.Model
{
    public class BanjinModel : NotifyBase
    {
        public ModelProperty ModelProperty { get; set; }
 
        public BanjinModel(ModelProperty modelProperty)
        {
            ModelProperty = modelProperty;
            PropertyGrid.Add(ModelProperty);
        }
 
        private string _stuffFee;
        public string stuffFee
        {
            get => _stuffFee;
            set
            {
                RaiseAndSetIfChanged(ref _stuffFee, value);
                price = CountTotal(out string _).ToString();
            }
        }
 
        private string _workFee = "0";
        public string workFee
        {
            get => _workFee;
            set
            {
                RaiseAndSetIfChanged(ref _workFee, value);
                price = CountTotal(out string _).ToString();
            }
        }
 
        private string _surfaceFee;
        public string surfaceFee
        {
            get => _surfaceFee;
            set
            {
                RaiseAndSetIfChanged(ref _surfaceFee, value);
                price = CountTotal(out string _).ToString();
            }
        }
 
        //private string _heatFee;
        //public string heatFee
        //{
        //    get => _heatFee;
        //    set
        //    {
        //        RaiseAndSetIfChanged(ref _heatFee, value);
        //        price = CountTotal(out string _).ToString();
        //    }
        //}
 
        private string _discount = "1";
        public string discount
        {
            get => _discount;
            set
            {
                RaiseAndSetIfChanged(ref _discount, value);
                price = CountTotal(out string _).ToString();
            }
        }
 
        private string _price;
        public string price
        {
            get => _price;
            set => RaiseAndSetIfChanged(ref _price, value);
        }
 
        private ObservableCollection<ModelProperty> _propertyGrid = new ObservableCollection<ModelProperty>();
        public ObservableCollection<ModelProperty> PropertyGrid
        {
            get => _propertyGrid;
            set => RaiseAndSetIfChanged(ref _propertyGrid, value);
        }
 
        public double CountTotal(out string message)
        {
            message = null;
            if (!double.TryParse(stuffFee, out double stuff))
            {
                message = "请输入正确的材料费";
                return 0;
            }
            if (!double.TryParse(workFee, out double work))
            {
                message = "请输入正确的加工费";
                return 0;
            }
 
            if (!double.TryParse(surfaceFee, out double surface))
            {
                message = "请输入正确的表处理费";
                return 0;
            }
 
            if (!double.TryParse(discount, out double dis))
            {
                message = "请输入正确的系数";
                return 0;
            }
            return dis * ModelProperty.weight * ModelProperty.stuffUnitPrice;
        }
    }
}