示例#1
0
        private void FillTipoCombustible()
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    var lts = from Tipos_Combustibles in db.Tipos_Combustibles
                              where Tipos_Combustibles.Estado == "Activo"
                              select Tipos_Combustibles;

                    if (lts.Count() > 0)
                    {
                        cmbTipoCombustible.DataSource    = lts.ToList();
                        cmbTipoCombustible.DisplayMember = "Descripcion";
                        cmbTipoCombustible.ValueMember   = "Id_Tipos_Combustible";
                        if (cmbTipoCombustible.Items.Count > 1)
                        {
                            cmbTipoCombustible.SelectedIndex = -1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void FillModelo()
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    var lts = from Modelos in db.Modelos
                              where Modelos.Estado == "Activo"
                              select Modelos;

                    if (lts.Count() > 0)
                    {
                        cmbModelo.DataSource    = lts.ToList();
                        cmbModelo.DisplayMember = "Descripcion";
                        cmbModelo.ValueMember   = "Id_Modelo";
                        if (cmbModelo.Items.Count > 1)
                        {
                            cmbModelo.SelectedIndex = -1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Vehiculo in db.Vehiculos
                           join Tipos_Vehiculos in db.Tipos_Vehiculos
                           on Vehiculo.Tipo_Vehiculo equals Tipos_Vehiculos.Id_Tipos_Vehiculo
                           join Marcas in db.Marcas
                           on Vehiculo.Marca equals Marcas.Id_Marca
                           join Modelos in db.Modelos
                           on Vehiculo.Modelo equals Modelos.Id_Modelo
                           join Tipos_Combustibles in db.Tipos_Combustibles
                           on Vehiculo.Tipo_Combustible equals Tipos_Combustibles.Id_Tipos_Combustible
                           select new
                {
                    Id = Vehiculo.Id_Vehiculo,
                    Descripcion = Vehiculo.Descripcion,
                    Chasis = Vehiculo.No_Chasis,
                    Motor = Vehiculo.No_Motor,
                    Placa = Vehiculo.No_Placa,
                    TipoVehiculo = Tipos_Vehiculos.Descripcion,
                    Marca = Marcas.Descripcion,
                    Modelo = Modelos.Descripcion,
                    TipoCombustible = Tipos_Combustibles.Descripcion,
                    Estado = Vehiculo.Estado
                }).AsQueryable();

                if (!txtBusqueda.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Descripcion.Contains(txtBusqueda.Text.Trim()));
                }

                dataGridView1.DataSource = lst.ToList();
            }
        }
示例#4
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         string            message = "¿Estas seguro de eliminar el registo?";
         string            title   = "Eliminar";
         MessageBoxButtons buttons = MessageBoxButtons.YesNo;
         DialogResult      result  = MessageBox.Show(message, title, buttons);
         if (result == DialogResult.Yes)
         {
             int?Id_Marca = GetId();
             if (Id_Marca != null)
             {
                 using (rentcarEntities db = new rentcarEntities())
                 {
                     Models.Marca oMarca = db.Marcas.Find(Id_Marca);
                     db.Marcas.Remove(oMarca);
                     db.SaveChanges();
                 }
                 Refresh();
             }
         }
     }
     catch
     {
         MessageBox.Show("Este registro esta enzalado a otra tabla.");
     }
 }
示例#5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                if (Id_Empleado == null)
                {
                    oEmpleado = new Models.Empleado();
                }

                if (txtNombre.Text.Trim().Equals("") || txtApellido.Text.Trim().Equals("") || txtCedula.Text.Trim().Equals("") ||
                    txtCorreo.Text.Trim().Equals("") || txtContrasena.Text.Trim().Equals("") || cmbTandaLaboral.Text.Trim().Equals("") ||
                    nudPorcientoComision.Text.Trim().Equals("") || dtpFechaIngreso.Text.Trim().Equals("") || cmbEstado.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Por favor, llenar todos los campos.");
                }
                else
                {
                    if (CheckCedula(txtCedula.Text))
                    {
                        var exists = db.Empleados.Any(x => x.Cedula.Equals(txtCedula.Text));

                        if (exists && Id_Empleado == null)
                        {
                            MessageBox.Show("Este empleado ya habia sido registrado.");
                            return;
                        }
                        else
                        {
                            oEmpleado.Nombre             = txtNombre.Text;
                            oEmpleado.Apellido           = txtApellido.Text;
                            oEmpleado.Cedula             = txtCedula.Text;
                            oEmpleado.Correo             = txtCorreo.Text;
                            oEmpleado.Contrasena         = txtContrasena.Text;
                            oEmpleado.Tanda_laboral      = cmbTandaLaboral.Text;
                            oEmpleado.Porciento_Comision = Convert.ToInt32(nudPorcientoComision.Value);
                            oEmpleado.Fecha_Ingreso      = dtpFechaIngreso.Value;
                            oEmpleado.Estado             = cmbEstado.Text;

                            if (Id_Empleado == null)
                            {
                                db.Empleados.Add(oEmpleado);
                            }
                            else
                            {
                                db.Entry(oEmpleado).State = System.Data.Entity.EntityState.Modified;
                            }
                            db.SaveChanges();
                            MessageBox.Show("Guardado exitosamente");
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cedula es invalida.");
                    }
                }
            }
        }
