private void payButton_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(cardNumberTextBox.Text) || String.IsNullOrEmpty(cvvTextBox.Text) || String.IsNullOrEmpty(addressTextBox.Text)) { showLabel.Text = "Please enter payment information to pay."; showLabel.ForeColor = System.Drawing.Color.Red; } else { MessageBox.Show("You have ordered successfully.Happy Shopping!!"); //To insert into ordered product table MobileClass mobileClass = new MobileClass(); DBConnection dbConnection = new DBConnection(); for (int n = 0; n < (cartDataGridView.Rows.Count); n++) { string brandName = cartDataGridView.Rows[n].Cells[0].Value.ToString(); string name = cartDataGridView.Rows[n].Cells[1].Value.ToString(); string totallValue = cartDataGridView.Rows[n].Cells[2].Value.ToString(); int price = Convert.ToInt32(totallValue.Substring(1, (totallValue.Length - 1))); int quantity = Convert.ToInt32(cartDataGridView.Rows[n].Cells[3].Value); int result = mobileClass.insertMobile(brandName, name, price, quantity, usernameString); } this.Hide(); } }
private void UserAccountForm_Load(object sender, EventArgs e) { userNameLabel.Text = uName; //for the full window this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; //load Mobile data into ProductDetails gridview from database //instantiating the mobile class MobileClass loadMobileDetails = new MobileClass(); loadMobileDetails.loadGridviewDetails(productsGridView); }
}//end function checkoutButton_Click //On search Button Click private void searchButton_Click(object sender, EventArgs e) { try { MobileClass mobileClass = new MobileClass(); string sqlString = "select * from ProductDetails where ProductName like '" + searchTextBox.Text + "%'"; mobileClass.searchAndloadGridviewDetails(productsGridView, sqlString); searchTextBox.Text = ""; } catch (Exception ex) { MessageBox.Show("No products are there with the search."); } }
private void OrderHistoryForm_Load(object sender, EventArgs e) { userLabel.Text = uName; MobileClass mobileClass = new MobileClass(); string sqlString = "select * from OrderedProducts where UserName='******'"; DataTable orderTable = mobileClass.getTable(sqlString); foreach (DataRow row in orderTable.Rows) { int numberofRows = orderedProsuctsDatagridview.Rows.Add(); orderedProsuctsDatagridview.Rows[numberofRows].Cells[0].Value = row["BrandName"].ToString(); orderedProsuctsDatagridview.Rows[numberofRows].Cells[1].Value = row["ProductName"].ToString(); orderedProsuctsDatagridview.Rows[numberofRows].Cells[2].Value = row["Quantity"].ToString(); orderedProsuctsDatagridview.Rows[numberofRows].Cells[3].Value = "$" + row["Price"].ToString(); } }
//for Checkbox filter private void filterButton_Click(object sender, EventArgs e) { string filterdata = ""; if (appleCheckBox.Checked) { if (samsungCheckBox.Checked || motorolaCheckBox.Checked) { filterdata = "'1',"; } else { filterdata = "'1'"; } } if (samsungCheckBox.Checked) { if (motorolaCheckBox.Checked) { filterdata = filterdata + "'3',"; } else { filterdata = filterdata + "'3'"; } } if (motorolaCheckBox.Checked) { filterdata = filterdata + "'2'"; } MobileClass mobileClass = new MobileClass(); string sqlString = "select * from ProductDetails where BrandID in(" + filterdata + ")"; mobileClass.searchAndloadGridviewDetails(productsGridView, sqlString); }