private void Button_Click_1(object sender, RoutedEventArgs e) { if (this.waterCounterStart.Text != "" && this.waterCounterValue.Text != "" && this.waterTariff.Text != "" && this.waterDate.Text != "") { WaterService ws = new WaterService(); int startValue = Convert.ToInt32(this.waterCounterStart.Text); int counterValue = Convert.ToInt32(this.waterCounterValue.Text); decimal tariff = Decimal.Parse(this.waterTariff.Text) / 100; decimal calculatedPrice = ws.CalculatePrice(startValue, counterValue, tariff); DateTime dateTime = DateTime.Parse(this.waterDate.Text); MessageBox.Show( $"\nСпожито: {ws.Consumed} од. куб." + $"\nВсього ціна: {calculatedPrice} грн." ); Water water = new Water() { CounterValue = counterValue, Date = dateTime, Price = calculatedPrice }; _context.Water.Add(water); _context.SaveChanges(); main.drawChart(); } else { MessageBox.Show("Всі поля повинні бути заповнені"); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="service"></param> public PatientController(PatientService service, WeightService weightService, BloodPressureService bloodPressureService, BloodSugarService bloodSugarService, WaterService waterService, HandRingService handRingService, DialysisService dialysisService, HospitalService hospitalService, DoctorService doctorService) { _service = service; _weightService = weightService; _bloodPressureService = bloodPressureService; _bloodSugarService = bloodSugarService; _waterService = waterService; _handRingService = handRingService; _dialysisService = dialysisService; _hospitalService = hospitalService; _doctorService = doctorService; }
/// <summary> /// 构造函数 /// </summary> /// <param name="service"></param> public WaterController(WaterService service) { _service = service; }