Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string sReturn = "";
            string studID  = "";

            lblUnselectCheck.Text = "";
            int iCount = 0;

            if (hidRightsFlag.Value == "0")
            {
                DataGridItemCollection items = DG_University.Items;
                for (int i = 0; i < items.Count; i++)
                {
                    CheckBox cb = (CheckBox)items[i].FindControl("chkSelect");
                    if ((cb != null) && (cb.Checked == true))
                    {
                        studID += DG_University.DataKeys[i].ToString().Trim() + ",";
                        iCount  = iCount + 1;
                    }
                }
            }
            else
            {
                if (DG_College.Items.Count > 0)
                {
                    iCount = DG_College.Items.Count;
                }
            }

            sReturn = clsEligibilityRights.Bulk_Process_Eligibility_Data(hidUniID.Value, hidYear.Value, hidInstID.Value, hidCrMoLrnPtrnID.Value, hidCrPrID.Value, studID, hidCollege_Eligibility_Flag.Value, "1", "", sUser);
            if (sReturn == "Y")
            {
                string  SMSreturn  = "";
                string  SMSMessage = "";
                clsUser u          = (clsUser)Session["User"]; //Added By Saroj on 1st Nov 2007
                try
                {
                    SendSMS objSendSMS = new SendSMS();
                    DataSet ds         = clsEligibilityRights.FetchRegisteredStudentDetailsForSMS(hidUniID.Value, hidYear.Value, hidInstID.Value, hidCrMoLrnPtrnID.Value, hidCrPrID.Value, studID);
                    if (ds != null)
                    {
                        //if (ds.Tables.Count > 0)
                        //{
                        //    for (int i = 0; i < ds.Tables.Count; i++)
                        //    {
                        //        SMSMessage = "Congrats " + ds.Tables[i].Rows[0]["FirstName"].ToString() + ",U R elgble for " + ds.Tables[i].Rows[0]["CrAbbr"].ToString() + ",PRN:" + ds.Tables[i].Rows[0]["PRN"].ToString() + ",Collect eSuvidha LoginId,Password from college and visit " + UniversityPortal.clsGetSettings.SitePath.Replace("http://","");
                        //        objSendSMS.epMessage = SMSMessage;
                        //        SMSreturn = objSendSMS.SendPersonalizedSMS(ds.Tables[i].Rows[0]["MobileNumber"].ToString().Trim(), "ELG" + ds.Tables[i].Rows[0]["EligibilityFormNo"].ToString());
                        //    }
                        //}
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                //SMSMessage = "Congrats " + hidSMSFirstName.Value + ",You are eligible for " + hidSMSCrAbbr.Value + " of " + TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["SMSPcode"].ToString().ToUpper() + ". Your PRN:" + PRN + ".";
                                SMSMessage           = "Congrats " + ds.Tables[0].Rows[i]["FirstName"].ToString() + ",You are eligible for " + ds.Tables[0].Rows[i]["CrAbbr"].ToString() + " of " + TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["SMSPcode"].ToString().ToUpper() + ". Your PRN:" + ds.Tables[0].Rows[i]["PRN"].ToString();
                                objSendSMS.epMessage = SMSMessage;
                                objSendSMS.epUser    = u.User_ID; //Added By Saroj on 1st Nov 2007
                                SMSreturn            = objSendSMS.SendPersonalizedSMS(ds.Tables[0].Rows[i]["MobileNumber"].ToString().Trim(), "ELG" + ds.Tables[0].Rows[i]["EligibilityFormNo"].ToString());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string sMsg      = ex.Message;
                    string strScript = "<script language=JavaScript>alert('" + sMsg + "');</Script>";
                    ClientScript.RegisterStartupScript(this.GetType(), "key1", strScript);
                }
                lblSave.Visible    = true;
                lblSave.CssClass   = "SaveNote";
                lblSave.Text       = "Eligibility processed for " + iCount + " students and PRN generated successfully.<br>To view list of eligible students and PRN generated click on \"View Eligible Students With PRN\" link.";
                lblUniCollPrn.Text = "";
                displayGrids();
            }
            else
            {
                lblSave.CssClass = "ErrorNote";
                lblSave.Text     = "System has encountered an error during Process.<br>Please try again later";
            }
        }
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            divEligibilityDecision.Style.Add("display", "none");


            //if (rbPending.Checked == true)
            //{
            //    divPRN.Style.Add("display", "block");
            //    lblPRN.Text = "<Font color='#c00000' size='3'>Selected record has already been processed for 'Pending Eligible' decision.</font><br>The SMS regarding the same is already been sent to the student.";
            //}
            if (GoToDataBase == 1)
            {
                string  sReason = "";
                string  PRN, ElgLabel = "";
                string  flag   = "0";
                DataSet dsDocs = new DataSet();
                DataRow dr;
                dsDocs.Tables.Add("StudentDocs");
                dsDocs.Tables["StudentDocs"].Columns.Add("fk_Doc_ID");
                dsDocs.Tables["StudentDocs"].Columns.Add("RecvdBy_Uni");
                dsDocs.Tables["StudentDocs"].Columns.Add("ValidityBy_Uni");
                int j = 0;
                for (int i = 0; i < hidDocXML.Value.Length; i += 2)
                {
                    if (hidDocXML.Value[i] == '1')     //if checkbox checked =  true
                    {
                        dr = dsDocs.Tables["StudentDocs"].NewRow();
                        dr["fk_Doc_ID"]      = DGSubmittedDocs1.Rows[j].Cells[5].Text.Trim();
                        dr["RecvdBy_Uni"]    = '1';
                        dr["ValidityBy_Uni"] = hidDocXML.Value[i + 1];
                        dsDocs.Tables["StudentDocs"].Rows.Add(dr);
                    }
                    else if (hidDocXML.Value[i] == '0')     //if checkbox checked =  false
                    {
                        dr = dsDocs.Tables["StudentDocs"].NewRow();
                        dr["fk_Doc_ID"]      = DGSubmittedDocs1.Rows[j].Cells[5].Text.Trim();
                        dr["RecvdBy_Uni"]    = '0';
                        dr["ValidityBy_Uni"] = "";
                        dsDocs.Tables["StudentDocs"].Rows.Add(dr);
                    }
                    j++;
                }


                sReason = tbOldReason.Text.Replace("'", "");

                System.Text.StringBuilder sb = new System.Text.StringBuilder(1000);    //contains XML fmt of Docs
                System.IO.StringWriter    sw = new System.IO.StringWriter(sb);
                dsDocs.WriteXml(sw, XmlWriteMode.IgnoreSchema);
                //string sbuilder = "";
                //if(sb.Length==14)     //if empty contains "</newdataset>"
                // sb = (System.Text.StringBuilder)null;
                //sb = (System.Text.StringBuilder)Convert.DBNull;
                if (rbEligible.Checked) //Eligible
                {
                    divReason.Attributes.Add("style", "display:none");
                    flag     = "1";
                    ElgLabel = "Eligible";
                    lblPendingReason.Text = "";

                    sReason = tbOldReason.Text.Replace("\r\n", "") + "[Resolved]";
                }
                else if (rbDefaulter.Checked) //Not Eligible
                {
                    flag     = "2";
                    ElgLabel = "Not Eligible";
                    sReason  = tbOldReason.Text.Replace("\r\n", "") + "===" + DateTime.Now.ToString("MM/dd/yy HH:mm") + "===" + tbReason.Text.ToString().Trim();
                }
                else if (rbPending.Checked) //Pending
                {
                    flag     = "3";
                    ElgLabel = "Pending";
                    sReason  = tbOldReason.Text.Replace("\r\n", "") + "===" + DateTime.Now.ToString("MM/dd/yy HH:mm") + "===" + tbReason.Text.ToString().Trim();

                    divPRN.Style.Add("display", "block");
                    lblPRN.Text = "<Font color='#c00000' size='3'>Selected record has already been processed for 'Pending Eligible' decision with probably some changes in the Student Document details.</font>"; //<br>The SMS regarding the same is already been sent to the student.";
                }
                else if (rbProvisional.Checked)                                                                                                                                                                   //Provisionally Eligible
                {
                    flag     = "5";
                    ElgLabel = "Provisionally Eligible";
                    sReason  = tbOldReason.Text.Replace("\r\n", "") + "===" + DateTime.Now.ToString("MM/dd/yy HH:mm") + "===" + tbReason.Text.ToString().Trim();
                }

                tbOldReason.Text = FormatReason(sReason).Replace("<br/>", Environment.NewLine);

                hidElgFlag.Value = flag;
                if (lblPermRegNo.Text == "" || lblPermRegNo.Text == null || lblPermRegNo.Text == "-" || lblPermRegNo.Text == "Not Generated")
                {
                    lblPermRegNo.Text = "00";
                }
                RefIDarr = hidElgFormNo.Value.Split('-');
                //PRN = clsEligibilityDBAccess.REG_PendingEStudEligibilityDecision(Convert.ToInt32(ConfigurationSettings.AppSettings["UniversityID"].ToString()),Convert.ToInt32(Session["pk_Year"].ToString()),Convert.ToInt32(Session["pk_Student_ID"].ToString()),Convert.ToInt32(Session["pk_CrMoLrnPtrn_ID"].ToString()),flag,sb,tbReason.Text.Trim(),lblPermRegNo.Text.Trim(),userid);
                string[] strArr = new string[2];
                int      Error;

                //string DCServer = TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["DCServer"].ToString();
                //string DCDataBase = TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["DCDataBase"].ToString();
                string DCServer   = Convert.ToString(clsGetSettings.DCServer);
                string DCDataBase = Convert.ToString(clsGetSettings.DCDatabase);

                strArr            = clsEligibilityDBAccess.REG_PendingStudentEligibilityDecision(Convert.ToInt32(Classes.clsGetSettings.UniversityID.ToString()), Convert.ToInt32(hidpkYear.Value), Convert.ToInt32(hidpkStudentID.Value), Convert.ToInt32(RefIDarr[0].ToString()), Convert.ToInt32(RefIDarr[1].ToString()), Convert.ToInt32(RefIDarr[2].ToString()), Convert.ToInt32(RefIDarr[3].ToString()), Convert.ToInt32(hidpkFacID.Value), Convert.ToInt32(hidpkCrID.Value), Convert.ToInt32(hidpkMoLrnID.Value), Convert.ToInt32(hidpkPtrnID.Value), Convert.ToInt32(hidpkBrnID.Value), Convert.ToInt32(hidpkCrPrDetailsID.Value), Convert.ToInt32(hid_fk_AcademicYr_ID.Value), flag, sb, lblPermRegNo.Text.Trim(), sReason, userid, DCServer, DCDataBase);
                PRN               = strArr[0];
                Error             = Convert.ToInt32(strArr[1]);
                lblPermRegNo.Text = PRN;
                //FetchStudentDetails();
                clsUser u = (clsUser)Session["User"]; //Added By Saroj on 1st Nov 2007
                if (Error == 0 && flag != "3")
                {
                    string SMSreturn  = "";
                    string SMSMessage = "";

                    try
                    {
                        SendSMS objSendSMS = new SendSMS();
                        divPRN.Style.Add("Display", "block");
                        //lblPRN.Text ="The Student is Marked as <br><Font color='red' size='2'>"+ElgLabel+"</font><br> for the Course "+lblCourse.Text +" .";
                        lblPRN.Text = "The Student is Marked as <br><Font color='red' size='2'>" + ElgLabel + "</font><br>";
                        if (flag == "1")
                        {
                            if (lblPermRegNo.Text != "" && lblPermRegNo.Text != "00" && lblPermRegNo.Text != null)
                            {
                                lblPRN.Text          += " The " + lblPermanentRegistrationNumber.Text + " for the Student ";
                                lblPRN.Text          += "<i>" + lblNameOfStudent.Text + "</i> is <br><Font color='red' size='3'>" + PRN + "</Font><br>Please write " + lblPRNNomenclature.Text + " on the Admission/Eligibility form.";
                                Cache["PRN"]          = lblPRN.Text;
                                Cache["GeneratedPRN"] = PRN;
                            }
                            else
                            {
                                lblPRN.Text          += " \nThe " + lblPermanentRegistrationNumber.Text + " for the Student ";
                                lblPRN.Text          += "<i>" + lblNameOfStudent.Text + "</i> is same<br><Font color='red' size='3'>" + lblPermRegNo.Text + "</Font><br>Please write " + lblPRNNomenclature.Text + " on the Admission/Eligibility form.";
                                Cache["PRN"]          = lblPRN.Text;
                                Cache["GeneratedPRN"] = PRN;
                            }

                            //==========================================================================================
                            // To fetch Student login credentials for displaying in SMS
                            string  userName = string.Empty, password = string.Empty;
                            DataSet Ds = clsEligibilityRights.GetStudentCredentialsForSMS(hidUniID.Value, hidpkYear.Value, hidpkStudentID.Value);
                            if (Ds != null && Ds.Tables[0] != null && Ds.Tables[0].Rows.Count > 0)
                            {
                                userName = Ds.Tables[0].Rows[0]["UserName"].ToString();
                                password = Ds.Tables[0].Rows[0]["Password"].ToString();
                            }
                            //==========================================================================================

                            //SMSMessage = "Congrats " + hidSMSFirstName.Value + ",You are eligible for " + hidSMSCrAbbr.Value + " for Academic Year " + hidAcademicYr.Value + " of " + TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["SMSPcode"].ToString().ToUpper() + ". Your " + lblPRNNomenclature.Text + ":" + PRN + ".";
                            //SMSMessage = clsEligibilityRights.GetSMSBody("24", hidSMSFirstName.Value, hidSMSCrAbbr.Value, hidAcademicYr.Value, hidUniAbbrv.Value, PRN, TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["SitePath"].ToString(), userName, password, string.Empty);
                            SMSMessage            = clsEligibilityRights.GetSMSBody("24", hidSMSFirstName.Value, hidSMSCrAbbr.Value, hidAcademicYr.Value, hidUniAbbrv.Value, PRN, clsGetSettings.SitePath, userName, password, string.Empty);
                            objSendSMS.epMessage  = SMSMessage;
                            objSendSMS.epUser     = u.User_ID;//Added By Saroj on 1st Nov 2007
                            lblPendingReason.Text = FormatReason(tbOldReason.Text);
                        }
                        else if (flag == "5")
                        {
                            if (PRN != null && PRN != "")
                            {
                                lblPRN.Text           = "The Student is Marked as <Font color='red' size='2'><b>" + ElgLabel + "</b></font><br>";
                                lblPRN.Text          += "The " + lblPermanentRegistrationNumber.Text + " for the Student ";
                                lblPRN.Text          += "<b><i>" + lblNameOfStudent.Text + "</i></b> is <br><Font color='#c00000' size='3'>" + PRN + "</Font><br><Font size=2>Please write " + lblPRNNomenclature.Text + " on the Admission/Eligibility form.</Font>";
                                Cache["PRN"]          = lblPRN.Text;
                                Cache["GeneratedPRN"] = PRN;

                                //==========================================================================================
                                // To fetch Student login credentials for displaying in SMS
                                string  userName = string.Empty, password = string.Empty;
                                DataSet Ds = clsEligibilityRights.GetStudentCredentialsForSMS(hidUniID.Value, hidpkYear.Value, hidpkStudentID.Value);
                                if (Ds != null && Ds.Tables[0] != null && Ds.Tables[0].Rows.Count > 0)
                                {
                                    userName = Ds.Tables[0].Rows[0]["UserName"].ToString();
                                    password = Ds.Tables[0].Rows[0]["Password"].ToString();
                                }
                                //==========================================================================================
                                //SMSMessage = "Dear " + hidSMSFirstName.Value + ",You are provisionally eligible for " + hidSMSCrAbbr.Value + " for Academic Year " + hidAcademicYr.Value + " of " + TripleDESEncryption.clsAppSettings.DecryptAppsettings().AppSettings["SMSPcode"].ToString().ToUpper() + ". Your " + lblPRNNomenclature.Text + ":" + PRN + ". Discrepancy is available in " + lblCollege.Text.ToLower() + "'s login on Digital " + lblUniversity.Text + " Portal of eSuvidha.";
                                SMSMessage           = clsEligibilityRights.GetSMSBody("3", hidSMSFirstName.Value, hidSMSCrAbbr.Value, hidAcademicYr.Value, hidUniAbbrv.Value, PRN, clsGetSettings.SitePath, userName, password, string.Empty);
                                objSendSMS.epMessage = SMSMessage;
                                objSendSMS.epUser    = u.User_ID; //Added By Saroj on 1st Nov 2007
                            }
                            else
                            {
                                lblPRN.Text = "System has encountered an error in the registration process. Hence, Registration failed !!!<br>Please try again later.";
                            }
                            lblPendingReason.Text = FormatReason(tbOldReason.Text);
                        }
                        else if ((flag == "2") || (flag == "3"))
                        {
                            if (lblPermRegNo.Text != "" && lblPermRegNo.Text != "00" && lblPermRegNo.Text != null)
                            {
                                lblPRN.Text          += "\nThe " + lblPermanentRegistrationNumber.Text + " for the Student ";
                                lblPRN.Text          += "<i>" + lblNameOfStudent.Text + "</i> is same<br><Font color='red' size='3'>" + lblPermRegNo.Text + "</Font><br>Please write " + lblPRNNomenclature.Text + " on the Admission/Eligibility form.";
                                Cache["PRN"]          = lblPRN.Text;
                                Cache["GeneratedPRN"] = PRN;
                            }
                            else
                            {
                                lblPRN.Text  = "The Student <i>" + lblNameOfStudent.Text + "</i> is marked <br><Font color='#c00000' size='2'>" + ElgLabel + "</Font><br> for the " + lblCr.Text + " " + lblCourse.Text;
                                Cache["PRN"] = lblPRN.Text;
                            }
                            lblPendingReason.Text = FormatReason(tbOldReason.Text);
                            if (flag == "2")
                            {
                                //SMSMessage = "Dear " + hidSMSFirstName.Value + ", You are found ineligible for " + hidSMSCrAbbr.Value + " for Academic Year " + hidAcademicYr.Value + ". For more details contact your " + lblCollege.Text.ToLower() + ".";
                                SMSMessage = clsEligibilityRights.GetSMSBody("5", hidSMSFirstName.Value, hidSMSCrAbbr.Value, hidAcademicYr.Value, hidUniAbbrv.Value, "", clsGetSettings.SitePath, "", "", string.Empty);
                            }
                            else if (flag == "3")
                            {
                                //SMSMessage = "Dear " + hidSMSFirstName.Value + ", your eligibility for " + hidSMSCrAbbr.Value + " for Academic Year " + hidAcademicYr.Value + " is pending. Discrepancy is available in " + lblCollege.Text.ToLower() + "'s login on Digital " + lblUniversity.Text.ToLower() + " Portal of eSuvidha.";
                                SMSMessage = clsEligibilityRights.GetSMSBody("4", hidSMSFirstName.Value, hidSMSCrAbbr.Value, hidAcademicYr.Value, hidUniAbbrv.Value, "", clsGetSettings.SitePath, "", "", string.Empty);
                            }
                            objSendSMS.epMessage = SMSMessage;
                            objSendSMS.epUser    = u.User_ID; //Added By Saroj on 1st Nov 2007
                        }
                        SMSreturn = objSendSMS.SendPersonalizedSMS(hidSMSMobileNumber.Value.Trim(), "ELG" + hidElgFormNo.Value);
                        if (SMSreturn.Substring(0, 7) == "Invalid")
                        {
                            lblSMSError.Text = "SMS could not be sent because of following reason:<br><font size=2>" + SMSreturn + "</font>";
                        }
                        else
                        {
                            lblSMSError.Text = "<font size=2>Following SMS has been sent to Student on:" + hidSMSMobileNumber.Value.Trim() + "<br><font size=2> (" + SMSMessage + ")</font>";
                        }
                    }
                    catch (Exception ex)
                    {
                        lblSMSError.Text = ex.Message;
                    }
                }
                else if (Error != 0)
                {
                    lblPRN.Text = "System has encountered an error in the registration process. Hence, Registration failed !!!<br>Please try again later.";
                }

                divEligibilityDecision.Attributes.Add("display", "none");

                int k = 0;
                for (int l = 0; l < hidDocXML.Value.Length; l += 2)
                {
                    if (hidDocXML.Value[l] == '1')     //if checkbox checked =  true
                    {
                        if (hidDocXML.Value[l + 1] == '1')
                        {
                            ((RadioButton)DGSubmittedDocs1.Rows[k].Cells[4].Controls[1]).Checked = true;
                            ((RadioButton)DGSubmittedDocs1.Rows[k].Cells[4].Controls[1]).Enabled = false;
                        }
                        else
                        {
                            ((RadioButton)DGSubmittedDocs1.Rows[k].Cells[4].Controls[3]).Checked = true;
                            ((RadioButton)DGSubmittedDocs1.Rows[k].Cells[4].Controls[3]).Enabled = false;
                        }
                    }
                    k++;
                }
                if (lblPermRegNo.Text == "" || lblPermRegNo.Text == null || lblPermRegNo.Text == "00")
                {
                    lblPermRegNo.Text = "-";
                }
                GoToDataBase            = 0;
                Session["GoToDataBase"] = GoToDataBase;
            }
            else
            {
                divPRN.Style.Add("display", "block");
                lblPermRegNo.Text = Cache["GeneratedPRN"].ToString();
                if (Cache["GeneratedPRN"] != null && Cache["GeneratedPRN"].ToString() != "")
                {
                    divReason.Attributes.Add("style", "display:none");
                }
                lblPRN.Text = "<Font color='#c00000' size='3'>Selected Record has Already been Processed</font><br>" + Cache["PRN"].ToString();
            }

            for (int i = 0; i < DGSubmittedDocs1.Rows.Count; i++)
            {
                ((CheckBox)DGSubmittedDocs1.Rows[i].Cells[3].Controls[1]).Enabled    = false;
                ((RadioButton)DGSubmittedDocs1.Rows[i].Cells[4].Controls[1]).Enabled = false;
                ((RadioButton)DGSubmittedDocs1.Rows[i].Cells[4].Controls[3]).Enabled = false;
            }
        }