Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string     x        = Request.QueryString["serial"];
            Vehiculito vehiculo = objGestion.consultarVehiculo(x);

            if (vehiculo != null)
            {
                Label9.Text  = vehiculo.placa;
                Label10.Text = vehiculo.color;
                Label16.Text = vehiculo.marca;
                Label11.Text = vehiculo.modelo;
                Label13.Text = vehiculo.serial;
            }
            else
            {
                Label9.Text  = "";
                Label10.Text = "";
                Label16.Text = "";
                Label11.Text = "";
                Label13.Text = "";
            }
        }
Exemplo n.º 2
0
        public Vehiculito consultarVehiculo(string serial)
        {
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
            {
                DataSource     = "lincecars123.database.windows.net",
                UserID         = "admin123",
                Password       = "******",
                InitialCatalog = "linceCars"
            };

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                connection.Open();
                SqlCommand comando = new SqlCommand();
                comando.Connection  = connection;
                comando.CommandText = "exec [dbo].[usp_ConsultaVeh] " + '"' + serial + '"';
                SqlDataReader registro = comando.ExecuteReader();

                if (registro.Read())
                {
                    Vehiculito vehiculo = new Vehiculito();
                    vehiculo.serial = registro.GetString(0);
                    vehiculo.placa  = registro.GetString(1);
                    vehiculo.color  = registro.GetString(2);
                    vehiculo.marca  = registro.GetString(3);
                    vehiculo.modelo = registro.GetString(4);
                    vehiculo.QR     = registro.GetString(5);
                    vehiculo.imagen = registro.GetString(6);
                    vehiculo.nitEmp = registro.GetInt64(7);
                    return(vehiculo);
                }
                else
                {
                    registro.Close();
                    return(null);
                }
            }
        }