Пример #1
0
        internal List <Order> getUserOrders(String username)
        {
            using (OleDbConnection sqlconn = new OleDbConnection(database))
            {
                List <Order> userOrders = new List <Order>();
                try
                {
                    sqlconn.Open();
                    OleDbCommand cmd = sqlconn.CreateCommand();

                    String select = "SELECT * FROM [ORDERS] INNER JOIN [USERS] ON [USERS].user_id = [ORDERS].user_id WHERE [USERS].username = @username";
                    cmd.CommandText = select;
                    cmd.Parameters.Add("username", OleDbType.VarChar, 255).Value = username;

                    OleDbDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Order userOrder = new Order();
                        userOrder.setOrderIdForOrderOnly((int)reader["order_id"]);
                        userOrder.setUserId((int)reader["Orders.user_id"]);
                        userOrder.setValidated((bool)reader["validated"]);
                        userOrder.setIsCollctOnDelivery((bool)reader["collect_on_delivery"]);
                        userOrder.setCompleted((bool)reader["completed"]);
                        userOrder.setPaymentAmount(Double.Parse(reader["payment_amount"].ToString(), NumberStyles.Currency));

                        userOrder.setPaymentInformation(PaymentManager.getUserCreditCard((int)reader["payment_id"]));

                        userOrder.setOrderItems(getOrderItems(userOrder.getOrderId()));

                        userOrders.Add(userOrder);
                    }

                    return(userOrders);
                }
                catch (OleDbException ex)
                {
                    userOrders = null;
                    return(userOrders);
                }
                finally
                {
                    sqlconn.Close();
                }
            }
        }
Пример #2
0
        internal Order getSingleOrder(int orderId)
        {
            Order order = new Order();

            using (OleDbConnection sqlConn = new OleDbConnection(database))
            {
                try
                {
                    sqlConn.Open();
                    OleDbCommand cmd = sqlConn.CreateCommand();

                    String select = "SELECT * FROM [ORDERS] WHERE [order_id] = @orderId";
                    cmd.CommandText = select;
                    cmd.Parameters.Add("orderId", OleDbType.Integer).Value = orderId;

                    OleDbDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        order.setOrderIdForOrderOnly((int)reader["order_id"]);
                        order.setUserId((int)reader["user_id"]);
                        order.setValidated((bool)reader["validated"]);
                        order.setCompleted((bool)reader["completed"]);
                        order.setPaymentAmount(Double.Parse(reader["payment_amount"].ToString(), NumberStyles.Currency));
                        order.setIsCollctOnDelivery((bool)reader["collect_on_delivery"]);
                        order.setPaymentInformation(getPaymentInformation((int)reader["payment_id"]));
                        order.setOrderItems(getOrderItems((int)reader["order_id"]));
                    }

                    return(order);
                }
                catch (OleDbException ex)
                {
                    return(order);
                }
                finally
                {
                    sqlConn.Close();
                }
            }
        }
Пример #3
0
        internal List<Order> getUserOrders(String username)
        {
            using (OleDbConnection sqlconn = new OleDbConnection(database))
            {
                List<Order> userOrders = new List<Order>();
                try
                {
                    sqlconn.Open();
                    OleDbCommand cmd = sqlconn.CreateCommand();

                    String select = "SELECT * FROM [ORDERS] INNER JOIN [USERS] ON [USERS].user_id = [ORDERS].user_id WHERE [USERS].username = @username";
                    cmd.CommandText = select;
                    cmd.Parameters.Add("username", OleDbType.VarChar, 255).Value = username;

                    OleDbDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Order userOrder = new Order();
                        userOrder.setOrderIdForOrderOnly((int)reader["order_id"]);
                        userOrder.setUserId((int)reader["Orders.user_id"]);
                        userOrder.setValidated((bool)reader["validated"]);
                        userOrder.setIsCollctOnDelivery((bool)reader["collect_on_delivery"]);
                        userOrder.setCompleted((bool)reader["completed"]);
                        userOrder.setPaymentAmount(Double.Parse(reader["payment_amount"].ToString(), NumberStyles.Currency));

                        userOrder.setPaymentInformation(PaymentManager.getUserCreditCard((int)reader["payment_id"]));

                        userOrder.setOrderItems(getOrderItems(userOrder.getOrderId()));

                        userOrders.Add(userOrder);
                    }

                    return userOrders;
                }
                catch (OleDbException ex)
                {
                    userOrders = null;
                    return userOrders;
                }
                finally
                {
                    sqlconn.Close();
                }
            }
        }
Пример #4
0
        internal Order getSingleOrder(int orderId)
        {
            Order order = new Order();

            using (OleDbConnection sqlConn = new OleDbConnection(database))
            {
                try
                {
                    sqlConn.Open();
                    OleDbCommand cmd = sqlConn.CreateCommand();

                    String select = "SELECT * FROM [ORDERS] WHERE [order_id] = @orderId";
                    cmd.CommandText = select;
                    cmd.Parameters.Add("orderId", OleDbType.Integer).Value = orderId;

                    OleDbDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        order.setOrderIdForOrderOnly((int)reader["order_id"]);
                        order.setUserId((int)reader["user_id"]);
                        order.setValidated((bool)reader["validated"]);
                        order.setCompleted((bool)reader["completed"]);
                        order.setPaymentAmount(Double.Parse(reader["payment_amount"].ToString(), NumberStyles.Currency));
                        order.setIsCollctOnDelivery((bool)reader["collect_on_delivery"]);
                        order.setPaymentInformation(getPaymentInformation((int)reader["payment_id"]));
                        order.setOrderItems(getOrderItems((int)reader["order_id"]));
                    }

                    return order;
                }
                catch(OleDbException ex)
                {
                    return order;
                }
                finally
                {
                    sqlConn.Close();
                }
            }
        }