示例#6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    if (Id_Vehiculo == null)
                    {
                        oVehiculo = new Models.Vehiculo();
                    }

                    if (txtDescripcion.Text.Trim().Equals("") || txtNoChasis.Text.Trim().Equals("") || txtNoMotor.Text.Trim().Equals("") ||
                        txtNoPlaca.Text.Trim().Equals("") || cmbTipoVehiculo.Text.Trim().Equals("") || cmbMarca.Text.Trim().Equals("") ||
                        cmbModelo.Text.Trim().Equals("") || cmbTipoCombustible.Text.Trim().Equals("") || cmbEstado.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Por favor, llenar todos los campos.");
                    }
                    else
                    {
                        var exists = db.Vehiculos.Any(x => x.No_Placa.Equals(txtNoPlaca.Text) || x.No_Chasis.Equals(txtNoChasis.Text));

                        if (exists && Id_Vehiculo == null)
                        {
                            MessageBox.Show("Este vehículo ya habia sido registrado.");
                            return;
                        }
                        else
                        {
                            oVehiculo.Descripcion      = txtDescripcion.Text;
                            oVehiculo.No_Chasis        = txtNoChasis.Text;
                            oVehiculo.No_Motor         = txtNoMotor.Text;
                            oVehiculo.No_Placa         = txtNoPlaca.Text;
                            oVehiculo.Tipo_Vehiculo    = Convert.ToInt32(cmbTipoVehiculo.SelectedValue.ToString());
                            oVehiculo.Marca            = Convert.ToInt32(cmbMarca.SelectedValue.ToString());
                            oVehiculo.Modelo           = Convert.ToInt32(cmbModelo.SelectedValue.ToString());
                            oVehiculo.Tipo_Combustible = Convert.ToInt32(cmbTipoCombustible.SelectedValue.ToString());
                            oVehiculo.Estado           = cmbEstado.Text;

                            if (Id_Vehiculo == null)
                            {
                                db.Vehiculos.Add(oVehiculo);
                            }
                            else
                            {
                                db.Entry(oVehiculo).State = System.Data.Entity.EntityState.Modified;
                            }
                            db.SaveChanges();
                            MessageBox.Show("Guardado exitosamente");
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#7
0
 private void LoadData()
 {
     using (rentcarEntities db = new rentcarEntities())
     {
         oMarca = db.Marcas.Find(Id_Marca);
         txtDescripcion.Text = oMarca.Descripcion;
         cmbEstado.Text      = oMarca.Estado;
     }
 }
示例#8
0
        private void LoadData()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                oVehiculo = db.Vehiculos.Find(Id_Vehiculo);

                txtDescripcion.Text = oVehiculo.Descripcion;
                txtNoChasis.Text    = oVehiculo.No_Chasis;
                txtNoMotor.Text     = oVehiculo.No_Motor;
                txtNoPlaca.Text     = oVehiculo.No_Placa;
                cmbEstado.Text      = oVehiculo.Estado;

                var marcas        = db.Marcas.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Marca, x.Descripcion }).ToList();
                var marcaSelected = db.Marcas.Where(w => w.Id_Marca == oVehiculo.Marca).Select(x => new { x.Id_Marca, x.Descripcion }).FirstOrDefault();

                marcas.Insert(0, marcaSelected);
                marcas = marcas.Distinct().ToList();

                cmbMarca.DataSource    = marcas;
                cmbMarca.DisplayMember = "Descripcion";
                cmbMarca.ValueMember   = "Id_Marca";
                cmbMarca.SelectedItem  = marcaSelected;

                var modelos        = db.Modelos.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Modelo, x.Descripcion }).ToList();
                var modeloSelected = db.Modelos.Where(w => w.Id_Modelo == oVehiculo.Modelo).Select(x => new { x.Id_Modelo, x.Descripcion }).FirstOrDefault();

                modelos.Insert(0, modeloSelected);
                modelos = modelos.Distinct().ToList();

                cmbModelo.DataSource    = modelos;
                cmbModelo.DisplayMember = "Descripcion";
                cmbModelo.ValueMember   = "Id_Modelo";
                cmbModelo.SelectedItem  = modeloSelected;

                var combustibles        = db.Tipos_Combustibles.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Tipos_Combustible, x.Descripcion }).ToList();
                var combustibleSelected = db.Tipos_Combustibles.Where(w => w.Id_Tipos_Combustible == oVehiculo.Tipo_Combustible).Select(x => new { x.Id_Tipos_Combustible, x.Descripcion }).FirstOrDefault();

                combustibles.Insert(0, combustibleSelected);
                combustibles = combustibles.Distinct().ToList();

                cmbTipoCombustible.DataSource    = combustibles;
                cmbTipoCombustible.DisplayMember = "Descripcion";
                cmbTipoCombustible.ValueMember   = "Id_Tipos_Combustible";
                cmbTipoCombustible.SelectedItem  = combustibleSelected;

                var tiposvehiculos = db.Tipos_Vehiculos.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Tipos_Vehiculo, x.Descripcion }).ToList();
                var tipoSelected   = db.Tipos_Vehiculos.Where(w => w.Id_Tipos_Vehiculo == oVehiculo.Tipo_Vehiculo).Select(x => new { x.Id_Tipos_Vehiculo, x.Descripcion }).FirstOrDefault();

                tiposvehiculos.Insert(0, tipoSelected);
                tiposvehiculos = tiposvehiculos.Distinct().ToList();

                cmbTipoVehiculo.DataSource    = tiposvehiculos;
                cmbTipoVehiculo.DisplayMember = "Descripcion";
                cmbTipoVehiculo.ValueMember   = "Id_Tipos_Vehiculo";
                cmbTipoVehiculo.SelectedItem  = tipoSelected;
            }
        }
