private void btnViewAttr_Click(object sender, EventArgs e) { //Pass the software id into the form if (dataGridView1.SelectedRows.Count != 0) { AttributeControl attControl = new AttributeControl(_userInfo); switch (cmbDataViews.SelectedIndex) { case 0: attControl.viewAttributes(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[8].Value.ToString()), dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Trim()); break; case 1: attControl.viewAttributes(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[4].Value.ToString()), dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Trim()); break; case 2: attControl.viewAttributes(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[7].Value.ToString()), dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Trim()); break; } } }
private void btnAddAttribute_Click(object sender, EventArgs e) { AttributeControl operAttributeControl = new AttributeControl(); switch (comboViewAttr.SelectedIndex) { case 1: operAttributeControl.openAttributeForm(_softwareID, _software, _dashBoard, comboViewAttr.SelectedIndex); break; case 2: if (dgvViewAttr.SelectedRows.Count < 0) //Assume we are adding a configItem { operAttributeControl.openAttributeForm(_softwareID, _software, _dashBoard, comboViewAttr.SelectedIndex); } else { operAttributeControl.openAttributeForm(_softwareID, _software, _dashBoard, comboViewAttr.SelectedIndex, Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString())); } break; default: operAttributeControl.openAttributeForm(_softwareID, _software, _dashBoard); break; } }
private void btnAddAttr_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count != 0) { AttributeControl attControl = new AttributeControl(); switch (cmbDataViews.SelectedIndex) { case 0: attControl.openAttributeForm( Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[8].Value.ToString()), dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Trim(), this); break; case 1: attControl.openAttributeForm( Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[4].Value.ToString()), dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Trim(), this); break; case 2: attControl.openAttributeForm( Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[7].Value.ToString()), dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Trim(), this); break; } } }
private void btnSubmitCIDoc_Click(object sender, EventArgs e) { if (txtCIDocName.Text != String.Empty && txtCIDocRevision.Text != String.Empty) { var obj = new CIDocs() { ID = _cidocInfo.ID != null?Convert.ToInt32(_cidocInfo.ID) : 0, Name = txtCIDocName.Text.Trim(), Date = Convert.ToString(CIDocDate.Value.Date), Revision = txtCIDocRevision.Text.Trim(), Location = txtCIDocLocation.Text.Trim(), Description = txtCIInfoCI.Text.Trim(), }; AttributeControl control = new AttributeControl(); if (_update) { if (control.updateConfigItemDoc(obj)) { MessageBox.Show("Update succeeded", "Message", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("An unknown error occured", "Error", MessageBoxButtons.OK); this.Close(); } } else { if (control.submitCIDoc(obj, _ci)) { MessageBox.Show("Item added", "Message", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("An unknown error occured", "Error", MessageBoxButtons.OK); this.Close(); } } } else { MessageBox.Show("Name and Revision fields cannot be empty", "ERROR", MessageBoxButtons.OK); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (txtSoftDocName.Text != String.Empty && txtSoftDocRevision.Text != String.Empty) { var obj = new SoftwareDoc { ID = _softwareDocument != null?Convert.ToInt32(_softwareDocument.ID) : 0, Name = txtSoftDocName.Text.Trim(), Date = Convert.ToString(SoftwarDocDate.Value.Date), Revision = txtSoftDocRevision.Text.Trim(), Location = txtSoftDocRevision.Text.Trim(), Description = txtSoftDocDescription.Text.Trim(), }; AttributeControl attributeControl = new AttributeControl(); if (_update) { if (attributeControl.updateSoftDoc(obj)) { MessageBox.Show("Software Doc updated", "Success", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("An error occured while updating", "ERROR", MessageBoxButtons.OK); this.Close(); } } else { if (attributeControl.submitSoftDoc(obj, _softwareID)) { MessageBox.Show("Software Doc added", "Success", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("An error occured while updating", "ERROR", MessageBoxButtons.OK); } } } else { MessageBox.Show("Name and Revision fields cannot be empty", "ERROR", MessageBoxButtons.OK); } }
private void btnSubmitCI_Click(object sender, EventArgs e) { if (txtCIName.Text != String.Empty && txtCIRevision.Text != String.Empty) { var Obj = new CI() { ID = _CI.ID != null?Convert.ToInt32(_CI.ID) : 0, Name = txtCIName.Text.Trim(), Date = Convert.ToString(CIDate.Value.Date), Revision = txtCIRevision.Text.Trim(), Location = txtCILocation.Text.Trim(), Description = txtCIInfoCI.Text.Trim(), }; AttributeControl attributeControl = new AttributeControl(); if (_update) { if (attributeControl.updateConfigItem(Obj)) { MessageBox.Show("ConfigItem updated", "Success", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("An error occured while updating", "ERROR", MessageBoxButtons.OK); this.Close(); } } else { if (attributeControl.submitCI(Obj, _softwareID)) { MessageBox.Show("ConfigItem added", "Success", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("An error occured while updating", "ERROR", MessageBoxButtons.OK); } } } else { MessageBox.Show("Name and Revision fields cannot be empty", "ERROR", MessageBoxButtons.OK); } }
private void selectView(object sender, EventArgs e) { //if (comboViewAttr.SelectedValue != null) //{ int viewSelection = Convert.ToInt32(comboViewAttr.SelectedIndex); AttributeControl attributes = new AttributeControl(); switch (viewSelection) { case 0: dgvViewAttr.DataSource = attributes.SoftwareItemOverview(_softwareID); //Hide columns dgvViewAttr.Columns[0].Visible = false; dgvViewAttr.Columns[6].Visible = false; dgvViewAttr.Columns[12].Visible = false; //Alter column headers dgvViewAttr.Columns["SoftwareDocName"].HeaderText = "Software Document: Name"; dgvViewAttr.Columns["SoftwareDocRevision"].HeaderText = "Software Document: Revision"; dgvViewAttr.Columns["SoftwareDocLocation"].HeaderText = "Software Document: Location"; dgvViewAttr.Columns["SoftwareDocDate"].HeaderText = "Software Document: Date"; dgvViewAttr.Columns["SoftwareDocDesc"].HeaderText = "Software Document: Description"; dgvViewAttr.Columns["ConfigItemName"].HeaderText = "Configuration Item: Name"; dgvViewAttr.Columns["ConfigItemRev"].HeaderText = "Configuration Item: Revision"; dgvViewAttr.Columns["ConfigItemLocal"].HeaderText = "Configuration Item: Location"; dgvViewAttr.Columns["ConfigItemDate"].HeaderText = "Configuration Item: Date"; dgvViewAttr.Columns["ConfigItemDes"].HeaderText = "Configuration Item: Description"; dgvViewAttr.Columns["ConfigItemDocName"].HeaderText = "Configuration Item Document: Name"; dgvViewAttr.Columns["ConfigItemDocRev"].HeaderText = "Configuration Item Document: Revision"; dgvViewAttr.Columns["ConfigItemDocLocal"].HeaderText = "Configuration Item Document: Location"; dgvViewAttr.Columns["ConfigItemDocDate"].HeaderText = "Configuration Item Document: Date"; dgvViewAttr.Columns["ConfigItemDocDesc"].HeaderText = "Configuration Item Document: Description"; break; case 1: dgvViewAttr.DataSource = attributes.SoftwareViewOne(_softwareID); dgvViewAttr.Columns["SoftwareDocID"].Visible = false; dgvViewAttr.Columns["Software_Id"].Visible = false; dgvViewAttr.Columns["Name"].HeaderText = "Software Document: Name"; dgvViewAttr.Columns["Revision"].HeaderText = "Software Document: Revision"; dgvViewAttr.Columns["Date"].HeaderText = "Software Document: Date"; dgvViewAttr.Columns["Description"].HeaderText = "Software Document: Description"; dgvViewAttr.Columns["Location"].HeaderText = "Software Document: Location"; break; case 2: dgvViewAttr.DataSource = attributes.SoftwareViewTwo(_softwareID); dgvViewAttr.Columns["CI_ID"].Visible = false; dgvViewAttr.Columns["SoftwareID"].Visible = false; dgvViewAttr.Columns["Name"].HeaderText = "Configuration Item: Name"; dgvViewAttr.Columns["Revision"].HeaderText = "Configuration Item: Revision"; dgvViewAttr.Columns["Date"].HeaderText = "Configuration Item: Date"; dgvViewAttr.Columns["Description"].HeaderText = "Configuration Item: Description"; dgvViewAttr.Columns["Location"].HeaderText = "Configuration Item: Location"; break; case 3: dgvViewAttr.DataSource = attributes.SoftwareViewThree(_softwareID); dgvViewAttr.Columns["CID_ID"].Visible = false; dgvViewAttr.Columns["Name"].HeaderText = "Configuration Item Document: Name"; dgvViewAttr.Columns["Revision"].HeaderText = "Configuration Item Document: Revision"; dgvViewAttr.Columns["Date"].HeaderText = "Configuration Item Document: Date"; dgvViewAttr.Columns["Description"].HeaderText = "Configuration Item Document: Description"; dgvViewAttr.Columns["Location"].HeaderText = "Configuration Item Document: Location"; break; default: break; } //} }
private void btnDeleteAttr_Click(object sender, EventArgs e) { StringBuilder attributeDeleteResult = new StringBuilder(); AttributeControl deleteAttributeControl = new AttributeControl(); if (dgvViewAttr.SelectedRows.Count != 0) { //Will need a switch for which view is being used switch (comboViewAttr.SelectedIndex) { case 1: { if (deleteAttributeControl.deleteSoftDoc( Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()))) { MessageBox.Show("Software Document has been removed", "Success", MessageBoxButtons.OK); } break; } case 2: { if (deleteAttributeControl.deleteConfigItem( Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()))) { MessageBox.Show("Config Item has been removed", "Success", MessageBoxButtons.OK); } break; } case 3: { if (deleteAttributeControl.deleteConfigItemDOC( Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()))) { MessageBox.Show("Config Item has been removed", "Success", MessageBoxButtons.OK); } break; } default: // mass delete 0 { if (deleteAttributeControl.deleteSoftDoc( Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()))) { attributeDeleteResult.Append("Software Document has been deleted" + Environment.NewLine); } if (deleteAttributeControl.deleteConfigItem( Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[6].Value.ToString()))) { attributeDeleteResult.Append("ConfigItem has been deleted" + Environment.NewLine); } if (deleteAttributeControl.deleteConfigItemDOC( Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[12].Value.ToString()))) { attributeDeleteResult.Append("ConfigItem Document has been deleted" + Environment.NewLine); } MessageBox.Show(attributeDeleteResult.ToString(), "Result", MessageBoxButtons.OK); break; } } } }
private void btnEditViewAttr_Click(object sender, EventArgs e) { //Need to do edits based on views if (dgvViewAttr.SelectedRows.Count != 0) { switch (comboViewAttr.SelectedIndex) { case 0: { List <Attributes> attributes = new List <Attributes>(); //don't know yet: var softwareDOC = new Attributes() { ID = dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString() != string.Empty ? Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString().Trim()) : 0, Name = dgvViewAttr.SelectedRows[0].Cells[1].Value.ToString().Trim(), Revision = dgvViewAttr.SelectedRows[0].Cells[2].Value.ToString().Trim(), Location = dgvViewAttr.SelectedRows[0].Cells[3].Value.ToString().Trim(), Date = dgvViewAttr.SelectedRows[0].Cells[4].Value.ToString().Trim(), Description = dgvViewAttr.SelectedRows[0].Cells[5].Value.ToString().Trim() }; attributes.Add(softwareDOC); var configItem = new Attributes() { ID = dgvViewAttr.SelectedRows[0].Cells[6].Value.ToString() != string.Empty ? Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[6].Value.ToString().Trim()): 0, Name = dgvViewAttr.SelectedRows[0].Cells[7].Value.ToString().Trim(), Revision = dgvViewAttr.SelectedRows[0].Cells[8].Value.ToString().Trim(), Location = dgvViewAttr.SelectedRows[0].Cells[9].Value.ToString().Trim(), Date = dgvViewAttr.SelectedRows[0].Cells[10].Value.ToString().Trim(), Description = dgvViewAttr.SelectedRows[0].Cells[11].Value.ToString().Trim() }; attributes.Add(configItem); var configItemDOC = new Attributes() { ID = dgvViewAttr.SelectedRows[0].Cells[12].Value.ToString() != string.Empty ? Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[12].Value.ToString().Trim()) : 0, Name = dgvViewAttr.SelectedRows[0].Cells[13].Value.ToString().Trim(), Revision = dgvViewAttr.SelectedRows[0].Cells[14].Value.ToString().Trim(), Location = dgvViewAttr.SelectedRows[0].Cells[15].Value.ToString().Trim(), Date = dgvViewAttr.SelectedRows[0].Cells[16].Value.ToString().Trim(), Description = dgvViewAttr.SelectedRows[0].Cells[17].Value.ToString().Trim() }; attributes.Add(configItemDOC); AttributeControl massEdit = new AttributeControl(); massEdit.openAttributForEditAll(attributes, 0, this, _softwareID); break; } case 1: //Edit Software Documents { var attribute = new Attributes() { ID = Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()), Name = dgvViewAttr.SelectedRows[0].Cells[2].Value.ToString(), Revision = dgvViewAttr.SelectedRows[0].Cells[3].Value.ToString(), Date = dgvViewAttr.SelectedRows[0].Cells[4].Value.ToString(), Description = dgvViewAttr.SelectedRows[0].Cells[5].Value.ToString(), Location = dgvViewAttr.SelectedRows[0].Cells[6].Value.ToString() }; AttributeControl attributeControl = new AttributeControl(); // attributeControl.openAttributForEdit(attribute, 1, this); attributeControl.openSoftwareDocForEdit(attribute); } break; case 2: //Edit ConfigItem { var attribute = new Attributes() { ID = Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()), Name = dgvViewAttr.SelectedRows[0].Cells[2].Value.ToString(), Revision = dgvViewAttr.SelectedRows[0].Cells[3].Value.ToString(), Date = dgvViewAttr.SelectedRows[0].Cells[4].Value.ToString(), Description = dgvViewAttr.SelectedRows[0].Cells[5].Value.ToString(), Location = dgvViewAttr.SelectedRows[0].Cells[6].Value.ToString() }; AttributeControl attributeControl = new AttributeControl(); // attributeControl.openAttributForEdit(attribute, 2, this); attributeControl.openConfigItemForEdit(attribute); } break; case 3: // Edit ConfigItemDoc { var attribute = new Attributes() { ID = Convert.ToInt32(dgvViewAttr.SelectedRows[0].Cells[0].Value.ToString()), Name = dgvViewAttr.SelectedRows[0].Cells[1].Value.ToString(), Description = dgvViewAttr.SelectedRows[0].Cells[2].Value.ToString(), Location = dgvViewAttr.SelectedRows[0].Cells[3].Value.ToString(), Revision = dgvViewAttr.SelectedRows[0].Cells[4].Value.ToString(), Date = dgvViewAttr.SelectedRows[0].Cells[5].Value.ToString() }; AttributeControl attributeControl = new AttributeControl(); //attributeControl.openAttributForEdit(attribute, 3, this); attributeControl.openConfigItemDocForEdit(attribute); } break; default: break; } } else { MessageBox.Show("You must select an attribute in order to edit", "ERROR!", MessageBoxButtons.OK); } }
private void btnAttrSubmit_Click(object sender, EventArgs e) { StringBuilder result = new StringBuilder(); AttributeControl newAttributes = new AttributeControl(); bool haultFormCloser = false; if (!_update) { if (chkboxSoftDocAttr.Checked == false) { if (txtSoftDocNameAttr.Text != String.Empty && txtSoftDocRevisionAttr.Text != String.Empty) { var objSoftware = new SoftwareDoc() { Name = txtSoftDocNameAttr.Text, Date = Convert.ToString(dateSoftDocAttr.Value.Date), Revision = txtSoftDocRevisionAttr.Text, Location = txtSoftDocLocAttr.Text, Description = txtSoftDocDescAttr.Text, }; if (newAttributes.submitSoftDoc(objSoftware, _softwareID)) { result.Append("Software Document has been added" + Environment.NewLine); chkboxSoftDocAttr.Checked = true; } } else { MessageBox.Show("Please make sure that a Name and Revision for Software Document are filled", "ERROR!", MessageBoxButtons.OK); haultFormCloser = true; } } if (chkboxCIAttr.Checked == false) { if (txtCINameAttr.Text != String.Empty && txtCIRevisionAttr.Text != String.Empty) { var objCI = new CI() { Name = txtCINameAttr.Text.Trim(), Date = Convert.ToString(dateCIAttr.Value.Date), Revision = txtCIRevisionAttr.Text.Trim(), Location = txtCILocAttr.Text.Trim(), Description = txtCIDesAttr.Text.Trim() }; if (newAttributes.submitCI(objCI, _softwareID)) { result.Append("Configuration Item added" + Environment.NewLine); chkboxCIAttr.Checked = true; } } else { MessageBox.Show("Please make sure that a Name and Revision for Configuration Item are filled", "ERROR!", MessageBoxButtons.OK); haultFormCloser = true; } } if (chkboxCIDocAttr.Checked == false) { if (txtCIDocNameAttr.Text != String.Empty && txtCIDocRevisAttr.Text != String.Empty) { var objCIDoc = new CIDocs() { Name = txtCIDocNameAttr.Text.Trim(), Date = Convert.ToString(dateCIDocAttr.Value.Date), Revision = txtCIDocRevisAttr.Text.Trim(), Location = txtCIDocLocAttr.Text.Trim(), Description = txtCIDocDesAttr.Text.Trim() }; if (newAttributes.submitCIDoc(objCIDoc, _configItemID)) { result.Append("CI Document Added" + Environment.NewLine); chkboxCIDocAttr.Checked = true; } } else { MessageBox.Show("Please make sure that a Name and Revision for Configuration Item Document are filled", "ERROR!", MessageBoxButtons.OK); haultFormCloser = true; } } MessageBox.Show(result.ToString(), "Adding Attribute(s) Result:", MessageBoxButtons.OK); if (!haultFormCloser) { _myDashBoard.UpdateGrid(sender, e); this.Close(); } } else { AttributeControl updateAttributeControl = new AttributeControl(); //MessageBox.Show("Update", "Message", MessageBoxButtons.OK); if (chkboxSoftDocAttr.Checked == false) { var objSoftware = new SoftwareDoc() { ID = (_attributesInfo != null ? _attributesInfo.ID : _attributesesInfoAll[0].ID), Name = txtSoftDocNameAttr.Text.Trim(), Date = Convert.ToString(dateSoftDocAttr.Value.Date), Revision = txtSoftDocRevisionAttr.Text.Trim(), Location = txtSoftDocLocAttr.Text.Trim(), Description = txtSoftDocDescAttr.Text.Trim(), }; if (updateAttributeControl.updateSoftDoc(objSoftware, lblSoftwareID.Text)) { result.Append("Software Document has been updated" + Environment.NewLine); } } if (chkboxCIAttr.Checked == false) { var objCI = new CI() { ID = (_attributesInfo != null ? _attributesInfo.ID : _attributesesInfoAll[1].ID), Name = txtCINameAttr.Text.Trim(), Date = Convert.ToString(dateCIAttr.Value.Date), Revision = txtCIRevisionAttr.Text.Trim(), Location = txtCILocAttr.Text.Trim(), Description = txtCIDesAttr.Text.Trim() }; if (updateAttributeControl.updateConfigItem(objCI, lblSoftwareID.Text)) { result.Append("ConfigItem updated" + Environment.NewLine); } } if (chkboxCIDocAttr.Checked == false) { var objCIDoc = new CIDocs() { ID = (_attributesInfo != null ? _attributesInfo.ID : _attributesesInfoAll[2].ID), Name = txtCIDocNameAttr.Text.Trim(), Date = Convert.ToString(dateCIDocAttr.Value.Date), Revision = txtCIDocRevisAttr.Text.Trim(), Location = txtCIDocLocAttr.Text.Trim(), Description = txtCIDocDesAttr.Text.Trim() }; if (updateAttributeControl.updateConfigItemDoc(objCIDoc, lblSoftwareID.Text)) { result.Append("ConfigItem Doc updated" + Environment.NewLine); } } MessageBox.Show(result.ToString(), "Update Attribute(s) Result", MessageBoxButtons.OK); _attributes.RefreshGrid(sender, e); this.Close(); } }