コード例 #1
0
ファイル: Inspeccion.cs プロジェクト: thefather20014/RentCar
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Estás seguro que quieres eliminar el registro?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                inspeccion.IdInspeccion = (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value;

                using (RentCarEntities db = new RentCarEntities())
                {
                    inspeccion = db.INSPECCION.Where(x => x.IdInspeccion == inspeccion.IdInspeccion).FirstOrDefault();
                    db.INSPECCION.Remove(inspeccion);
                    db.SaveChanges();
                    Clear();
                    ReFill();
                    MessageBox.Show("Deleted Successfully!");
                }
            }
        }
コード例 #2
0
ファイル: FromRenta.cs プロジェクト: briangomezc/RentCar
        private void gridRenta_DoubleClick_1(object sender, EventArgs e)
        {
            if (gridRenta.CurrentRow.Index != -1)
            {
                renta.ID = Convert.ToInt32(gridRenta.CurrentRow.Cells["ID"].Value);
                using (DBEntities db = new DBEntities())
                {
                    //Renta
                    renta                    = db.RENTA.Where(x => x.ID == renta.ID).FirstOrDefault();
                    dpCliente.Enabled        = true;
                    dpCliente.SelectedValue  = Convert.ToInt32(renta.ID_CLIENTE);
                    dpVehiculo.Enabled       = true;
                    dpVehiculo.SelectedValue = Convert.ToInt32(renta.ID_VEHICULO);
                    dpFechaRenta.Enabled     = true;
                    dpFechaRenta.Value       = Convert.ToDateTime(renta.FECHA_RENTA);
                    dpDevolucion.Enabled     = true;
                    dpDevolucion.Value       = Convert.ToDateTime(renta.FECHA_DEVOLUCION);
                    txtDescripcion.Enabled   = true;
                    txtDescripcion.Text      = renta.DESCRIPCION;
                    txtCantidadDias.Text     = renta.CANTIDAD_DIAS.ToString();
                    txtMontoDia.Enabled      = true;
                    txtMontoDia.Text         = renta.MONTO_DIA.ToString();
                    txtCodigo.Text           = renta.CODIGO;
                    chcEstado.Enabled        = true;
                    chcEstado.Checked        = Convert.ToBoolean(renta.ESTADO);

                    //inspeccion
                    inspeccion = db.INSPECCION.Where(x => x.ID == renta.ID_INSPECCION).FirstOrDefault();
                    chcLlantaDerechaD.Checked          = Convert.ToBoolean(inspeccion.GOMA_DELANTERA_DERECHA);
                    chcLlantaIzquierdaD.Checked        = Convert.ToBoolean(inspeccion.GOMA_DELANTERA_IZQUIERDA);
                    chcLlantaDerechaT.Checked          = Convert.ToBoolean(inspeccion.GOMA_TRASERA_DERECHA);
                    chcLlantaIzquierdaT.Checked        = Convert.ToBoolean(inspeccion.GOMA_TRASERA_IZQUIERDA);
                    chcTieneGoma.Checked               = Convert.ToBoolean(inspeccion.TIENE_GOMA);
                    chcRayadura.Checked                = Convert.ToBoolean(inspeccion.TIENE_RAYADURAS);
                    chcTieneGato.Checked               = Convert.ToBoolean(inspeccion.TIENE_GATO);
                    chcTieneRoturaCristal.Checked      = Convert.ToBoolean(inspeccion.TIENE_ROTURA_CRISTAL);
                    dpCantidaCombustible.SelectedValue = Convert.ToInt32(inspeccion.ID_CANTIDAD_COMBUSTIBLE);
                }

                btnNuevo.Enabled    = false;
                btnCancelar.Enabled = true;
                btnSave.Enabled     = true;
            }
        }