示例#9
0
 private void LoadData()
 {
     using (rentcarEntities db = new rentcarEntities())
     {
         oTipos_Combustibles = db.Tipos_Combustibles.Find(Id_Tipos_Combustible);
         txtDescripcion.Text = oTipos_Combustibles.Descripcion;
         cmbEstado.Text      = oTipos_Combustibles.Estado;
     }
 }
示例#10
0
        private void LoadData()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                oInspeccione = db.Inspecciones.Find(Id_Transaccion);

                cmbCantidadCombustible.Text = oInspeccione.Cantidad_Combustible;
                cmbEstadoGomaA.Text         = oInspeccione.Estado_GomaA;
                cmbEstadoGomaB.Text         = oInspeccione.Estado_GomaB;
                cmbEstadoGomaC.Text         = oInspeccione.Estado_GomaC;
                cmbEstadoGomaD.Text         = oInspeccione.Estado_GomaD;
                dtpInspeccion.Value         = oInspeccione.Fecha;
                cmbEstado.Text       = oInspeccione.Estado;
                ckRalladuras.Checked = oInspeccione.Tiene_Ralladuras == "Si" ? true : false;
                ckRespuesta.Checked  = oInspeccione.Tiene_Goma_respuesta == "Si" ? true : false;
                ckGato.Checked       = oInspeccione.Tiene_Gato == "Si" ? true : false;
                ckRoturas.Checked    = oInspeccione.Tiene_Roturas_Cristal == "Si" ? true : false;


                var empleados   = db.Empleados.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Empleado, Empleado = x.Nombre + " " + x.Apellido }).ToList();
                var empSelected = db.Empleados.Where(w => w.Id_Empleado == oInspeccione.Empleado_Inspeccion).Select(x => new { x.Id_Empleado, Empleado = x.Nombre + " " + x.Apellido }).FirstOrDefault();

                empleados.Insert(0, empSelected);
                empleados = empleados.Distinct().ToList();

                cmbEmpleado.DataSource    = empleados;
                cmbEmpleado.DisplayMember = "Empleado";
                cmbEmpleado.ValueMember   = "Id_Empleado";
                cmbEmpleado.SelectedItem  = empSelected;


                var vehiculos        = db.Vehiculos.Where(x => x.Estado == "Disponible").Select(x => new { x.Id_Vehiculo, Vehiculo = x.Descripcion + " - " + x.No_Placa }).ToList();
                var vehiculoSelected = db.Vehiculos.Where(w => w.Id_Vehiculo == oInspeccione.Vehiculo).Select(x => new { x.Id_Vehiculo, Vehiculo = x.Descripcion + " - " + x.No_Placa }).ToList().FirstOrDefault();

                vehiculos.Insert(0, vehiculoSelected);
                vehiculos = vehiculos.Distinct().ToList();

                cmbVehiculo.DataSource    = vehiculos;
                cmbVehiculo.DisplayMember = "Vehiculo";
                cmbVehiculo.ValueMember   = "Id_Vehiculo";
                cmbVehiculo.SelectedItem  = vehiculoSelected;


                var clientes        = db.Clientes.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Cliente, Cliente = x.Nombre + " " + x.Apellido }).ToList();
                var clienteSelected = db.Clientes.Where(w => w.Id_Cliente == oInspeccione.Id_Cliente).Select(x => new { x.Id_Cliente, Cliente = x.Nombre + " " + x.Apellido }).ToList().FirstOrDefault();

                clientes.Insert(0, clienteSelected);
                clientes = clientes.Distinct().ToList();

                cmbCliente.DataSource    = clientes;
                cmbCliente.DisplayMember = "Cliente";
                cmbCliente.ValueMember   = "Id_Cliente";
                cmbCliente.SelectedItem  = vehiculoSelected;
            }
        }
