Esempio n. 1
0
        public seeOrdersForm(Connection connection, List <Order> orders_list)
        {
            InitializeComponent();
            List <Order> products_Info_list = new List <Order>();
            //  Products_Info
            // Products_Info products_Info = new Products_Info(name,Int32.Parse(price),1,category,material);

            //listView2.Clear();
            int count = 0;

            //check if item exists already in the cart
            listViewOrders.Clear();

            listViewOrders.Columns.Add("Order id");
            listViewOrders.Columns.Add("Product");

            Products_List products_List = new Products_List();

            foreach (var id_list in orders_list)
            {
                List <Products_Info> products_Infos_list = products_List.GetDbProductsList(connection, id_list.list_id);

                foreach (var products_Info in products_Infos_list)
                {
                    //display new item in cart
                    ListViewItem item = new ListViewItem(products_Info.name);
                    item.SubItems.Add(products_Info.price.ToString());
                    listViewOrders.Items.Add(item);
                    listViewOrders.Refresh();
                }
            }
        }
Esempio n. 2
0
        //add item to cart
        private void testBtn_Click(object sender, EventArgs e)
        {
            Connection connection = new Connection();
            // Insert product in db list
            Products_List products_List = new Products_List();
            int           max_index     = products_List.GetMaxListId(connection) + 1;
            int           product_id    = 1;
            var           selectedtItem = listView1.SelectedItems[0].Tag;
            var           sel           = selectedtItem.ToString();

            product_id = Int32.Parse(sel);

            List <Products_Info> products_Infos_list;

            if (user_exists != 0)
            {
                products_List.InsertProductInList(user_exists, product_id, 1, connection);
                products_Infos_list = products_List.GetDbProductsList(connection, user_exists);
            }
            else
            //insert product in db list
            {
                products_List.InsertProductInList(max_index, product_id, 1, connection);
                user_exists         = max_index;
                products_Infos_list = products_List.GetDbProductsList(connection, max_index);
            }
            AdjustStock(-1, product_id, connection);

            Update_DataGrid(connection);
            //get price

            PriceLabel.Text = (GetPrice(connection, user_exists)).ToString();

            //update cart view
            update_listView2(products_Infos_list, connection);
        }