private void btnDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you wanna delete this? ", "Computer Parts", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int index = this.gridManageComputers.Rows.IndexOf((GridViewDataRowInfo)this.gridManageComputers.CurrentRow); if (index < 0) { return; } BO.Computer computer = (BO.Computer)gridManageComputers.Rows[index].DataBoundItem; if (index != null) { _computersBll.Remove(computer.ComputerID); } } else if (dialogResult == DialogResult.No) { this.Hide(); ManageComputers mg = new ManageComputers(); mg.ShowDialog(); } }
private void btnUpdate_Click(object sender, EventArgs e) { int index = this.gridManageComputers.Rows.IndexOf((GridViewDataRowInfo)this.gridManageComputers.CurrentRow); if (index < 0) { return; } BO.Computer computer = (BO.Computer)gridManageComputers.Rows[index].DataBoundItem; if (computer != null) { ComputersEdit ce = new ComputersEdit(); ce.txtComputerID.Text = gridManageComputers.CurrentRow.Cells[0].Value.ToString(); ce.cmbPC.Text = gridManageComputers.CurrentRow.Cells[1].Value.ToString(); ce.txtPricePerHour.Text = gridManageComputers.CurrentRow.Cells[2].Value.ToString(); ce.ShowDialog(); } }