示例#11
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    if (Id_Modelo == null)
                    {
                        oModelo = new Models.Modelo();
                    }

                    if (cmbMarca.Text.Trim().Equals("") || txtDescripcion.Text.Trim().Equals("") || cmbEstado.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Por favor, llenar todos los campos.");
                    }
                    else
                    {
                        var exists = db.Modelos.Any(x => x.Descripcion.Equals(txtDescripcion.Text));

                        if (exists && Id_Modelo == null)
                        {
                            MessageBox.Show("Esta marca ya esta registrada.");
                            return;
                        }
                        else
                        {
                            oModelo.Id_Marca    = Convert.ToInt32(cmbMarca.SelectedValue.ToString());
                            oModelo.Descripcion = txtDescripcion.Text;
                            oModelo.Estado      = cmbEstado.Text;

                            if (Id_Modelo == null)
                            {
                                db.Modelos.Add(oModelo);
                            }
                            else
                            {
                                db.Entry(oModelo).State = System.Data.Entity.EntityState.Modified;
                            }
                            db.SaveChanges();
                            MessageBox.Show("Guardado exitosamente.");
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#12
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    if (Id_Tipos_Combustible == null)
                    {
                        oTipos_Combustibles = new Models.Tipos_Combustibles();
                    }

                    if (txtDescripcion.Text.Trim().Equals("") || cmbEstado.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Por favor, llenar todos los campos.");
                    }
                    else
                    {
                        var exists = db.Tipos_Combustibles.Any(x => x.Descripcion.Equals(txtDescripcion.Text));

                        if (exists && Id_Tipos_Combustible == null)
                        {
                            MessageBox.Show("Este tipo de combustible ya habia sido registrado.");
                            return;
                        }
                        else
                        {
                            oTipos_Combustibles.Descripcion = txtDescripcion.Text;
                            oTipos_Combustibles.Estado      = cmbEstado.Text;

                            if (Id_Tipos_Combustible == null)
                            {
                                db.Tipos_Combustibles.Add(oTipos_Combustibles);
                            }
                            else
                            {
                                db.Entry(oTipos_Combustibles).State = System.Data.Entity.EntityState.Modified;
                            }
                            db.SaveChanges();
                            MessageBox.Show("Guardado exitosamente");
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#13
0
        private void LoadData()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                oCliente = db.Clientes.Find(Id_Cliente);

                txtNombre.Text         = oCliente.Nombre;
                txtApellido.Text       = oCliente.Apellido;
                txtCedula.Text         = oCliente.Cedula;
                txtNoTarjetaCR.Text    = oCliente.No_Tarjeta_CR;
                nudLimiteCredito.Value = oCliente.Limite_Credito;
                cmbTipoPersona.Text    = oCliente.Tipo_Persona;
                cmbEstado.Text         = oCliente.Estado;
            }
        }
示例#14
0
        private void FillCombo()
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    var tipos = db.Tipos_Vehiculos.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Tipos_Vehiculo, x.Descripcion }).ToList();
                    cmbTipoVehiculo.DataSource    = tipos;
                    cmbTipoVehiculo.DisplayMember = "Descripcion";
                    cmbTipoVehiculo.ValueMember   = "Id_Tipos_Vehiculo";
                    if (cmbTipoVehiculo.Items.Count > 1)
                    {
                        cmbTipoVehiculo.SelectedIndex = -1;
                    }

                    var marcas = db.Marcas.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Marca, x.Descripcion }).ToList();
                    cmbMarca.DataSource    = marcas;
                    cmbMarca.DisplayMember = "Descripcion";
                    cmbMarca.ValueMember   = "Id_Marca";
                    if (cmbMarca.Items.Count > 1)
                    {
                        cmbMarca.SelectedIndex = -1;
                    }

                    var modelos = db.Modelos.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Modelo, x.Descripcion }).ToList();
                    cmbModelo.DataSource    = modelos;
                    cmbModelo.DisplayMember = "Descripcion";
                    cmbModelo.ValueMember   = "Id_Modelo";
                    if (cmbModelo.Items.Count > 1)
                    {
                        cmbModelo.SelectedIndex = -1;
                    }

                    var combustibles = db.Tipos_Combustibles.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Tipos_Combustible, x.Descripcion }).ToList();
                    cmbTipoCombustible.DataSource    = combustibles;
                    cmbTipoCombustible.DisplayMember = "Descripcion";
                    cmbTipoCombustible.ValueMember   = "Id_Tipos_Combustible";
                    if (cmbTipoCombustible.Items.Count > 1)
                    {
                        cmbTipoCombustible.SelectedIndex = -1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#15
0
        private void LoadData()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                oRenta = db.Renta_Devolucion.Find(Id_Renta);

                dtpRenta.Value        = oRenta.Fecha_Renta;
                dtpDevolucion.Value   = oRenta.Fecha_Devolucion;
                nudMontoxDia.Value    = oRenta.MontoxDia;
                nudCantidadDias.Value = oRenta.Cantidad_Dias;
                txtComentario.Text    = oRenta.Comentario;
                cmbEstado.Text        = oRenta.Estado;

                var empleados   = db.Empleados.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Empleado, Empleado = x.Nombre + " " + x.Apellido }).ToList();
                var empSelected = db.Empleados.Where(w => w.Id_Empleado == oRenta.Empleado).Select(x => new { x.Id_Empleado, Empleado = x.Nombre + " " + x.Apellido }).FirstOrDefault();

                empleados.Insert(0, empSelected);
                empleados = empleados.Distinct().ToList();

                cmbEmpleado.DataSource    = empleados;
                cmbEmpleado.DisplayMember = "Empleado";
                cmbEmpleado.ValueMember   = "Id_Empleado";
                cmbEmpleado.SelectedItem  = empSelected;

                var vehiculos        = db.Vehiculos.Where(x => x.Estado == "Disponible").Select(x => new { x.Id_Vehiculo, Vehiculo = x.Descripcion + " - " + x.No_Placa }).ToList();
                var vehiculoSelected = db.Vehiculos.Where(w => w.Id_Vehiculo == oRenta.Vehiculo).Select(x => new { x.Id_Vehiculo, Vehiculo = x.Descripcion + " - " + x.No_Placa }).ToList().FirstOrDefault();

                vehiculos.Insert(0, vehiculoSelected);
                vehiculos = vehiculos.Distinct().ToList();

                cmbVehiculo.DataSource    = vehiculos;
                cmbVehiculo.DisplayMember = "Vehiculo";
                cmbVehiculo.ValueMember   = "Id_Vehiculo";
                cmbVehiculo.SelectedItem  = vehiculoSelected;

                var clientes        = db.Clientes.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Cliente, Cliente = x.Nombre + " " + x.Apellido }).ToList();
                var clienteSelected = db.Clientes.Where(w => w.Id_Cliente == oRenta.Cliente).Select(x => new { x.Id_Cliente, Cliente = x.Nombre + " " + x.Apellido }).ToList().FirstOrDefault();

                clientes.Insert(0, clienteSelected);
                clientes = clientes.Distinct().ToList();

                cmbCliente.DataSource    = clientes;
                cmbCliente.DisplayMember = "Cliente";
                cmbCliente.ValueMember   = "Id_Cliente";
                cmbCliente.SelectedItem  = vehiculoSelected;
            }
        }
