protected void MakeChange(bool _override) { // Check to see if new name already exists int intNameID = Int32.Parse(lblNameID.Text); int intID = Int32.Parse(lblID.Text); bool boolExists = false; string strName = Request.Form[hdnName.UniqueID]; string strError = ""; switch (ddlType.SelectedValue) { case "-1": // Workstation DataSet dsWorkstation = oWorkstation.GetName(strName); if (dsWorkstation.Tables[0].Rows.Count > 0 && dsWorkstation.Tables[0].Rows[0]["available"].ToString() == "0" && _override == false) { boolExists = true; } else { // Does not exist or is otherwise available for use - update boolExists = false; // Set old name to available oWorkstation.UpdateName(intNameID, 1); if (dsWorkstation.Tables[0].Rows.Count > 0) { // If name already exists (available is marked or _override = true) then use that intNameID = Int32.Parse(dsWorkstation.Tables[0].Rows[0]["id"].ToString()); } else { // Create the name string strSequence = txtWorkstationSequence.Text; intNameID = oWorkstation.AddName(ddlWorkstationEnvironment.SelectedItem.Value, ddlWorkstationCode.SelectedItem.Value, lblWorkstationIdentifier.Text, strSequence.Substring(0, 1), strSequence.Substring(1, 1), strSequence.Substring(2, 1), strSequence.Substring(3, 1), strSequence.Substring(4, 1), strSequence.Substring(5, 1), 0); } // Set new name to unavailable oWorkstation.UpdateName(intNameID, 0); // Update workstation record oWorkstation.UpdateVirtualName(intID, intNameID); } break; case "0": // Server (National City) int intNameNCB = oServerName.GetName(strName); DataSet dsNCB = oServerName.Get(intNameNCB); if (dsNCB.Tables[0].Rows.Count > 0 && dsNCB.Tables[0].Rows[0]["available"].ToString() == "0" && _override == false) { boolExists = true; } else { // Does not exist or is otherwise available for use - update boolExists = false; // Set old name to available oServerName.Update(intNameID, 1); if (dsNCB.Tables[0].Rows.Count > 0) { // If name already exists (available is marked or _override = true) then use that intNameID = intNameNCB; } else { // Create the name string strSequence = txtNCBSequence.Text; intNameID = oServerName.Add(0, txtNCBState.Text + txtNCBCity.Text, ddlNCBFunction.SelectedItem.Value, ddlNCBSiteCode.SelectedItem.Value, strSequence.Substring(0, 1), strSequence.Substring(1, 1), intProfile, "CHANGE", 0); } // Set new name to unavailable oServerName.Update(intNameID, 0); // Update server record oServer.UpdateServerNamed(intID, intNameID); } break; case "1": // Server (PNC Financial Services) int intNamePNC = oServerName.GetNameFactory(strName); DataSet dsPNC = oServerName.GetFactory(intNamePNC); if (dsPNC.Tables[0].Rows.Count > 0 && dsPNC.Tables[0].Rows[0]["available"].ToString() == "0" && _override == false) { boolExists = true; } else { // Does not exist or is otherwise available for use - update boolExists = false; // Set old name to available oServerName.UpdateFactory(intNameID, 1); if (dsPNC.Tables[0].Rows.Count > 0) { // If name already exists (available is marked or _override = true) then use that intNameID = intNamePNC; } else { // Create the name string strSequence = txtPNCSequence.Text; intNameID = oServerName.AddFactory(ddlPNCOS.SelectedItem.Value, ddlPNCLocation.SelectedItem.Value, Request.Form["hdnPNCMnemonic"], ddlPNCEnvironment.SelectedItem.Value, strSequence.Substring(0, 1), strSequence.Substring(1, 1), ddlPNCFunction.SelectedItem.Value, ddlPNCSpecific.SelectedItem.Value, intProfile, "CHANGE", 0); } // Set new name to unavailable oServerName.UpdateFactory(intNameID, 0); // Update server record oServer.UpdateServerNamed(intID, intNameID); } break; } if (boolExists == true) { panExists.Visible = true; lblAlready.Text = strName; panChange.Visible = false; panButtons.Visible = false; btnAlreadyCancel.Focus(); } else { if (strError == "") { // Update asset oAsset.AddStatus(intAsset, strName, intStatus, intProfile, DateTime.Now); // Redirect Response.Redirect(Request.Path + "?assetid=" + intAsset.ToString() + "&clear=" + radClear.SelectedItem.Value + "&changed=true"); } else { // Build Error Message Response.Redirect(Request.Path + "?assetid=" + intAsset.ToString() + "&clear=" + radClear.SelectedItem.Value + "&error=" + strError); } } }