Exemplo n.º 1
0
        private void BtnInsert_Click(object sender, RoutedEventArgs e)
        {
            var responce = CarLogic.AddOrUpdate(new Common.ViewModel.CarVM
            {
                Make           = tbCarMake.Text,
                Model          = tbCompanyName.Text,
                RegistrationNo = tbCarRegistrationNo.Text,
            });

            if (responce.IsCompleted)
            {
                var listresponce = CarLogic.List();
                if (listresponce.IsCompleted)
                {
                    Vehicle.dataGrid.ItemsSource = listresponce.Object;
                    this.Hide();
                }
            }
        }
Exemplo n.º 2
0
        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            var response = CarLogic.AddOrUpdate(new Common.ViewModel.CarVM()
            {
                Id             = _Id,
                Make           = tbCarMake.Text,
                Model          = tbCompanyName.Text,
                RegistrationNo = tbCarRegistrationNo.Text,
            }, true);

            if (response.IsCompleted)
            {
                var listResponse = CarLogic.List();
                if (listResponse.IsCompleted)
                {
                    Vehicle.dataGrid.ItemsSource = listResponse.Object;
                }
                this.Hide();
            }
            //Car updateCar = (from c in _db.Cars where c.CarId == _Id select c).SingleOrDefault();
            //var totalKm = Int32.Parse(tbCarKmIn.Text) - Int32.Parse(tbCarKmOut.Text);
            //var totalTime = DateTime.Parse(tbTImeIn.Value.Value.ToLongTimeString()) - DateTime.Parse(tbTimeOut.Value.Value.ToLongTimeString());

            //updateCar.CarKmIn = Int32.Parse(tbCarKmIn.Text);
            //updateCar.CarKmOut =Int32.Parse(tbCarKmOut.Text);
            //updateCar.CarMake = tbCarMake.Text;
            //updateCar.CarRegistrationNo = tbCarRegistrationNo.Text;
            //updateCar.DateIn = tbDateIn.SelectedDate.Value.ToShortDateString();
            //updateCar.DateOut =tbDateOut.SelectedDate.Value.ToShortDateString();
            //updateCar.KmBill = Int32.Parse(tbKmBill.Text);
            //updateCar.TImeIn = tbTImeIn.Value.Value.ToShortTimeString();
            //updateCar.TimeOut = tbTimeOut.Value.Value.ToShortTimeString();
            //updateCar.TimeBill = Int32.Parse(tbTimeBill.Text);
            //updateCar.TotalKm = totalKm;
            //updateCar.TotalTime = Convert.ToInt16(totalTime.TotalHours.ToString());

            //if (updateCar.CarOwner == "Own")
            //{
            //    updateCar.CarOwner = cbCarOwnerOwn.Content.ToString();
            //}
            //else if (updateCar.CarOwner == "Investor")
            //{
            //    updateCar.CarOwner = cbCarOwnerInvestor.Content.ToString();
            //}
            //else
            //{
            //    updateCar.CarOwner = cbCarOwnerNonPool.Content.ToString();
            //}

            //if(cbCarFuelStateFull.IsChecked == true)
            //{
            //    updateCar.CarFuelState = cbCarFuelStateFull.Content.ToString();
            //}
            //else if (cbCarFuelStateQuarter.IsChecked == true)
            //{
            //    updateCar.CarFuelState = cbCarFuelStateQuarter.Content.ToString();
            //}
            //else if(cbCarFuelStateHalf.IsChecked == true)
            //{
            //    updateCar.CarFuelState = cbCarFuelStateHalf.Content.ToString();
            //}
            //else
            //{
            //    updateCar.CarFuelState = cbCarFuelStateEmpty.Content.ToString();
            //}
            //_db.SaveChanges();
            //Vehicle.dataGrid.ItemsSource = _db.Cars.ToList();
            //this.Hide();
        }