示例#16
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Renta in db.Renta_Devolucion
                           join Empleados in db.Empleados
                           on Renta.Empleado equals Empleados.Id_Empleado
                           join Vehiculos in db.Vehiculos
                           on Renta.Vehiculo equals Vehiculos.Id_Vehiculo
                           join Clientes in db.Clientes
                           on Renta.Cliente equals Clientes.Id_Cliente
                           where DbFunctions.TruncateTime(Renta.Fecha_Renta) == DbFunctions.TruncateTime(dtpFechaRenta.Value)
                           select new
                {
                    Id = Renta.No_Renta,
                    Placa = Vehiculos.No_Placa,
                    Vehiculo = Vehiculos.Descripcion,
                    Cliente = Clientes.Nombre + " " + Clientes.Apellido,
                    CedulaCliente = Clientes.Cedula,
                    FechaRenta = Renta.Fecha_Renta,
                    FechaDevolucion = Renta.Fecha_Devolucion,
                    MontoxDia = Renta.MontoxDia,
                    Dias = Renta.Cantidad_Dias,
                    EstadoVehiculo = Vehiculos.Estado,
                    Comentario = Renta.Comentario,
                    Empleado = Empleados.Nombre + " " + Empleados.Apellido,
                    CedulaEmpleado = Empleados.Cedula,
                    Estado = Renta.Estado
                }).AsQueryable();

                if (!txtCedulaCliente.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.CedulaCliente.Contains(txtCedulaCliente.Text.Trim()));
                }

                if (!txtCedulaEmpleado.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.CedulaEmpleado.Contains(txtCedulaEmpleado.Text.Trim()));
                }
                if (!txtPlaca.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Placa.Contains(txtPlaca.Text.Trim()));
                }
                dataGridView1.DataSource = lst.ToList();
            }
        }
示例#17
0
        private void LoadData()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                oEmpleado = db.Empleados.Find(Id_Empleado);

                txtNombre.Text             = oEmpleado.Nombre;
                txtApellido.Text           = oEmpleado.Apellido;
                txtCedula.Text             = oEmpleado.Cedula;
                txtCorreo.Text             = oEmpleado.Correo;
                txtContrasena.Text         = oEmpleado.Contrasena;
                cmbTandaLaboral.Text       = oEmpleado.Tanda_laboral;
                nudPorcientoComision.Value = oEmpleado.Porciento_Comision;
                dtpFechaIngreso.Value      = oEmpleado.Fecha_Ingreso;
                cmbEstado.Text             = oEmpleado.Estado;
            }
        }
示例#18
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Marcas in db.Marcas
                           select new { Id = Marcas.Id_Marca,
                                        Descripcion = Marcas.Descripcion,
                                        Estado = Marcas.Estado }).AsQueryable();

                if (!txtBusqueda.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Descripcion.Contains(txtBusqueda.Text.Trim()));
                }

                dataGridView1.DataSource = lst.ToList();
            }
        }
示例#19
0
        private void LoadData()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                oModelo             = db.Modelos.Find(Id_Modelo);
                txtDescripcion.Text = oModelo.Descripcion;
                cmbEstado.Text      = oModelo.Estado;

                var marcas        = db.Marcas.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Marca, x.Descripcion }).ToList();
                var marcaSelected = db.Marcas.Where(w => w.Id_Marca == oModelo.Id_Marca).Select(x => new { x.Id_Marca, x.Descripcion }).FirstOrDefault();

                marcas.Insert(0, marcaSelected);
                marcas = marcas.Distinct().ToList();

                cmbMarca.DataSource    = marcas;
                cmbMarca.DisplayMember = "Descripcion";
                cmbMarca.ValueMember   = "Id_Marca";
                cmbMarca.SelectedItem  = marcaSelected;
            }
        }
