コード例 #1
0
 protected void ButtonCreate_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text != null && TextBox2.Text != null)
     {
         Vehiculo car = new Vehiculo();
         car.marca  = TextBox1.Text;
         car.modelo = TextBox2.Text;
         using (var context = new DBFormativaEntities1())
         {
             context.Vehiculo.Add(car);
             context.SaveChanges();
         }
     }
 }
コード例 #2
0
 protected void ButtonDeleteRental_Click(object sender, EventArgs e)
 {
     if (DropDownList7.SelectedIndex != 0)
     {
         String   name   = DropDownList7.SelectedValue;
         string[] words  = name.Split(',');
         Alquiler rental = new Alquiler();
         using (var context = new DBFormativaEntities1())
         {
             rental = context.Alquiler.Find(int.Parse(words[0]));
             context.Alquiler.Remove(rental);
             context.SaveChanges();
             ActualizarListaAlquiler(DropDownList7);
         }
     }
 }
コード例 #3
0
        protected void ButtonEditCar_Click(object sender, EventArgs e)
        {
            String   name = DropDownList3.SelectedValue;
            Vehiculo car  = new Vehiculo();

            string[] words = name.Split(',');
            if (TextBox3.Text != null && TextBox4.Text != null)
            {
                using (var context = new DBFormativaEntities1())
                {
                    car        = context.Vehiculo.Find(int.Parse(words[0]));
                    car.marca  = TextBox3.Text;
                    car.modelo = TextBox4.Text;
                    context.SaveChanges();
                    ActualizarLista(DropDownList3);
                }
            }
        }
コード例 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox5.Text != null && DropDownList6.SelectedIndex != 0 && TextBox6.Text != null && TextBox7.Text != null)
            {
                String   name   = DropDownList6.SelectedValue;
                string[] words  = name.Split(',');
                Alquiler rental = new Alquiler();

                rental.cliente  = TextBox5.Text;
                rental.vehiculo = int.Parse(words[0]);
                rental.precio   = int.Parse(TextBox6.Text);
                rental.dias     = int.Parse(TextBox7.Text);

                using (var context = new DBFormativaEntities1())
                {
                    context.Alquiler.Add(rental);
                    context.SaveChanges();
                }
            }
            else
            {
                MessageBox.Show("Campos Imcompletos");
            }
        }