本文整理汇总了C#中DBConnection.Select方法的典型用法代码示例。如果您正苦于以下问题:C# DBConnection.Select方法的具体用法?C# DBConnection.Select怎么用?C# DBConnection.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection.Select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exists
public bool Exists(string usuario)
{
DataTable dt = new DataTable();
DBConnection dbconnectionObj = new DBConnection();
string query = @"select id from usuarios where usuario = @usuario";
dt = dbconnectionObj.Select(query,
new SqlParameter("@usuario", usuario)
);
return dt.Rows.Count > 0 ? true : false;
}
示例2: Get
public DataTable Get()
{
DataTable dt = new DataTable();
DBConnection dbconnectionObj = new DBConnection();
string query = @"
select id, nombre from roles
";
dt = dbconnectionObj.Select(query, null);
return dt;
}
示例3: FillSession
public void FillSession(string usuario)
{
DBConnection dbconnectionObj = new DBConnection();
string query = @"select
u.id as usuario_id,
u.usuario as usuario,
p.id as empleado_id,
p.num_placa,
p.nombre as nombre_personal,
p.delegacion_id
from
usuarios as u inner join personal as p on u.empleado_id = p.id
where u.usuario = @usuario";
DataTable dt = dbconnectionObj.Select(query,
new SqlParameter("@usuario", usuario)
);
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
Sesion.usuario_id = int.Parse(row["usuario_id"].ToString());
Sesion.empleado_id = int.Parse(row["empleado_id"].ToString());
Sesion.nombre_personal = row["nombre_personal"].ToString();
Sesion.num_placa = row["num_placa"].ToString();
Sesion.delegacion_id = int.Parse(row["delegacion_id"].ToString());
}
}
}
示例4: Login
/// <summary>
/// Login para el sistema
/// </summary>
/// <param name="usuario"></param>
/// <param name="pwd"></param>
/// <returns></returns>
public bool Login(string usuario, string pwd)
{
DBConnection dbconnectionObj = new DBConnection();
string query = "select usuario from usuarios where usuario = @usuario and pwd = HashBytes('MD5', cast(@pwd as varchar)) ";
DataTable dt = dbconnectionObj.Select(query,
new SqlParameter("@usuario", usuario),
new SqlParameter("@pwd", pwd));
return dt.Rows.Count > 0 ? true : false;
}
示例5: GetById
/// <summary>
/// Obtiene un usuario por el identificador
/// </summary>
/// <param name="usuario_id"></param>
/// <returns></returns>
public Usuario GetById(int usuario_id)
{
DataTable dt = new DataTable();
DBConnection dbconnectionObj = new DBConnection();
string query = @"select id, usuario, empleado_id, rol_id where [email protected]_id";
dt = dbconnectionObj.Select(query, null);
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
return new Usuario(
int.Parse(row["id"].ToString()),
row["usuario"].ToString(),
"",
int.Parse(row["empleado_id"].ToString()),
int.Parse(row["rol_id"].ToString())
);
}
}
return new Usuario();
}
示例6: Get
public DataTable Get()
{
DataTable dt = new DataTable();
DBConnection dbconnectionObj = new DBConnection();
string query = @"select
u.id as usuario_id,
u.usuario,
e.num_placa as 'Placa',
e.nombre as 'Nombre Empleado',
e.telefono,
r.nombre as rol
from
usuarios as u inner join personal as e on u.empleado_id = e.id
inner join roles as r on u.rol_id = r.id";
dt = dbconnectionObj.Select(query, null);
return dt;
}