Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile       = Int32.Parse(Request.Cookies["profileid"].Value);
            oProjectRequest  = new ProjectRequest(intProfile, dsn);
            oResourceRequest = new ResourceRequest(intProfile, dsn);
            oProjectNumber   = new ProjectNumber(intProfile, dsn);
            oPage            = new Pages(intProfile, dsn);
            oUser            = new Users(intProfile, dsn);
            oRequest         = new Requests(intProfile, dsn);
            oRequestItem     = new RequestItems(intProfile, dsn);
            oApplication     = new Applications(intProfile, dsn);
            oFunction        = new Functions(intProfile, dsn, intEnvironment);
            oVariable        = new Variables(intEnvironment);
            oProject         = new Projects(intProfile, dsn);
            oPlatform        = new Platforms(intProfile, dsn);
            oServiceRequest  = new ServiceRequests(intProfile, dsn);
            oService         = new Services(intProfile, dsn);
            oRequestField    = new RequestFields(intProfile, dsn);
            oDelegate        = new Delegates(intProfile, dsn);
            oLog             = new Log(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 (Request.QueryString["action"] != null && Request.QueryString["action"] != "")
            {
                panFinish.Visible = true;
            }
            else
            {
                if (!IsPostBack)
                {
                    if (Request.QueryString["rrid"] != null && Request.QueryString["rrid"] != "")
                    {
                        // PLATFORM
                        int intResource = Int32.Parse(Request.QueryString["rrid"]);
                        lblRequest.Text = Request.QueryString["rrid"];
                        if (intResource > 0)
                        {
                            DataSet dsResource = oResourceRequest.Get(intResource);
                            if (dsResource.Tables[0].Rows.Count > 0)
                            {
                                int intRequest = Int32.Parse(dsResource.Tables[0].Rows[0]["requestid"].ToString());
                                int intService = Int32.Parse(dsResource.Tables[0].Rows[0]["serviceid"].ToString());
                                int intNumber  = Int32.Parse(dsResource.Tables[0].Rows[0]["number"].ToString());
                                if (oRequest.Allowed(intRequest, intService, intNumber, intProfile, true))
                                {
                                    panRequest.Visible = true;
                                    int intProject = oRequest.GetProjectNumber(intRequest);
                                    int intItem    = Int32.Parse(dsResource.Tables[0].Rows[0]["itemid"].ToString());
                                    int intApp     = oRequestItem.GetItemApplication(intItem);
                                    lblView.Text = oRequestField.GetBodyOverall(intResource, 0, dsnServiceEditor, intEnvironment, dsnAsset, dsnIP);
                                    //LoadProject(intProject, intRequest);
                                }
                                else
                                {
                                    panDenied.Visible = true;
                                }
                            }
                            else
                            {
                                panDenied.Visible = true;
                            }
                        }
                        else
                        {
                            panDenied.Visible = true;
                        }
                    }
                    else if (Request.QueryString["srid"] != null && Request.QueryString["srid"] != "")
                    {
                        // SERVICE
                        int intServiceSelectedID = Int32.Parse(Request.QueryString["srid"]);
                        if (intServiceSelectedID > 0)
                        {
                            DataSet dsServiceSelected = oService.GetSelectedById(intServiceSelectedID);
                            if (dsServiceSelected.Tables[0].Rows.Count > 0)
                            {
                                DataRow drServiceSelected = dsServiceSelected.Tables[0].Rows[0];
                                int     intRequest        = Int32.Parse(drServiceSelected["requestid"].ToString());
                                int     intService        = Int32.Parse(drServiceSelected["serviceid"].ToString());
                                int     intItem           = oService.GetItemId(intService);
                                int     intNumber         = Int32.Parse(drServiceSelected["number"].ToString());
                                if (drServiceSelected["approvedon"].ToString() == "" || drServiceSelected["approved"].ToString() == "0")
                                {
                                    int intApp = oRequestItem.GetItemApplication(intItem);
                                    lblRequest.Text = intRequest.ToString();
                                    if (oRequest.Allowed(intRequest, intService, intNumber, intProfile, true))
                                    {
                                        panRequest.Visible = true;
                                        int intProject = oRequest.GetProjectNumber(intRequest);
                                        lblView.Text = oRequestField.GetBodyNoEnv(intRequest, intItem, intNumber, intService, 0, 0, dsnServiceEditor, intEnvironment, dsnAsset, dsnIP);
                                        //LoadProject(intProject, intRequest);
                                    }
                                    else
                                    {
                                        panDenied.Visible = true;
                                    }
                                }
                                else
                                {
                                    // Already approved
                                    litAlreadyStatus.Text = (drServiceSelected["approved"].ToString() == "1" ? "Approved" : "Denied");
                                    litAlreadyBy.Text     = oUser.GetFullNameWithLanID(Int32.Parse(drServiceSelected["approvedby"].ToString()));
                                    litAlreadyOn.Text     = " on " + drServiceSelected["approvedon"].ToString();
                                    panAlready.Visible    = true;
                                }
                            }
                            else
                            {
                                panDenied.Visible = true;
                            }
                        }
                        else
                        {
                            panDenied.Visible = true;
                        }
                    }
                    else if (Request.QueryString["rid"] != null && Request.QueryString["rid"] != "")
                    {
                        // MANAGER
                        int intRequest = Int32.Parse(Request.QueryString["rid"]);
                        lblRequest.Text = Request.QueryString["rid"];
                        int intProject = Int32.Parse(oRequest.Get(intRequest, "projectid"));
                        //ds = oResourceRequest.GetRequestAll(intRequest);
                        int intRequester = Int32.Parse(oRequest.Get(intRequest, "userid"));
                        if (intRequest > 0)
                        {
                            bool boolAllowed = oUser.IsManager(intRequester, intProfile, true);
                            if (boolAllowed == false)
                            {
                                int intManager = oUser.GetManager(intRequester, true);
                                boolAllowed = (oDelegate.Get(intManager, intProfile) > 0);
                            }
                            if (oUser.IsAdmin(intProfile) || boolAllowed)
                            {
                                trHR.Visible       = false;
                                panRequest.Visible = true;
                                lblView.Text       = "As the manager of <b>" + oUser.GetFullName(intRequester) + "</b>, you will need to approve this request before it is submitted. You can view the details of the request by clicking [<a href=\"javascript:void(0);\">View</a>] next to each item.";
                                Control oControl = (Control)LoadControl("/controls/resource_request_new.ascx");
                                PHForm.Controls.Add(oControl);
                                if (String.IsNullOrEmpty(Request.QueryString["approve"]))
                                {
                                    btnApprove.Visible = btnDeny.Visible = false;
                                    lblView.Text       = "Here are the details of the service request...";
                                }

                                if (oServiceRequest.Get(intRequest, "manager_approval") != "0")
                                {
                                    // Already approved
                                    btnApprove.Enabled    = btnDeny.Enabled = false;
                                    litAlreadyStatus.Text = (oServiceRequest.Get(intRequest, "manager_approval") == "1" ? "Approved" : "Denied");
                                    litAlreadyBy.Text     = oUser.GetFullNameWithLanID(oUser.GetManager(intRequester, true));
                                    panAlready.Visible    = true;
                                }
                            }
                            else
                            {
                                panDenied.Visible = true;
                            }
                        }
                        else
                        {
                            panDenied.Visible = true;
                        }
                    }
                    else
                    {
                        panDenied.Visible = true;
                    }
                }
            }
            btnClose.Attributes.Add("onclick", "return CloseWindow();");
            btnFinish.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();");
            btnAlready.Attributes.Add("onclick", "return ProcessButton(this) && LoadWait();");
            btnApprove.Attributes.Add("onclick", "return confirm('Are you sure you want to APPROVE this request?') && ProcessButton(this) && LoadWait();");
            btnDeny.Attributes.Add("onclick", "return Deny('" + divDeny.ClientID + "','" + divApprove.ClientID + "','" + txtReason.ClientID + "');");
            btnDone.Attributes.Add("onclick", "return ValidateText('" + txtReason.ClientID + "', 'Please enter a reason') && confirm('Are you sure you want to DENY this request?') && ProcessButton(this) && LoadWait();");
            btnCancel.Attributes.Add("onclick", "return Cancel('" + divDeny.ClientID + "','" + divApprove.ClientID + "');");
        }