Exemple #1
0
        private void BtnGuardarLicencia_Click(object sender, EventArgs e)
        {
            if (lstResultadoBusqueda.SelectedItems.Count > 0 && lstResultadoBusqueda.SelectedItems[0] != null)
            {
                ChoferBE chofer = lstResultadoBusqueda.SelectedItems[0].Tag as ChoferBE;
                chofer.FechaFinLicencia = dtpFechaFinLicencia.Value;
                try
                {
                    Chofer.Guardar(chofer);

                    MessageBox.Show(ObtenerLeyenda("msgLicenciaGuardada"));

                    LimpiarDetalles();
                    grpDetalles.Enabled = false;
                    grpLicencias.Enabled = false;
                    btnEditar.Enabled = false;
                    btnCargarLicencia.Enabled = false;
                    btnEliminar.Enabled = false;
                    lstResultadoBusqueda.Items.Clear();
                }
                catch
                {
                    MostrarError();
                }
            }
        }
        private void ActualizarChofer(Chofer chofer)
        {
            if (chofer.Activo == false)
            {
                MessageBox.Show("Este chofer no se encuentra activo");
                return;
            }

            _chofer = chofer;

            //Deuda Sistema
            //var deudaTotal = _clienteNegocio.DeudaTotal(_cliente.Id, this.Context.SucursalActual.Id);
            //var deudaVencida = _clienteNegocio.DeudaVencida(_cliente.Id, this.Context.SucursalActual.Id);
            _celularAnterior = Uow.Celulares.Listado(c => c.TiposCelulares).Where((c => c.Id == _chofer.CelularId && !c.Baja.HasValue)).FirstOrDefault();


            ucEstadoCuentaChofer.ActualizarChofer(_chofer);
            _celularAnterior = Uow.Celulares.Listado(c => c.TiposCelulares).Where(c => c.Id == chofer.CelularId).FirstOrDefault();
            if (_celularAnterior != null)
            {
                CelularAnterior = _celularAnterior.TiposCelulares.Tipo;
            }
            else
            {
                MessageBox.Show("Este chofer no tiene celular asociado");
            }
        }
Exemple #3
0
        public void guardarChofer(Chofer chofer)
        {
            SqlConnection conexion  = SqlGeneral.nuevaConexion();
            SqlCommand    ponerAuto = new SqlCommand("INSERT INTO SQLGROUP.Choferes (Chofer_Nombre, Chofer_Apellido, Chofer_Direccion, Chofer_Dni, Chofer_Telefono, Chofer_Mail, Chofer_Fecha_Nac, Chofer_Estado)" +
                                                     " VALUES (@nombre,@apellido,@direccion,@dni, @telefono,@mail,@nacimiento,@estado)", conexion);

            ponerAuto.Parameters.AddWithValue("@nombre", chofer.nombre);
            ponerAuto.Parameters.AddWithValue("@apellido", chofer.apellido);
            ponerAuto.Parameters.AddWithValue("@direccion", chofer.direccion);
            ponerAuto.Parameters.AddWithValue("@dni", chofer.dni);
            ponerAuto.Parameters.AddWithValue("@telefono", chofer.telefono);
            ponerAuto.Parameters.AddWithValue("@mail", chofer.mail);
            ponerAuto.Parameters.AddWithValue("@nacimiento", chofer.fechaNacimiento);
            ponerAuto.Parameters.AddWithValue("@estado", chofer.estado);
            conexion.Open();
            try
            {
                ponerAuto.ExecuteNonQuery();
                conexion.Close();
            }
            catch (Exception ex) {
                conexion.Close();
                throw ex;
            }
        }
 private void OnChoferSelected(Chofer chofer)
 {
     if (ChoferSelected != null)
     {
         ChoferSelected(this, chofer);
     }
 }
Exemple #5
0
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (Convert.ToDecimal(textBoxImporteTotal.Text) == 0)
         {
             throw new Exception("El importe no puede ser cero");
         }
         Rendicion rendicion     = new Rendicion();
         Chofer    chofer_mapper = new Chofer();
         Turno     turno_mapper  = new Turno();
         Viaje     viaje_mapper  = new Viaje();
         Chofer    chofer        = chofer_mapper.Mapear((comboBoxChofer.SelectedItem as dynamic).Value);
         Turno     turno         = turno_mapper.Mapear((comboBoxTurno.SelectedItem as dynamic).Value);
         rendicion.fecha   = dateTimePickerFecha.Value;
         rendicion.chofer  = chofer;
         rendicion.turno   = turno;
         rendicion.importe = Convert.ToDecimal(textBoxImporteTotal.Text);
         rendicion.viajes  = new List <Viaje>();
         foreach (DataGridViewRow row in dataGridView1.Rows)
         {
             int   viaje_id = Convert.ToInt32(row.Cells[0].Value);
             Viaje viaje    = viaje_mapper.Mapear(viaje_id);
             rendicion.viajes.Add(viaje);
         }
         string respuesta = rendicion.Guardar();
         MessageBox.Show(respuesta, "Guardado de rendicion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Hide();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error en guardado de rendicion", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("CI,Nombre,Telefono,Direccion")] Chofer chofer)
        {
            if (id != chofer.CI)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chofer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChoferExists(chofer.CI))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(chofer));
        }
        public async Task <IActionResult> Get([FromRoute] int id)
        {
            if (!ConexionOracle.Activa)
            {
                ConexionOracle.Open();
                if (!ConexionOracle.Activa)
                {
                    return(StatusCode(504, ConexionOracle.NoConResponse));
                }
            }
            Chofer c = await cmd.Get <Chofer>(id);

            if (c != null)
            {
                Persona p = await cmd.Get <Persona>(c.Rut);

                if (p != null)
                {
                    return(Ok(new PersonaChofer {
                        Chofer = c, Persona = p
                    }));
                }
            }
            return(BadRequest());
        }
