private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == dataGridView1.Columns.Count - 1 && e.RowIndex >= 0) { var name = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); var phonenumber = u.GetCustomerByEmail(mail).Rows[0][6].ToString(); var userId = int.Parse(u.GetCustomerByEmail(mail).Rows[0][0].ToString()); if (cc.GetByName(phonenumber, name).Rows.Count > 0) { var piece = int.Parse(cc.GetByName(phonenumber, name).Rows[0][2].ToString()); if (piece > 1) { cc.UpdatePiece(piece - 1, name, phonenumber); order.UpdatePiece(piece - 1, name, userId); } else { cc.Delete(phonenumber, name); order.Delete(userId, name); } } Payment_Load(sender, e); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void bRegister_Click(object sender, EventArgs e) { var name1 = tName.Text.Trim(); var card_number = maskedTextBox1.Text.Trim(); var expire_date = maskedTextBox2.Text.Trim(); var ccv = maskedTextBox3.Text.Trim(); if (name1.Length == 0 || card_number.Length != 14 || expire_date.Length != 5 || ccv.Length != 3) { label12.Text = "Please enter informations correctly"; } else { if (dataGridView1.Rows.Count < 1) { return; } for (var i = 0; i < dataGridView1.RowCount; i++) { var name = dataGridView1.Rows[i].Cells[0].Value.ToString(); var category = dataGridView1.Rows[i].Cells[3].Value.ToString(); var number = int.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString()); var current_stock = int.Parse(product.GetByName(name, category).Rows[0][3].ToString()); product.UpdatePiece(name, current_stock - number, category); } MessageBox.Show("Your order has been received. Thank you"); var user_id = int.Parse(u.GetCustomerByEmail(email).Rows[0][0].ToString()); for (var i = 0; i < dataGridView1.RowCount; i++) { var name = dataGridView1.Rows[i].Cells[0].Value.ToString(); order.UpdateStatus(name, user_id); order.UpdateAddress(u.GetCustomerByEmail(email).Rows[0][5].ToString(), user_id); cc.Delete(phonenumber, name); } //this.Visible = false; printPreviewDialog1.Document = printDocument1; printPreviewDialog1.ShowDialog(); //this.Visible = true; PaymentDelivery_Load(sender, e); label12.Text = ""; } try { } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void bunifuCustomDataGrid5_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex != bunifuCustomDataGrid5.Columns.Count - 1 || e.RowIndex < 0) { return; } var name = bunifuCustomDataGrid5.Rows[e.RowIndex].Cells[0].Value.ToString(); var phonenumber = _u.GetCustomerByEmail(_beforeMail).Rows[0][6].ToString(); var userId = int.Parse(_u.GetCustomerByEmail(_beforeMail).Rows[0][0].ToString()); if (_cc.GetByName(phonenumber, name).Rows.Count > 0) { var piece = int.Parse(_cc.GetByName(phonenumber, name).Rows[0][2].ToString()); if (piece > 1) { _cc.UpdatePiece(piece - 1, name, phonenumber); _order.UpdatePiece(piece - 1, name, userId); } else { _cc.Delete(phonenumber, name); _order.Delete(userId, name); } } bunifuCustomDataGrid5.Columns.Clear(); bunifuCustomDataGrid5.DataSource = _cc.Get(_u.GetCustomerByEmail(_beforeMail).Rows[0][6].ToString()); AddButton(bunifuCustomDataGrid5, "Delete"); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(_u.GetCustomerByEmail(_beforeMail).Rows[0][6].ToString()); } }