private void btnDeleteSoft_Click(object sender, EventArgs e) { SoftwareControl software = new SoftwareControl(); int column = 0; if (cmbDataViews.SelectedIndex == 0) { column = 8; } else if (cmbDataViews.SelectedIndex == 2) { column = 7; } else { column = 4; } if (dataGridView1.SelectedRows.Count == 0 || dataGridView1.SelectedRows.Count < 2) { if (software.DeleteSoftware(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[column].Value.ToString()))) { MessageBox.Show("Software has been successfully deleted", "Success", MessageBoxButtons.OK); } else { MessageBox.Show("Failure has occured", "Error!", MessageBoxButtons.OK); } UpdateGrid(sender, e); } else { MessageBox.Show("Must select one row to delete software", "Error", MessageBoxButtons.OK); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (txtSoftwareName.Text == String.Empty || txtSystemName.Text == String.Empty) //A group will always be selected { MessageBox.Show("Please make sure that the Software and System Name fields are filled, and that the Group and Classification is selected!", "ERROR!", MessageBoxButtons.OK); } else { switch (mAddUpdate) { case 1: // add { var obj = new Software() { SoftwareName = txtSoftwareName.Text, SystemName = txtSystemName.Text, Group = ddlGroups.SelectedValue.ToString().Trim(), Owner = txtOwner.Text, Classification = cmbClass.SelectedItem.ToString(), ResponsibleEngineer = txtResponsibleEngineer.Text, Description = txtSoftwareDescription.Text, DesignAuthority = txtDesignAuthority.Text }; SoftwareControl softwareOperation = new SoftwareControl(); if (softwareOperation.AddNewSoftware(mUser, obj)) { MessageBox.Show("Software System has been added"); myDashBoard.UpdateGrid(sender, e); Close(); } else { MessageBox.Show("An unknown error has occur, or the software already exists", "ERROR!", MessageBoxButtons.OK); } break; } case 2: // update except software nmae { var obj = new Software() { Software_ID = mSoftware.Software_ID, // SoftwareName = txtSoftwareName.Text.Trim(), SystemName = txtSystemName.Text.Trim(), Group = ddlGroups.SelectedValue.ToString().Trim(), Owner = txtOwner.Text.Trim(), Classification = cmbClass.SelectedItem.ToString().Trim(), ResponsibleEngineer = txtResponsibleEngineer.Text.Trim(), Description = txtSoftwareDescription.Text.Trim(), DesignAuthority = txtDesignAuthority.Text.Trim() }; SoftwareControl softwareOperation = new SoftwareControl(); if (softwareOperation.UpdateSoftware(obj)) { MessageBox.Show("Software System has been updated"); myDashBoard.UpdateGrid(sender, e); Close(); } else { MessageBox.Show("An unknown error has occur", "ERROR!", MessageBoxButtons.OK); } break; } default: break; } } }