private void ModifyCommand_Handler(object sender, ExecutedRoutedEventArgs e)
        {
            if (commercial_nameTextBox.Text == "")
            {
                MessageBox.Show("El campo nombre comercial no puede estar vacio)");
                return;
            }

            var mbrand = new Solutec.Models.brands {
                id_brand = brand.id_brand
            };

            using (var context = new Solutec.Models.solutecEntities())

            {
                context.brands.Attach(mbrand);

                mbrand.commercial_name = commercial_nameTextBox.Text;
                mbrand.nit             = nitTextBox.Text;
                mbrand.nrc             = nrcTextBox.Text;
                mbrand.start_date      = start_dateDatePicker.DisplayDate;
                context.Configuration.ValidateOnSaveEnabled = false;

                context.SaveChanges();
            }

            lblNotification.Content = "La marca ha sido modificada";
            notification.Visibility = Visibility.Visible;
            mainw.Succesful("brand");
        }
        private void DeleteCommand_Handler(object sender, ExecutedRoutedEventArgs e)
        {
            var dbrand = new Solutec.Models.brands {
                id_brand = brand.id_brand
            };

            using (var context = new Solutec.Models.solutecEntities())

            {
                context.brands.Attach(dbrand);

                context.brands.Remove(dbrand);

                context.SaveChanges();
            }

            lblNotification.Content = "La marca ha sido eliminada";
            notification.Visibility = Visibility.Visible;
            mainw.Succesful("brand");
            commercial_nameTextBox.IsEnabled = false;
            nitTextBox.IsEnabled             = false;
            nrcTextBox.IsEnabled             = false;
            start_dateDatePicker.IsEnabled   = false;
            btnDelete.IsEnabled = false;
            btnModify.IsEnabled = false;
        }
        private void BrandsDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //DataRowView row = brandsDataGrid.SelectedItem as DataRowView;

            if (brandsDataGrid.SelectedItem != null)
            {
                //mainw.brandSelected(row["id_brand"].ToString());
                Solutec.Models.brands brand = (Solutec.Models.brands)brandsDataGrid.SelectedItem;

                mainw.brandSelected(brand);
            }
        }
 public new_brand(Solutec.MainWindow mainwin, Solutec.Models.brands nbrand)
 {
     InitializeComponent();
     notification.Visibility = Visibility.Hidden;
     brand = nbrand;
     mainw = mainwin;
     btnSave.Visibility          = Visibility.Hidden;
     commercial_nameTextBox.Text = brand.commercial_name;
     nitTextBox.Text             = brand.nit;
     nrcTextBox.Text             = brand.nrc;
     start_dateDatePicker.Text   = brand.start_date.ToString();
     btnDelete.Visibility        = Visibility.Visible;
     btnModify.Visibility        = Visibility.Visible;
     btnSave.Visibility          = Visibility.Hidden;
     newBrand.Content            = "Modificar marca";
 }
 public void brandSelected(Solutec.Models.brands brand)
 {
     Solutec.Views.new_brand nb = new Solutec.Views.new_brand(this, brand);
     secondary_frame.NavigationService.Navigate(nb);
 }