Beispiel #1
0
        protected void compareDates()
        {
            DateTime doB;
            var      leohii = DateTime.Today;

            var dofB = dateofBirth.Value.Trim();

            if (string.IsNullOrWhiteSpace(dofB))
            {
                KCDFAlert.ShowAlert("Select a valid date!");
                dateofBirth.Focus();
                return;
            }
            else
            {
                doB = DateTime.Parse(dofB);
            }
            var myAge = (leohii - doB).TotalDays;

            if (myAge < 18)
            {
                KCDFAlert.ShowAlert("PG 13 pls go to bed");
            }
            else
            {
                KCDFAlert.ShowAlert("18 and above, greenlight");
            }
        }
Beispiel #2
0
        public bool CheckConsultant(string idNoReg)
        {
            bool    status      = false;
            var     credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
            Portals sup         = new Portals();

            sup.Credentials     = credentials;
            sup.PreAuthenticate = true;

            if (sup.FnVerifyConsultant(idNoReg) == true)
            {
                status = true;
                KCDFAlert.ShowAlert(status.ToString() + "That Reg No/ID No is already taken");
                //Session["myStatusIs"] = status;
                //lblStatus.Text = Session["myStatusIs"].ToString();
            }
            else
            {
                status = false;
                //Session["myStatusIsFalse"] = status;
                // KCDFAlert.ShowAlert(status.ToString()+"Not Taken");
                CreateAConsultant();
            }

            return(status);
        }
        protected void readEducBgData()
        {
            var edctnData = nav.studentsRegister.ToList().Where(r => r.Username == Session["username"].ToString());

            try
            {
                var ggNN = edctnData.Select(p => p.Parent_or_Guardian_Phone).SingleOrDefault();
                if (ggNN != null)
                {
                    var mobileBuilder = new StringBuilder(ggNN);
                    mobileBuilder.Remove(0, 4);   //Trim four characters from position 1
                    mobileBuilder.Insert(0, "0"); // replace position +254 with 0
                    ggNN = mobileBuilder.ToString();
                    txtGuardianPhone.Text = ggNN;
                }
            }
            catch (Exception ex)
            {
                txtGuardianPhone.Text = "";
            }

            try
            {
                var secsh = edctnData.Select(se => se.Secondary_School).SingleOrDefault();
                txtSecon.Text     = secsh;
                txtCollg.Text     = edctnData.Select(un => un.University_or_College).SingleOrDefault();
                txtDegree.Text    = edctnData.Select(fc => fc.Course).SingleOrDefault();
                txtFaculty.Text   = edctnData.Select(fc => fc.Course).SingleOrDefault();
                txtYearofStd.Text = edctnData.Select(yos => yos.Year_of_Study).Single();
                txtForm.Text      = edctnData.Select(yos => yos.Year_of_Study).Single();
                var yoAd = edctnData.Select(yoa => Convert.ToDateTime(yoa.Year_of_Admission)).SingleOrDefault();
                var yoC  = edctnData.Select(yoc => Convert.ToDateTime(yoc.Year_of_Completion)).SingleOrDefault();
                txtGuardianEmail.Text   = edctnData.Select(em => em.Parent_or_Guardian_Email).SingleOrDefault();
                txtGuardianAddress.Text = edctnData.Select(ad => ad.Parent_or_Guardian_Address).SingleOrDefault();

                txtYoAdmn.Text     = yoAd.ToShortDateString();
                txtSecoYofAdm.Text = yoAd.ToShortDateString();

                txtYofcomplt.Text   = yoC.ToShortDateString();
                txtSecoEndYear.Text = yoC.ToShortDateString();

                int marsk  = edctnData.Select(mk => Convert.ToInt32(mk.KCPE_Marks)).SingleOrDefault();
                var fGrade = edctnData.Select(grd => grd.KCSE_Grade).SingleOrDefault();
                int ttMks  = edctnData.Select(ttm => Convert.ToInt32(ttm.KCPE_Total_Marks)).SingleOrDefault();
                txtMarks.Text                 = Convert.ToString(marsk);
                txtTotalMarks.Text            = Convert.ToString(ttMks);
                rdoBtnListGrade.SelectedValue = fGrade;

                txtMyPrimo.Text = edctnData.Select(pr => pr.Primary_School).SingleOrDefault();
            }
            catch (Exception exr)
            {
                KCDFAlert.ShowAlert("Your Data is Incomplete, Please Fill all the data!");
            }
        }
 protected void loadRefs()
 {
     try
     {
         var allmyrefs = nav.myReferees.ToList().Where(us => us.Username == Session["username"].ToString());
         tblRefs.AutoGenerateColumns = false;
         tblRefs.DataSource          = allmyrefs;
         tblRefs.DataBind();
     }
     catch (Exception ex)
     {
         KCDFAlert.ShowAlert(ex.Message);
     }
 }
        protected void readData()
        {
            try
            {
                var granteeData = nav.grantees_Register.ToList().Where(r => r.Organization_Username == Session["username"].ToString());

                txPhoneNo.Text  = granteeData.Select(pn => pn.Phone).SingleOrDefault().ToString();
                txOrgname.Text  = granteeData.Select(fn => fn.Organization_Name).SingleOrDefault().ToString();
                txEmailAdd.Text = granteeData.Select(em => em.Email).SingleOrDefault().ToString();
            }
            catch (Exception exp)
            {
                KCDFAlert.ShowAlert("Your Information is not Up to Date, update!");
            }
        }
        protected void readData()
        {
            var studData = nav.studentsRegister.ToList().Where(r => r.Username == Session["username"].ToString());

            try
            {
                var ppNN = studData.Select(p => p.Phone_Number).SingleOrDefault();
                if (ppNN != null)
                {
                    var mobileBuilder = new StringBuilder(ppNN);
                    mobileBuilder.Remove(0, 4);   //Trim four characters from position 1
                    mobileBuilder.Insert(0, "0"); // replace position +254 with 0
                    ppNN            = mobileBuilder.ToString();
                    txtPhoneNo.Text = ppNN;
                }
            }
            catch (Exception ex)
            {
                txtPhoneNo.Text = "";
            }
            try
            {
                txtfNname.Text    = studData.Select(fn => fn.First_name).SingleOrDefault();
                txtMname.Text     = studData.Select(mn => mn.Middle_name).SingleOrDefault();
                txtLname.Text     = studData.Select(ln => ln.Last_name).SingleOrDefault();
                txtResidence.Text = studData.Select(r => r.Residence).SingleOrDefault();
                txtIDNo.Text      = studData.Select(id => id.ID_No).SingleOrDefault();
                txtEmailAdd.Text  = studData.Select(em => em.Email).SingleOrDefault();
                txtCounty.Text    = studData.Select(em => em.County).SingleOrDefault();
                txtSubCounty.Text = studData.Select(em => em.SubCounty).SingleOrDefault();
                var dtB = studData.Select(dtoB => dtoB.Date_of_Birth).SingleOrDefault().ToString();
                var dt1 = DateTime.Parse(dtB);
                dateOFBirth.Value = dt1.ToShortDateString();
                var gent = studData.Select(g => g.Gender).SingleOrDefault();
                if (gent == "Male")
                {
                    lstGender.SelectedIndex = 1;
                }
                else
                {
                    lstGender.SelectedIndex = 2;
                }
            }
            catch (Exception exr)
            {
                KCDFAlert.ShowAlert("Your Data is Incomplete, please fill all your information");
            }
        }
 protected void getPostaCodes()
 {
     try
     {
         var posta = nav.list_myPosta.ToList();
         ddlPostalCode.DataSource     = posta;
         ddlPostalCode.DataTextField  = "Postal_Code";
         ddlPostalCode.DataValueField = "Postal_Code";
         ddlPostalCode.DataBind();
         ddlPostalCode.Items.Insert(0, "--Select Postal Code--");
     }
     catch (Exception exp)
     {
         KCDFAlert.ShowAlert("Your Postal code is not updated, Please update");
     }
 }
        protected void btnAddRefer_OnClick(object sender, EventArgs e)
        {
            var usernaMe = Session["username"].ToString();
            var studNo   =
                nav.studentsRegister.ToList()
                .Where(s => s.Username == Session["username"].ToString())
                .Select(sn => sn.No)
                .SingleOrDefault();

            var refFname      = txtrefFname.Text.Trim();
            var refmname      = refMidName.Text.Trim();
            var refLname      = refLName.Text.Trim();
            var refemail      = refEmail.Text.Trim();
            var ferPhneNo     = refMobile.Text.Trim();
            var mobileBuilder = new StringBuilder(ferPhneNo);

            mobileBuilder.Remove(0, 1);      //Trim one character from position 1
            mobileBuilder.Insert(0, "+254"); // replace position 0 with +254
            ferPhneNo = mobileBuilder.ToString();
            try
            {
                var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"],
                                                        ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                var nws = new Portals();
                nws.Credentials     = credentials;
                nws.PreAuthenticate = true;

                nws.FnAddReferee(usernaMe, studNo, refFname, refmname, refLname, ferPhneNo, refemail);
                KCDFAlert.ShowAlert("Referee Added Successfully!");
                loadRefs();
                txtrefFname.Text = "";
                refMidName.Text  = "";
                refLName.Text    = "";
                refEmail.Text    = "";
                refMobile.Text   = "";
            }
            catch (Exception ep)
            {
                KCDFAlert.ShowAlert(ep.Message);
            }
        }
        protected void ddlnonPartisan_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            int selVal = ddlnonPartisan.SelectedIndex;

            if (selVal == 0)
            {
                KCDFAlert.ShowAlert("Please select a valid choice");
            }
            else
            if (selVal == 1)
            {
                txtAreaPartisan.Visible = true;
                txtAreaPartisan.Focus();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "pageLoad();", true);
            }
            else
            {
                txtAreaPartisan.Visible = false;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "pageLoad();", true);
            }
        }
        protected void lnkDelete_OnClick(object sender, EventArgs e)
        {
            var usnme = Session["username"].ToString();
            var refNo = Session["ref_no"].ToString();

            try
            {
            }
            catch (Exception ex)
            {
                var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"],
                                                        ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                var nws = new Portals();
                nws.Credentials     = credentials;
                nws.PreAuthenticate = true;

                nws.FnDeleteReferee(usnme, refNo);
                KCDFAlert.ShowAlert("Referee Deleted!");
                loadRefs();
            }
        }
        protected void ddlSelCounty_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            int selIndex = ddlSelCounty.SelectedIndex;

            switch (selIndex)
            {
            case 0:
                KCDFAlert.ShowAlert("Invalid County selection");
                break;

            default:
                var sbCntysplit00 = ddlSelCounty.SelectedValue;
                var subCnty       = nav.mysubCountyIs.Where(sc => sc.County_Code == sbCntysplit00).ToList();
                ddlConstituency.DataSource     = subCnty;
                ddlConstituency.DataTextField  = "Sub_County_Name";
                ddlConstituency.DataValueField = "Sub_County_Name";
                ddlConstituency.DataBind();
                ddlConstituency.Items.Insert(0, "--Select your Sub County--");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "pageLoad();", true);
                //KCDFAlert.ShowAlert(sbCntysplit00);
                break;
            }
        }
        protected void editProfile()
        {
            var MobileString  = txPhoneNo.Text.Trim();
            var mobileBuilder = new StringBuilder(MobileString);

            mobileBuilder.Remove(0, 1);      //Trim one character from position 1
            mobileBuilder.Insert(0, "+254"); // replace position 0 with +254
            MobileString = mobileBuilder.ToString();

            string usname = Session["username"].ToString();
            string coName = txOrgname.Text.Trim();
            string eAddr  = txEmailAdd.Text.Trim();

            var     credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
            Portals sup         = new Portals();

            sup.Credentials     = credentials;
            sup.PreAuthenticate = true;

            // sup.FnRegisterStudent(fname, mname, lname, idno, resid, MobileString, usname, gentype);

            KCDFAlert.ShowAlert("Your account succcessfully Edited");
        }