示例#20
0
 private void FillCombo()
 {
     try
     {
         using (rentcarEntities db = new rentcarEntities())
         {
             var marcas = db.Marcas.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Marca, x.Descripcion }).ToList();
             cmbMarca.DataSource    = marcas;
             cmbMarca.DisplayMember = "Descripcion";
             cmbMarca.ValueMember   = "Id_Marca";
             if (cmbMarca.Items.Count > 1)
             {
                 cmbMarca.SelectedIndex = -1;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#21
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Inspeccione in db.Inspecciones
                           join Vehiculos in db.Vehiculos
                           on Inspeccione.Vehiculo equals Vehiculos.Id_Vehiculo
                           join Clientes in db.Clientes
                           on Inspeccione.Id_Cliente equals Clientes.Id_Cliente
                           join Empleados in db.Empleados
                           on Inspeccione.Empleado_Inspeccion equals Empleados.Id_Empleado
                           select new
                {
                    Id = Inspeccione.Id_Transaccion,
                    Fecha = Inspeccione.Fecha,
                    Placa = Vehiculos.No_Placa,
                    Vehiculo = Vehiculos.Descripcion,
                    CedulaCliente = Clientes.Cedula,
                    Cliente = Clientes.Nombre + " " + Clientes.Apellido,
                    Combustible = Inspeccione.Cantidad_Combustible,
                    GomaA = Inspeccione.Estado_GomaA,
                    GomaB = Inspeccione.Estado_GomaB,
                    GomaC = Inspeccione.Estado_GomaC,
                    GomaD = Inspeccione.Estado_GomaD,
                    Ralladuras = Inspeccione.Tiene_Ralladuras,
                    Roturas = Inspeccione.Tiene_Roturas_Cristal,
                    Respuesta = Inspeccione.Tiene_Goma_respuesta,
                    Gato = Inspeccione.Tiene_Gato,
                    Empleado = Empleados.Nombre + " " + Empleados.Apellido,
                    Estado = Inspeccione.Estado
                }).AsQueryable();

                if (!txtBusqueda.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Placa.Contains(txtBusqueda.Text.Trim()));
                }

                dataGridView1.DataSource = lst.ToList();
            }
        }
示例#22
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Clientes in db.Clientes
                           select new { Id = Clientes.Id_Cliente,
                                        Nombre = Clientes.Nombre,
                                        Apellido = Clientes.Apellido,
                                        Cedula = Clientes.Cedula,
                                        Trajeta = Clientes.No_Tarjeta_CR,
                                        Credito = Clientes.Limite_Credito,
                                        Tipo_Persona = Clientes.Tipo_Persona,
                                        Estado = Clientes.Estado }).AsQueryable();

                if (!txtBusqueda.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Nombre.Contains(txtBusqueda.Text.Trim()));
                }

                dataGridView1.DataSource = lst.ToList();
            }
        }
示例#23
0
        private void FillCombo()
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    var empleados = db.Empleados.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Empleado, Empleado = x.Nombre + " " + x.Apellido }).ToList();
                    cmbEmpleado.DataSource    = empleados;
                    cmbEmpleado.DisplayMember = "Empleado";
                    cmbEmpleado.ValueMember   = "Id_Empleado";
                    if (cmbEmpleado.Items.Count > 1)
                    {
                        cmbEmpleado.SelectedIndex = -1;
                    }

                    var clientes = db.Clientes.Where(x => x.Estado == "Activo").Select(x => new { x.Id_Cliente, Cliente = x.Nombre + " " + x.Apellido }).ToList();
                    cmbCliente.DataSource    = clientes;
                    cmbCliente.DisplayMember = "Cliente";
                    cmbCliente.ValueMember   = "Id_Cliente";
                    if (cmbCliente.Items.Count > 1)
                    {
                        cmbCliente.SelectedIndex = -1;
                    }

                    var vehiculos = db.Vehiculos.Where(x => x.Estado == "Disponible").Select(x => new { x.Id_Vehiculo, Vehiculo = x.Descripcion + " - " + x.No_Placa }).ToList();
                    cmbVehiculo.DataSource    = vehiculos;
                    cmbVehiculo.DisplayMember = "Vehiculo";
                    cmbVehiculo.ValueMember   = "Id_Vehiculo";
                    if (cmbVehiculo.Items.Count > 1)
                    {
                        cmbVehiculo.SelectedIndex = -1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#24
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Empleados in db.Empleados
                           select new { Id = Empleados.Id_Empleado,
                                        Nombre = Empleados.Nombre, Apellido =
                                            Empleados.Apellido,
                                        Cedula = Empleados.Cedula,
                                        Correo = Empleados.Correo,
                                        Tanda = Empleados.Tanda_laboral,
                                        Comision = Empleados.Porciento_Comision,
                                        Fecha_Ingreso = Empleados.Fecha_Ingreso,
                                        Estado = Empleados.Estado }).AsQueryable();

                if (!txtBusqueda.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Nombre.Contains(txtBusqueda.Text.Trim()));
                }

                dataGridView1.DataSource = lst.ToList();
            }
        }
