Esempio n. 1
0
        public Account GetAuthenticateUser(string uName, string pwd)
        {
            SqlDataReader reader = null;

            if (myconn.State != ConnectionState.Open)
            {
                myconn.Open();
            }

            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.CommandText = "SP_GetAuthenticateUser";
            sqlCmd.Parameters.Add(new SqlParameter("@userName", gs.CipherText(uName, "E")));
            sqlCmd.Parameters.Add(new SqlParameter("@password", gs.CipherText(pwd, "E")));
            sqlCmd.Connection = myconn;
            reader            = sqlCmd.ExecuteReader();
            Account acct = new Account();

            while (reader.Read())
            {
                acct.Id       = Convert.ToInt32(reader.GetValue(0));
                acct.uId      = Convert.ToInt32(reader.GetValue(1));
                acct.userName = uName;
                acct.password = pwd;
                acct.userType = reader.GetValue(2).ToString();
                acct.roleId   = Convert.ToInt32(reader.GetValue(3));
                acct.roles    = reader.GetValue(4).ToString();
            }

            if (myconn.State != ConnectionState.Closed)
            {
                myconn.Close();
            }


            return(acct);
        }