Beispiel #13
0
        protected void CreateStudentUser()
        {
            string fname          = txtFirstname.Text.Trim();
            string mname          = txtMiddlename.Text.Trim();
            string lname          = txtLastname.Text.Trim();
            string email          = txtEmail.Text.Trim();
            string username       = txtUserName.Text.Trim();
            string passW1         = txtPassword1.Text.Trim();
            string confirPwd      = txtPassConfirmed.Text.Trim();
            string activationCode = Guid.NewGuid().ToString();
            int    gender         = Convert.ToInt32(Session["gender"].ToString());
            string admNo          = txtIDorRegNo.Text.Trim();

            string passEncrypt = EncryptP(confirPwd);

            DateTime doB;
            var      leohii = DateTime.Today;

            var dofB = dateofBirth.Value.Trim();

            if (string.IsNullOrWhiteSpace(dofB))
            {
                KCDFAlert.ShowAlert("Select a valid date!");
                dateofBirth.Focus();
                return;
            }
            else
            {
                doB = DateTime.Parse(dofB);
            }

            if (string.IsNullOrEmpty(fname) || string.IsNullOrEmpty(lname) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(passW1) || string.IsNullOrEmpty(confirPwd))
            {
                lblError.Text = "Please fill all the empty required fields!";
                return;
            }
            if (passW1 != confirPwd)
            {
                lblError.Text = "Password Mismatch, try again!";
                KCDFAlert.ShowAlert("Password Mismatch, try again!");
                txtPassword1.Text     = "";
                txtPassConfirmed.Text = "";
            }

            else
            {
                try
                {
                    var     credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                    Portals sup         = new Portals();
                    sup.Credentials     = credentials;
                    sup.PreAuthenticate = true;
                    if (sup.FnCreateAccount(fname, mname, lname, email, username, passEncrypt, activationCode, gender, doB,
                                            admNo))
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "getmeTohomeConfirm()", true);

                        //call goback to login to load Default page for user

                        InsertToActivationDB(username, activationCode);

                        using (MailMessage mm = new MailMessage("*****@*****.**", email))
                        {
                            string ActivationUrl = string.Empty;
                            ActivationUrl =
                                System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) +
                                "/Account/Activated.aspx?ActivationCode=" + activationCode + "&username="******"";

                            //Click here to activate your account
                            //var contactUsUrl = Page.ResolveClientUrl("~/Account/Register.aspx");

                            mm.Subject = "KCDF Account Activation";
                            string body = "Hello " + username + ",";
                            body += "<br /><br />Please click the following link to activate your account";

                            // body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("/Account/Register.aspx", "/Account/Activated.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";

                            body         += "<br />" + ActivationUrl + "";
                            body         += "<br /><br />Thanks";
                            mm.Body       = body;
                            mm.IsBodyHtml = true;
                            SmtpClient smtp = new SmtpClient();
                            smtp.Host      = "smtp.gmail.com";
                            smtp.EnableSsl = true;
                            NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "Kcdfportal@4321*~");
                            smtp.UseDefaultCredentials = true;
                            smtp.Credentials           = NetworkCred;
                            smtp.Port = 587;
                            smtp.Send(mm);
                            // KCDFAlert.ShowAlert("Activation link has been send to your email");
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                    return;
                }
            }
        }
