Пример #1
0
        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);
            }
        }
Пример #2
0
        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();
            }
        }