protected void Page_Load(object sender, EventArgs e)
        {
            intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            oPage      = new Pages(intProfile, dsn);
            oService   = new Services(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);
            }
            int intRequest = 0;

            Int32.TryParse(Request.QueryString["rid"], out intRequest);
            int intService = 0;

            Int32.TryParse(Request.QueryString["cid"], out intService);
            int intNumber = 0;

            Int32.TryParse(Request.QueryString["num"], out intNumber);
            int intItem = oService.GetItemId(intService);
            // *****************************************************************************
            // ********* Additional Cancel Functionality to be performed here **************
            // *****************************************************************************
            Workstations oWorkstation = new Workstations(intProfile, dsn);
            DateTime     datOff       = DateTime.Today;
            // Get from manaul table
            DataSet dsRebuild = oWorkstation.GetVirtualRebuild(intRequest, intService, intNumber);

            foreach (DataRow drRebuild in dsRebuild.Tables[0].Rows)
            {
                if (drRebuild["cancelled"].ToString() == "")
                {
                    DateTime.TryParse(drRebuild["scheduled"].ToString(), out datOff);
                    break;
                }
            }

            if (datOff > DateTime.Now)
            {
                // Cancel automated table
                oWorkstation.UpdateVirtualRebuildCancel(intRequest, intService, intNumber);
            }
            // *****************************************************************************
            // ********* END of Additional Cancel Functionality  ***************************
            // *****************************************************************************
            Page.ClientScript.RegisterStartupScript(typeof(Page), "cancelled", "<script type=\"text/javascript\">ExecuteCancel('" + oService.GetName(intService) + "','" + oPage.GetFullLink(intPage) + "?rid=" + intRequest.ToString() + "');<" + "/" + "script>");
        }
        private void LoadValues()
        {
            //int intRequest = Int32.Parse(Request.QueryString["rid"]);
            //DataSet dsItems = oRequestItem.GetForms(intRequest);
            //if (dsItems.Tables[0].Rows.Count > 0)
            //{
            //    foreach (DataRow drItem in dsItems.Tables[0].Rows)
            //    {
            //        if (drItem["done"].ToString() == "-1")
            //        {
            //            lblItem.Text = drItem["itemid"].ToString();
            //            lblService.Text = drItem["serviceid"].ToString();
            //            lblNumber.Text = drItem["number"].ToString();
            //            break;
            //        }
            //    }
            //}
            int     intRequest = Int32.Parse(Request.QueryString["rid"]);
            DataSet dsItems;
            int     intForm = 0;

            if (Request.QueryString["formid"] != null && Request.QueryString["formid"] != "")
            {
                intForm = Int32.Parse(Request.QueryString["formid"]);
                dsItems = oRequestItem.GetForm(intRequest, intForm);
            }
            else
            {
                dsItems = oRequestItem.GetForms(intRequest);
            }
            if (dsItems.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow drItem in dsItems.Tables[0].Rows)
                {
                    if (drItem["done"].ToString() == "-1" || intForm > 0)
                    {
                        lblItem.Text    = drItem["itemid"].ToString();
                        lblService.Text = drItem["serviceid"].ToString();
                        if (intForm > 0 && Request.QueryString["num"] != null && Request.QueryString["num"] != "")
                        {
                            lblNumber.Text = Request.QueryString["num"];
                        }
                        else
                        {
                            lblNumber.Text = drItem["number"].ToString();
                        }
                        break;
                    }
                }
            }
            else
            {
                lblService.Text = intForm.ToString();
            }
            // Load Data
            if (Request.QueryString["formid"] != null && Request.QueryString["formid"] != "")
            {
                int     intItem   = Int32.Parse(lblItem.Text);
                int     intNumber = Int32.Parse(lblNumber.Text);
                DataSet dsEdit    = oWorkstation.GetVirtualRebuild(intRequest, intForm, intNumber);
                foreach (DataRow drEdit in dsEdit.Tables[0].Rows)
                {
                    if (drEdit["cancelled"].ToString() == "")
                    {
                        int intName = 0;
                        if (Int32.TryParse(drEdit["nameid"].ToString(), out intName) == true)
                        {
                            lblId.Text          = drEdit["workstationid"].ToString();
                            txtDate.Text        = DateTime.Parse(drEdit["scheduled"].ToString()).ToShortDateString();
                            txtName.Text        = lblName.Text = oWorkstation.GetName(intName);
                            btnContinue.Enabled = false;
                            panFound.Visible    = true;
                            btnNext.Text        = "Update";
                            btnBack.Text        = "Cancel";
                            btnNext.Attributes.Add("onclick", "return ValidateDate('" + txtDate.ClientID + "','Please enter a valid date')" +
                                                   " && ValidateDateToday('" + txtDate.ClientID + "','The date must occur after today')" +
                                                   " && ProcessButton(this) && LoadWait()" +
                                                   ";");
                            btnCancel1.Visible = false;
                        }
                        break;
                    }
                }
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            RequestItems    oRequestItem    = new RequestItems(intProfile, dsn);
            RequestFields   oRequestField   = new RequestFields(intProfile, dsn);
            ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn);
            Services        oService        = new Services(intProfile, dsn);

            oFunction = new Functions(intProfile, dsn, intEnvironment);
            oUser     = new Users(intProfile, dsn);
            oRequest  = new Requests(intProfile, dsn);

            int     intRequest = Int32.Parse(Request.QueryString["rid"]);
            string  strStatus  = oServiceRequest.Get(intRequest, "checkout");
            DataSet dsItems    = oRequestItem.GetForms(intRequest);

            int intItem    = 0;
            int intService = 0;
            int intNumber  = 0;

            if (dsItems.Tables[0].Rows.Count > 0)
            {
                bool boolBreak = false;
                foreach (DataRow drItem in dsItems.Tables[0].Rows)
                {
                    if (boolBreak == true)
                    {
                        break;
                    }
                    if (drItem["done"].ToString() == "0")
                    {
                        intItem    = Int32.Parse(drItem["itemid"].ToString());
                        intService = Int32.Parse(drItem["serviceid"].ToString());
                        intNumber  = Int32.Parse(drItem["number"].ToString());
                        boolBreak  = true;
                    }
                    if (intItem > 0 && (strStatus == "1" || strStatus == "2"))
                    {
                        bool boolSuccess = true;
                        //string strResult = oService.GetName(intService) + " Completed";
                        string strResult = "";
                        string strError  = oService.GetName(intService) + " Error";
                        // ********* BEGIN PROCESSING **************

                        Workstations oWorkstation = new Workstations(intProfile, dsn);
                        DataSet      dsRebuild    = oWorkstation.GetVirtualRebuild(intRequest, intService, intNumber);
                        bool         found        = false;
                        foreach (DataRow drRebuild in dsRebuild.Tables[0].Rows)
                        {
                            if (drRebuild["cancelled"].ToString() == "")
                            {
                                found = true;
                                int intWorkstation = Int32.Parse(drRebuild["workstationid"].ToString());
                                int intName        = Int32.Parse(drRebuild["nameid"].ToString());
                                oWorkstation.UpdateVirtualRebuild(intRequest, intService, intNumber);
                                string strName  = oWorkstation.GetName(intName);
                                string strPower = drRebuild["scheduled"].ToString();
                                strResult += "<p>The workstation " + strName + " was successfully queued for rebuild on " + strPower + "</p>";
                                strError   = "";
                                break;
                            }
                        }
                        if (found == false)
                        {
                            strError = "<p>There was a problem configuring the workstation for rebuild ~ Request not found.</p>";
                        }

                        if (strResult == "")
                        {
                            boolSuccess = false;
                        }
                        // ******** END PROCESSING **************
                        if (oService.Get(intService, "automate") == "1" && boolSuccess == true)
                        {
                            strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strResult + "</td></tr></table>";
                        }
                        else
                        {
                            if (boolSuccess == false)
                            {
                                strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_error.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strError + "</td></tr></table>";
                            }
                            else
                            {
                                strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>";
                            }
                        }
                        oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1, 1);
                    }
                }
            }
        }