Beispiel #14
0
        protected void GetScholarAccount()
        {
            string email          = txtExEmail.Text.Trim();
            string username       = txtExUsername.Text.Trim();
            string passW1         = txtXPass1.Text.Trim();
            string confirPwd      = txtXPass2.Text.Trim();
            string activationCode = Guid.NewGuid().ToString();

            if (string.IsNullOrWhiteSpace(email) ||
                string.IsNullOrWhiteSpace(username) ||
                string.IsNullOrWhiteSpace(passW1) ||
                string.IsNullOrWhiteSpace(confirPwd))
            {
                lblError.Text = "Please fill all the empty required fields!";
                return;
            }
            if (passW1 != confirPwd)
            {
                lblError.Text = "Password Mismatch, try again!";
                KCDFAlert.ShowAlert("Password Mismatch, try again!");
                txtPassword1.Text     = "";
                txtPassConfirmed.Text = "";
                return;
            }
            else
            {
                try
                {
                    var     credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                    Portals sup         = new Portals();
                    sup.Credentials     = credentials;
                    sup.PreAuthenticate = true;
                    if (sup.FnAddXstingScholar(email, username, EncryptP(confirPwd), activationCode))
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "getmeTohomeConfirm()", true);

                        //call goback to login to load Default page for user
                        InsertToActivationDB(username, activationCode);

                        using (MailMessage mm = new MailMessage("*****@*****.**", email))
                        {
                            string ActivationUrl = string.Empty;
                            ActivationUrl =
                                System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) +
                                "/Account/Activated.aspx?ActivationCode=" + activationCode + "";

                            //Click here to activate your account
                            //var contactUsUrl = Page.ResolveClientUrl("~/Account/Register.aspx");

                            mm.Subject = "KCDF Grantee Account Activation";
                            string body = "Hello " + username + ",";
                            body += "<br /><br />Please click the following link to activate your account";

                            // body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("/Account/Register.aspx", "/Account/Activated.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";

                            body         += "<br />" + ActivationUrl + "";
                            body         += "<br /><br />Thanks";
                            mm.Body       = body;
                            mm.IsBodyHtml = true;
                            SmtpClient smtp = new SmtpClient();
                            smtp.Host      = "smtp.gmail.com";
                            smtp.EnableSsl = true;
                            NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "Kcdfportal@4321*~");
                            smtp.UseDefaultCredentials = true;
                            smtp.Credentials           = NetworkCred;
                            smtp.Port = 587;
                            smtp.Send(mm);
                            // KCDFAlert.ShowAlert("Activation link has been send to your email");
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                    KCDFAlert.ShowAlert(ex.Message);
                    return;
                }
            }
        }
        protected void loadApplicationInfo()
        {
            try
            {
                var granteeInfo =
                    nav.grantees_Register.ToList()
                    .Where(n => n.Organization_Username.Equals(Session["username"].ToString()));

                TextBxcont.Text     = granteeInfo.Select(co => co.Contact_Person).SingleOrDefault();
                TextBoposition.Text = granteeInfo.Select(po => po.Current_Position).SingleOrDefault();
                TextBxpostal.Text   = granteeInfo.Select(pa => pa.Postal_Address).SingleOrDefault();
                txtMyPostaIs.Text   = granteeInfo.Select(pc => Convert.ToString(pc.Postal_Code)).SingleOrDefault();
                //   KCDFAlert.ShowAlert(txtMyPostaIs.Text);
                txtPostalTown.Text    = granteeInfo.Select(ta => ta.Town).SingleOrDefault();
                TextBoxphone.Text     = granteeInfo.Select(pn => pn.Phone).SingleOrDefault();
                txPhoneNo.Text        = granteeInfo.Select(pn => pn.Phone).SingleOrDefault();
                TextBoxweb.Text       = granteeInfo.Select(wb => wb.Website).SingleOrDefault();
                txtPhysicallAddr.Text = granteeInfo.Select(pad => pad.Physical_Address).SingleOrDefault();
                var ngO = granteeInfo.Select(ot => ot.NGO).SingleOrDefault();
                txtNgO.Text = ngO.ToString();
                if (ngO == false)
                {
                    ddlOrgType.SelectedIndex = 1;
                }
                if (ngO == true)
                {
                    ddlOrgType.SelectedIndex = 2;
                }
                if (ngO == null)
                {
                    ddlOrgType.SelectedIndex = 0;
                }
                var partsn = granteeInfo.Select(pt => pt.Partisan).SingleOrDefault();
                txtpartsan.Text = partsn.ToString();

                if (partsn == true)
                {
                    ddlnonPartisan.SelectedIndex = 2;
                }
                if (partsn == false)
                {
                    ddlnonPartisan.SelectedIndex = 1;
                    txtAreaPartisan.Visible      = true;
                    txtAreaPartisan.Text         = granteeInfo.Select(p => p.Non_Partisan_Describe).SingleOrDefault();
                }
                var nonPr = granteeInfo.Select(np => np.Profitable).SingleOrDefault();
                if (nonPr == false)
                {
                    ddlNonProfitable.SelectedIndex = 1;
                }
                if (nonPr == true)
                {
                    ddlNonProfitable.SelectedIndex = 2;
                }
                var legl = granteeInfo.Select(lg => lg.Legally_registered).SingleOrDefault();
                txtlegalY.Text = legl.ToString();
                if (legl == false)
                {
                    ddlLegal.SelectedIndex = 1;
                }
                if (legl == true)
                {
                    ddlLegal.SelectedIndex = 2;
                }
                ddlRegtype.SelectedItem.Text = granteeInfo.Select(rt => rt.Type_Of_Organization).SingleOrDefault();
                txtOrgtype.Text = granteeInfo.Select(rt => rt.Type_Of_Organization).SingleOrDefault();

                var doR = granteeInfo.Select(dr => Convert.ToDateTime(dr.Date_Registered)).SingleOrDefault();
                dateofReg.Value   = doR.ToShortDateString();
                TextBoxreg.Text   = granteeInfo.Select(rg => rg.Registration_No).SingleOrDefault();
                txtregtypeIs.Text = granteeInfo.Select(rT => rT.Type_of_registration).SingleOrDefault();
            }
            catch (Exception exp)
            {
                KCDFAlert.ShowAlert("Your Information is not up to date, please Update!");
            }
        }
