private void LoadServer()
        {
            string strName = oFunction.decryptQueryString(Request.QueryString["n"]);

            txtName.Text = strName;
            bool boolFound   = false;
            bool boolAlready = false;

            DataSet dsRecom = oAsset.GetDecommissionRecommission(strName);

            foreach (DataRow drRecom in dsRecom.Tables[0].Rows)
            {
                if (drRecom["name"].ToString().ToUpper().Trim() == strName.ToUpper().Trim())
                {
                    DateTime datDecom = DateTime.Now;
                    boolAlready             = true;
                    lblAlreadySerial.Text   = drRecom["serial"].ToString();
                    lblAlreadySerialDR.Text = drRecom["serialdr"].ToString();
                    lblAlreadyBy.Text       = drRecom["username"].ToString();
                    lblAlreadyOn.Text       = drRecom["created"].ToString();
                    lblAlreadyReason.Text   = drRecom["reason"].ToString();
                    lblAlreadyPower.Text    = drRecom["decom"].ToString();
                    if (drRecom["running"].ToString() == "-1")
                    {
                        lblAlreadyStatus.Text = "Manual Intervention Required";
                    }
                    else if (drRecom["running"].ToString() == "-2")
                    {
                        boolAlready           = false;
                        lblAlreadyStatus.Text = "Cancelled";
                    }
                    else if (drRecom["running"].ToString() == "2")
                    {
                        lblAlreadyStatus.Text = "In Progress";
                    }
                    else if (drRecom["running"].ToString() == "3")
                    {
                        lblAlreadyStatus.Text = "Completed";
                    }
                    else if (drRecom["running"].ToString() == "1")
                    {
                        lblAlreadyStatus.Text = "Running...";
                    }
                    else if (drRecom["running"].ToString() == "0")
                    {
                        if (drRecom["recommissioned"].ToString() != "")
                        {
                            boolAlready           = false;
                            lblAlreadyStatus.Text = "Recommissioned on " + drRecom["recommissioned"].ToString();
                        }
                        else if (drRecom["destroyed"].ToString() != "")
                        {
                            lblAlreadyStatus.Text  = "Powered off on " + drRecom["turnedoff"].ToString();
                            lblAlreadyStatus.Text += "<br/>Finished on " + drRecom["destroyed"].ToString();
                        }
                        else if (drRecom["destroy"].ToString() != "")
                        {
                            lblAlreadyStatus.Text  = "Powered off on " + drRecom["turnedoff"].ToString();
                            lblAlreadyStatus.Text += "<br/>Will be finished on " + drRecom["destroy"].ToString();
                        }
                        else if (drRecom["turnedoff"].ToString() != "")
                        {
                            lblAlreadyStatus.Text = "Powered off on " + drRecom["turnedoff"].ToString();
                        }
                        else
                        {
                            lblAlreadyStatus.Text = "Will be powered off on " + drRecom["decom"].ToString();
                        }
                    }
                    else
                    {
                        lblAlreadyStatus.Text = "Status Unavailable";
                    }
                }
            }

            if (boolAlready == false)
            {
                DataSet ds = oServer.GetDecommission(strName);
                if (ds.Tables[0].Rows.Count == 1)
                {
                    boolFound = true;
                    bool boolPermit = false;
                    int  intServer  = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());

                    int      intRequest = Int32.Parse(Request.QueryString["rid"]);
                    int      intProject = oRequest.GetProjectNumber(intRequest);
                    Projects oProject   = new Projects(intProfile, dsn);
                    bool     boolDemo   = false;
                    string   strNumber  = oProject.Get(intProject, "number");
                    // Check to see if Demo
                    DataSet dsDemo = oFunction.GetSetupValuesByKey("DEMO_PROJECT");
                    foreach (DataRow drDemo in dsDemo.Tables[0].Rows)
                    {
                        if (strNumber == drDemo["Value"].ToString())
                        {
                            boolDemo = true;
                            break;
                        }
                    }

                    if (boolDemo == false &&
                        (String.IsNullOrEmpty(oServer.Get(intServer, "build_ready")) == true ||
                         oServer.Get(intServer, "rebuilding") == "1"))
                    {
                        panBuilding.Visible = true;
                        btnNext.Enabled     = false;
                    }
                    else
                    {
                        int intAnswer = 0;
                        if (ds.Tables[0].Rows[0]["answerid"].ToString() != "")
                        {
                            intAnswer = Int32.Parse(ds.Tables[0].Rows[0]["answerid"].ToString());
                        }
                        int intUser = 0;
                        if (ds.Tables[0].Rows[0]["userid"].ToString() != "")
                        {
                            intUser = Int32.Parse(ds.Tables[0].Rows[0]["userid"].ToString());
                        }
                        int    intOwner     = 0;
                        int    intPrimary   = 0;
                        int    intSecondary = 0;
                        int    intRequestor = 0;
                        string strAgree     = "";
                        if (intAnswer > 0)
                        {
                            if (oForecast.GetAnswer(intAnswer, "appcontact") != "")
                            {
                                intOwner = Int32.Parse(oForecast.GetAnswer(intAnswer, "appcontact"));
                            }
                            if (oForecast.GetAnswer(intAnswer, "admin1") != "")
                            {
                                intPrimary = Int32.Parse(oForecast.GetAnswer(intAnswer, "admin1"));
                            }
                            if (oForecast.GetAnswer(intAnswer, "admin2") != "")
                            {
                                intSecondary = Int32.Parse(oForecast.GetAnswer(intAnswer, "admin2"));
                            }
                            if (oForecast.GetAnswer(intAnswer, "userid") != "")
                            {
                                intRequestor = Int32.Parse(oForecast.GetAnswer(intAnswer, "userid"));
                            }
                            if (intProfile == intOwner || intProfile == intPrimary || intProfile == intSecondary || intProfile == intRequestor)
                            {
                                boolPermit = true;
                            }

                            if (intOwner > 0)
                            {
                                strAgree += " - " + oUser.GetFullName(intOwner) + " (" + oUser.GetName(intOwner) + ")\\n";
                            }
                            if (intPrimary > 0)
                            {
                                strAgree += " - " + oUser.GetFullName(intPrimary) + " (" + oUser.GetName(intPrimary) + ")\\n";
                            }
                            if (intSecondary > 0)
                            {
                                strAgree += " - " + oUser.GetFullName(intSecondary) + " (" + oUser.GetName(intSecondary) + ")\\n";
                            }
                            if (intRequestor > 0)
                            {
                                strAgree += " - " + oUser.GetFullName(intRequestor) + " (" + oUser.GetName(intRequestor) + ")\\n";
                            }
                        }
                        if (oApplication.Get(intApplication, "decom") == "1" || oUser.IsAdmin(intProfile) || intProfile == intUser)
                        {
                            boolPermit = true;
                        }

                        if (boolPermit == true)
                        {
                            chkAgree.Attributes.Add("onclick", "ShowAgreeAlert(this,\"" + strAgree + "\");");
                            int     intAsset   = 0;
                            int     intAssetDR = 0;
                            DataSet dsAsset    = oServer.GetAssets(intServer);
                            foreach (DataRow drAsset in dsAsset.Tables[0].Rows)
                            {
                                if (drAsset["latest"].ToString() == "1")
                                {
                                    intAsset = Int32.Parse(drAsset["assetid"].ToString());
                                }
                                if (drAsset["dr"].ToString() == "1")
                                {
                                    intAssetDR = Int32.Parse(drAsset["assetid"].ToString());
                                }
                            }

                            if (intAsset > 0)
                            {
                                panFound.Visible  = true;
                                panDetail.Visible = true;

                                int intClass   = 0;
                                int intEnv     = 0;
                                int intAddress = 0;
                                try
                                {
                                    intClass   = Int32.Parse(oAsset.GetServerOrBlade(intAsset, "classid"));
                                    intEnv     = Int32.Parse(oAsset.GetServerOrBlade(intAsset, "environmentid"));
                                    intAddress = Int32.Parse(oAsset.GetServerOrBlade(intAsset, "addressid"));
                                }
                                catch
                                {
                                    DataSet dsCatch = oServer.GetAsset(intAsset);
                                    if (dsCatch.Tables[0].Rows.Count > 0)
                                    {
                                        intClass   = Int32.Parse(dsCatch.Tables[0].Rows[0]["classid"].ToString());
                                        intEnv     = Int32.Parse(dsCatch.Tables[0].Rows[0]["environmentid"].ToString());
                                        intAddress = Int32.Parse(dsCatch.Tables[0].Rows[0]["addressid"].ToString());
                                    }
                                }
                                if (intClass == 0 && intAnswer > 0)
                                {
                                    Int32.TryParse(oForecast.GetAnswer(intAnswer, "classid"), out intClass);
                                }
                                if (intEnv == 0 && intAnswer > 0)
                                {
                                    Int32.TryParse(oForecast.GetAnswer(intAnswer, "environmentid"), out intEnv);
                                }
                                if (intAddress == 0 && intAnswer > 0)
                                {
                                    Int32.TryParse(oForecast.GetAnswer(intAnswer, "addressid"), out intAddress);
                                }
                                int intModel = 0;
                                if (oAsset.Get(intAsset, "modelid") != "")
                                {
                                    intModel = Int32.Parse(oAsset.Get(intAsset, "modelid"));
                                }
                                lblModel.Text     = oModelsProperties.Get(intModel, "name");
                                lblModel.ToolTip  = "ModelID: " + intModel.ToString();
                                lblSerial.Text    = oAsset.Get(intAsset, "serial");
                                lblSerial.ToolTip = "AssetID: " + intAsset.ToString();
                                if (intAssetDR > 0)
                                {
                                    panDR.Visible       = true;
                                    lblSerialDR.Text    = oAsset.Get(intAssetDR, "serial");
                                    lblSerialDR.ToolTip = "AssetID: " + intAssetDR.ToString();
                                }
                                lblClass.Text       = oClass.Get(intClass, "name");
                                lblClass.ToolTip    = intClass.ToString();
                                lblEnvironment.Text = oEnvironment.Get(intEnv, "name");
                                lblAddress.Text     = oLocation.GetFull(intAddress);
                                panValid.Visible    = true;
                                lblId.Text          = intServer.ToString();
                                btnNext.Attributes.Add("onclick", "return ValidateCheck('" + chkAgree.ClientID + "','Please check the box stating that you agree to the disclaimer notice')" +
                                                       " && ValidateDate('" + txtDate.ClientID + "','Please enter a valid date')" +
                                                       " && ValidateDateToday('" + txtDate.ClientID + "','The date must occur after today')" +
                                                       GetClass(intServer, intClass, intEnv) +
                                                       " && ValidateText('" + txtReason.ClientID + "','Please enter a reason')" +
                                                       " && ValidateRadioButtons('" + radRetrieveYes.ClientID + "','" + radRetrieveNo.ClientID + "','Please select whether or not special hardware should be retrieved')" +
                                                       " && (document.getElementById('" + radRetrieveYes.ClientID + "').checked == false || (document.getElementById('" + radRetrieveYes.ClientID + "').checked == true && ValidateText('" + txtRetrieve.ClientID + "','Please provide a description')))" +
                                                       " && (document.getElementById('" + radRetrieveYes.ClientID + "').checked == false || (document.getElementById('" + radRetrieveYes.ClientID + "').checked == true && ValidateText('" + txtRetrieveAddress.ClientID + "','Please provide an address')))" +
                                                       " && (document.getElementById('" + radRetrieveYes.ClientID + "').checked == false || (document.getElementById('" + radRetrieveYes.ClientID + "').checked == true && ValidateText('" + txtRetrieveLocator.ClientID + "','Please provide a locator')))" +
                                                       " && ProcessButton(this)" +
                                                       ";");
                            }
                            else
                            {
                                boolFound = false;
                            }
                        }
                        else
                        {
                            panInvalid.Visible = true;
                            if (intUser > 0)
                            {
                                strContacts += "<tr><td>Server Owner:</td><td>" + oUser.GetFullName(intUser) + " (" + oUser.GetName(intUser) + ")" + "</td></tr>";
                            }
                            if (intOwner > 0)
                            {
                                strContacts += "<tr><td>Departmental Manager:</td><td>" + oUser.GetFullName(intOwner) + " (" + oUser.GetName(intOwner) + ")" + "</td></tr>";
                            }
                            if (intPrimary > 0)
                            {
                                strContacts += "<tr><td>Application Technical Lead:</td><td>" + oUser.GetFullName(intPrimary) + " (" + oUser.GetName(intPrimary) + ")" + "</td></tr>";
                            }
                            if (intSecondary > 0)
                            {
                                strContacts += "<tr><td>Administrative Contact:</td><td>" + oUser.GetFullName(intSecondary) + " (" + oUser.GetName(intSecondary) + ")" + "</td></tr>";
                            }
                            if (intRequestor > 0)
                            {
                                strContacts += "<tr><td>Design Initiated By:</td><td>" + oUser.GetFullName(intRequestor) + " (" + oUser.GetName(intRequestor) + ")" + "</td></tr>";
                            }
                            DataSet dsDecoms = oApplication.GetDecoms();
                            if (dsDecoms.Tables[0].Rows.Count > 0)
                            {
                                strContacts += "<tr><td colspan=\"2\">Alternatively, you can contact a resource from one of the following departments:</td></tr>";
                                foreach (DataRow drDecom in dsDecoms.Tables[0].Rows)
                                {
                                    strContacts += "<tr><td></td><td>" + drDecom["name"].ToString() + "</td></tr>";
                                }
                            }
                            btnNext.Enabled = false;
                        }
                    }
                }
                else if (ds.Tables[0].Rows.Count > 1)
                {
                    boolFound       = true;
                    panMore.Visible = true;
                    btnNext.Enabled = false;
                }

                if (boolFound == false)
                {
                    panNotFound.Visible = true;
                    lblName.Text        = strName;
                    if (Request.QueryString["yn"] != null)
                    {
                        if (Request.QueryString["yn"] == "y")
                        {
                            panConfirm.Visible = true;
                            radYes.Checked     = true;
                            LoadLists();
                            int intClass = 0;
                            if (Request.QueryString["cid"] != null && Request.QueryString["cid"] != "")
                            {
                                intClass = Int32.Parse(Request.QueryString["cid"]);
                            }
                            if (oClass.Get(intClass).Tables[0].Rows.Count > 0)
                            {
                                panClass.Visible       = true;
                                ddlClass.SelectedValue = intClass.ToString();
                                ddlEnvironment.Enabled = true;
                                Environments oEnvironment = new Environments(intProfile, dsn);
                                ddlEnvironment.DataValueField = "id";
                                ddlEnvironment.DataTextField  = "name";
                                ddlEnvironment.DataSource     = oClass.GetEnvironment(intClass, 0);
                                ddlEnvironment.DataBind();
                                ddlEnvironment.Items.Insert(0, new ListItem("-- SELECT --", "0"));
                                int intEnv = 0;
                                if (Request.QueryString["eid"] != null && Request.QueryString["eid"] != "")
                                {
                                    intEnv = Int32.Parse(Request.QueryString["eid"]);
                                }
                                if (oEnvironment.Get(intEnv).Tables[0].Rows.Count > 0)
                                {
                                    panEnvironment.Visible       = true;
                                    panDetail.Visible            = true;
                                    ddlEnvironment.SelectedValue = intEnv.ToString();
                                    lblId.Text = "0";
                                    btnNext.Attributes.Add("onclick", "return ValidateDropDown('" + ddlPlatform.ClientID + "','Please select a platform')" +
                                                           " && ValidateDropDown('" + ddlPlatformType.ClientID + "','Please select a type')" +
                                                           " && ValidateDropDown('" + ddlPlatformModel.ClientID + "','Please select a model')" +
                                                           " && ValidateDropDown('" + ddlPlatformModelProperty.ClientID + "','Please select a model property')" +
                                                           " && ValidateText('" + txtSerial.ClientID + "','Please enter a serial number')" +
                                                           " && ValidateHidden0('" + hdnLocation.ClientID + "','ddlState','Please select a location')" +
                                                           " && ValidateCheck('" + chkAgree.ClientID + "','Please check the box stating that you agree to the disclaimer notice')" +
                                                           " && ValidateDate('" + txtDate.ClientID + "','Please enter a valid date')" +
                                                           " && ValidateDateToday('" + txtDate.ClientID + "','The date must occur after today')" +
                                                           GetClass(0, intClass, intEnv) +
                                                           " && ValidateText('" + txtReason.ClientID + "','Please enter a reason')" +
                                                           " && ValidateRadioButtons('" + radRetrieveYes.ClientID + "','" + radRetrieveNo.ClientID + "','Please select whether or not special hardware should be retrieved')" +
                                                           " && (document.getElementById('" + radRetrieveYes.ClientID + "').checked == false || (document.getElementById('" + radRetrieveYes.ClientID + "').checked == true && ValidateText('" + txtRetrieve.ClientID + "','Please provide a description')))" +
                                                           " && (document.getElementById('" + radRetrieveYes.ClientID + "').checked == false || (document.getElementById('" + radRetrieveYes.ClientID + "').checked == true && ValidateText('" + txtRetrieveAddress.ClientID + "','Please provide an address')))" +
                                                           " && (document.getElementById('" + radRetrieveYes.ClientID + "').checked == false || (document.getElementById('" + radRetrieveYes.ClientID + "').checked == true && ValidateText('" + txtRetrieveLocator.ClientID + "','Please provide a locator')))" +
                                                           " && ProcessButton(this)" +
                                                           ";");
                                }
                                else
                                {
                                    btnNext.Enabled = false;
                                }
                            }
                            else
                            {
                                btnNext.Enabled = false;
                            }
                        }
                    }
                    else
                    {
                        btnNext.Enabled = false;
                    }
                }
            }
            else
            {
                panAlready.Visible = true;
                btnNext.Enabled    = false;
            }
        }
        private void LoadServer(DataRow dr)
        {
            int intRequest = Int32.Parse(dr["requestid"].ToString());
            int intItem    = Int32.Parse(dr["itemid"].ToString());
            int intNumber  = Int32.Parse(dr["number"].ToString());

            string strNameCurrent  = dr["name_current"].ToString();
            string strIPCurrent    = dr["ip_current"].ToString();
            string strAliasCurrent = dr["alias_current"].ToString();
            string strNameNew      = dr["name_new"].ToString();
            string strIPNew        = dr["ip_new"].ToString();
            string strAliasNew     = dr["alias_new"].ToString();
            string strReason       = dr["reason"].ToString();

            txtSearchName.Text  = strNameCurrent;
            txtSearchIP.Text    = strIPCurrent;
            txtSearchAlias.Text = strAliasCurrent;

            if (strReason != "")
            {
                // Show Confirmation Page
                lblName.Text       = strNameCurrent;
                lblIP.Text         = strIPCurrent;
                lblAlias.Text      = strAliasCurrent;
                panConfirm.Visible = true;
                strConfirm         = oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment);
                btnNext.Attributes.Add("onclick", "return ValidateCheck('" + chkAgree.ClientID + "','Please check the box stating that you agree to the disclaimer notice')" +
                                       " && ProcessButton(this)" +
                                       ";");
                btnDiscard.Attributes.Add("onclick", "return confirm('WARNING: Starting over will discard all the changes you have made.\\n\\nAre you sure you want to continue?') && ProcessButton(this);");
                btnContinue.Visible = false;
                btnConfirm.Visible  = false;
            }
            else
            {
                panSearch.Visible = true;
                btnNext.Visible   = false;

                // Get Record from DNS
                System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                ClearViewWebServices         oWebService  = new ClearViewWebServices();
                oWebService.Timeout     = Int32.Parse(ConfigurationManager.AppSettings["WS_TIMEOUT"]);
                oWebService.Credentials = oCredentials;
                oWebService.Url         = oVariable.WebServiceURL();
                Settings oSetting        = new Settings(0, dsn);
                bool     boolDNS_QIP     = oSetting.IsDNS_QIP();
                bool     boolDNS_Bluecat = oSetting.IsDNS_Bluecat();

                // Get Values
                if (strNameCurrent != "")
                {
                    if (boolDNS_QIP == true)
                    {
                        strIPCurrent = oWebService.SearchDNSforPNC("", strNameCurrent, false, true);
                        if (strIPCurrent.StartsWith("***") == false)
                        {
                            strNameCurrent  = oWebService.SearchDNSforPNC(strIPCurrent, "", false, true);
                            strAliasCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", true, true);
                            if (strAliasCurrent.StartsWith("***") == true)
                            {
                                strAliasCurrent = "";
                            }
                        }
                        else
                        {
                            strNameCurrent = "";
                            strIPCurrent   = "";
                        }
                    }
                    if (boolDNS_Bluecat == true)
                    {
                        strIPCurrent = oWebService.SearchBluecatDNS("", strNameCurrent);
                        if (strIPCurrent.StartsWith("***") == false)
                        {
                            strNameCurrent  = oWebService.SearchBluecatDNS(strIPCurrent, "");
                            strAliasCurrent = "";
                        }
                        else
                        {
                            strNameCurrent = "";
                            strIPCurrent   = "";
                        }
                    }
                }
                else if (strIPCurrent != "")
                {
                    if (boolDNS_QIP == true)
                    {
                        strNameCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", false, true);
                        if (strNameCurrent.StartsWith("***") == false)
                        {
                            strAliasCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", true, true);
                            if (strAliasCurrent.StartsWith("***") == true)
                            {
                                strAliasCurrent = "";
                            }
                        }
                        else
                        {
                            strNameCurrent = "";
                            strIPCurrent   = "";
                        }
                    }
                    if (boolDNS_Bluecat == true)
                    {
                        strNameCurrent = oWebService.SearchBluecatDNS(strIPCurrent, "");
                        if (strNameCurrent.StartsWith("***") == false)
                        {
                            strAliasCurrent = "";
                        }
                        else
                        {
                            strNameCurrent = "";
                            strIPCurrent   = "";
                        }
                    }
                }
                else if (strAliasCurrent != "")
                {
                    if (boolDNS_QIP == true)
                    {
                        strIPCurrent = oWebService.SearchDNSforPNC("", strAliasCurrent, true, true);
                        if (strIPCurrent.StartsWith("***") == false)
                        {
                            strNameCurrent  = oWebService.SearchDNSforPNC(strIPCurrent, "", false, true);
                            strAliasCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", true, true);
                            if (strAliasCurrent.StartsWith("***") == true)
                            {
                                strAliasCurrent = "";
                            }
                        }
                        else
                        {
                            strAliasCurrent = "";
                            strIPCurrent    = "";
                        }
                    }
                    if (boolDNS_Bluecat == true)
                    {
                        strAliasCurrent = "";
                        strIPCurrent    = "";
                    }
                }

                if (strNameCurrent.Contains(".") == true)
                {
                    strDomain      = strNameCurrent.Substring(strNameCurrent.IndexOf("."));
                    strNameCurrent = strNameCurrent.Substring(0, strNameCurrent.IndexOf("."));
                }

                if (strNameCurrent != "" && strIPCurrent != "")
                {
                    DataSet ds = oServer.GetDNS(strNameCurrent);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        bool boolPermit   = false;
                        int  intServer    = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                        int  intUser      = (ds.Tables[0].Rows[0]["userid"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["userid"].ToString()));
                        int  intOwner     = (ds.Tables[0].Rows[0]["appcontact"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["appcontact"].ToString()));
                        int  intPrimary   = (ds.Tables[0].Rows[0]["admin1"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["admin1"].ToString()));
                        int  intSecondary = (ds.Tables[0].Rows[0]["admin2"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["admin2"].ToString()));
                        int  intRequestor = (ds.Tables[0].Rows[0]["requestor"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["requestor"].ToString()));
                        int  intClass     = (ds.Tables[0].Rows[0]["classid"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["classid"].ToString()));
                        int  intProd      = (intClass > 0 ? (oClass.IsProd(intClass) ? 1 : 0) : -1);

                        panShow.Visible  = true;
                        panAlias.Visible = boolDNS_QIP;
                        lblName.Text     = strNameCurrent;
                        lblIP.Text       = strIPCurrent;
                        lblAlias.Text    = strAliasCurrent;
                        lblDomain.Text   = strDomain;

                        // Load Values
                        txtName.Text = strNameCurrent;
                        char[]   strIPSplit = { '.' };
                        string[] strIP      = strIPCurrent.Split(strIPSplit);
                        txtIP1.Text = strIP[0];
                        txtIP2.Text = strIP[1];
                        txtIP3.Text = strIP[2];
                        txtIP4.Text = strIP[3];
                        char[]   strAliasSplit = { ';' };
                        string[] strAlias      = strAliasCurrent.Split(strAliasSplit);
                        for (int ii = 0; ii < strAlias.Length; ii++)
                        {
                            if (strAlias[ii].Trim() != "")
                            {
                                string strAliasName = strAlias[ii].Trim();
                                while (strAliasName.Contains(strDomain) == true)
                                {
                                    strAliasName = strAliasName.Replace(strDomain, "");
                                }
                                lstAlias.Items.Add(new ListItem(strAliasName, strAliasName));
                            }
                        }

                        // Check Permission and either show read only, or permit edit
                        if (intProfile == intOwner || intProfile == intPrimary || intProfile == intSecondary || intProfile == intRequestor)
                        {
                            boolPermit = true;
                        }
                        if (oApplication.Get(intApplication, "dns") == "1" || oUser.IsAdmin(intProfile) || intProfile == intUser)
                        {
                            boolPermit = true;
                        }

                        if (boolPermit == true)
                        {
                            btnContinue.Visible    = false;
                            txtSearchName.Enabled  = false;
                            txtSearchIP.Enabled    = false;
                            txtSearchAlias.Enabled = false;
                            chkName.Attributes.Add("onclick", "CheckChange3('" + chkName.ClientID + "','" + chkIP.ClientID + "','" + chkAlias.ClientID + "','" + txtName.ClientID + "');");
                            chkIP.Attributes.Add("onclick", "CheckChange3('" + chkIP.ClientID + "','" + chkName.ClientID + "','" + chkAlias.ClientID + "','" + txtIP1.ClientID + "','" + txtIP2.ClientID + "','" + txtIP3.ClientID + "','" + txtIP4.ClientID + "');");
                            chkAlias.Attributes.Add("onclick", "CheckChange3('" + chkAlias.ClientID + "','" + chkName.ClientID + "','" + chkIP.ClientID + "','" + lstAlias.ClientID + "','" + btnAdd.ClientID + "','" + btnEdit.ClientID + "','" + btnRemove.ClientID + "','" + txtAlias.ClientID + "');");
                            btnAdd.Attributes.Add("onclick", "return AddDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');");
                            btnEdit.Attributes.Add("onclick", "return EditDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');");
                            btnRemove.Attributes.Add("onclick", "return RemoveDNS('" + lstAlias.ClientID + "','" + hdnAlias.ClientID + "');");
                            string strChange = "";
                            if (intProd != 0 || oServer.Get(intServer, "infrastructure") == "1")
                            {
                                panChange.Visible = true;
                                strChange         = " && ValidateTextLength('" + txtChange.ClientID + "', 'Please enter a valid change control number\\n\\n - Must start with either \"CHG\" or \"PTM\"\\n - Must be exactly 10 characters in length', 10, ['CHG','PTM'], ['CHG0000000','PTM0000000','CHG1111111','PTM1111111','CHG9999999','PTM9999999','CHGXXXXXXX','PTMXXXXXXX'])";
                            }
                            btnConfirm.Attributes.Add("onclick", "return EnsureDNSCheck('" + chkName.ClientID + "','" + chkIP.ClientID + "','" + chkAlias.ClientID + "')" +
                                                      " && (document.getElementById('" + chkName.ClientID + "').checked == false || (document.getElementById('" + chkName.ClientID + "').checked == true" +
                                                      " && ValidateText('" + txtName.ClientID + "','Please enter a valid name')" +
                                                      "))" +
                                                      " && (document.getElementById('" + chkIP.ClientID + "').checked == false || (document.getElementById('" + chkIP.ClientID + "').checked == true" +
                                                      " && ValidateNumberBetween('" + txtIP1.ClientID + "',1,255,'Please enter a valid IP Address')" +
                                                      " && ValidateNumberBetween('" + txtIP2.ClientID + "',1,255,'Please enter a valid IP Address')" +
                                                      " && ValidateNumberBetween('" + txtIP3.ClientID + "',1,255,'Please enter a valid IP Address')" +
                                                      " && ValidateNumberBetween('" + txtIP4.ClientID + "',1,255,'Please enter a valid IP Address')" +
                                                      "))" +
                                                      strChange +
                                                      " && ValidateText('" + txtReason.ClientID + "','Please enter a reason')" +
                                                      " && ProcessButton(this)" +
                                                      ";");
                        }
                        else
                        {
                            btnConfirm.Visible = false;
                            panAccess.Visible  = true;
                            chkName.Enabled    = false;
                            chkIP.Enabled      = false;
                            chkAlias.Enabled   = false;
                            btnAdd.Enabled     = false;
                            btnEdit.Enabled    = false;
                            btnRemove.Enabled  = false;
                            if (intUser > 0)
                            {
                                strContacts += "<tr><td>Device Owner:</td><td>" + oUser.GetFullName(intUser) + " (" + oUser.GetName(intUser) + ")" + "</td></tr>";
                            }
                            if (intOwner > 0)
                            {
                                strContacts += "<tr><td>Departmental Manager:</td><td>" + oUser.GetFullName(intOwner) + " (" + oUser.GetName(intOwner) + ")" + "</td></tr>";
                            }
                            if (intPrimary > 0)
                            {
                                strContacts += "<tr><td>Application Technical Lead:</td><td>" + oUser.GetFullName(intPrimary) + " (" + oUser.GetName(intPrimary) + ")" + "</td></tr>";
                            }
                            if (intSecondary > 0)
                            {
                                strContacts += "<tr><td>Administrative Contact:</td><td>" + oUser.GetFullName(intSecondary) + " (" + oUser.GetName(intSecondary) + ")" + "</td></tr>";
                            }
                            if (intRequestor > 0)
                            {
                                strContacts += "<tr><td>Design Initiated By:</td><td>" + oUser.GetFullName(intRequestor) + " (" + oUser.GetName(intRequestor) + ")" + "</td></tr>";
                            }
                            DataSet dsDecoms = oApplication.GetDecoms();
                            if (dsDecoms.Tables[0].Rows.Count > 0)
                            {
                                strContacts += "<tr><td colspan=\"2\">Alternatively, you can contact a resource from one of the following departments:</td></tr>";
                                foreach (DataRow drDecom in dsDecoms.Tables[0].Rows)
                                {
                                    strContacts += "<tr><td></td><td>" + drDecom["name"].ToString() + "</td></tr>";
                                }
                            }
                        }
                    }
                    else
                    {
                        btnReset.Enabled   = false;
                        btnConfirm.Visible = false;
                        panExist.Visible   = true;
                        lblExist.Text      = "This device does not exist in the database. Please try again...";
                    }
                }
                else
                {
                    btnReset.Enabled   = false;
                    btnConfirm.Visible = false;
                    panExist.Visible   = true;
                    lblExist.Text      = "This device does not exist in DNS. Please try again...";
                }
            }
        }
