private void depositToolStripMenuItem_Click(object sender, EventArgs e) { if (dgvMain.SelectedRows.Count == 1) { using (ProcessTransaction procTrans = new ProcessTransaction()) { this.Hide(); // Using SetType() method inside of ProcessTransaction to set the combo box index procTrans.SetType(2); // Uses details from Datagrid to populate ProcessTransaction form PassDetailsFromDgv(procTrans); procTrans.ShowDialog(); } this.Show(); PrimeMainGrid(); } else if (dgvMain.SelectedRows.Count > 1) { MessageBox.Show("Please select a single account"); } else if (dgvMain.SelectedRows.Count < 1) { MessageBox.Show("Please select an account"); } else { MessageBox.Show("Error, Please try again"); } }
private void withdrawToolStripMenuItem_Click(object sender, EventArgs e) { if (dgvMain.SelectedRows.Count == 1) { using (ProcessTransaction procTrans = new ProcessTransaction()) { this.Hide(); procTrans.SetType(1); PassDetailsFromDgv(procTrans); procTrans.ShowDialog(); } this.Show(); PrimeMainGrid(); } else if (dgvMain.SelectedRows.Count > 1) { MessageBox.Show("Please select a single account"); } else if (dgvMain.SelectedRows.Count < 1) { MessageBox.Show("Please select an account"); } else { MessageBox.Show("Error, Please try again"); } }
private void PassDetailsFromDgv(ProcessTransaction procTrans) { //Populates public fields and variables in ProcessTransaction with details from the datagrid procTrans.txtName.Text = (dgvMain.SelectedRows[selectedRow].Cells[1].Value + " " + dgvMain.SelectedRows[selectedRow].Cells[2].Value); procTrans.txtAccountNumber.Text = dgvMain.SelectedRows[selectedRow].Cells[6].Value.ToString(); procTrans.accountID = (int)dgvMain.SelectedRows[selectedRow].Cells[0].Value; procTrans.balance = (int)dgvMain.SelectedRows[selectedRow].Cells[8].Value; procTrans.overdraftLimit = (int)dgvMain.SelectedRows[selectedRow].Cells[9].Value; }