public static Int32 SaveUser(UsersRegistration user)
        {
            try
            {
                sqlConnection          = new SqlConnection(dataAccess.ConnectionString());
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "sp_UserReg";

                sqlConnection.Close();
                sqlCommand.Connection.Open();

                sqlCommand.Parameters.AddWithValue("@UserId", user.UserId);
                sqlCommand.Parameters.AddWithValue("@UserName", user.UserName);
                sqlCommand.Parameters.AddWithValue("@Email", user.UserEmail);
                sqlCommand.Parameters.AddWithValue("@Password", user.Password);

                int result = sqlCommand.ExecuteNonQuery();
                sqlCommand.Connection.Close();
                sqlConnection.Close();
                return(result);
            }
            catch (Exception Err)
            {
                throw new Exception(Err.Message);
            }
        }
Esempio n. 2
0
 public Int32 SaveUser(UsersRegistration users)
 {
     try
     {
         int success            = 0;
         UsersRegistration user = new UsersRegistration();
         user.UserId    = users.UserId;
         user.UserName  = users.UserName;
         user.UserEmail = users.UserEmail;
         user.Password  = users.Password;
         if (UserManager.SaveUser(users) > 0)
         {
             success = 1;
         }
         else
         {
             success = 0;
         }
         return(success);
     }
     catch (Exception excp)
     {
         throw excp;
     }
 }
        public static List <UsersRegistration> GetUsersList()
        {
            try
            {
                sqlConnection          = new SqlConnection(dataAccess.ConnectionString());
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = "Select * from tblUsers";

                List <UsersRegistration> userList = null;
                sqlConnection.Close();
                sqlCommand.Connection.Open();

                SqlDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.HasRows)
                {
                    userList = new List <UsersRegistration>();

                    while (dataReader.Read())
                    {
                        UsersRegistration user = new UsersRegistration();
                        user.UserId    = Convert.ToInt32(dataReader["UserId"]);
                        user.UserName  = dataReader["UserName"].ToString();
                        user.UserEmail = dataReader["Email"].ToString();
                        user.Password  = dataReader["Password"].ToString();
                        userList.Add(user);
                    }
                }
                dataReader.Close();
                sqlCommand.Connection.Close();
                sqlConnection.Close();
                return(userList);
            }
            catch (Exception Err)
            {
                throw new Exception(Err.Message);
            }
        }
 public static Int32 SaveUser(UsersRegistration user)
 {
     return(UserGateWay.SaveUser(user));
 }