示例#25
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    if (Id_Cliente == null)
                    {
                        oCliente = new Models.Cliente();
                    }

                    if (txtNombre.Text.Trim().Equals("") || txtApellido.Text.Trim().Equals("") || txtCedula.Text.Trim().Equals("") ||
                        txtNoTarjetaCR.Text.Trim().Equals("") || cmbTipoPersona.Text.Trim().Equals("") || cmbEstado.Text.Trim().Equals("") || nudLimiteCredito.Value.Equals(""))
                    {
                        MessageBox.Show("Por favor, llenar todos los campos.");
                    }
                    else
                    {
                        if (cmbTipoPersona.SelectedItem.ToString() == "Fisica")
                        {
                            if (CheckCedula(txtCedula.Text))
                            {
                                if (txtNoTarjetaCR.Text.Length != 16)
                                {
                                    MessageBox.Show("La tarjeta de credito debe tener 16 digitos.");
                                }
                                else
                                {
                                    var exists = db.Clientes.Any(x => x.Cedula.Equals(txtCedula.Text));

                                    if (exists && Id_Cliente == null)
                                    {
                                        MessageBox.Show("Este cliente ya ha sido registrado.");
                                        return;
                                    }
                                    else
                                    {
                                        oCliente.Nombre         = txtNombre.Text;
                                        oCliente.Apellido       = txtApellido.Text;
                                        oCliente.Cedula         = txtCedula.Text;
                                        oCliente.No_Tarjeta_CR  = txtNoTarjetaCR.Text;
                                        oCliente.Limite_Credito = Convert.ToInt32(nudLimiteCredito.Value);
                                        oCliente.Tipo_Persona   = cmbTipoPersona.Text;
                                        oCliente.Estado         = cmbEstado.Text;

                                        if (Id_Cliente == null)
                                        {
                                            db.Clientes.Add(oCliente);
                                        }
                                        else
                                        {
                                            db.Entry(oCliente).State = System.Data.Entity.EntityState.Modified;
                                        }
                                        db.SaveChanges();
                                        MessageBox.Show("Guardado exitosamente");
                                        this.Close();
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("La cedula no es válida.");
                            }
                        }
                        else
                        {
                            if (CheckRNC(txtCedula.Text))
                            {
                                if (txtNoTarjetaCR.Text.Length != 16)
                                {
                                    MessageBox.Show("La tarjeta de credito debe tener 16 digitos.");
                                }
                                else
                                {
                                    var exists = db.Clientes.Any(x => x.Cedula.Equals(txtCedula.Text));

                                    if (exists && Id_Cliente == null)
                                    {
                                        MessageBox.Show("Este cliente ya ha sido registrado.");
                                        return;
                                    }
                                    else
                                    {
                                        oCliente.Nombre         = txtNombre.Text;
                                        oCliente.Apellido       = txtApellido.Text;
                                        oCliente.Cedula         = txtCedula.Text;
                                        oCliente.No_Tarjeta_CR  = txtNoTarjetaCR.Text;
                                        oCliente.Limite_Credito = Convert.ToInt32(nudLimiteCredito.Value);
                                        oCliente.Tipo_Persona   = cmbTipoPersona.Text;
                                        oCliente.Estado         = cmbEstado.Text;

                                        if (Id_Cliente == null)
                                        {
                                            db.Clientes.Add(oCliente);
                                        }
                                        else
                                        {
                                            db.Entry(oCliente).State = System.Data.Entity.EntityState.Modified;
                                        }
                                        db.SaveChanges();
                                        MessageBox.Show("Guardado exitosamente");
                                        this.Close();
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("El RNC no es válido.");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#26
0
        private void Refresh()
        {
            using (rentcarEntities db = new rentcarEntities())
            {
                var lst = (from Renta in db.Renta_Devolucion
                           join Empleados in db.Empleados
                           on Renta.Empleado equals Empleados.Id_Empleado
                           join Vehiculos in db.Vehiculos
                           on Renta.Vehiculo equals Vehiculos.Id_Vehiculo
                           join Clientes in db.Clientes
                           on Renta.Cliente equals Clientes.Id_Cliente
                           join Marcas in db.Marcas
                           on Vehiculos.Marca equals Marcas.Id_Marca
                           join Modelos in db.Modelos
                           on Vehiculos.Modelo equals Modelos.Id_Modelo
                           join Tipos_Combustibles in db.Tipos_Combustibles
                           on Vehiculos.Tipo_Combustible equals Tipos_Combustibles.Id_Tipos_Combustible
                           join Tipos_Vehiculos in db.Tipos_Vehiculos
                           on Vehiculos.Tipo_Vehiculo equals Tipos_Vehiculos.Id_Tipos_Vehiculo
                           where ckFechaRenta.Checked ? DbFunctions.TruncateTime(Renta.Fecha_Renta) >= DbFunctions.TruncateTime(dtpDesde.Value) &&
                           DbFunctions.TruncateTime(Renta.Fecha_Devolucion) <= DbFunctions.TruncateTime(dtpHasta.Value) : true
                           select new
                {
                    Id = Renta.No_Renta,
                    Vehiculo = Vehiculos.Descripcion,
                    EstadoVehiculo = Vehiculos.Estado,
                    Marca = Marcas.Descripcion,
                    Modelo = Modelos.Descripcion,
                    TipoVehiculo = Tipos_Vehiculos.Descripcion,
                    TipoCombustible = Tipos_Combustibles.Descripcion,
                    Cliente = Clientes.Nombre + " " + Clientes.Apellido,
                    CedulaCliente = Clientes.Cedula,
                    FechaRenta = Renta.Fecha_Renta,
                    FechaDevolucion = Renta.Fecha_Devolucion,
                    MontoxDia = Renta.MontoxDia,
                    Dias = Renta.Cantidad_Dias,
                    Comentario = Renta.Comentario,
                    Empleado = Empleados.Nombre + " " + Empleados.Apellido,
                    CedulaEmpleado = Empleados.Cedula,
                    Estado = Renta.Estado
                }).AsQueryable();

                if (!cmbTipoVehiculo.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.TipoVehiculo.Contains(cmbTipoVehiculo.Text.Trim()));
                }

                if (!cmbMarca.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Marca.Contains(cmbMarca.Text.Trim()));
                }

                if (!cmbModelo.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.Modelo.Contains(cmbModelo.Text.Trim()));
                }

                if (!cmbTipoCombustible.Text.Trim().Equals(""))
                {
                    lst = lst.Where(d => d.TipoCombustible.Contains(cmbTipoCombustible.Text.Trim()));
                }
                dataGridView2.DataSource = lst.ToList();
            }
        }
示例#27
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    if (Id_Renta == null)
                    {
                        oRenta = new Models.Renta_Devolucion();
                    }

                    if (cmbEmpleado.Text.Trim().Equals("") || cmbVehiculo.Text.Trim().Equals("") || cmbCliente.Text.Trim().Equals("") ||
                        cmbEstado.Text.Trim().Equals("") || dtpRenta.Text.Trim().Equals("") || dtpDevolucion.Text.Trim().Equals("") ||
                        nudMontoxDia.Text.Trim().Equals("") || nudCantidadDias.Text.Trim().Equals("") || txtComentario.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Por favor, llenar todos los campos.");
                    }
                    else
                    {
                        try
                        {
                            if (dtpRenta.Value > dtpDevolucion.Value)
                            {
                                MessageBox.Show("Debe seleccionar una fecha de devolución mayor a la de renta.");
                            }
                            else
                            {
                                oRenta.Empleado         = Convert.ToInt32(cmbEmpleado.SelectedValue.ToString());
                                oRenta.Vehiculo         = Convert.ToInt32(cmbVehiculo.SelectedValue.ToString());
                                oRenta.Cliente          = Convert.ToInt32(cmbCliente.SelectedValue.ToString());
                                oRenta.Fecha_Renta      = dtpRenta.Value;
                                oRenta.Fecha_Devolucion = dtpDevolucion.Value;
                                oRenta.MontoxDia        = Convert.ToInt32(nudMontoxDia.Value);
                                oRenta.Cantidad_Dias    = Convert.ToInt32(nudCantidadDias.Value);
                                oRenta.Comentario       = txtComentario.Text;
                                oRenta.Estado           = cmbEstado.Text;

                                if (Id_Renta == null)
                                {
                                    db.Renta_Devolucion.Add(oRenta);
                                }
                                else
                                {
                                    db.Entry(oRenta).State = System.Data.Entity.EntityState.Modified;
                                }
                                db.SaveChanges();
                                MessageBox.Show("Guardado exitosamente");
                                this.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#28
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (rentcarEntities db = new rentcarEntities())
                {
                    if (Id_Transaccion == null)
                    {
                        oInspeccione = new Models.Inspeccione();
                    }

                    if (cmbVehiculo.Text.Trim().Equals("") || cmbCliente.Text.Trim().Equals("") || cmbCantidadCombustible.Text.Trim().Equals("") ||
                        cmbEstadoGomaA.Text.Trim().Equals("") || cmbEstadoGomaB.Text.Trim().Equals("") || cmbEstadoGomaC.Text.Trim().Equals("") ||
                        cmbEstadoGomaD.Text.Trim().Equals("") || dtpInspeccion.Text.Trim().Equals("") || cmbEmpleado.Text.Trim().Equals("") ||
                        cmbEstado.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Por favor, llenar todos los campos.");
                    }
                    else
                    {
                        oInspeccione.Vehiculo             = Convert.ToInt32(cmbVehiculo.SelectedValue.ToString());
                        oInspeccione.Id_Cliente           = Convert.ToInt32(cmbCliente.SelectedValue.ToString());
                        oInspeccione.Cantidad_Combustible = cmbCantidadCombustible.Text;
                        oInspeccione.Estado_GomaA         = cmbEstadoGomaA.Text;
                        oInspeccione.Estado_GomaB         = cmbEstadoGomaB.Text;
                        oInspeccione.Estado_GomaC         = cmbEstadoGomaC.Text;
                        oInspeccione.Estado_GomaD         = cmbEstadoGomaD.Text;
                        oInspeccione.Fecha = dtpInspeccion.Value;
                        oInspeccione.Empleado_Inspeccion = Convert.ToInt32(cmbEmpleado.SelectedValue.ToString());
                        oInspeccione.Estado = cmbEstado.Text;

                        if (ckRalladuras.Checked)
                        {
                            oInspeccione.Tiene_Ralladuras = "Si";
                        }
                        else
                        {
                            oInspeccione.Tiene_Ralladuras = "No";
                        }

                        if (ckRespuesta.Checked)
                        {
                            oInspeccione.Tiene_Goma_respuesta = "Si";
                        }
                        else
                        {
                            oInspeccione.Tiene_Goma_respuesta = "No";
                        }

                        if (ckGato.Checked)
                        {
                            oInspeccione.Tiene_Gato = "Si";
                        }
                        else
                        {
                            oInspeccione.Tiene_Gato = "No";
                        }

                        if (ckRoturas.Checked)
                        {
                            oInspeccione.Tiene_Roturas_Cristal = "Si";
                        }
                        else
                        {
                            oInspeccione.Tiene_Roturas_Cristal = "No";
                        }

                        if (Id_Transaccion == null)
                        {
                            db.Inspecciones.Add(oInspeccione);
                        }
                        else
                        {
                            db.Entry(oInspeccione).State = System.Data.Entity.EntityState.Modified;
                        }
                        db.SaveChanges();
                        MessageBox.Show("Guardado exitosamente");
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }