示例#1
0
        public void actualizar(Entrega entregaInstanciada)
        {
            AccesoDatos s = new AccesoDatos();

            conexion  = new SqlConnection(s.CadenaConexion());
            consulta  = new SqlCommand("update Entregas set codigoEncargado=@codigoEncargado, codigoVenta=@codigoVenta, fechaEntrega=@fechaEntrega, horaEntregaDesde=@horaEntregaDesde, horaEntregaHasta=@horaEntregaHasta, provincia=@provincia, departamento=@departamento, localidad=@localidad, calle=@calle, numero=@numero, codigoPostal=@codigoPostal, nombreBarrio=@nombreBarrio, tipoTelefono=@tipoTelefono, numeroTelefono=@numeroTelefono, descripcion=@descripcion, precio=@precio, distancia=@distancia where codigoEntrega=@codigoEntrega", conexion);
            adaptador = new SqlDataAdapter();
            adaptador.UpdateCommand = consulta;
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@codigoEntrega", SqlDbType.Int));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@codigoEncargado", SqlDbType.Int));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@codigoVenta", SqlDbType.Int));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@fechaEntrega", SqlDbType.Date));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@horaEntregaDesde", SqlDbType.Time));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@horaEntregaHasta", SqlDbType.Time));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@provincia", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@departamento", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@localidad", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@calle", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@numero", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@codigoPostal", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@nombreBarrio", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@tipoTelefono", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@numeroTelefono", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@descripcion", SqlDbType.VarChar));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@precio", SqlDbType.Money));
            adaptador.UpdateCommand.Parameters.Add(new SqlParameter("@distancia", SqlDbType.Float));

            adaptador.UpdateCommand.Parameters["@codigoEntrega"].Value    = entregaInstanciada.CodigoEntrega;
            adaptador.UpdateCommand.Parameters["@codigoEncargado"].Value  = entregaInstanciada.CodigoEncargado;
            adaptador.UpdateCommand.Parameters["@codigoVenta"].Value      = entregaInstanciada.Venta.CodigoVenta;
            adaptador.UpdateCommand.Parameters["@fechaEntrega"].Value     = entregaInstanciada.FechaEntrega.Date;
            adaptador.UpdateCommand.Parameters["@horaEntregaDesde"].Value = entregaInstanciada.HoraEntregaDesde.ToShortTimeString();
            adaptador.UpdateCommand.Parameters["@horaEntregaHasta"].Value = entregaInstanciada.HoraEntregaHasta.ToShortTimeString();
            adaptador.UpdateCommand.Parameters["@provincia"].Value        = entregaInstanciada.NombreProvincia;
            adaptador.UpdateCommand.Parameters["@departamento"].Value     = entregaInstanciada.NombreDepartamento;
            adaptador.UpdateCommand.Parameters["@localidad"].Value        = entregaInstanciada.NombreLocalidad;
            adaptador.UpdateCommand.Parameters["@calle"].Value            = entregaInstanciada.NombreCalle;
            adaptador.UpdateCommand.Parameters["@numero"].Value           = entregaInstanciada.NumeroCalle;
            adaptador.UpdateCommand.Parameters["@codigoPostal"].Value     = entregaInstanciada.CodigoPostal;
            adaptador.UpdateCommand.Parameters["@nombreBarrio"].Value     = entregaInstanciada.NombreBarrio;
            adaptador.UpdateCommand.Parameters["@tipoTelefono"].Value     = entregaInstanciada.NombreTipoTelefono;
            adaptador.UpdateCommand.Parameters["@numeroTelefono"].Value   = entregaInstanciada.NumeroTelefono;
            adaptador.UpdateCommand.Parameters["@descripcion"].Value      = entregaInstanciada.Descripcion;
            adaptador.UpdateCommand.Parameters["@precio"].Value           = entregaInstanciada.PrecioEntrega;
            adaptador.UpdateCommand.Parameters["@distancia"].Value        = entregaInstanciada.DistanciaEntrega;

            try
            {
                conexion.Open();
                adaptador.UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException excepcion)
            {
                //supuestamente se registra un log
                excepcion.ToString();
            }
            finally
            {
                conexion.Close();
            }
        }