コード例 #3
0
ファイル: Inspeccion.cs プロジェクト: thefather20014/RentCar
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                inspeccion.IdInspeccion = (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value;

                using (RentCarEntities db = new RentCarEntities())
                {
                    var lst = from inspeccion in db.INSPECCION
                              join vehiculo in db.Vehiculo
                              on inspeccion.IdVehiculo equals vehiculo.IdVehiculo
                              join cliente in db.CLIENTE
                              on inspeccion.IdCliente equals cliente.IdCliente
                              join empleado in db.EMPLEADO
                              on inspeccion.IdEmpleado equals empleado.IdEmpleado
                              join marca in db.MARCA
                              on vehiculo.IdMarca equals marca.IdMarca
                              join modelo in db.MODELO
                              on vehiculo.IdModelo equals modelo.IdModelo
                              select new InspeccionClass
                    {
                        IdInspeccion        = inspeccion.IdInspeccion,
                        Vehiculo            = marca.Despcricion + " " + modelo.Despcricion,
                        Cliente             = cliente.Nombre,
                        Empleado            = empleado.Nombre,
                        Ralladuras          = inspeccion.Ralladuras,
                        CantidadCombustible = inspeccion.CantidadCombustible,
                        GomaRepuesto        = inspeccion.GomaRepuesto,
                        Gato          = inspeccion.Gato,
                        RoturaCristal = inspeccion.RoturaCristal,
                        Neumatico1    = inspeccion.EstadoNeumatico1,
                        Neumatico2    = inspeccion.EstadoNeumatico2,
                        Neumatico3    = inspeccion.EstadoNeumatico3,
                        Neumatico4    = inspeccion.EstadoNeumatico4,
                        Fecha         = inspeccion.Fecha,
                        Estado        = inspeccion.Estado
                    };

                    dataGridView1.DataSource = lst.ToList();

                    var descri = lst.Where(x => x.IdInspeccion == inspeccion.IdInspeccion).FirstOrDefault();
                    inspeccion = db.INSPECCION.Where(x => x.IdInspeccion == inspeccion.IdInspeccion).FirstOrDefault();

                    cbVehiculo.Text  = descri.Vehiculo;
                    cbEmpleado.Text  = descri.Empleado;
                    cbCliente.Text   = descri.Cliente;
                    cbCantidadC.Text = inspeccion.CantidadCombustible;

                    //Ralladuras
                    if (inspeccion.Ralladuras == "S")
                    {
                        rbRalladurasSi.Checked = true;
                    }
                    else if (inspeccion.Ralladuras == "N")
                    {
                        rbRalladurasNo.Checked = true;
                    }
                    //Goma de Respuesto
                    if (inspeccion.GomaRepuesto == "S")
                    {
                        rbGomaSi.Checked = true;
                    }
                    else if (inspeccion.GomaRepuesto == "N")
                    {
                        rbGomaNo.Checked = true;
                    }
                    // Gato
                    if (inspeccion.Gato == "S")
                    {
                        rbGatoSi.Checked = true;
                    }
                    else if (inspeccion.Gato == "N")
                    {
                        rbGatoNo.Checked = true;
                    }
                    // Cristal Roto
                    if (inspeccion.RoturaCristal == "S")
                    {
                        rbCristalSi.Checked = true;
                    }
                    else if (inspeccion.RoturaCristal == "N")
                    {
                        rbCristalNo.Checked = true;
                    }
                    // Neumatico 1
                    if (inspeccion.EstadoNeumatico1 == "B")
                    {
                        rbNeumatico1B.Checked = true;
                    }
                    else if (inspeccion.EstadoNeumatico1 == "M")
                    {
                        rbNeumatico1M.Checked = true;
                    }
                    // Neumatico 2
                    if (inspeccion.EstadoNeumatico2 == "B")
                    {
                        rbNeumatico2B.Checked = true;
                    }
                    else if (inspeccion.EstadoNeumatico2 == "M")
                    {
                        rbNeumatico2M.Checked = true;
                    }
                    // Neumatico 3
                    if (inspeccion.EstadoNeumatico3 == "B")
                    {
                        rbNeumatico3B.Checked = true;
                    }
                    else if (inspeccion.EstadoNeumatico3 == "M")
                    {
                        rbNeumatico3M.Checked = true;
                    }
                    // Neumatico 4
                    if (inspeccion.EstadoNeumatico4 == "B")
                    {
                        rbNeumatico4B.Checked = true;
                    }
                    else if (inspeccion.EstadoNeumatico4 == "M")
                    {
                        rbNeumatico4M.Checked = true;
                    }
                    //Estado
                    if (inspeccion.Estado == "A")
                    {
                        cbEstado.Text = "Activo";
                    }
                    else if (inspeccion.Estado == "I")
                    {
                        cbEstado.Text = "Inactivo";
                    }

                    dtpFecha.Text = inspeccion.Fecha.ToString();
                }

                btnSave.Text = "Update";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }