private void toolStripMenuItem3_Click(object sender, EventArgs e) { this.Hide(); Views.Renta.IndexRenta c = new Views.Renta.IndexRenta(); c.ShowDialog(); this.Close(); }
private void button1_Click(object sender, EventArgs e) { using (RentcarEntities db = new RentcarEntities()) { if (string.IsNullOrEmpty(cmb_empleado.Text) || string.IsNullOrEmpty(cmb_combustible.Text) || !radio_ralladura_si.Checked && !radio_ralladura_no.Checked || !radio_goma_repuesta_si.Checked && !radio_goma_repuesta_no.Checked || !radio_gato_si.Checked && !radio_gato_no.Checked || !radio_cristal_si.Checked && !radio_cristal_no.Checked || !radio_activo.Checked && !radio_inactivo.Checked) { MessageBox.Show("Todos los campos son obligatorios."); } else { if (this.action == "New") { inspeccions oInspeccion = new inspeccions(); oInspeccion.renta_id = this.id; oInspeccion.fecha_inspeccion = dtp_fecha_inspeccion.Value; oInspeccion.empleado_id = int.Parse(cmb_empleado.SelectedValue.ToString()); oInspeccion.combustible = cmb_combustible.SelectedItem.ToString(); //Tiene ralladuras if (radio_ralladura_si.Checked) { oInspeccion.ralladura = true; } else if (radio_ralladura_no.Checked) { oInspeccion.ralladura = false; } //Tiene goma de repuesta if (radio_goma_repuesta_si.Checked) { oInspeccion.goma_repuesto = true; } else if (radio_goma_repuesta_no.Checked) { oInspeccion.goma_repuesto = false; } //Tiene gato if (radio_gato_si.Checked) { oInspeccion.gato = true; } else if (radio_gato_no.Checked) { oInspeccion.gato = false; } // Tiene rotura de cristal if (radio_cristal_si.Checked) { oInspeccion.rotura_cristal = true; } else if (radio_cristal_no.Checked) { oInspeccion.rotura_cristal = false; } //Estado de Inspeccion if (radio_activo.Checked) { oInspeccion.estado = true; } else if (radio_inactivo.Checked) { oInspeccion.estado = false; } //Goma superior derecha if (check_s_derecha.Checked) { oInspeccion.goma_superior_derecha = true; } //Goma inferior derecha if (check_i_derecha.Checked) { oInspeccion.goma_inferior_derecha = true; } //Goma superior izquierda if (check_s_izquierda.Checked) { oInspeccion.goma_superior_izquierda = true; } //Goma inferior izquierda if (check_i_izquierda.Checked) { oInspeccion.goma_inferior_izquierda = true; } db.inspeccions.Add(oInspeccion); db.SaveChanges(); this.Close(); } else if (this.action == "Edit") { //ESTO NO ESTA GUARDANDO oInspeccion = db.inspeccions.Where(c => c.renta_id == this.id).First(); oInspeccion.fecha_inspeccion = dtp_fecha_inspeccion.Value; oInspeccion.empleado_id = int.Parse(cmb_empleado.SelectedValue.ToString()); oInspeccion.combustible = cmb_combustible.SelectedItem.ToString(); //Tiene ralladuras if (radio_ralladura_si.Checked) { oInspeccion.ralladura = true; } else if (radio_ralladura_no.Checked) { oInspeccion.ralladura = false; } //Tiene goma de repuesta if (radio_goma_repuesta_si.Checked) { oInspeccion.goma_repuesto = true; } else if (radio_goma_repuesta_no.Checked) { oInspeccion.goma_repuesto = false; } //Tiene gato if (radio_gato_si.Checked) { oInspeccion.gato = true; } else if (radio_gato_no.Checked) { oInspeccion.gato = false; } // Tiene rotura de cristal if (radio_cristal_si.Checked) { oInspeccion.rotura_cristal = true; } else if (radio_cristal_no.Checked) { oInspeccion.rotura_cristal = false; } //Goma superior derecha if (check_s_derecha.Checked) { oInspeccion.goma_superior_derecha = true; } //Goma inferior derecha if (check_i_derecha.Checked) { oInspeccion.goma_inferior_derecha = true; } //Goma superior izquierda if (check_s_izquierda.Checked) { oInspeccion.goma_superior_izquierda = true; } //Goma inferior izquierda if (check_i_izquierda.Checked) { oInspeccion.goma_inferior_izquierda = true; } //Estado de Inspeccion if (radio_activo.Checked) { oInspeccion.estado = true; } else if (radio_inactivo.Checked) { oInspeccion.estado = false; } db.Entry(oInspeccion).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); this.Hide(); Views.Renta.IndexRenta a = new Views.Renta.IndexRenta(); a.ShowDialog(); this.Close(); } } } }