public bool submitSoftDoc(SoftwareDoc aDoc, int softwareID) { bool value; //Changed to bool to indicate whether insert was a success. using (SqlConnection connect = new SqlConnection(_connectionString)) { using (SqlCommand command = new SqlCommand("usp_Insert_NewSoftwareDOC", connect)) { connect.Open(); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@SoftwareID", softwareID); command.Parameters.AddWithValue("@Name", aDoc.Name); command.Parameters.AddWithValue("@Revision", aDoc.Revision); command.Parameters.AddWithValue("@Date", aDoc.Date); command.Parameters.AddWithValue("@Description", aDoc.Description); command.Parameters.AddWithValue("@Location", aDoc.Location); int success = command.ExecuteNonQuery(); if (success > 0) { value = true; } else { value = false; } } } return(value); }
private void btnSubmit_Click(object sender, EventArgs e) { var obj = new SoftwareDoc { Name = txtSoftDocName.Text, Date = Convert.ToString(SoftwarDocDate.Value.Date), Revision = txtSoftDocRevision.Text, Location = txtSoftDocRevision.Text, Description = txtSoftDocDescription.Text, }; }
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 btnAttrSubmit_Click(object sender, EventArgs e) { if (chkboxSoftDocAttr.Checked == false) { var objSoftware = new SoftwareDoc() { ID = 1, Name = txtSoftDocNameAttr.Text, Date = Convert.ToString(dateSoftDocAttr.Value.Date), Revision = txtSoftDocRevisionAttr.Text, Location = txtSoftDocLocAttr.Text, Description = txtSoftDocDescAttr.Text, }; } if (chkboxCIAttr.Checked == false) { var objCI = new CI() { ID = 1, Name = txtCINameAttr.Text, Date = Convert.ToString(dateCIAttr.Value.Date), Revision = txtCIRevisionAttr.Text, Location = txtCILocAttr.Text, Description = txtCIDesAttr.Text }; } if (chkboxCIDocAttr.Checked == false) { var objCIDoc = new CIDocs() { ID = 1, Name = txtCIDocNameAttr.Text, Date = Convert.ToString(dateCIDocAttr.Value.Date), Revision = txtCIRevisionAttr.Text, Location = txtCIDocLocAttr.Text, Description = txtCIDocDesAttr.Text }; } }
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(); } }