コード例 #1
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (cbpro.SelectedIndex > -1 && cbser.SelectedIndex > -1 && cbasis.SelectedIndex > -1)
            {
                ProyectoFinal.BD.ProyectoFinal db = new BD.ProyectoFinal();

                int id = int.Parse(cbser.Text);
                Servicio p = db.Servicio.SingleOrDefault(x => x.ServicioId == id);

                if (p != null)
                {
                    tempServicio = p;
                }

                AgregarAlGrid.Add(new Servicio()
                {
                    ServicioId = tempServicio.ServicioId,
                    NombreServicio = tempServicio.NombreServicio,
                    Precio = tempServicio.Precio,
                    ProveedorProveedorId = tempServicio.ProveedorProveedorId,
                });

                actualizaGrid();
                tempServicio = null;
            }
            else
            {
                MessageBox.Show("Tiene que seleccionar un elemento en cada campo", "precaucion", MessageBoxButton.OK, MessageBoxImage.Hand);
            }
        }
コード例 #2
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     if (Regex.IsMatch(txtnombre.Text, @"^[a-zA-Z\s]+$") && Regex.IsMatch(txtpre.Text, @"^\d+$") && Regex.IsMatch(CbProveedores.Text, @"^\d+$"))
     {
         //ProyectoFinal db = new ProyectoFinal();
         ProyectoFinal.BD.ProyectoFinal db = new BD.ProyectoFinal();
         Servicio ser = new Servicio();
         ser.NombreServicio = txtnombre.Text;
         ser.Precio = float.Parse(txtpre.Text);
         ser.ProveedorProveedorId = (int)CbProveedores.SelectedValue;
         db.Servicio.Add(ser);
         db.SaveChanges();
     }
     else { MessageBox.Show("Solo Letras en #nombre, numeros en #precio y seleccionar un elemento en #Proveedor"); }
 }
コード例 #3
0
 private void CleanUp()
 {
     AgregarAlGrid = new List<Servicio>();
     tot.Content = "Total: $0.00";
     grid.ItemsSource = null;
     grid.Items.Refresh();
     //Tmp variable is erased using null
     tempServicio = null;
 }