Exemple #8
0
 public static bool modificarChofer(Chofer chofer)
 {
     try
     {
         SQLSentencia sentencia = new SQLSentencia();
         sentencia.Peticion = @"PA_Chofer_Update @id, @chofer, @estado";
         SqlParameter paramChofer = new SqlParameter();
         paramChofer.Value         = chofer.nombreChofer;
         paramChofer.ParameterName = "@chofer";
         paramChofer.SqlDbType     = System.Data.SqlDbType.VarChar;
         SqlParameter paramEstado = new SqlParameter();
         paramEstado.Value         = chofer.estadoChofer;
         paramEstado.ParameterName = "@estado";
         paramEstado.SqlDbType     = System.Data.SqlDbType.Bit;
         SqlParameter paramId = new SqlParameter();
         paramId.Value         = chofer.idChofer;
         paramId.ParameterName = "@id";
         paramId.SqlDbType     = System.Data.SqlDbType.Int;
         sentencia.lstParametros.Add(paramChofer);
         sentencia.lstParametros.Add(paramEstado);
         sentencia.lstParametros.Add(paramId);
         AD acceso = new AD();
         return(acceso.ejecutarSentecia(sentencia));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #9
0
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         int valueParsed;
         if (!Int32.TryParse(textBoxKilometrosRecorridos.Text.Trim(), out valueParsed))
         {
             throw new Exception("Debe ingresar una cantidad de kilometros del tipo numerico");
         }
         Viaje     viaje            = new Viaje();
         Chofer    chofer_mapper    = new Chofer();
         Turno     turno_mapper     = new Turno();
         Cliente   cliente_mapper   = new Cliente();
         Automovil automovil_mapper = new Automovil();
         Chofer    chofer           = chofer_mapper.Mapear((comboBoxChofer.SelectedItem as dynamic).Value);
         Turno     turno            = turno_mapper.Mapear((comboBoxTurno.SelectedItem as dynamic).Value);
         Cliente   cliente          = cliente_mapper.Mapear((comboBoxCliente.SelectedItem as dynamic).Value);
         Automovil automovil        = automovil_mapper.Mapear((comboBoxAutomovil.SelectedItem as dynamic).Value);
         viaje.chofer              = chofer;
         viaje.automovil           = automovil;
         viaje.turno               = turno;
         viaje.cantidad_kilometros = Convert.ToInt32(textBoxKilometrosRecorridos.Text);
         viaje.fecha_inicio        = dateTimePickerFechaInicio.Value;
         viaje.fecha_fin           = dateTimePickerFechaFin.Value;
         viaje.cliente             = cliente;
         string respuesta = viaje.Guardar();
         MessageBox.Show(respuesta, "Guardado de viaje", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Hide();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error en guardado de Registro de viaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #10
0
        public static DataTable filtrarChoferesHabilitados(Chofer chofer)
        {
            try
            {
                conectar();

                sqlCommand = new SqlCommand();

                sqlCommand.CommandText = "SELECT id_usuario, nombre, apellido, usuario_dni, mail, telefono, direccion, fecha_nacimiento, habilitado FROM NONAME.Chofer join NONAME.Usuario on id_Chofer = id_usuario WHERE habilitado = 1 And " + (String.IsNullOrEmpty(chofer.nombre) ? "1=1" : ("nombre like '%" + chofer.nombre) + "%'") + (chofer.dni == 0 ? " And 1=1" : (" And usuario_dni = '" + chofer.dni.ToString() + "'")) + (String.IsNullOrEmpty(chofer.apellido) ? " And 1=1" : (" And apellido like '%" + chofer.apellido.ToString() + "%'"));
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Connection  = miConexion;

                SqlDataReader sqlReader         = sqlCommand.ExecuteReader();
                DataTable     dataTableChoferes = new DataTable();
                dataTableChoferes.Load(sqlReader);
                return(dataTableChoferes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                desconectar();
            }
        }
Exemple #11
0
 public static bool agregarChofer(Chofer chofer)
 {
     try
     {
         //List<SqlParameter> lstparametros = new List<SqlParameter>();
         SQLSentencia sentencia = new SQLSentencia();
         sentencia.Peticion = @"EXEC PA_Choferes_Add @chofer, @estado";
         SqlParameter paramChofer = new SqlParameter();
         paramChofer.Value         = chofer.nombreChofer;
         paramChofer.ParameterName = "@chofer";
         paramChofer.SqlDbType     = System.Data.SqlDbType.VarChar;
         SqlParameter paramEstado = new SqlParameter();
         paramEstado.Value         = chofer.estadoChofer;
         paramEstado.ParameterName = "@estado";
         paramEstado.SqlDbType     = System.Data.SqlDbType.Bit;
         sentencia.lstParametros.Add(paramChofer);
         sentencia.lstParametros.Add(paramEstado);
         AD acceso = new AD();
         return(acceso.ejecutarSentecia(sentencia));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #12
0
        public static string eliminarChofer(Chofer chofer)
        {
            try
            {
                conectar();
                sqlCommand             = new SqlCommand("NONAME.sproc_chofer_baja");
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Connection  = miConexion;

                sqlCommand.Parameters.AddWithValue("@id_usuario", chofer.id_Chofer);

                int response = sqlCommand.ExecuteNonQuery();
                if (response > 0)
                {
                    return("Chofer eliminado correctamente");
                }
                else
                {
                    return("Fallo al eliminar el chofer: " + chofer.nombre + " " + chofer.apellido);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                desconectar();
            }
        }
Exemple #13
0
        public static void insertarChofer(Chofer chofer)
        {
            try
            {
                conectar();

                sqlCommand             = new SqlCommand("NONAME.sproc_chofer_alta");
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Connection  = miConexion;

                sqlCommand.Parameters.AddWithValue("@nombre", chofer.nombre);
                sqlCommand.Parameters.AddWithValue("@apellido", chofer.apellido);
                sqlCommand.Parameters.AddWithValue("@usuario_dni", chofer.dni);
                sqlCommand.Parameters.AddWithValue("@mail", chofer.mail);
                sqlCommand.Parameters.AddWithValue("@telefono", chofer.telefono);
                sqlCommand.Parameters.AddWithValue("@direccion", chofer.direccion);
                sqlCommand.Parameters.AddWithValue("@fecha_nacimiento", chofer.fechaNacimiento);

                sqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                desconectar();
            }
        }
Exemple #14
0
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            if (lstResultadoBusqueda.SelectedItems.Count > 0 && lstResultadoBusqueda.SelectedItems[0] != null)
            {
                try
                {
                    ChoferBE chofer = lstResultadoBusqueda.SelectedItems[0].Tag as ChoferBE;
                    Chofer.Borrar(chofer);

                    MessageBox.Show(ObtenerLeyenda("msgChoferBorrado"), string.Empty,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                    LimpiarDetalles();
                    grpDetalles.Enabled = false;
                    grpLicencias.Enabled = false;
                    btnEditar.Enabled = false;
                    btnCargarLicencia.Enabled = false;
                    btnEliminar.Enabled = false;
                    lstResultadoBusqueda.Items.Clear();
                }
                catch
                {
                    MostrarError();
                }
            }
        }
Exemple #15
0
        public async Task <ActionResult> Delete(string id)
        {
            try
            {
                var token = _session.GetString("Token");
                if (Seguridad.validarUsuarioAdministrativo(token))
                {
                    Chofer chofer = await _controladoraUsuarios.getChofer(id);

                    return(View(chofer));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "No posee los permisos. Inicie sesión");
                    return(RedirectToAction("Login"));
                }
            }
            catch (MensajeException msg)
            {
                ModelState.AddModelError(string.Empty, msg.Message);
                return(View());
            }
            catch (Exception)
            {
                ModelState.AddModelError(string.Empty, "Se produjo un error inesperado. Intente de nuevo mas tarde");
                return(View());
            }
        }
Exemple #16
0
        public DataTable getViajes(DateTime fecha, Chofer chofer, Turno turno)
        {
            List <Viaje>  viajes   = new List <Viaje>();
            SqlConnection conexion = SqlGeneral.nuevaConexion();
            SqlCommand    query    = new SqlCommand("SELECT Viaje_Id as 'Id', Viaje_Cant_Kilometros as 'Cantidad de kilometros', Viaje_Fecha_INIC as 'Fecha de inicio', Viaje_Fecha_Fin as 'Fecha de finalizacion', Viaje_Cliente_Id as 'Cliente id', SQLGROUP.getAutoPatente(Viaje_Auto_Id) as 'Auto Patente' , (Viaje_Cant_Kilometros*Turno_Valor_Kilometro)+Turno_Precio_Base as 'Precio del viaje'" +
                                                    " FROM SQLGROUP.Viajes, SQLGROUP.Turno WHERE Turno_Id = @turnoid AND Viaje_Chofer_Id = @id AND Viaje_Turno_Id = @turnoid AND DAY(@fecha)=DAY(Viaje_Fecha_INIC) AND MONTH(@fecha) = MONTH(Viaje_Fecha_INIC) AND YEAR(@fecha) = YEAR(Viaje_Fecha_INIC)", conexion);

            query.Parameters.AddWithValue("@fecha", fecha);
            query.Parameters.AddWithValue("@id", chofer.id);
            query.Parameters.AddWithValue("@turnoid", turno.id);
            conexion.Open();
            try
            {
                SqlDataAdapter da = new SqlDataAdapter(query);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                conexion.Close();
                return(dt);
            }
            catch (Exception ex)
            {
                conexion.Close();
                throw ex;
            }
        }
Exemple #17
0
        public async Task <ActionResult> Delete(string id, Chofer chofer)
        {
            try
            {
                var token = _session.GetString("Token");
                if (Seguridad.validarUsuarioAdministrativo(token))
                {
                    await _controladoraUsuarios.EliminarChofer(chofer, id);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            catch (MensajeException msg)
            {
                TempData["Error"] = msg.Message;
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                TempData["Error"] = "Se produjo un error inesperado. Intente de nuevo mas tarde";
                return(RedirectToAction("Index"));
            }
        }
Exemple #18
0
        private void FRMAutomovil_Load(object sender, EventArgs e)
        {
            this.CMBestado.Items.Add("Activo");
            this.CMBestado.Items.Add("Inactivo");
            if (!formularioPrecargado)
            {
                this.CMBestado.Text = "Activo"; BTNeliminar.Visible = false;
            }
            ;

            Dictionary <String, String> searchAll = new Dictionary <string, string>();

            marcas   = Marca.buscar(searchAll);
            turnos   = Turno.buscar(searchAll);
            choferes = Chofer.buscar(searchAll);

            //---Atributos que mostramos en los combos---
            marcas.ForEach(marca => CMBmarca.Items.Add(marca.Nombre));

            turnos.ForEach(turno => CMBturno.Items.Add(turno.Descripcion));

            choferes.ForEach(chofer => CMBChofer.Items.Add(chofer.Nombre));

            if (formularioPrecargado)
            {
                this.TXTpatente.Text = patente;
                this.CMBmarca.Text   = marcas.Find(marca => marca.IdMarca == idmarca).Nombre;
                this.TXTmodelo.Text  = idmodelo.ToString();
                this.CMBturno.Text   = turnos.Find(turno => turno.IdTurno == idturno).Descripcion;
                this.CMBestado.Text  = estado;
                this.CMBChofer.Text  = choferes.Find(chofer => chofer.Dni == idChofer).Nombre;
            }
        }
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            ChoferNegocio negocio = new ChoferNegocio();

            try
            {
                chofer = new Chofer();

                chofer.IdChofer        = int.Parse(txtID.Text.Trim());
                chofer.Legajo          = int.Parse(txtLegajo.Text.Trim());
                chofer.Apellido        = txtApellido.Text.Trim();
                chofer.Nombre          = txtNombre.Text.Trim();
                chofer.Sexo            = txtSexo.Text.Trim();
                chofer.FechaNacimiento = DateTime.Parse(txtFechaNac.Text.ToString());
                chofer.Estado          = "A";

                //if (chofer.IdChofer == 0)
                negocio.modificarChofer(chofer);


                Response.Redirect("Choferes.aspx");


                //else
                //    negocio.modificar(articulo);

                //Dispose();
            }
            catch (Exception EX)
            {
                throw EX;
            }
        }
Exemple #20
0
        public ActionResult Edit([Bind(Include = "choferId,nombres,apellidos,nroDocumentoIdentidad,tipoDocumentoIdentidadId,fechaNacimiento,numeroBrevete,proveedorId")] Chofer chofer)
        {
            if (ModelState.IsValid)
            {
                //foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones())
                //    Console.WriteLine(z.Id, z.BaseUtcOffset);

                DateTime     timeUtc = DateTime.UtcNow;
                TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
                DateTime     cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone);

                chofer.fechaModificacion   = cstTime;
                chofer.usuarioModificacion = User.Identity.Name;

                db.Entry(chofer).State = EntityState.Modified;
                db.Entry(chofer).Property(x => x.fechaCreacion).IsModified   = false;
                db.Entry(chofer).Property(x => x.usuarioCreacion).IsModified = false;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.proveedorId = new SelectList(db.Proveedores.OrderBy(a => a.razonSocial), "proveedorId", "razonSocial", chofer.proveedorId);
            ViewBag.tipoDocumentoIdentidadId = new SelectList(db.TiposDocumentoIdentidad.OrderBy(a => a.nombre), "tipoDocumentoIdentidadId", "nombre", chofer.tipoDocumentoIdentidadId);
            return(View(chofer));
        }
 public ComboBox Chofer(ComboBox combo, string chofer_nombre_apellido = "")
 {
     try
     {
         Chofer        chofer_mapper = new Chofer();
         List <Chofer> choferes      = chofer_mapper.ObtenerChoferes();
         combo.DisplayMember = "Text";
         combo.ValueMember   = "Value";
         combo.Items.Add(new { Text = "Seleccione el Chofer", Value = 0 });
         foreach (Chofer chofer in choferes)
         {
             combo.Items.Add(new { Text = chofer.nombre + ' ' + chofer.apellido, Value = chofer.id });
         }
         combo.SelectedIndex = 0;
         if (!String.IsNullOrWhiteSpace(chofer_nombre_apellido))
         {
             combo.SelectedIndex = combo.FindString(chofer_nombre_apellido);
         }
         return(combo);
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
        /*********************************** SELECCION DE DATOS PARA ASIGNACION DE RECORRIDO ***********************************/

        public Chofer seleccionChofer(List <Chofer> choferesRegistrados)
        {
            Chofer objChofer  = null;
            bool   boolEntrar = true;

            while (boolEntrar)
            {
                Console.Write("Seleccion:");
                try
                {
                    int intSeleccion = int.Parse(Console.ReadLine());

                    if (intSeleccion > choferesRegistrados.Count || intSeleccion <= 0)
                    {
                        throw new ExceptionSeleccionNoValida();
                    }
                    else
                    {
                        objChofer  = choferesRegistrados[intSeleccion - 1];
                        boolEntrar = false;
                    }
                }
                catch (ExceptionSeleccionNoValida e) { e.mensajeError(); }
                catch (FormatException) { Console.WriteLine("Solo se Permite la Seleccion con Numeros."); }
            }
            return(objChofer);
        }
Exemple #23
0
 private void OnEntityAgregada(Chofer entity)
 {
     if (EntityAgregada != null)
     {
         EntityAgregada(this, entity);
     }
 }
Exemple #24
0
        public void Update(Chofer chofer)
        {
            using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["SurfactanSA"].ToString()))
            {
                cnx.Open();
                const string sqlQuery =
                    "UPDATE Chofer SET Descripcion = @descr, CodigoEmpresa = @codigoemp, AplicaIII = @aplica,  FechaVtoI = @fechavtoI, FechaVtoII = @fechavtoII, FechaVtoIII = @fechavtoIII, OrdFechaVtoI = @ordFechaVtoI, OrdFechaVtoII = @ordFechaVtoII, OrdFechaVtoIII = @ordFechaVtoIII, FechaEntregaI = @fechaEntI, FechaEntregaII = @fechaEntII, FechaEntregaIII = @fechaEntIII, OrdFechaEntregaI = @ordFechEntI, OrdFechaEntregaII = @ordFechEntII, OrdFechaEntregaIII = @ordFechEntIII, ComentarioI = @comentI, ComentarioII = @comentII, ComentarioIII = @comentIII, Proveedor = @proveedor, Titulo = @titulo  WHERE Codigo = @codigo";
                using (SqlCommand cmd = new SqlCommand(sqlQuery, cnx))
                {
                    cmd.Parameters.AddWithValue("@codigo", chofer.Codigo);
                    cmd.Parameters.AddWithValue("@descr", chofer.Descripcion);
                    cmd.Parameters.AddWithValue("@codigoemp", chofer.CodigoEmpresa);
                    cmd.Parameters.AddWithValue("@aplica", chofer.Aplica);
                    cmd.Parameters.AddWithValue("@fechavtoI", chofer.FechaVto1);
                    cmd.Parameters.AddWithValue("@fechavtoII", chofer.FechaVto2);
                    cmd.Parameters.AddWithValue("@fechavtoIII", chofer.FechaVto3);
                    cmd.Parameters.AddWithValue("@ordFechaVtoI", chofer.OrdFechaVto1);
                    cmd.Parameters.AddWithValue("@ordFechaVtoII", chofer.OrdFechaVto2);
                    cmd.Parameters.AddWithValue("@ordFechaVtoIII", chofer.OrdFechaVto3);
                    cmd.Parameters.AddWithValue("@fechaEntI", chofer.FechaEnt1);
                    cmd.Parameters.AddWithValue("@fechaEntII", chofer.FechaEnt2);
                    cmd.Parameters.AddWithValue("@fechaEntIII", chofer.FechaEnt3);
                    cmd.Parameters.AddWithValue("@ordFechEntI", chofer.OrdFechaEnt1);
                    cmd.Parameters.AddWithValue("@ordFechEntII", chofer.OrdFechaEnt2);
                    cmd.Parameters.AddWithValue("@ordFechEntIII", chofer.OrdFechaEnt3);
                    cmd.Parameters.AddWithValue("@comentI", chofer.Comentario1);
                    cmd.Parameters.AddWithValue("@comentII", chofer.Comentario2);
                    cmd.Parameters.AddWithValue("@comentIII", chofer.Comentario3);
                    cmd.Parameters.AddWithValue("@proveedor", chofer.Proveedor);
                    cmd.Parameters.AddWithValue("@titulo", chofer.Titulo);

                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemple #25
0
        public Chofer AutorizarChofer(string correoElectronico, string password)
        {
            Chofer user = null;

            using (SqlCommand com = new SqlCommand($"SELECT TOP 1 u.id, u.nombre ,u.primerApellido, u.segundoApellido, u.contrasena, u.telefono, u.correoelectronico, u.token  FROM USUARIO u inner join chofer c on u.id = c.idUsuario where u.correoElectronico='{correoElectronico}' and u.contrasena='{password}'", db))
            {
                SqlDataReader reader = null;
                try
                {
                    reader = com.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        string id              = reader.GetString(0);
                        string nombre          = reader.GetString(1);
                        string primerApellido  = reader.GetString(2);
                        string segundoApellido = reader.GetString(3);
                        string telefono        = reader.GetString(5);
                        //string token = reader.GetString(7);
                        user = new Chofer(id, nombre, primerApellido, segundoApellido, telefono, correoElectronico, password);
                    }
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
            }
            return(user);
        }
        private void busquedaDeValores()
        {
            Dictionary <String, String> parametrosDeBusqueda = new Dictionary <string, string>();

            if (TXTnombre.Text != "")
            {
                parametrosDeBusqueda.Add("chofer_nombre", TXTnombre.Text);
            }
            if (TXTapellido.Text != "")
            {
                parametrosDeBusqueda.Add("chofer_apellido", TXTapellido.Text);
            }
            if (TXTdni.Text != "")
            {
                parametrosDeBusqueda.Add("chofer_dni", TXTdni.Text);
            }
            if (CHKsoloActivos.Checked)
            {
                parametrosDeBusqueda.Add("chofer_estado", "Activo");
            }

            List <Chofer> choferes = Chofer.buscar(parametrosDeBusqueda);

            construccionDeGridView(choferes);
        }
Exemple #27
0
        public void updateChofer(Chofer choferNuevo, int id)
        {
            SqlConnection conexion   = SqlGeneral.nuevaConexion();
            SqlCommand    updateAuto = new SqlCommand("UPDATE SQLGROUP.Choferes SET Chofer_Nombre = @nombre, Chofer_Apellido = @apellido, Chofer_Direccion = @direccion, Chofer_Dni = @dni, Chofer_Telefono = @telefono, Chofer_Mail = @mail, Chofer_Fecha_Nac = @nacimiento, Chofer_Estado = @estado WHERE Chofer_Id = @id", conexion);

            updateAuto.Parameters.AddWithValue("@nombre", choferNuevo.nombre);
            updateAuto.Parameters.AddWithValue("@apellido", choferNuevo.apellido);
            updateAuto.Parameters.AddWithValue("@direccion", choferNuevo.direccion);
            updateAuto.Parameters.AddWithValue("@dni", choferNuevo.dni);
            updateAuto.Parameters.AddWithValue("@telefono", choferNuevo.telefono);
            updateAuto.Parameters.AddWithValue("@mail", choferNuevo.mail);
            updateAuto.Parameters.AddWithValue("@nacimiento", choferNuevo.fechaNacimiento);
            updateAuto.Parameters.AddWithValue("@estado", choferNuevo.estado);
            updateAuto.Parameters.AddWithValue("@id", id);
            conexion.Open();
            try
            {
                updateAuto.ExecuteNonQuery();
                conexion.Close();
            }
            catch (Exception ex)
            {
                conexion.Close();
                throw ex;
            }
        }
Exemple #28
0
        private void tablaChoferes_DoubleClick(object sender, EventArgs e)
        {
            Chofer chofer = new Chofer();

            chofer.limpiarAtributos(chofer);

            // datos de interes para la interfaz
            chofer.Nombre         = this.tablaChoferes.CurrentRow.Cells["nombre"].Value.ToString();
            chofer.Apellido       = this.tablaChoferes.CurrentRow.Cells["apellido"].Value.ToString();
            chofer.DniString      = this.tablaChoferes.CurrentRow.Cells["dni"].Value.ToString();       // ojo es un int en realidad
            chofer.FechaNacString = this.tablaChoferes.CurrentRow.Cells["fecha_nac"].Value.ToString(); // ojo es un datetime en realidad
            chofer.TelefonoString = this.tablaChoferes.CurrentRow.Cells["telefono"].Value.ToString();  // ojo es un int en realidad
            chofer.Mail           = this.tablaChoferes.CurrentRow.Cells["mail"].Value.ToString();
            chofer.Direccion      = this.tablaChoferes.CurrentRow.Cells["direccion"].Value.ToString();
            chofer.Localidad      = this.tablaChoferes.CurrentRow.Cells["localidad"].Value.ToString();
            chofer.NroPisoString  = this.tablaChoferes.CurrentRow.Cells["nro_piso"].Value.ToString(); // ojo es un int en realidad
            chofer.Depto          = this.tablaChoferes.CurrentRow.Cells["depto"].Value.ToString();
            chofer.Estado         = this.tablaChoferes.CurrentRow.Cells["estado"].Value.ToString();

            // otros datos de interes
            chofer.Id         = Convert.ToInt32(this.tablaChoferes.CurrentRow.Cells["id_chofer"].Value);
            chofer.Habilitado = Convert.ToInt32(this.tablaChoferes.CurrentRow.Cells["habilitado"].Value);
            chofer.IdUsuario  = Convert.ToInt32(this.tablaChoferes.CurrentRow.Cells["id_usuario"].Value);

            Edicion ventana = new Edicion(chofer);

            ventana.ShowDialog(this);
        }
Exemple #29
0
        public static int Create(Chofer chofer)
        {
            context.Choferes.Add(chofer);
            int result = context.SaveChanges();

            return(result);
        }
Exemple #30
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            ChoferNuevo = new Chofer();
            ChoferNuevo.limpiarAtributos(ChoferNuevo);

            this.ChoferNuevo.Nombre         = this.txtNombreNuevo.Text;
            this.ChoferNuevo.Apellido       = this.txtApellidoNuevo.Text;
            this.ChoferNuevo.DniString      = this.txtDniNuevo.Text;
            this.ChoferNuevo.FechaNacString = this.txtFechaNacNueva.Text;
            this.ChoferNuevo.TelefonoString = this.txtTelefonoNuevo.Text;
            this.ChoferNuevo.Mail           = this.txtMailNuevo.Text;
            this.ChoferNuevo.Direccion      = this.txtDireccionNueva.Text;
            this.ChoferNuevo.Localidad      = this.txtLocalidadNueva.Text;
            this.ChoferNuevo.NroPisoString  = this.txtNroPisoNuevo.Text;
            this.ChoferNuevo.Depto          = this.txtDeptoNuevo.Text;
            this.ChoferNuevo.Estado         = this.cbxEstado.Text;

            this.ChoferNuevo.Id         = this.ChoferViejo.Id;
            this.ChoferNuevo.IdUsuario  = this.ChoferViejo.IdUsuario;
            this.ChoferNuevo.Habilitado = this.ChoferViejo.Habilitado;

            string mensaje = CapaInterfaz.IChofer.actualizarChofer(this.ChoferNuevo, this.ChoferViejo);

            CapaInterfaz.Decoracion.mostrarInfo(mensaje);

            this.Close();
        }