Example #1
0
        private void AddBookButton_Click(object sender, EventArgs e)
        {
            if (ProductDataGridView.Rows.Count > 0)
            {
                int CID = controllerObj.GetCUID(Cuser);



                string storename = ProductDataGridView.Rows[index].Cells[4].Value.ToString();


                string ItemName    = ProductDataGridView.Rows[index].Cells[0].Value.ToString();
                string priceDollar = ProductDataGridView.Rows[index].Cells[2].Value.ToString();
                string PricePoints = ProductDataGridView.Rows[index].Cells[3].Value.ToString();

                int result = controllerObj.AddProductToSC(CID, CID, ItemName, storename, Int32.Parse(priceDollar), Int32.Parse(PricePoints), DepartmentComboBox.Text);
                if (result == 1)
                {
                    controllerObj.DecPQuantity(ItemName, storename);
                    MessageBox.Show("Item Added To Shopping Cart");
                    if (search == 1)
                    {
                        DataTable dt = controllerObj.GetProductsByName(ProductTextBox.Text, DepartmentComboBox.Text);
                        ProductDataGridView.DataSource = dt;
                        ProductDataGridView.Refresh();
                        index = 0;
                        if (ProductDataGridView.Rows.Count > 0)
                        {
                            label10.Text = ProductDataGridView.Rows[index].Cells[0].Value.ToString();
                            label11.Text = ProductDataGridView.Rows[index].Cells[1].Value.ToString();
                            label12.Text = ProductDataGridView.Rows[index].Cells[2].Value.ToString();
                            label13.Text = ProductDataGridView.Rows[index].Cells[3].Value.ToString();
                            label14.Text = ProductDataGridView.Rows[index].Cells[4].Value.ToString();
                            label17.Text = ProductDataGridView.Rows[index].Cells[5].Value.ToString();
                        }
                        else
                        {
                            label10.Text = "";
                            label11.Text = "";
                            label12.Text = "";
                            label13.Text = "";
                            label14.Text = "";
                            label17.Text = "";
                        }
                    }
                    if (search == 2)
                    {
                        string StoreName = StoreComboBox.Text;
                        storeselected = StoreName;
                        DataTable dt = controllerObj.GetProductsByStoreName(StoreName, DepartmentComboBox.Text);
                        ProductDataGridView.DataSource = dt;
                        ProductDataGridView.Refresh();
                        index = 0;
                        if (ProductDataGridView.Rows.Count > 0)
                        {
                            label10.Text = ProductDataGridView.Rows[index].Cells[0].Value.ToString();
                            label11.Text = ProductDataGridView.Rows[index].Cells[1].Value.ToString();
                            label12.Text = ProductDataGridView.Rows[index].Cells[2].Value.ToString();
                            label13.Text = ProductDataGridView.Rows[index].Cells[3].Value.ToString();
                            label14.Text = ProductDataGridView.Rows[index].Cells[4].Value.ToString();
                            label17.Text = ProductDataGridView.Rows[index].Cells[5].Value.ToString();
                        }
                        else
                        {
                            label10.Text = "";
                            label11.Text = "";
                            label12.Text = "";
                            label13.Text = "";
                            label14.Text = "";
                            label17.Text = "";
                        }
                    }
                    if (search == 3)
                    {
                        string StoreName = StoreComboBox.Text;
                        storeselected = StoreName;
                        DataTable dt = controllerObj.GetProductsByNameAndStore(ProductTextBox.Text, StoreName, DepartmentComboBox.Text);
                        ProductDataGridView.DataSource = dt;
                        ProductDataGridView.Refresh();
                        index = 0;
                        if (ProductDataGridView.Rows.Count > 0)
                        {
                            label10.Text = ProductDataGridView.Rows[index].Cells[0].Value.ToString();
                            label11.Text = ProductDataGridView.Rows[index].Cells[1].Value.ToString();
                            label12.Text = ProductDataGridView.Rows[index].Cells[2].Value.ToString();
                            label13.Text = ProductDataGridView.Rows[index].Cells[3].Value.ToString();
                            label14.Text = ProductDataGridView.Rows[index].Cells[4].Value.ToString();
                            label17.Text = ProductDataGridView.Rows[index].Cells[5].Value.ToString();
                        }
                        else
                        {
                            label10.Text = "";
                            label11.Text = "";
                            label12.Text = "";
                            label13.Text = "";
                            label14.Text = "";
                            label17.Text = "";
                        }
                    }
                }
            }
        }