Révision 09d4a0de GES_PAC/ViewModel/CreateCalibrationViewModel.cs

Voir les différences:

GES_PAC/ViewModel/CreateCalibrationViewModel.cs
15 15
        private double? _conc_o2;
16 16
        private double? _conc_co2;
17 17
        private double? _conc_ch4;
18
        private string _ref_bouteille;
18
        private string _refBouteille;
19
        private bool _isRefBouteilleVisible;
19 20
        private bool _isFormValid;
20 21
        #endregion
21 22

  
......
31 32
            set
32 33
            {
33 34
                _selectedType = value;
35
                IsRefBouteilleVisible = _selectedType.Name != "Air";
34 36
                OnPropertyChanged();
35 37
                ValidateForm();
36 38
            }
......
70 72
        }
71 73
        public string RefBouteille
72 74
        {
73
            get => _ref_bouteille;
75
            get => _refBouteille;
74 76
            set
75 77
            {
76
                _ref_bouteille = value;
78
                _refBouteille = value;
77 79
                OnPropertyChanged();
78 80
                ValidateForm();
79 81
            }
80 82
        }
83
        public bool IsRefBouteilleVisible
84
        {
85
            get => _isRefBouteilleVisible;
86
            set
87
            {
88
                _isRefBouteilleVisible = value;
89
                OnPropertyChanged();
90
            }
91
        }
92

  
81 93
        public bool IsFormValid
82 94
        {
83 95
            get => _isFormValid;
......
92 104
        public bool ConcO2Error { get; private set; } = true;
93 105
        public bool ConcCO2Error { get; private set; } = true;
94 106
        public bool ConcCH4Error { get; private set; } = true;
107
        public bool RefBouteilleError { get; private set; } = true;
95 108
        #endregion
96 109

  
97 110
        #region Constructeurs
......
116 129

  
117 130
            var date = DateTime.Now;
118 131
            var newCalib = new MesureCalibration(date, ConcO2 ?? 0, ConcCO2 ?? 0, ConcCH4 ?? 0, SelectedType, RefBouteille);
119
            var isComplete = JourneeViewModel.Instance.GetCurrentDay().AddCalibration(newCalib);
132
            var phaseCalibration = JourneeViewModel.Instance.GetCurrentPhase();
133
            var isComplete = JourneeViewModel.Instance.GetCurrentDay().AddCalibration(newCalib, phaseCalibration);
120 134

  
121 135
            if (isComplete)
122 136
            {
123
                await Shell.Current.GoToAsync(nameof(MainView));
137
                await Shell.Current.GoToAsync(nameof(SetListView));
124 138
            }
125 139
            else
126 140
            {
......
136 150
            ConcO2Error = ConcO2 == null;
137 151
            ConcCO2Error = ConcCO2 == null;
138 152
            ConcCH4Error = ConcCH4 == null;
153
            RefBouteilleError = IsRefBouteilleVisible && (RefBouteille == null || RefBouteille.Length < 5);
139 154

  
140 155
            OnPropertyChanged(nameof(TypeError));
141 156
            OnPropertyChanged(nameof(ConcO2Error));
142 157
            OnPropertyChanged(nameof(ConcCO2Error));
143 158
            OnPropertyChanged(nameof(ConcCH4Error));
159
            OnPropertyChanged(nameof(RefBouteilleError));
144 160

  
145
            IsFormValid = !TypeError && !ConcO2Error && !ConcCO2Error && !ConcCH4Error;
161
            IsFormValid = !TypeError && !ConcO2Error && !ConcCO2Error && !ConcCH4Error && !RefBouteilleError;
146 162

  
147 163
            (CreateCalibrationCommand as Command)?.ChangeCanExecute();
148 164
        }

Formats disponibles : Unified diff