Exemple #3
0
        private void LoadServer(DataRow dr)
        {
            int intRequest = Int32.Parse(dr["requestid"].ToString());
            int intItem    = Int32.Parse(dr["itemid"].ToString());
            int intNumber  = Int32.Parse(dr["number"].ToString());

            string strNameNew  = dr["name_new"].ToString();
            string strIPNew    = dr["ip_new"].ToString();
            string strAliasNew = dr["alias_new"].ToString();

            ddlType.SelectedValue = dr["typeid"].ToString();
            txtName.Text          = strNameNew;
            char[]   strIPSplit = { '.' };
            string[] strIP      = strIPNew.Split(strIPSplit);
            txtIP1.Text = strIP[0];
            txtIP2.Text = strIP[1];
            txtIP3.Text = strIP[2];
            txtIP4.Text = strIP[3];

            if (strAliasNew != "NONE")
            {
                // Show Confirmation Page
                lblName.Text       = strNameNew;
                lblIP.Text         = strIPNew;
                lblAlias.Text      = strAliasNew;
                panConfirm.Visible = true;
                strConfirm         = oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment);
                btnNext.Attributes.Add("onclick", "return ValidateCheck('" + chkAgree.ClientID + "','Please check the box stating that you agree to the disclaimer notice')" +
                                       " && ProcessButton(this)" +
                                       ";");
                btnDiscard.Attributes.Add("onclick", "return confirm('WARNING: Starting over will discard all the changes you have made.\\n\\nAre you sure you want to continue?') && ProcessButton(this);");
                btnContinue.Visible = false;
                btnConfirm.Visible  = false;
            }
            else
            {
                panSearch.Visible = true;
                btnNext.Visible   = false;

                // Get Record from DNS
                System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                ClearViewWebServices         oWebService  = new ClearViewWebServices();
                oWebService.Timeout     = Int32.Parse(ConfigurationManager.AppSettings["WS_TIMEOUT"]);
                oWebService.Credentials = oCredentials;
                oWebService.Url         = oVariable.WebServiceURL();
                bool boolFoundName = false;
                bool boolFoundIP   = false;
                // Get Values
                if (strNameNew != "")
                {
                    string strTemp = "";
                    if (boolDNS_QIP == true)
                    {
                        strTemp = oWebService.SearchDNSforPNC("", strNameNew, false, true);
                        if (strTemp.StartsWith("***") == false)
                        {
                            boolFoundName = true;
                        }
                    }
                    if (boolDNS_Bluecat == true)
                    {
                        strTemp = oWebService.SearchBluecatDNS("", strNameNew);
                        if (strTemp.StartsWith("***") == false)
                        {
                            boolFoundName = true;
                        }
                    }
                }
                if (strIPNew != "")
                {
                    string strTemp = "";
                    if (boolDNS_QIP == true)
                    {
                        strTemp = oWebService.SearchDNSforPNC(strIPNew, "", false, true);
                        if (strTemp.StartsWith("***") == false)
                        {
                            boolFoundIP = true;
                        }
                    }
                    if (boolDNS_Bluecat == true)
                    {
                        strTemp = oWebService.SearchBluecatDNS(strIPNew, "");
                        if (strTemp.StartsWith("***") == false)
                        {
                            boolFoundIP = true;
                        }
                    }
                }

                //DataSet ds = oServer.GetDNS(strNameNew);
                //if (ds.Tables[0].Rows.Count == 0)
                if (boolFoundName == false && boolFoundIP == false)
                {
                    //if (boolFound == true)
                    //{
                    //    btnReset.Enabled = false;
                    //    btnConfirm.Visible = false;
                    //    panExist.Visible = true;
                    //    lblExist.Text = "This device already exists in DNS. Please try again...";
                    //}
                    //else
                    //{
                    bool boolPermit = true;
                    panAlias.Visible = boolDNS_QIP;
                    panShow.Visible  = true;
                    lblName.Text     = strNameNew;
                    lblIP.Text       = strIPNew;
                    lblAlias.Text    = strAliasNew;

                    // Check Permission and either show read only, or permit edit
                    if (oApplication.Get(intApplication, "dns") == "1" || oUser.IsAdmin(intProfile))
                    {
                        boolPermit = true;
                    }

                    if (boolPermit == true)
                    {
                        btnContinue.Visible = false;
                        ddlType.Enabled     = false;
                        txtName.Enabled     = false;
                        txtIP1.Enabled      = false;
                        txtIP2.Enabled      = false;
                        txtIP3.Enabled      = false;
                        txtIP4.Enabled      = false;
                        txtAlias.Enabled    = true;
                        lstAlias.Enabled    = true;
                        txtContact1.Enabled = true;
                        txtContact2.Enabled = true;
                        btnAdd.Attributes.Add("onclick", "return AddDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');");
                        btnEdit.Attributes.Add("onclick", "return EditDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');");
                        btnRemove.Attributes.Add("onclick", "return RemoveDNS('" + lstAlias.ClientID + "','" + hdnAlias.ClientID + "');");
                        string strChange = "";
                        if (boolChange == true)
                        {
                            panChange.Visible = true;
                            strChange         = " && ValidateTextLength('" + txtChange.ClientID + "', 'Please enter a valid change control number\\n\\n - Must start with either \"CHG\" or \"PTM\"\\n - Must be exactly 10 characters in length', 10, ['CHG','PTM'], ['CHG0000000','PTM0000000','CHG1111111','PTM1111111','CHG9999999','PTM9999999','CHGXXXXXXX','PTMXXXXXXX'])";
                        }
                        btnConfirm.Attributes.Add("onclick", "return ValidateHidden0('" + hdnContact1.ClientID + "','" + txtContact1.ClientID + "','Please enter the LAN ID of your contact # 1')" +
                                                  " && ValidateHidden0('" + hdnContact2.ClientID + "','" + txtContact2.ClientID + "','Please enter the LAN ID of your contact # 2')" +
                                                  strChange +
                                                  " && ValidateText('" + txtReason.ClientID + "','Please enter a reason')" +
                                                  " && ProcessButton(this)" +
                                                  ";");
                    }
                    else
                    {
                        btnConfirm.Visible = false;
                        panAccess.Visible  = true;
                        btnAdd.Enabled     = false;
                        btnEdit.Enabled    = false;
                        btnRemove.Enabled  = false;
                        DataSet dsDecoms = oApplication.GetDecoms();
                        if (dsDecoms.Tables[0].Rows.Count > 0)
                        {
                            strContacts += "<tr><td colspan=\"2\">Alternatively, you can contact a resource from one of the following departments:</td></tr>";
                            foreach (DataRow drDecom in dsDecoms.Tables[0].Rows)
                            {
                                strContacts += "<tr><td></td><td>" + drDecom["name"].ToString() + "</td></tr>";
                            }
                        }
                    }
                    //}
                }
                else
                {
                    btnReset.Enabled   = false;
                    btnConfirm.Visible = false;
                    panExist.Visible   = true;
                    lblExist.Text      = "The " + (boolFoundName ? "device name" : "IP address") + " is already registered in DNS. Please try again...";
                    //lblExist.Text = "This device already exists in the database. Please try again...";
                }
            }
        }