private DataTable GetOrders(int userID)
        {
            DataTable     datTable          = new DataTable();
            StringBuilder sqliteQuerySelect = new StringBuilder();

            sqliteQuerySelect.Append("SELECT ");
            sqliteQuerySelect.Append("id, ");
            sqliteQuerySelect.Append("user_id, ");
            sqliteQuerySelect.Append("payment_id, ");
            sqliteQuerySelect.Append("state, ");
            sqliteQuerySelect.Append("amount, ");
            sqliteQuerySelect.Append("description, ");
            sqliteQuerySelect.Append("created_at, ");
            sqliteQuerySelect.Append("updated_at ");
            sqliteQuerySelect.Append("FROM orders ");
            sqliteQuerySelect.Append("WHERE user_id = @user_id ");
            sqliteQuerySelect.Append("ORDER BY updated_at DESC, id DESC");
            SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();

            sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
            sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@user_id", userID);
            dataAccessObject = new DataAccessLayer();
            datTable         = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);
            return(datTable);
        }
Пример #2
0
        private DataTable GetUser(string email)
        {
            DataTable     datTable          = new DataTable();
            StringBuilder sqliteQuerySelect = new StringBuilder();

            sqliteQuerySelect.Append("SELECT ");
            sqliteQuerySelect.Append("id, ");
            sqliteQuerySelect.Append("email, ");
            sqliteQuerySelect.Append("encrypted_password, ");
            sqliteQuerySelect.Append("sign_in_count, ");
            sqliteQuerySelect.Append("current_sign_in_at, ");
            sqliteQuerySelect.Append("last_sign_in_at, ");
            sqliteQuerySelect.Append("last_sign_in_ip, ");
            sqliteQuerySelect.Append("created_at, ");
            sqliteQuerySelect.Append("updated_at, ");
            sqliteQuerySelect.Append("credit_card_id, ");
            sqliteQuerySelect.Append("credit_card_description ");
            sqliteQuerySelect.Append("FROM users ");
            sqliteQuerySelect.Append("WHERE email = @email");
            SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();

            sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
            sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@email", email);
            dataAccessObject = new DataAccessLayer();
            datTable         = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);
            return(datTable);
        }
 private DataTable GetPaymentID(string orderID)
 {
     DataTable datTable = new DataTable();
     string sqliteQuery = "SELECT payment_id FROM orders WHERE id = @id";
     SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();
     sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
     sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@id", orderID);
     dataAccessObject = new DataAccessLayer();
     datTable = dataAccessObject.Select(sqliteQuery, sqliteDataAdapterSelect);
     return datTable;
 }
        private DataTable GetPaymentID(string orderID)
        {
            DataTable         datTable                = new DataTable();
            string            sqliteQuery             = "SELECT payment_id FROM orders WHERE id = @id";
            SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();

            sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
            sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@id", orderID);
            dataAccessObject = new DataAccessLayer();
            datTable         = dataAccessObject.Select(sqliteQuery, sqliteDataAdapterSelect);
            return(datTable);
        }
 private DataTable GetUser(string email)
 {
     DataTable datTable = new DataTable();
     StringBuilder sqliteQuerySelect = new StringBuilder();
     sqliteQuerySelect.Append("SELECT ");
     sqliteQuerySelect.Append("id, ");
     sqliteQuerySelect.Append("email, ");
     sqliteQuerySelect.Append("encrypted_password, ");
     sqliteQuerySelect.Append("sign_in_count ");
     sqliteQuerySelect.Append("FROM users ");
     sqliteQuerySelect.Append("WHERE email = @email");
     SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();
     sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
     sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@email", email);
     dataAccessObject = new DataAccessLayer();
     datTable = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);
     return datTable;
 }
 private DataTable GetUser(string email)
 {
     DataTable datTable = null;
     StringBuilder selectQuery = new StringBuilder();
     selectQuery.Append("SELECT ");
     selectQuery.Append("id, ");
     selectQuery.Append("email, ");
     selectQuery.Append("encrypted_password, ");
     selectQuery.Append("sign_in_count ");
     selectQuery.Append("FROM users ");
     selectQuery.Append("WHERE email = @email;");
     using (SQLiteCommand commandSQLite = new SQLiteCommand(selectQuery.ToString()))
     {
         commandSQLite.Parameters.AddWithValue("@email", email);
         DataAccessLayer dataAccessObject = new DataAccessLayer();
         datTable = dataAccessObject.Select(commandSQLite);
     }
     return datTable;
 }
 private DataTable GetOrders(int userID)
 {
     DataTable datTable = new DataTable();
     StringBuilder sqliteQuerySelect = new StringBuilder();
     sqliteQuerySelect.Append("SELECT ");
     sqliteQuerySelect.Append("DISTINCT id, ");
     sqliteQuerySelect.Append("user_id, ");
     sqliteQuerySelect.Append("payment_id, ");
     sqliteQuerySelect.Append("state, ");
     sqliteQuerySelect.Append("amount, ");
     sqliteQuerySelect.Append("description, ");
     sqliteQuerySelect.Append("created_at, ");
     sqliteQuerySelect.Append("updated_at ");
     sqliteQuerySelect.Append("FROM orders ");
     sqliteQuerySelect.Append("WHERE user_id = @user_id ORDER BY id DESC LIMIT 1");
     SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();
     sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
     sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@user_id", userID);
     dataAccessObject = new DataAccessLayer();
     datTable = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);
     return datTable;
 }
        private bool CheckIsExistingUser()
        {
            bool          isExistingUser    = false;
            DataTable     datTable          = new DataTable();
            int           rows              = 0;
            var           email             = TextBoxEmail.Text.Trim();
            StringBuilder sqliteQuerySelect = new StringBuilder();

            sqliteQuerySelect.Append("SELECT ");
            sqliteQuerySelect.Append("count(*) AS NumberOfUsers ");
            sqliteQuerySelect.Append("FROM users ");
            sqliteQuerySelect.Append("WHERE email = @email");
            SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();

            sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
            sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@email", email);
            dataAccessObject = new DataAccessLayer();
            datTable         = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);

            if (datTable != null && datTable.Rows.Count > 0)
            {
                var distinctRows = from DataRow dRow in datTable.Rows
                                   select new { column1 = dRow["NumberOfUsers"] };
                if (distinctRows != null)
                {
                    foreach (var row in distinctRows)
                    {
                        rows = Convert.ToInt32(row.column1);
                        break;
                    }
                }
            }
            if (rows == 1)
            {
                isExistingUser = true;
            }
            return(isExistingUser);
        }
        private bool CheckIsExistingUser()
        {
            bool isExistingUser = false;
            DataTable datTable = new DataTable();
            int rows = 0;
            var email = TextBoxEmail.Text.Trim();
            StringBuilder sqliteQuerySelect = new StringBuilder();
            sqliteQuerySelect.Append("SELECT ");
            sqliteQuerySelect.Append("count(*) AS NumberOfUsers ");
            sqliteQuerySelect.Append("FROM users ");
            sqliteQuerySelect.Append("WHERE email = @email");
            SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();
            sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
            sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@email", email);
            dataAccessObject = new DataAccessLayer();
            datTable = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);

            if (datTable != null && datTable.Rows.Count > 0)
            {
                var distinctRows = from DataRow dRow in datTable.Rows
                                   select new { column1 = dRow["NumberOfUsers"] };
                if (distinctRows != null)
                {
                    foreach (var row in distinctRows)
                    {
                        rows = Convert.ToInt32(row.column1);
                        break;
                    }
                }
            }
            if (rows == 1)
            {
                isExistingUser = true;
            }
            return isExistingUser;
        }
 private DataTable GetPaymentId(string orderId)
 {
     DataTable datTable = null;
     string selectQuery = "SELECT payment_id FROM orders WHERE id = @id;";
     using (SQLiteCommand commandSQLite = new SQLiteCommand(selectQuery))
     {
         commandSQLite.Parameters.AddWithValue("@id", orderId);
         DataAccessLayer dataAccessObject = new DataAccessLayer();
         datTable = dataAccessObject.Select(commandSQLite);
     }
     return datTable;
 }
 private DataTable GetOrders(int userId)
 {
     DataTable datTable = null;
     StringBuilder selectQuery = new StringBuilder();
     selectQuery.Append("SELECT ");
     selectQuery.Append("id, ");
     selectQuery.Append("user_id, ");
     selectQuery.Append("payment_id, ");
     selectQuery.Append("state, ");
     selectQuery.Append("amount, ");
     selectQuery.Append("description, ");
     selectQuery.Append("created_at, ");
     selectQuery.Append("updated_at ");
     selectQuery.Append("FROM orders ");
     selectQuery.Append("WHERE user_id = @user_id ");
     selectQuery.Append("ORDER BY updated_at DESC, id DESC;");
     using (SQLiteCommand commandSQLite = new SQLiteCommand(selectQuery.ToString()))
     {
         commandSQLite.Parameters.AddWithValue("@user_id", userId);
         DataAccessLayer dataAccessObject = new DataAccessLayer();
         datTable = dataAccessObject.Select(commandSQLite);
     }
     return datTable;
 }
 private bool CheckIsExistingUser(string email)
 {
     bool isExistingUser = false;
     DataTable datTable = null;
     int rows = 0;
     StringBuilder selectQuery = new StringBuilder();
     selectQuery.Append("SELECT ");
     selectQuery.Append("count(*) AS NumberOfUsers ");
     selectQuery.Append("FROM users ");
     selectQuery.Append("WHERE email = @email;");
     using (SQLiteCommand commandSQLite = new SQLiteCommand(selectQuery.ToString()))
     {
         commandSQLite.Parameters.AddWithValue("@email", email);
         DataAccessLayer dataAccessObject = new DataAccessLayer();
         datTable = dataAccessObject.Select(commandSQLite);
     }
     if (datTable != null && datTable.Rows.Count > 0)
     {
         var distinctRows = (from DataRow dRow in datTable.Rows
                             select new { column1 = dRow["NumberOfUsers"] }).Distinct();
         if (distinctRows != null)
         {
             foreach (var row in distinctRows)
             {
                 rows = Convert.ToInt32(row.column1);
                 break;
             }
         }
     }
     if (rows == 1)
     {
         isExistingUser = true;
     }
     return isExistingUser;
 }