Esempio n. 1
0
        protected void btnApproveOrDeny_Click(object sender, EventArgs e)
        {
            lblAppOrDenyMsg.Text = string.Empty;
            string SPXML = string.Empty;
            List <PaperStudXML> oPaperStudXMLList = new List <PaperStudXML>();
            PaperStudXML        oPaperStudXML;
            StringBuilder       oStringBuilder1 = new StringBuilder();
            StringBuilder       oStringBuilder2 = new StringBuilder();

            //-------------
            List <ExamFormModifyXML> oExamFormModifyReq = new List <ExamFormModifyXML>();
            ExamFormModifyXML        ExamFormModifyReq;

            hidUniID.Value = Classes.clsGetSettings.UniversityID.ToString();
            //-------------

            for (int j = 0; j < GVPaperTLMAMAT.Rows.Count; j++)
            {
                if (((CheckBox)GVPaperTLMAMAT.Rows[j].Cells[4].FindControl("chkSelectStudents")).Checked)
                {
                    oPaperStudXML           = new PaperStudXML();
                    oPaperStudXML.StudentID = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Student_ID"].ToString());
                    oPaperStudXML.Year      = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Year"].ToString());
                    oPaperStudXML.TLM       = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["TLM-AM-AT-ID"].ToString().Split('-')[0]);
                    oPaperStudXML.AM        = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["TLM-AM-AT-ID"].ToString().Split('-')[1]);
                    oPaperStudXML.AT        = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["TLM-AM-AT-ID"].ToString().Split('-')[2]);
                    oPaperStudXML.Pk_Pp_PpHead_CrPrCh_ID = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Pp_PpHead_CrPrCh_ID"].ToString());
                    oPaperStudXML.FacID     = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Fac_ID"].ToString());
                    oPaperStudXML.CRID      = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Cr_ID"].ToString());
                    oPaperStudXML.MOLID     = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_MoLrn_ID"].ToString());
                    oPaperStudXML.PtrnID    = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Ptrn_ID"].ToString());
                    oPaperStudXML.BrnID     = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Brn_ID"].ToString());
                    oPaperStudXML.CrPrDetID = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_CrPr_Details_ID"].ToString());
                    oPaperStudXML.CrPrChtID = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_CrPrCh_ID"].ToString());
                    oPaperStudXML.UniID     = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Uni_ID"].ToString());

                    oPaperStudXMLList.Add(oPaperStudXML);

                    // hidStudentID.Value += GVPaperTLMAMAT.DataKeys[j]["pk_Student_ID"].ToString()+",";
                    oStringBuilder1.Append(GVPaperTLMAMAT.DataKeys[j]["pk_Student_ID"].ToString());
                    oStringBuilder1.Append(",");
                    //  hidYearID.Value += GVPaperTLMAMAT.DataKeys[j]["pk_Year"].ToString() + ",";
                    oStringBuilder2.Append(GVPaperTLMAMAT.DataKeys[j]["pk_Year"].ToString());
                    oStringBuilder2.Append(",");


                    //---------------
                    ExamFormModifyReq               = new ExamFormModifyXML();
                    ExamFormModifyReq.UniID         = int.Parse(hidUniID.Value);
                    ExamFormModifyReq.StudentID     = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Student_ID"].ToString());
                    ExamFormModifyReq.Year          = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Year"].ToString());
                    ExamFormModifyReq.AcYrID        = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["fk_AcademicYear_ID"].ToString());
                    ExamFormModifyReq.InstID        = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["Ref_InstReg_Institute_ID"].ToString());
                    ExamFormModifyReq.FacID         = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Fac_ID"].ToString());
                    ExamFormModifyReq.CrID          = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Cr_ID"].ToString());
                    ExamFormModifyReq.MoLrnID       = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_MoLrn_ID"].ToString());
                    ExamFormModifyReq.PtrnID        = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Ptrn_ID"].ToString());
                    ExamFormModifyReq.BrnID         = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_Brn_ID"].ToString());
                    ExamFormModifyReq.CrPrDetailsID = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_CrPr_Details_ID"].ToString());
                    ExamFormModifyReq.CrPrChID      = int.Parse(GVPaperTLMAMAT.DataKeys[j].Values["pk_CrPrCh_ID"].ToString());
                    ExamFormModifyReq.CreatedBy     = user.User_ID.ToString();
                    //ExamFormModifyReq.RequestDetails = createExamFormModifyXML(ExamFormModifyReq.StudentID, ExamFormModifyReq.Year);
                    oExamFormModifyReq.Add(ExamFormModifyReq);
                    //---------------
                }
            }

            hidStudentID.Value = oStringBuilder1.ToString();
            hidYearID.Value    = oStringBuilder2.ToString();

            //set hidden variables

            hidStudentID.Value     = oStringBuilder1.ToString();
            hidYearID.Value        = oStringBuilder2.ToString();
            hidFacID.Value         = GVPaperTLMAMAT.DataKeys[0]["pk_Fac_ID"].ToString();
            hidCrID.Value          = GVPaperTLMAMAT.DataKeys[0]["pk_Cr_ID"].ToString();
            hidMoLrnID.Value       = GVPaperTLMAMAT.DataKeys[0]["pk_MoLrn_ID"].ToString();
            hidPtrnID.Value        = GVPaperTLMAMAT.DataKeys[0]["pk_Ptrn_ID"].ToString();
            hidBrnID.Value         = GVPaperTLMAMAT.DataKeys[0]["pk_Brn_ID"].ToString();
            hidCrPrDetailsID.Value = GVPaperTLMAMAT.DataKeys[0]["pk_CrPr_Details_ID"].ToString();
            hidCrPrChID.Value      = GVPaperTLMAMAT.DataKeys[0]["pk_CrPrCh_ID"].ToString();
            hidUniID.Value         = GVPaperTLMAMAT.DataKeys[0]["pk_Uni_ID"].ToString();

            //******************************
            //commented old code
            //if (GVPaperTLMAMAT.DataKeys[0]["fk_ExEv_ID"].ToString().Equals("0") || GVPaperTLMAMAT.DataKeys[0]["fk_ExEv_ID"].ToString().Equals("-"))
            //{
            //    hidExamFormModifyReq.Value = "No";
            //}
            //else
            //{
            //    hidExamFormModifyReq.Value = "Yes";
            //}
            //******************************

            int    result = 0;
            string status = string.Empty;

            if (((Button)sender).ID == "btnApprove")
            {
                result = clsCollegeAdmissionReports.PaperExemptionApproveOrDeny(user.User_ID, 1, PaperStudXML.SerializeObject(oPaperStudXMLList));
                status = "Granted";
            }
            else if (((Button)sender).ID == "btnDeny")
            {
                result = clsCollegeAdmissionReports.PaperExemptionApproveOrDeny(user.User_ID, 2, PaperStudXML.SerializeObject(oPaperStudXMLList));
                status = "Denied";
            }
            if (result != 0)
            {
                divMsg.Style.Add("display", "block");

                lblAppOrDenyMsg.Text = "The Exemption claimed is " + status + " successfully for the selected student(s).";

                //--------------------------------
                //send exam for modify request
                string resStatus = clsPaperChange.SendExamFormModifyRequest_PaperExemptionApproval_MultipleStuds(ExamFormModifyXML.SerializeObject(oExamFormModifyReq)).ToString();

                if (resStatus != "U") //successful (resStatus gives the number of requests sent)
                {
                    //if (user.UserTypeCode != "2")
                    //{

                    //    lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent for " + resStatus + " number of student(s).";
                    //}
                    //else if (user.UserTypeCode == "2")
                    //{
                    //    lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent for " + resStatus + " number of student(s).";
                    //}

                    lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent for " + resStatus + " number of student(s).";
                }

                else if (resStatus == "U") //unsuccessful
                {
                    lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request could not be sent.";
                }
                //--------------------------------

                #region commented old code
                //***************************************************
                //commented old code
                //if (hidExamFormModifyReq.Value.Equals("Yes"))
                //{
                //    Hashtable HT = new Hashtable();
                //    HT.Add("UniID", hidUniID.Value);
                //    HT.Add("InstID", hidInstID.Value);
                //    HT.Add("FacID", hidFacID.Value);
                //    HT.Add("CrID", hidCrID.Value);
                //    HT.Add("MoLrnID", hidMoLrnID.Value);
                //    HT.Add("PtrnID", hidPtrnID.Value);
                //    HT.Add("BrnID", hidBrnID.Value);
                //    HT.Add("CrPrDetailsID", hidCrPrDetailsID.Value);
                //    HT.Add("CrPrChID", hidCrPrChID.Value);
                //    HT.Add("AcYrID", hid_fk_AcademicYr_ID.Value);
                //    HT.Add("CreatedBy", user.User_ID.ToString());
                //    HT.Add("RequestDetails", "'" + createExamFormModifyXML() + "'");

                //    if (clsPaperChange.SendExamFormModifyRequest(HT).Equals("S")) //successful
                //    {
                //        if (user.UserTypeCode != "2")
                //        {
                //            lblAppOrDenyMsg.Text = "<br>An Exam Form Modify Request has been sent. The results will also be re-processed.";
                //        }
                //        else if (user.UserTypeCode == "2")
                //        {
                //            lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent.";
                //        }
                //    }

                //    else
                //    {
                //        lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request could not be sent.";
                //    }

                //}
                //***************************************************
                #endregion

                //refill grid view
                //DT = clsCollegeAdmissionReports.PaperExemptionFetchStudentDetails(hidSelPaper.Value, hidInstID.Value, hid_fk_AcademicYr_ID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, Convert.ToString(Session["BranchID"]),
                //          hidCrPrDetailsID.Value, hidCrPrChID.Value, hidTLMIDs.Value, hidAMIDs.Value, hidATIDs.Value);
                DT = clsCollegeAdmissionReports.PaperExemptionFetchStudentDetails(hidSelPaper.Value, hidInstID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, Convert.ToString(Session["BranchID"]),
                                                                                  hidCrPrDetailsID.Value, hidCrPrChID.Value, hidTLMIDs.Value, hidAMIDs.Value, hidATIDs.Value);

                if (DT.Rows.Count > 0)
                {
                    divResultPageDetails.Style.Add("display", "block");
                    FillGridView(DT);
                    chkTLMAMAT.ClearSelection();
                    btnApprove.Style.Add("display", "block");
                    btnDeny.Style.Add("display", "block");
                }
                else
                {
                    btnApprove.Style.Add("display", "none");
                    btnDeny.Style.Add("display", "none");
                    divTLMAMATChoice.Style.Add("display", "none");
                    divPaperTLMAMAT.Style.Add("display", "none");
                    tblExportedDataMsg.Style.Add("display", "block");
                    //lblExportedData.Text = "No Record(s) found.";
                    divResultPageDetails.Style.Add("display", "none");
                }
            }
            else
            {
                divMsg.Style.Add("display", "block");
                lblAppOrDenyMsg.Text = "An error has occurred. Please try again later.";
            }

            if (oPaperStudXMLList != null)
            {
                oPaperStudXMLList = null;
            }
        }
        protected void btnDenyAll_Click(object sender, EventArgs e)
        {
            string resStatus = "";

            hidTLMIDs.Value = string.Empty;
            hidAMIDs.Value  = string.Empty;
            hidATIDs.Value  = string.Empty;
            List <PaperStudXML> oPaperStudXMLList = new List <PaperStudXML>();
            PaperStudXML        oPaperStudXML;

            //-------------
            List <ExamFormModifyXML> oExamFormModifyReq = new List <ExamFormModifyXML>();
            ExamFormModifyXML        ExamFormModifyReq;

            hidUniID.Value = Classes.clsGetSettings.UniversityID.ToString();
            //-------------

            foreach (ListItem li in chkTLMAMAT.Items)
            {
                if (li.Selected)
                {
                    hidSelTLMAmAt.Value += li.Value + "|" + li.Text + ",";
                    hidTLMIDs.Value     += li.Value.Split('-')[0].ToString() + ",";
                    hidAMIDs.Value      += li.Value.Split('-')[1].ToString() + ",";
                    hidATIDs.Value      += li.Value.Split('-')[2].ToString() + ",";
                }
            }
            hidTLMIDs.Value = hidTLMIDs.Value.TrimEnd(',');
            hidAMIDs.Value  = hidAMIDs.Value.TrimEnd(',');
            hidATIDs.Value  = hidATIDs.Value.TrimEnd(',');

            //DataTable DT = clsCollegeAdmissionReports.PaperExemptionFetchStudentDetails(hidSelPaper.Value, hidInstID.Value, hid_fk_AcademicYr_ID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, Convert.ToString(Session["BranchID"]),
            //             hidCrPrDetailsID.Value, hidCrPrChID.Value, hidTLMIDs.Value, hidAMIDs.Value, hidATIDs.Value);
            DataTable DT = clsCollegeAdmissionReports.PaperExemptionFetchStudentDetails(hidSelPaper.Value, hidInstID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, Convert.ToString(Session["BranchID"]),
                                                                                        hidCrPrDetailsID.Value, hidCrPrChID.Value, hidTLMIDs.Value, hidAMIDs.Value, hidATIDs.Value);

            if (DT.Rows.Count != 0)
            {
                for (int j = 0; j < DT.Rows.Count; j++)
                {
                    oPaperStudXML           = new PaperStudXML();
                    oPaperStudXML.StudentID = int.Parse(DT.Rows[j]["pk_Student_ID"].ToString());
                    oPaperStudXML.TLM       = int.Parse(DT.Rows[j]["TLM-AM-AT-ID"].ToString().Split('-')[0]);
                    oPaperStudXML.Year      = int.Parse(DT.Rows[j]["pk_Year"].ToString());
                    oPaperStudXML.AM        = int.Parse(DT.Rows[j]["TLM-AM-AT-ID"].ToString().Split('-')[1]);
                    oPaperStudXML.AT        = int.Parse(DT.Rows[j]["TLM-AM-AT-ID"].ToString().Split('-')[2]);
                    oPaperStudXML.FacID     = int.Parse(DT.Rows[j]["pk_Fac_ID"].ToString());
                    oPaperStudXML.Pk_Pp_PpHead_CrPrCh_ID = int.Parse(DT.Rows[j]["pk_Pp_PpHead_CrPrCh_ID"].ToString());
                    oPaperStudXML.CRID      = int.Parse(DT.Rows[j]["pk_Cr_ID"].ToString());
                    oPaperStudXML.MOLID     = int.Parse(DT.Rows[j]["pk_MoLrn_ID"].ToString());
                    oPaperStudXML.PtrnID    = int.Parse(DT.Rows[j]["pk_Ptrn_ID"].ToString());
                    oPaperStudXML.BrnID     = int.Parse(DT.Rows[j]["pk_Brn_ID"].ToString());
                    oPaperStudXML.CrPrDetID = int.Parse(DT.Rows[j]["pk_CrPr_Details_ID"].ToString());
                    oPaperStudXML.CrPrChtID = int.Parse(DT.Rows[j]["pk_CrPrCh_ID"].ToString());
                    oPaperStudXML.UniID     = int.Parse(DT.Rows[j]["pk_Uni_ID"].ToString());
                    oPaperStudXMLList.Add(oPaperStudXML);


                    //---------------
                    ExamFormModifyReq               = new ExamFormModifyXML();
                    ExamFormModifyReq.UniID         = int.Parse(hidUniID.Value);
                    ExamFormModifyReq.StudentID     = int.Parse(DT.Rows[j]["pk_Student_ID"].ToString());
                    ExamFormModifyReq.Year          = int.Parse(DT.Rows[j]["pk_Year"].ToString());
                    ExamFormModifyReq.AcYrID        = int.Parse(DT.Rows[j]["fk_AcademicYear_ID"].ToString());
                    ExamFormModifyReq.InstID        = int.Parse(DT.Rows[j]["Ref_InstReg_Institute_ID"].ToString());
                    ExamFormModifyReq.FacID         = int.Parse(DT.Rows[j]["pk_Fac_ID"].ToString());
                    ExamFormModifyReq.CrID          = int.Parse(DT.Rows[j]["pk_Cr_ID"].ToString());
                    ExamFormModifyReq.MoLrnID       = int.Parse(DT.Rows[j]["pk_MoLrn_ID"].ToString());
                    ExamFormModifyReq.PtrnID        = int.Parse(DT.Rows[j]["pk_Ptrn_ID"].ToString());
                    ExamFormModifyReq.BrnID         = int.Parse(DT.Rows[j]["pk_Brn_ID"].ToString());
                    ExamFormModifyReq.CrPrDetailsID = int.Parse(DT.Rows[j]["pk_CrPr_Details_ID"].ToString());
                    ExamFormModifyReq.CrPrChID      = int.Parse(DT.Rows[j]["pk_CrPrCh_ID"].ToString());
                    ExamFormModifyReq.CreatedBy     = user.User_ID.ToString();
                    //ExamFormModifyReq.RequestDetails = createExamFormModifyXML(ExamFormModifyReq.StudentID, ExamFormModifyReq.Year);
                    oExamFormModifyReq.Add(ExamFormModifyReq);
                    //---------------
                }
                int result = clsCollegeAdmissionReports.PaperExemptionApproveOrDeny(user.User_ID, 2, PaperStudXML.SerializeObject(oPaperStudXMLList));
                // int result = 1;

                if (result != 0)
                {
                    divMsg.Style.Add("display", "block");
                    lblAppOrDenyMsg.Text = "The Exemption claimed is denied successfully for the selected " + lblPaper.Text + "(s).";
                    btnDenyAll.Enabled   = false;
                    btnSelect.Enabled    = false;
                    resStatus            = clsPaperChange.SendExamFormModifyRequest_PaperExemptionApproval_MultipleStuds(ExamFormModifyXML.SerializeObject(oExamFormModifyReq)).ToString();

                    if (resStatus != "U") //successful (resStatus gives the number of requests sent)
                    {
                        //if (user.UserTypeCode != "2")
                        //{

                        //    lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent for " + resStatus + " number of student(s).";
                        //}
                        //else if (user.UserTypeCode == "2")
                        //{
                        //    lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent for " + resStatus + " number of student(s).";
                        //}

                        lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request has been sent for " + resStatus + " number of student(s).";
                    }

                    else if (resStatus == "U") //unsuccessful
                    {
                        lblAppOrDenyMsg.Text += "<br>An Exam Form Modify Request could not be sent.";
                    }
                }
                else
                {
                    divMsg.Style.Add("display", "block");
                    lblAppOrDenyMsg.Text = "An error has occurred. Please try again later.";
                }
            }
            else
            {
                divMsg.Style.Add("display", "block");
                lblAppOrDenyMsg.Text = "<br>Exemption Approval decision has already been taken for selected " + lblPaper.Text + "(s) and selected assessment type.";
            }

            //refill grid view

            if (hidInstID.Value == "")
            {
                //DT = clsCollegeAdmissionReports.ListStudentCountForPaperExemptionApprovalSelectedCourse(hid_fk_AcademicYr_ID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, Convert.ToString(Session["BranchID"]),
                //    hidCrPrDetailsID.Value, hidCrPrChID.Value);
                DT = clsCollegeAdmissionReports.ListStudentCountForPaperExemptionApprovalSelectedCourse(hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, Convert.ToString(Session["BranchID"]),
                                                                                                        hidCrPrDetailsID.Value, hidCrPrChID.Value);
            }
            else
            {
                //DT = clsCollegeAdmissionReports.ListStudentCountForPaperExemptionApprovalSelectedCollege(hid_fk_AcademicYr_ID.Value, hidInstID.Value);
                DT = clsCollegeAdmissionReports.ListStudentCountForPaperExemptionApprovalSelectedCollege(hidInstID.Value);
            }
            if (DT.Rows.Count > 0)
            {
                GVPapers.DataSource = DT;
                GVPapers.DataBind();
                divPapers.Style.Add("display", "block");
                btnPaperNext.Style.Add("display", "block");
            }
            else
            {
                tblExportedDataMsg.Style.Add("display", "block");
                lblExportedData.Text = "No Record(s) found.";
                divPapers.Style.Add("display", "none");
                btnPaperNext.Style.Add("display", "none");
            }
        }