Beispiel #16
0
        protected void btnCreateAcc_OnClick(object sender, EventArgs e)
        {
            string orgname        = txtOrgName.Text.Trim();
            string orgmail        = txtOrgEmail.Text.Trim();
            string userNm         = txtOrgUsername.Text.Trim();
            string passMe1        = txtPasswordOne.Text.Trim();
            string passMe         = txtPassConfir.Text.Trim();
            string activationCode = Guid.NewGuid().ToString();

            if (passMe1 != passMe)
            {
                lblError.Text         = "Password Mismatch, try again!";
                txtPassword1.Text     = "";
                txtPassConfirmed.Text = "";
            }
            else
            {
                try
                {
                    var     credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                    Portals sup         = new Portals();
                    sup.Credentials     = credentials;
                    sup.PreAuthenticate = true;
                    sup.FnAddGrantee(orgname, orgmail, userNm, EncryptP(passMe), activationCode);

                    KCDFAlert.ShowAlert("Your account succcessfully created, proceed to activation from your email");

                    InsertToActivationDB(userNm, activationCode);

                    using (MailMessage mm = new MailMessage("*****@*****.**", orgmail))
                    {
                        string ActivationUrl = string.Empty;
                        ActivationUrl =
                            System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
                            + "/Account/Activated_Grantees.aspx?ActivationCode=" + activationCode + "&username="******"";

                        //Click here to activate your account
                        //var contactUsUrl = Page.ResolveClientUrl("~/Account/Register.aspx");

                        mm.Subject = "KCDF Account Activation";
                        string body = "Hello " + userNm + ",";
                        body += "<br /><br />Please click the following link to activate your account";

                        // body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("/Account/Register.aspx", "/Account/Activated.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";

                        body         += "<br />" + ActivationUrl + "";
                        body         += "<br /><br />Thanks";
                        mm.Body       = body;
                        mm.IsBodyHtml = true;
                        SmtpClient smtp = new SmtpClient();
                        smtp.Host      = "smtp.gmail.com";
                        smtp.EnableSsl = true;
                        NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "Kcdfportal@4321*~");
                        smtp.UseDefaultCredentials = true;
                        smtp.Credentials           = NetworkCred;
                        smtp.Port = 587;
                        smtp.Send(mm);

                        KCDFAlert.ShowAlert("Activation link has been send to your email");
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                    return;
                }
            }
        }
        protected void EditEducationSecLevel()
        {
            try
            {
                DateTime yearOfAdmn;
                DateTime yrofCompln;
                int      marks   = 0;
                int      ttMarks = 0;
                string   mygradeIs;
                int      optionIs = 0;
                string   uni      = "";
                string   seco;
                string   YroStd;
                var      usname   = Session["username"].ToString();
                var      primo    = lblValues.Text;
                var      grdEmail = txtGuardianEmail.Text.Trim();
                var      grdAddr  = txtGuardianAddress.Text.Trim();

                //int edlev;

                //if (rdoBtnListEdLevel.SelectedIndex ==-1)
                //{
                //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                //        "alert('Please select level of Education first');", true);

                //    return;
                //}
                //else
                //{
                //    edlev = rdoBtnListEdLevel.SelectedIndex;
                //}

                int TorF = rdoBtnListEdLevel.SelectedIndex;
                switch (TorF)
                {
                case 0:
                    optionIs = 0;
                    break;

                case 1:
                    optionIs = 1;
                    break;

                default:
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode", "alert('Please select level of Education first!');", true);
                    break;
                }

                if (ddlSeco.SelectedIndex == 0)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select secondary school');", true);
                    return;
                }
                else
                {
                    seco = ddlSeco.SelectedItem.Text.Trim();
                }

                if (ddlFormwhat.SelectedIndex == 0)
                {
                    ddlFormwhat.Focus();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select class!');", true);
                    return;
                }
                else
                {
                    YroStd = ddlFormwhat.SelectedItem.Text;
                }

                var YoAdm = doAdm.Value;
                if (string.IsNullOrWhiteSpace(YoAdm))
                {
                    doAdm.Focus();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select valid date');", true);
                    return;
                }
                else
                {
                    yearOfAdmn = DateTime.Parse(YoAdm);
                }

                var YoComptn = doEnd.Value;
                if (string.IsNullOrWhiteSpace(YoComptn))
                {
                    doEnd.Focus();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select valid date');", true);
                    return;
                }
                else
                {
                    yrofCompln = DateTime.Parse(YoComptn);
                }

                if (string.IsNullOrWhiteSpace(txtMarks.Text))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please Fill in your marks');", true);
                    txtMarks.Focus();
                    txtMarks.BorderColor = Color.Red;
                    return;
                }
                else
                {
                    marks = Convert.ToInt32(txtMarks.Text);
                }
                if (string.IsNullOrWhiteSpace(txtTotalMarks.Text))
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please Fill in total marks');", true);
                    txtTotalMarks.Focus();
                    txtTotalMarks.BorderColor = Color.Red;
                    return;
                }
                else
                {
                    ttMarks = Convert.ToInt32(txtTotalMarks.Text);
                }

                var grdPhne       = txtGuardianPhone.Text.Trim();
                var mobileBuilder = new StringBuilder(grdPhne);
                mobileBuilder.Remove(0, 1);      //Trim one character from position 1
                mobileBuilder.Insert(0, "+254"); // replace position 0 with +254
                grdPhne = mobileBuilder.ToString();

                try
                {
                    if (yrofCompln < yearOfAdmn)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                                "alert('Admision Date should be later than Completion Date!');", true);
                        doEnd.Value = "";
                        doAdm.Value = "";
                        return;
                    }
                }
                catch (Exception ec)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('Please select correct dates!');", true);
                }

                try
                {
                    var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"],
                                                            ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                    var sup = new Portals();
                    sup.Credentials     = credentials;
                    sup.PreAuthenticate = true;
                    if (sup.FnEducatBg(usname, primo, seco, uni, yearOfAdmn, YroStd, yrofCompln, grdPhne, grdEmail,
                                       grdAddr, "", marks, ttMarks, "", optionIs) == true)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                                "alert('Your Education Data Updated Successfully!');", true);
                        // readEducBgData();
                    }
                }
                catch (Exception exc)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                            "alert('" + exc.Message + "');", true);
                }
            }
            catch (Exception ex)
            {
                KCDFAlert.ShowAlert(ex.Message);
            }
        }
        protected void EditProfile()
        {
            //try
            //{
            var MobileString  = txtPhoneNo.Text.Trim();
            var mobileBuilder = new StringBuilder(MobileString);

            mobileBuilder.Remove(0, 1);      //Trim one character from position 1
            mobileBuilder.Insert(0, "+254"); // replace position 0 with +254
            MobileString = mobileBuilder.ToString();

            DateTime dTOfBth;
            var      gentype = 0;
            var      usname  = Session["username"].ToString();
            var      fname   = txtfNname.Text.Trim();
            var      mname   = txtMname.Text.Trim();
            var      lname   = txtLname.Text.Trim();
            var      idno    = txtIDNo.Text.Trim();
            var      resid   = txtResidence.Text.Trim();
            var      gender  = lstGender.SelectedItem.Text;

            var mycounty    = "";
            var mysubcounty = "";

            if (ddlSelCounty.SelectedIndex == 0)
            {
                ddlSelCounty.Focus();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                        "alert('Please select your county!');", true);
                return;
            }
            else
            {
                mycounty = ddlSelCounty.SelectedItem.Text;
            }

            if (ddlConstituency.SelectedIndex == 0)
            {
                ddlConstituency.Focus();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                        "alert('Please select your subcounty!');", true);
                return;
            }
            else
            {
                mysubcounty = ddlConstituency.SelectedItem.Text;
            }

            if (lstGender.SelectedIndex == 0)
            {
                KCDFAlert.ShowAlert("Please select a valid gender type!");
                return;
            }
            if (gender.Equals("Male"))
            {
                gentype = 0;
            }
            else
            {
                gentype = 1;
            }
            var dtofBirth = dateOFBirth.Value;

            if (string.IsNullOrWhiteSpace(dtofBirth))
            {
                dateOFBirth.Focus();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                        "alert('Please select valid date');", true);
                return;
            }
            else
            {
                dTOfBth = DateTime.Parse(dtofBirth);
            }

            if (string.IsNullOrEmpty(idno))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                        "alert('Fill in ID Number!');", true);
                txtIDNo.Focus();
                txtIDNo.BorderColor = Color.Red;
                return;
            }
            if (string.IsNullOrEmpty(MobileString))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                        "alert('Fill in Mobile Number!');", true);
                txtPhoneNo.Focus();
                txtPhoneNo.BorderColor = Color.Red;
                return;
            }

            var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"],
                                                    ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
            var sup = new Portals();

            sup.Credentials     = credentials;
            sup.PreAuthenticate = true;
            if (
                sup.FnRegisterStudent(fname, mname, lname, idno, resid, MobileString, usname, gentype, dTOfBth, mycounty,
                                      mysubcounty) == true)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode",
                                                        "alert('Your account succcessfully Edited!');", true);
            }

            //}
            //catch (Exception ex)
            //{
            //    KCDFAlert.ShowAlert("Select Valid Date");
            // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode", "alert('Error!');", true);

            //}
        }
 protected void rdoBtnListGrade_OnSelectedIndexChanged(object sender, EventArgs e)
 {
     Session["myGrade"] = rdoBtnListGrade.SelectedValue;
     KCDFAlert.ShowAlert("My Grade: " + Session["myGrade"]);
 }
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            bool     ngo = false, notpartisan = false, nonprofit = false, legally = false;
            DateTime yearOfAdmn;
            string   usanm = Session["username"].ToString();

            string contactP        = TextBxcont.Text.Trim();
            string currposition    = TextBoposition.Text.Trim();
            string postaddress     = TextBxpostal.Text.Trim();
            string postcode        = "";
            string tao             = txtPostalTown.Text.Trim();
            string phoneNum        = TextBoxphone.Text.Trim();
            string webs            = TextBoxweb.Text.Trim();
            string registrationNum = TextBoxreg.Text.Trim();
            string physicAddre     = txtPhysicallAddr.Text.Trim();
            string nonPartisanTxtA = txtAreaPartisan.Text.Trim();

            //string nonPtrimmed  = txtAreaPartisan.Text.Substring(0, txtAreaPartisan.Text.Length - 1);
            string regType = ddlRegtype.SelectedItem.Text;

            int nonG = ddlOrgType.SelectedIndex;

            if (nonG == 0)
            {
                KCDFAlert.ShowAlert("Select valid option!");
            }
            if (nonG == 1)
            {
                ngo = false;
            }
            if (nonG == 2)
            {
                ngo = true;
            }
            int nonPart = ddlnonPartisan.SelectedIndex;

            if (nonPart == 0)
            {
                KCDFAlert.ShowAlert("Select valid option!");
            }
            if (nonPart == 1)
            {
                notpartisan = false;
            }
            if (nonPart == 2)
            {
                notpartisan = true;
            }

            if (nonPart == 1 && nonPartisanTxtA == "")
            {
                KCDFAlert.ShowAlert("Please describe your partisanship");
                return;
            }

            int nonProfit = ddlNonProfitable.SelectedIndex;

            if (nonProfit == 0)
            {
                KCDFAlert.ShowAlert("Select valid option!");
            }

            if (nonProfit == 1)
            {
                nonprofit = false;
            }
            if (nonProfit == 2)
            {
                nonprofit = true;
            }

            int legal = ddlLegal.SelectedIndex;

            if (legal == 0)
            {
                KCDFAlert.ShowAlert("Select valid option!");
            }

            if (legal == 1)
            {
                legally = false;
            }

            if (legal == 2)
            {
                legally = true;
            }

            if (ddlPostalCode.SelectedIndex == 0)
            {
                KCDFAlert.ShowAlert("Please select postal code");
                return;
            }
            else
            {
                postcode = ddlPostalCode.SelectedItem.Text;
            }
            var YoReg = dateofReg.Value.Trim();

            if (string.IsNullOrWhiteSpace(YoReg))
            {
                KCDFAlert.ShowAlert("Select a Valid Date");
                dateofReg.Focus();
                return;
            }
            else
            {
                yearOfAdmn = DateTime.Parse(YoReg);
            }

            try
            {
                var     credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
                Portals sup         = new Portals();
                sup.Credentials     = credentials;
                sup.PreAuthenticate = true;
                if (sup.FnRegGranteeInfo(usanm, contactP, currposition, phoneNum,
                                         postaddress, postcode, tao, ngo, notpartisan, nonprofit,
                                         legally, physicAddre, regType, yearOfAdmn, webs, registrationNum, nonPartisanTxtA))
                {
                    //  KCDFAlert.ShowAlert("Organization Information updated successfully!");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "thisBitchcode", "alert('Organization Information updated successfully!');", true);
                    loadApplicationInfo();
                }
            }
            catch (Exception exO)
            {
                KCDFAlert.ShowAlert("Error Occured, contact System Administrator!");
            }
        }