private void AddBookButton_Click(object sender, EventArgs e) { if (BookDataGridView.Rows.Count > 0) { int CID = controllerObj.GetCUID(Cuser); string storename = BookDataGridView.Rows[index].Cells[5].Value.ToString(); string ItemName = BookDataGridView.Rows[index].Cells[0].Value.ToString(); string priceDollar = BookDataGridView.Rows[index].Cells[3].Value.ToString(); string PricePoints = BookDataGridView.Rows[index].Cells[4].Value.ToString(); int result = controllerObj.AddBookToSC(CID, CID, ItemName, storename, Int32.Parse(priceDollar), Int32.Parse(PricePoints)); if (result == 1) { controllerObj.DecBQuantity(ItemName, storename); MessageBox.Show("Item Added To Shopping Cart"); if (search == 1) { index = 0; DataTable dt = controllerObj.GetBooksByBName(BookTextBox.Text); BookDataGridView.DataSource = dt; BookDataGridView.Refresh(); if (BookDataGridView.Rows.Count > 0) { label10.Text = BookDataGridView.Rows[index].Cells[0].Value.ToString(); label11.Text = BookDataGridView.Rows[index].Cells[1].Value.ToString(); label12.Text = BookDataGridView.Rows[index].Cells[3].Value.ToString(); label13.Text = BookDataGridView.Rows[index].Cells[4].Value.ToString(); label14.Text = BookDataGridView.Rows[index].Cells[5].Value.ToString(); label17.Text = BookDataGridView.Rows[index].Cells[2].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.GetBooksByName(StoreName); BookDataGridView.DataSource = dt; BookDataGridView.Refresh(); if (BookDataGridView.Rows.Count > 0) { index = 0; label10.Text = BookDataGridView.Rows[index].Cells[0].Value.ToString(); label11.Text = BookDataGridView.Rows[index].Cells[1].Value.ToString(); label12.Text = BookDataGridView.Rows[index].Cells[3].Value.ToString(); label13.Text = BookDataGridView.Rows[index].Cells[4].Value.ToString(); label14.Text = BookDataGridView.Rows[index].Cells[5].Value.ToString(); label17.Text = BookDataGridView.Rows[index].Cells[2].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.GetBooksByBNameAndStore(BookTextBox.Text, StoreName); BookDataGridView.DataSource = dt; BookDataGridView.Refresh(); index = 0; if (BookDataGridView.Rows.Count > 0) { label10.Text = BookDataGridView.Rows[index].Cells[0].Value.ToString(); label11.Text = BookDataGridView.Rows[index].Cells[1].Value.ToString(); label12.Text = BookDataGridView.Rows[index].Cells[3].Value.ToString(); label13.Text = BookDataGridView.Rows[index].Cells[4].Value.ToString(); label14.Text = BookDataGridView.Rows[index].Cells[5].Value.ToString(); label17.Text = BookDataGridView.Rows[index].Cells[2].Value.ToString(); } else { label10.Text = ""; label11.Text = ""; label12.Text = ""; label13.Text = ""; label14.Text = ""; label17.Text = ""; } } } } }