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 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(); } }