当前位置: 首页>>代码示例>>C#>>正文


C# DBConnection.Select方法代码示例

本文整理汇总了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;
 }
开发者ID:jesusvm,项目名称:delegacion-app,代码行数:10,代码来源:Usuario.cs

示例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;
 }
开发者ID:jesusvm,项目名称:delegacion-app,代码行数:10,代码来源:Rol.cs

示例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());
                }
            }
        }
开发者ID:jesusvm,项目名称:delegacion-app,代码行数:29,代码来源:Usuario.cs

示例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;
        }
开发者ID:jesusvm,项目名称:delegacion-app,代码行数:17,代码来源:Usuario.cs

示例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();
        }
开发者ID:jesusvm,项目名称:delegacion-app,代码行数:28,代码来源:Usuario.cs

示例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;
 }
开发者ID:jesusvm,项目名称:delegacion-app,代码行数:17,代码来源:Usuario.cs


注:本文中的DBConnection.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。