コード例 #1
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            string ServerGroup  = string.Empty;
            bool   DevSaved     = false;
            bool   UATSaved     = false;
            bool   ProdSaved    = false;
            bool   PreProdSaved = false;

            if (!DoValidation())
            {
                return;
            }

            if (cbServerGroup.Visible)
            {
                ServerGroup = cbServerGroup.Text;
            }
            else
            {
                ServerGroup = tServerGroup.Text;
            }

            try
            {
                using (DataStuff sn = new DataStuff())
                {
                    if (tServerAliasDev.Text.Trim() != "")
                    {
                        sn.SaveServerGroup(ServerGroup, tServerAliasDev.Text, tServerNameDev.Text, cbServerRoleDev.Text, tReleaseOrderDev.Text);
                        DevSaved = true;
                    }

                    if (tServerAliasUAT.Text.Trim() != "")
                    {
                        sn.SaveServerGroup(ServerGroup, tServerAliasUAT.Text, tServerNameUAT.Text, cbServerRoleUAT.Text, tReleaseOrderUAT.Text);
                        UATSaved = true;
                    }

                    if (tServerAliasPreProd.Text.Trim() != "")
                    {
                        sn.SaveServerGroup(ServerGroup, tServerAliasPreProd.Text, tServerNamePreProd.Text, cbServerRolePreProd.Text, tReleaseOrderPreProd.Text);
                        PreProdSaved = true;
                    }

                    if (tServerAliasProd.Text.Trim() != "")
                    {
                        sn.SaveServerGroup(ServerGroup, tServerAliasProd.Text, tServerNameProd.Text, cbServerRoleProd.Text, tReleaseOrderProd.Text);
                        ProdSaved = true;
                    }

                    if ((DevSaved) || (UATSaved) || (ProdSaved) || (PreProdSaved))
                    {
                        MessageBox.Show("Server group saved.", "Server Settings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        tServerGroup.Visible  = false;
                        cbServerGroup.Visible = true;
                        LoadServerGroups();
                    }
                    else
                    {
                        MessageBox.Show("There was an error saving the server group.", "Server Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }

            catch
            {
            }
        }