public void Guardar() { //AutoClasifica.ItemsSource = BaseDatos.GetBaseDatos().CLASIFICACION_ESTUDIOS.ToList(); if (txtNombre.Text == "") { System.Windows.MessageBox.Show("Ingrese un nombre"); } else { if (txtDescripcion.Text == "") { System.Windows.MessageBox.Show("Ingrese una Descripción"); } else { if (txtCosto.Text == "") { System.Windows.MessageBox.Show("Ingrese el costo"); } else { if (AutoClasifica.SelectedItem == null) { MessageBox.Show("Selecciona una Clasificacion"); } else { DateTime fec = DateTime.Now; int idClasifica = ((CLASIFICACION_ESTUDIOS)AutoClasifica.SelectedItem).CLASIFICACIONID; CATALOGO_ESTUDIOS cestudio = new CATALOGO_ESTUDIOS { NOMBRE = txtNombre.Text, DESCRIPCION = txtDescripcion.Text, COSTO = Decimal.Parse(txtCosto.Text), FECHA_CREACION = fec, CLASIFICACIONID = idClasifica, STATUS = "Activo" }; BaseDatos.GetBaseDatos().CATALOGO_ESTUDIOS.Add(cestudio); BaseDatos.GetBaseDatos().SaveChanges(); //Mensaje MessageBoxResult result = MessageBox.Show("Registro exitoso"); Limpiar(); this.Close(); } } } } }
public NuevoEstudio(CATALOGO_ESTUDIOS ces, CLASIFICACION_ESTUDIOS claes, bool save) { InitializeComponent(); AutoClasifica.ItemsSource = BaseDatos.GetBaseDatos().CLASIFICACION_ESTUDIOS.ToList(); idestudi = ces.CATALOGO_ESTUDIO_ID; idclasi = claes.CLASIFICACIONID; txtNombre.Text = ces.NOMBRE; txtDescripcion.Text = ces.DESCRIPCION; txtCosto.Text = ces.COSTO.ToString(); AutoClasifica.SearchText = claes.NOMBRE; btnEditar.Visibility = Visibility.Visible; btnGuardar.Visibility = Visibility.Hidden; }