protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["applicationId"] == null)
        {
            Response.Redirect("~/user/application.aspx");
        }
        else if (Request["applicationId"] != null)
        {
            applicationId = Convert.ToString(Request["applicationId"]);
        }
        tbAllotmentApplication application = AllotementApplications.GetApplication(Convert.ToInt64(applicationId));

        categoryId = application.QuarterCategory.Value;

        if (!Page.IsPostBack)
        {
            tblUser user = Users.getUser(application.Userid.Value);

            DateTime?dt = null;
            //Check if user is debarred or deferred
            if (Users.IsUserDeferred(user.Id, out dt))
            {
                Response.Redirect("~/user/notallowed.aspx");
            }

            if (Users.IsUserDebarred(user.Id, out dt))
            {
                Response.Redirect("~/user/notallowed.aspx?debar=true");
            }


            lblFullname.Text        = user.fullName;
            lblDesignation.Text     = Users.GetUserDesignation(user.Id);
            lblAllottedQuarter.Text = "N/A";

            var allottee = Allottee.GetAllotteeByAAN(user.AAN);
            if (allottee != null && (allottee.Status.Value == ((int)AllotementStatus.Possessed) || allottee.Status.Value == ((int)AllotementStatus.ChangeRequested)))
            {
                string allottedQuarter = allottee.QuarterNumber;
                lblAllottedQuarter.Text = allottedQuarter;
            }

            if (application.QuarterCategory.HasValue && !Quarters.IsQuarterCategoryActive(application.QuarterCategory.Value))
            {
                submissionClosedPanel.Visible = true;
                return;
            }
            else
            {
                //Quarter category is active
                if (lblAllottedQuarter.Text == "N/A" || application.Status == (int)ApplicationStatus.Pending) //New allottment cases
                {
                    if (application.MedicalCategory.HasValue && application.MedicalCategory.Value >= 0)       //Medical grounds
                    {
                        applyForQuarterMedicalGroundsPanel.Visible = true;
                        btnNewAllottmentMedical.Enabled            = true;
                    }
                    else
                    {
                        applyForQuarterPanel.Visible = true;
                        btnNewAllottment.Enabled     = true;
                    }
                }
                else
                {
                    if (application.MedicalCategory.HasValue && application.MedicalCategory.Value >= 0) //Medical grounds
                    {
                        applyForQuarterMedicalGroundsPanel.Visible = true;
                        btnChangeRequestMedical.Enabled            = true;
                    }
                    else
                    {
                        applyForQuarterPanel.Visible = true;
                        btnChangeRequest.Enabled     = true;
                    }
                }

                DataClassesDataContext dataContext = new DataClassesDataContext();

                string aan = Users.getUserByUserName(HttpContext.Current.User.Identity.Name).AAN;
                var    _alreadyRequested = from _requested in dataContext.tblChangeRequests
                                           where _requested.AAN == aan &&
                                           (_requested.Status == (int)ChangeRequestStatus.Pending ||
                                            _requested.Status == (int)ChangeRequestStatus.Approved)
                                           select _requested;

                if (_alreadyRequested.FirstOrDefault() != null)
                {
                    var changeRequest = _alreadyRequested.FirstOrDefault();
                    pnlChangeRequestInformation.Visible = true;
                    btnChangeRequest.Enabled            = false;
                    btnChangeRequestMedical.Enabled     = false;

                    lblRequestID.Text        = changeRequest.Id.ToString();
                    lblFirstPreference.Text  = changeRequest.FirstPerference ?? "N/A";
                    lblSecondPreference.Text = changeRequest.SecondPerference ?? "N/A";
                    lblThirdPreference.Text  = changeRequest.ThirdPerference ?? "N/A";
                }
                else
                {
                    pnlChangeRequestInformation.Visible = false;
                }
            }
            BindData();
        }

        changeRequests            = new DataClassesDataContext().tblChangeRequests.ToList();
        grdQuarters.RowDataBound += new GridViewRowEventHandler(grdQuarters_RowDataBound);
    }
Exemple #2
0
 private bool IsQuarterCategoryActive(long categoryId)
 {
     return(Quarters.IsQuarterCategoryActive(categoryId));
 }