Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            CarOwner carOwnerDelete = (CarOwner)lvOwners.SelectedItem;

            Global.ctx.CarOwners.Remove(carOwnerDelete);
            Global.ctx.SaveChanges();

            LoadData();
            ResetValues();
        }
Ejemplo n.º 2
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            string newName = txtName.Text;

            CarOwner carOwnerUpdate = (CarOwner)lvOwners.SelectedItem;

            carOwnerUpdate.Name = newName;
            Global.ctx.SaveChanges();

            LoadData();
        }
Ejemplo n.º 3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string   name        = txtName.Text;
            CarOwner newCarOwner = new CarOwner {
                Name = name
            };

            Global.ctx.CarOwners.Add(newCarOwner);
            Global.ctx.SaveChanges();

            LoadData();
            ResetValues();
        }
Ejemplo n.º 4
0
        public CarsDialog(CarOwner carOwner)
        {
            // Here we populate dynamic fields on initalization of dialog window with informations about cars of the user
            InitializeComponent();

            // Assign parameter passed as currentCarOwner if not null
            if (carOwner != null)
            {
                currCarOwner = carOwner;
            }

            LoadData();
        }
Ejemplo n.º 5
0
        private void lvOwners_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            btnUpdate.IsEnabled = true;
            btnDelete.IsEnabled = true;

            var selectedOwner = lvOwners.SelectedItem;

            if (selectedOwner is CarOwner)
            {
                CarOwner carOwner = (CarOwner)lvOwners.SelectedItem;

                txtName.Text  = carOwner.Name;
                lblId.Content = carOwner.OwnerId;
            }
        }
Ejemplo n.º 6
0
        private void btnManageCars_Click(object sender, RoutedEventArgs e)
        {
            // Showing Cars Dialog Window
            // Here I'm passing car owner selected item on list as a parameter to open new dialog window. But not sure yet how to fetch this owner from db.
            CarOwner   carOwner   = (CarOwner)lvOwners.SelectedItem;
            CarsDialog carsDialog = new CarsDialog(carOwner);

            carsDialog.Owner = this;
            bool?result = carsDialog.ShowDialog();

            if (result == true)
            {
                lvOwners.Items.Refresh();
            }
        }