Ejemplo n.º 1
0
        public bool CreateVehicle(string vehiculo, string marca, string linea, string modelo, string placa,
                                  string kilometraje, string motor, string ciudad, string precio, string url, string descripcion, int id_usuario)
        {
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "IngresarVehiculos";
            sqlCommand.Parameters.AddWithValue("@Vehiculo", vehiculo);
            sqlCommand.Parameters.AddWithValue("@Marca", marca);
            sqlCommand.Parameters.AddWithValue("@Linea", linea);
            sqlCommand.Parameters.AddWithValue("@Modelo", marca);
            sqlCommand.Parameters.AddWithValue("@Placa", placa);
            sqlCommand.Parameters.AddWithValue("@Kilometraje", kilometraje);
            sqlCommand.Parameters.AddWithValue("@Motor", motor);
            sqlCommand.Parameters.AddWithValue("@Ciudad", ciudad);
            sqlCommand.Parameters.AddWithValue("@Precio", precio);
            sqlCommand.Parameters.AddWithValue("@Url", url);
            sqlCommand.Parameters.AddWithValue("@Descripcion", descripcion);
            sqlCommand.Parameters.AddWithValue("@Id_Usuario", id_usuario);

            bool registroExitoso = conexionSQL.ExecuteStoreProcedure(sqlCommand);

            if (registroExitoso)
            {
                Mensaje = "Registro Exitoso";
                return(true);
            }
            else
            {
                Mensaje = conexionSQL.ErrorMessage;
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool Login(string usuario, string contrasena)
        {
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "validarUsuario";
            sqlCommand.Parameters.AddWithValue("@usuario", usuario);
            sqlCommand.Parameters.AddWithValue("@contrasena", contrasena);

            bool consultaExitosa = conexionSQL.ExecuteStoreProcedure(sqlCommand);

            sqlCommand = null;
            if (consultaExitosa)
            {
                if (conexionSQL.data.Rows.Count > 0)
                {
                    foreach (DataRow row in conexionSQL.data.Rows)
                    {
                        this.Nombre = row["nombre"].ToString();
                    }
                    return(true);
                }
                else
                {
                    this.Error = "Usuario o Contraseña incorrecta";
                    return(false);
                }
            }
            else
            {
                this.Error = conexionSQL.ErrorMessage;
                return(false);
            }
        }