private async void button_Pay_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(richTextBox_Street.Text)) { MessageBox.Show("Invalid Street!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (comboBox_Pincode.SelectedIndex < 0) { MessageBox.Show("Invalid Pincode!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!Regex.IsMatch(textBox_Contact.Text, "^[0-9]{10}$")) { MessageBox.Show("Invalid Contact Number!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!Regex.IsMatch(textBox_DebitCard.Text, "^(?:4[0-9]{12}(?:[0-9]{3})?)$" )) { MessageBox.Show("Invalid Card Number!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (CCustomer_Cart x in cart_items) { await COrder.Register(x.customer_id, x.product_id, x.seller_id, x.quantity, Int64.Parse(textBox_Contact.Text), richTextBox_Street.Text, ((CLocation)(comboBox_Pincode.SelectedItem)).pincode, GTotal); await CCustomer_Cart.Remove(x.customer_id, x.product_id, x.seller_id, true); // Update Sales in Product MySqlCommand tempcmd = new MySqlCommand(); tempcmd.Connection = Program.conn; tempcmd.CommandText = "UPDATE `product` SET sales = sales + @quantity WHERE id = @product_id"; tempcmd.Parameters.AddWithValue("@quantity", x.quantity); tempcmd.Parameters.AddWithValue("@product_id", x.product_id); await tempcmd.ExecuteNonQueryAsync(); tempcmd.Dispose(); } if (CUtils.LastLogMsg != null) { MessageBox.Show("Cause: " + CUtils.LastLogMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Successfully Ordered!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); prev.Visible = true; this.Visible = false; this.Dispose(); } }
private async void button_Cart_Delete_Click(object sender, EventArgs e) { foreach (DataGridViewRow x in dataGridView_Cart.Rows) { CCustomer_Cart y = (CCustomer_Cart)(x.Cells["extra_1"].Value); await CCustomer_Cart.Remove(y.customer_id, y.product_id, y.seller_id); dataGridView_Cart.Rows.Remove(x); } }