Esempio n. 1
0
        public List <OrderObj> getUserOrders(string uid)
        {
            List <OrderObj> orders = new List <OrderObj>();
            string          query  = @"SELECT oid,uid,details,status FROM orders WHERE uid='" + uid + "';";

            if (this.OpenConnection() == true)
            {
                MySqlCommand cmd = new MySqlCommand(query, connection);
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    OrderObj o = new OrderObj();
                    o.setOid(dataReader["oid"].ToString());
                    o.setUid(dataReader["uid"].ToString());
                    o.setDetails(dataReader["details"].ToString());
                    o.setStatus((int)dataReader["status"]);
                    orders.Add(o);
                }
                dataReader.Close();
                this.CloseConnection();
                return(orders);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 private void place_order_Click(object sender, EventArgs e)
 {
     if (cartList.Count <= 0)
     {
         MessageBox.Show("Your cart is empty !");
     }
     else
     {
         OrderObj o = new OrderObj();
         o.setOid(oidGenerator());
         o.setUid(f1.u.getUid());
         Dictionary <string, string> od = new Dictionary <string, string>();
         int    i;
         string pids       = "";
         int    totalPrice = 0;
         for (i = 0; i < cartList.Count; i++)
         {
             pids       += cartList[i].getPid() + ",";
             totalPrice += cartList[i].getPrice() * cartList[i].getProductCount();
         }
         od.Add("pids", pids);
         od.Add("totalPrice", totalPrice.ToString());
         AdressObj ao = (AdressObj)adressCB.SelectedItem;
         if (adressCB.SelectedIndex < 0)
         {
             MessageBox.Show("Please choose an adress");
         }
         else
         {
             od.Add("adress", ao.getAid());
             o.setDetails(generateDictionaryString(od));
             conn.sendCommand(conn.insertOrder(o));
             MessageBox.Show("Order send ! ");
             panel1.Controls.Clear();
             f1.clearCart();
         }
     }
 }