Exemplo n.º 1
0
        public void Update(Accesos acc)
        {
            string cnx = db.Database.Connection.ConnectionString;

            con = new SqlConnection(cnx);
            try
            {
                comando = new SqlCommand("usp_AccesoUpdate", con);
                comando.Parameters.AddWithValue("@Id_Personal", acc.Id_Personal);
                comando.Parameters.AddWithValue("@Usuario", acc.Usuario);
                comando.Parameters.AddWithValue("@Clave", acc.Clave);
                comando.Parameters.AddWithValue("@Id_Acceso", acc.Id_Acceso);
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                con.Open();
                comando.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 2
0
        public Accesos BuscarAcceso(int codigo)
        {
            Accesos objacc = new Accesos();
            string  cnx    = db.Database.Connection.ConnectionString;

            con = new SqlConnection(cnx);
            bool   hayRegistros;
            string find = "select*from Accesos where Id_Acceso='" + codigo + "'";

            try
            {
                comando = new SqlCommand(find, con);
                con.Open();
                SqlDataReader reader = comando.ExecuteReader();
                hayRegistros = reader.Read();
                if (hayRegistros)
                {
                    objacc.Id_Personal = Convert.ToInt32(reader[1].ToString());
                    objacc.Usuario     = reader[2].ToString();
                    objacc.Clave       = reader[3].ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
            return(objacc);
        }
Exemplo n.º 3
0
        public bool Ingreso(Accesos ac, out string id, out string nombre, out string idcargo, out string cargo)
        {
            string cnx = db.Database.Connection.ConnectionString;

            con = new SqlConnection(cnx);
            bool   hay;
            string Ingresar = "select* from v_Acc where Usuario='" + ac.Usuario + "' and " + " Clave='" + ac.Clave + "'";

            try
            {
                comando = new SqlCommand(Ingresar, con);
                con.Open();
                reader = comando.ExecuteReader();
                hay    = reader.Read();
                if (hay)
                {
                    id      = reader[6].ToString();
                    nombre  = reader[4].ToString();
                    idcargo = reader[3].ToString();
                    cargo   = reader[5].ToString();
                    return(hay);
                }
                else
                {
                    id      = "";
                    nombre  = "";
                    idcargo = "";
                    cargo   = "";
                    return(hay);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }