Exemplo n.º 1
0
        protected void PopulateLocations()
        {
            //Populate Location Selection
            if (intPlatform == 4)
            {
                if (hdnZoneId.Value == "")
                {
                    hdnZoneId.Value = "0";
                }
                Zones oZone = new Zones(intProfile, dsn);

                if (hdnRackId.Value == "")
                {
                    hdnRackId.Value = "0";
                }

                DataSet dsLocation = oZone.Gets(Int32.Parse(hdnRackId.Value));
                if (dsLocation.Tables[0].Rows.Count > 0)
                {
                    txtLocation.Text = dsLocation.Tables[0].Rows[0]["Location"].ToString();
                    txtRoom.Text     = dsLocation.Tables[0].Rows[0]["Room"].ToString();;
                    txtZone.Text     = dsLocation.Tables[0].Rows[0]["Zone"].ToString();;
                }
            }
            else
            {
                if (hdnRackId.Value == "")
                {
                    hdnRackId.Value = "0";
                }
                RacksNew oRack = new RacksNew(intProfile, dsn);

                DataSet dsLocation = oRack.Gets(Int32.Parse(hdnRackId.Value));
                if (dsLocation.Tables[0].Rows.Count > 0)
                {
                    txtLocation.Text = dsLocation.Tables[0].Rows[0]["Location"].ToString();
                    txtRoom.Text     = dsLocation.Tables[0].Rows[0]["Room"].ToString();;
                    txtZone.Text     = dsLocation.Tables[0].Rows[0]["Zone"].ToString();;
                    txtRack.Text     = dsLocation.Tables[0].Rows[0]["Rack"].ToString();;
                }
            }
        }
Exemplo n.º 2
0
        protected void LoadRack()
        {
            ddlRack.Items.Clear();
            ddlRack.ClearSelection();
            if (Int32.Parse(ddlZone.SelectedValue.ToString()) > 0)
            {
                ddlRack.DataTextField  = "Rack";
                ddlRack.DataValueField = "RackId";
                ddlRack.DataSource     = oRack.Gets(Int32.Parse(ddlZone.SelectedValue.ToString()), 1);
                ddlRack.DataBind();
                ddlRack.Items.Insert(0, new ListItem("-- SELECT --", "0"));
                ddlRack.Enabled = true;
            }
            else
            {
                ddlRack.Enabled = false;
                ddlRack.Items.Insert(0, new ListItem("-- SELECT ROOM --", "0"));
            }

            ddlRack.Items.FindByValue("0").Selected = true;
        }
Exemplo n.º 3
0
        protected void btnAdd_Click(Object Sender, EventArgs e)
        {
            if (hdnZoneId.Value == "")
            {
                hdnZoneId.Value = "0";
            }

            if (Request.Form[hdnId.UniqueID] == "0")
            {
                DataSet dsRack = oRacks.Gets(Int32.Parse(hdnZoneId.Value), txtName.Text.Trim());
                if (dsRack.Tables[0].Rows.Count > 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "DuplicateRack", "<script type=\"text/javascript\">alert('Rack " + txtName.Text + " already exists for selected zone.');<" + "/" + "script>");
                }
                else
                {
                    int intAsset = 0;
                    intAsset = oAsset.Add(0, 0, Int32.Parse(ddlModel.SelectedValue), txtAssetSerial.Text.Trim(), txtAssetTag.Text.Trim(), (int)AssetStatus.Available, intProfile, DateTime.Now, 0, 1, 0, "");
                    oRacks.Add(txtName.Text, intAsset, Int32.Parse(hdnZoneId.Value), txtDescription.Text.Trim(), (chkEnabled.Checked ? 1 : 0));
                }
            }
            else
            {
                Boolean blDuplicate = false;
                DataSet dsRack      = oRacks.Gets(Int32.Parse(hdnZoneId.Value), txtName.Text.Trim());
                if (dsRack.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow drRack in dsRack.Tables[0].Rows)
                    {
                        if (drRack["RackId"].ToString() != Request.Form[hdnId.UniqueID].ToString() && blDuplicate == false)
                        {
                            blDuplicate = true;
                            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "DuplicateRack", "<script type=\"text/javascript\">alert('Rack " + txtName.Text + " already exists for selected zone.');<" + "/" + "script>");
                        }
                    }
                }
                if (blDuplicate == false)
                {
                    if (hdnAssetId.Value == "" || hdnAssetId.Value == "0")
                    {
                        int intAsset = 0;
                        intAsset = oAsset.Add(0, 0, Int32.Parse(ddlModel.SelectedValue), txtAssetSerial.Text.Trim(), txtAssetTag.Text.Trim(), (int)AssetStatus.Available, intProfile, DateTime.Now, 0, 1, 0, "");
                    }
                    else
                    {
                        oAsset.Update(Int32.Parse(hdnAssetId.Value), Int32.Parse(ddlModel.SelectedValue), txtAssetSerial.Text.Trim(), txtAssetTag.Text.Trim(), 0);
                    }

                    oRacks.Update(Int32.Parse(Request.Form[hdnId.UniqueID]), txtName.Text.Trim(), Int32.Parse(hdnAssetId.Value), Int32.Parse(hdnZoneId.Value), txtDescription.Text.Trim(), (chkEnabled.Checked ? 1 : 0));
                }
            }
            if (Request.Form[hdnOrder.UniqueID] != "")
            {
                string strOrder = Request.Form[hdnOrder.UniqueID];
                int    intCount = 0;
                while (strOrder != "")
                {
                    intCount++;
                    int intId = Int32.Parse(strOrder.Substring(0, strOrder.IndexOf("&")));
                    strOrder = strOrder.Substring(strOrder.IndexOf("&") + 1);
                    //oRacks.UpdateOrder(intId, intCount);
                }
            }
            LoopRepeater();
            //Response.Redirect(Request.Path);
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["adminid"] != null && Request.Cookies["adminid"].Value != "")
            {
                intProfile = Int32.Parse(Request.Cookies["adminid"].Value);
            }
            else
            {
                Response.Redirect("/admin/login.aspx");
            }

            oLocation = new Locations(intProfile, dsn);
            oRoom     = new RoomsNew(intProfile, dsn);
            oRack     = new RacksNew(intProfile, dsn);
            oZone     = new Zones(intProfile, dsn);

            if (!Page.IsPostBack)
            {
                if (Request.QueryString["type"] != null && Request.QueryString["type"] != "")
                {
                    strSelectionType = Request.QueryString["type"].ToString();
                }

                strSelectionType = strSelectionType.ToLower();

                //Get controls to populate on parent page
                if (Request.QueryString["Id"] != null && Request.QueryString["Id"] != "")
                {
                    intSelectionId = Int32.Parse(Request.QueryString["Id"]);
                }
                else
                {
                    chkCommonLocation.Checked = true;
                }

                if (Request.QueryString["hdnId"] != null && Request.QueryString["hdnId"] != "")
                {
                    lblParentCtrlHdnId.Text = Request.QueryString["hdnId"];
                }

                if (Request.QueryString["ctrlLocation"] != null && Request.QueryString["ctrlLocation"] != "")
                {
                    lblParentCtrlLocation.Text = Request.QueryString["ctrlLocation"];
                }

                if (Request.QueryString["ctrlRoom"] != null && Request.QueryString["ctrlRoom"] != "")
                {
                    lblParentCtrlRoom.Text = Request.QueryString["ctrlRoom"];
                }


                if (Request.QueryString["ctrlZone"] != null && Request.QueryString["ctrlZone"] != "")
                {
                    lblParentCtrlZone.Text = Request.QueryString["ctrlZone"];
                }

                if (Request.QueryString["ctrlRack"] != null && Request.QueryString["ctrlRack"] != "")
                {
                    lblParentCtrlRack.Text = Request.QueryString["ctrlRack"];
                }


                SetControls();

                if (intSelectionId > 0)
                {
                    DataSet dsLocation = null;
                    if (strSelectionType == "location")
                    {
                        dsLocation = oLocation.GetAddress(intSelectionId);
                        if (dsLocation.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr            = dsLocation.Tables[0].Rows[0];
                            int     intLocationId = Int32.Parse(dr["id"].ToString());
                            int     intCityId     = Int32.Parse(oLocation.GetAddress(intLocationId, "cityid"));
                            int     intStateId    = Int32.Parse(oLocation.GetCity(intCityId, "stateid"));;
                            LoadState();
                            ddlState.SelectedValue = intStateId.ToString();
                            LoadCity();
                            ddlCity.SelectedValue = intCityId.ToString();
                            LoadAddress();
                            ddlLocation.SelectedValue = intLocationId.ToString();
                        }
                    }
                    else if (strSelectionType == "room")
                    {
                        dsLocation = oRoom.Gets(intSelectionId);
                        if (dsLocation.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr = dsLocation.Tables[0].Rows[0];
                            LoadState();
                            ddlState.SelectedValue = dr["StateId"].ToString();
                            LoadCity();
                            ddlCity.SelectedValue = dr["CityId"].ToString();
                            LoadAddress();
                            ddlLocation.SelectedValue = dr["LocationId"].ToString();
                            LoadRoom();
                            ddlRoom.SelectedValue = dr["RoomId"].ToString();
                        }
                    }
                    else if (strSelectionType == "zone")
                    {
                        dsLocation = oZone.Gets(intSelectionId);
                        if (dsLocation.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr = dsLocation.Tables[0].Rows[0];
                            LoadState();
                            ddlState.SelectedValue = dr["StateId"].ToString();
                            LoadCity();
                            ddlCity.SelectedValue = dr["CityId"].ToString();
                            LoadAddress();
                            ddlLocation.SelectedValue = dr["LocationId"].ToString();
                            LoadRoom();
                            ddlRoom.SelectedValue = dr["RoomId"].ToString();
                            LoadZone();
                            ddlZone.SelectedValue = dr["ZoneId"].ToString();
                        }
                    }
                    else if (strSelectionType == "rack")
                    {
                        dsLocation = oRack.Gets(intSelectionId);

                        if (dsLocation.Tables[0].Rows.Count > 0)
                        {
                            DataRow dr = dsLocation.Tables[0].Rows[0];
                            LoadState();
                            ddlState.SelectedValue = dr["StateId"].ToString();
                            LoadCity();
                            ddlCity.SelectedValue = dr["CityId"].ToString();
                            LoadAddress();
                            ddlLocation.SelectedValue = dr["LocationId"].ToString();
                            LoadRoom();
                            ddlRoom.SelectedValue = dr["RoomId"].ToString();
                            LoadZone();
                            ddlZone.SelectedValue = dr["ZoneId"].ToString();
                            LoadRack();
                            ddlRack.SelectedValue = dr["RackId"].ToString();
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            oPage      = new Pages(intProfile, dsn);
            oLocation  = new Locations(intProfile, dsn);
            oRoomsNew  = new RoomsNew(intProfile, dsn);
            oZone      = new Zones(intProfile, dsn);
            oRacksNew  = new RacksNew(intProfile, dsn);

            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "")
            {
                intPage = Int32.Parse(Request.QueryString["pageid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }

            if (!IsPostBack)
            {
                if (String.IsNullOrEmpty(Request.QueryString["ra"]) == false)
                {
                    DataSet rec = oRacksNew.Gets(Int32.Parse(Request.QueryString["ra"]));
                    if (rec.Tables[0].Rows.Count > 0)
                    {
                        lblRackZone.ToolTip      = rec.Tables[0].Rows[0]["zoneid"].ToString();
                        txtRackName.Text         = rec.Tables[0].Rows[0]["rack"].ToString();
                        txtRackU.Text            = "50";
                        txtRackAmp.Text          = "100";
                        txtRackDescription.Text  = rec.Tables[0].Rows[0]["description"].ToString();
                        chkRackAvailable.Checked = (rec.Tables[0].Rows[0]["enabled"].ToString() == "1");
                        btnRackUpdate.Visible    = true;
                        btnRackUpdate.Attributes.Add("onclick", "return ValidateText('" + txtRackName.ClientID + "','Please enter a name')" +
                                                     " && ProcessButton(this) && LoadWait()" +
                                                     ";");
                        btnRackDelete.Visible = true;
                        btnRackDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item') && ProcessButton(this) && LoadWait();");
                    }
                    else if (String.IsNullOrEmpty(Request.QueryString["z"]) == false)
                    {
                        lblRackZone.ToolTip = Request.QueryString["z"];
                        btnRackAdd.Visible  = true;
                        btnRackAdd.Attributes.Add("onclick", "return ValidateText('" + txtRackName.ClientID + "','Please enter a name')" +
                                                  " && ProcessButton(this) && LoadWait()" +
                                                  ";");
                    }
                    lblRackZone.Text = oZone.Get(Int32.Parse(lblRackZone.ToolTip), "zone");
                    btnRackCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();");
                    panRack.Visible = true;
                }
                else if (String.IsNullOrEmpty(Request.QueryString["z"]) == false)
                {
                    DataSet rec = oZone.Gets(Int32.Parse(Request.QueryString["z"]));
                    if (rec.Tables[0].Rows.Count > 0)
                    {
                        lblZoneRoom.ToolTip      = rec.Tables[0].Rows[0]["roomid"].ToString();
                        txtZoneName.Text         = rec.Tables[0].Rows[0]["zone"].ToString();
                        txtZoneDescription.Text  = rec.Tables[0].Rows[0]["description"].ToString();
                        chkZoneAvailable.Checked = (rec.Tables[0].Rows[0]["enabled"].ToString() == "1");
                        btnZoneUpdate.Visible    = true;
                        btnZoneUpdate.Attributes.Add("onclick", "return ValidateText('" + txtZoneName.ClientID + "','Please enter a name')" +
                                                     " && ProcessButton(this) && LoadWait()" +
                                                     ";");
                        btnZoneDelete.Visible = true;
                        btnZoneDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item') && ProcessButton(this) && LoadWait();");

                        rptRacks.DataSource = oLocation.GetInventory(null, null, Int32.Parse(Request.QueryString["z"]));
                        rptRacks.DataBind();
                        lblRacks.Visible = (rptRacks.Items.Count == 0);
                    }
                    else if (String.IsNullOrEmpty(Request.QueryString["ro"]) == false)
                    {
                        lblZoneRoom.ToolTip = Request.QueryString["ro"];
                        btnZoneAdd.Visible  = true;
                        btnZoneAdd.Attributes.Add("onclick", "return ValidateText('" + txtZoneName.ClientID + "','Please enter a name')" +
                                                  " && ProcessButton(this) && LoadWait()" +
                                                  ";");
                        btnAddRack.Enabled = false;
                    }
                    lblZoneRoom.Text = oRoomsNew.Get(Int32.Parse(lblZoneRoom.ToolTip), "room");
                    btnZoneCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();");
                    panZone.Visible = true;
                }
                else if (String.IsNullOrEmpty(Request.QueryString["ro"]) == false)
                {
                    DataSet rec = oRoomsNew.Gets(Int32.Parse(Request.QueryString["ro"]));
                    if (rec.Tables[0].Rows.Count > 0)
                    {
                        lblRoomLocation.ToolTip  = rec.Tables[0].Rows[0]["locationid"].ToString();
                        txtRoomName.Text         = rec.Tables[0].Rows[0]["room"].ToString();
                        txtRoomDescription.Text  = rec.Tables[0].Rows[0]["description"].ToString();
                        chkRoomAvailable.Checked = (rec.Tables[0].Rows[0]["enabled"].ToString() == "1");
                        btnRoomUpdate.Visible    = true;
                        btnRoomUpdate.Attributes.Add("onclick", "return ValidateText('" + txtRoomName.ClientID + "','Please enter a name')" +
                                                     " && ProcessButton(this) && LoadWait()" +
                                                     ";");
                        btnRoomDelete.Visible = true;
                        btnRoomDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item') && ProcessButton(this) && LoadWait();");

                        rptZones.DataSource = oLocation.GetInventory(null, Int32.Parse(Request.QueryString["ro"]), null);
                        rptZones.DataBind();
                        lblZones.Visible = (rptZones.Items.Count == 0);
                    }
                    else if (String.IsNullOrEmpty(Request.QueryString["l"]) == false)
                    {
                        lblRoomLocation.ToolTip = Request.QueryString["l"];
                        btnRoomAdd.Visible      = true;
                        btnRoomAdd.Attributes.Add("onclick", "return ValidateText('" + txtRoomName.ClientID + "','Please enter a name')" +
                                                  " && ProcessButton(this) && LoadWait()" +
                                                  ";");
                        btnAddZone.Enabled = false;
                    }
                    lblRoomLocation.Text = oLocation.GetAddress(Int32.Parse(lblRoomLocation.ToolTip), "commonname");
                    btnRoomCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();");
                    panRoom.Visible = true;
                }
                else if (String.IsNullOrEmpty(Request.QueryString["l"]) == false)
                {
                    DataSet rec = oLocation.GetAddress(Int32.Parse(Request.QueryString["l"]));
                    if (rec.Tables[0].Rows.Count > 0)
                    {
                        txtLocationName.Text         = rec.Tables[0].Rows[0]["commonname"].ToString();
                        txtLocationAddress.Text      = rec.Tables[0].Rows[0]["name"].ToString();
                        txtLocationCode.Text         = rec.Tables[0].Rows[0]["factory_code"].ToString();
                        chkLocationStorage.Checked   = (rec.Tables[0].Rows[0]["storage"].ToString() == "1");
                        chkLocationTSM.Checked       = (rec.Tables[0].Rows[0]["tsm"].ToString() == "1");
                        chkLocationProd.Checked      = (rec.Tables[0].Rows[0]["prod"].ToString() == "1");
                        chkLocationQA.Checked        = (rec.Tables[0].Rows[0]["qa"].ToString() == "1");
                        chkLocationTest.Checked      = (rec.Tables[0].Rows[0]["test"].ToString() == "1");
                        chkLocationDR.Checked        = (rec.Tables[0].Rows[0]["dr"].ToString() == "1");
                        txtLocationBuildingCode.Text = rec.Tables[0].Rows[0]["building_code"].ToString();
                        chkLocationAssignIP.Checked  = (rec.Tables[0].Rows[0]["vmware_ipaddress"].ToString() == "1");
                        chkLocationAvailable.Checked = (rec.Tables[0].Rows[0]["enabled"].ToString() == "1");
                        lblLocationCityID.Text       = rec.Tables[0].Rows[0]["cityid"].ToString();

                        btnLocationUpdate.Visible = true;
                        btnLocationUpdate.Attributes.Add("onclick", "return ValidateText('" + txtRoomName.ClientID + "','Please enter a name')" +
                                                         " && ProcessButton(this) && LoadWait()" +
                                                         ";");
                        btnLocationDelete.Visible = true;
                        btnLocationDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item') && ProcessButton(this) && LoadWait();");

                        rptRooms.DataSource = oLocation.GetInventory(Int32.Parse(Request.QueryString["l"]), null, null);
                        rptRooms.DataBind();
                        lblRooms.Visible = (rptRooms.Items.Count == 0);
                    }
                    else
                    {
                        btnLocationAdd.Visible = true;
                        btnLocationAdd.Attributes.Add("onclick", "return ValidateText('" + txtLocationName.ClientID + "','Please enter a name')" +
                                                      " && ProcessButton(this) && LoadWait()" +
                                                      ";");
                        btnAddRoom.Enabled = false;
                    }
                    btnLocationCancel.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();");
                    panLocation.Visible = true;
                }
                else
                {
                    panLocations.Visible    = true;
                    rptLocations.DataSource = oLocation.GetInventory(null, null, null);
                    rptLocations.DataBind();
                }
            }
        }