コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                try
                {
                    using (UniversalEntities entity = new UniversalEntities())
                    {
                        int          idMember = int.Parse(Session["IdMember"].ToString());
                        List <Limit> limits   = entity.Limits.Where(p => p.IdMember == idMember).ToList();
                        GridView1.DataSource = limits;
                        GridView1.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text = @"The system encountered and error retrieving your limits.  Please report this error to the <a href='mailto:[email protected]'>Webmaster</a>";
                }
            }

            lblYear.Text = DateTime.Today.Year.ToString();
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        int idMember = int.Parse(Session["IdMember"].ToString());

                        Member member = (from i in entity.Members
                                         where i.IdMember == idMember
                                         select i).SingleOrDefault();
                        Dependant dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                        tbEmail.Text  = dependant.EmailAddress != null ? dependant.EmailAddress : "";
                        tbEmail2.Text = dependant.EmailAddress != null ? dependant.EmailAddress : "";
                    }
                    catch (Exception ex)
                    {
                        function.ReportError("www.compcare.co.za", "statements.aspx", ex.ToString());
                    }
                }
            }
        }
コード例 #3
0
        protected void btnNextButton_Click(object sender, EventArgs e)
        {
            if (IAccept.Checked)
            {
                using (UniversalEntities entity = new UniversalEntities())
                {
                    Student student = entity.Students.Where(p => p.ReferenceNumber == hfReference.Value).FirstOrDefault();

                    if (cbBrokerAccept.Checked)
                    {
                        student.AppointedABSA = true;
                    }
                    else
                    {
                        student.AppointedABSA = false;
                    }
                    entity.SaveChanges();
                };

                RemotePost myremotepost = new RemotePost();
                myremotepost.Url = @"https://www.vcs.co.za/vvonline/ccform.asp";
                myremotepost.Add("p1", "2672");
                myremotepost.Add("p2", lblReference.Text);
                myremotepost.Add("p3", "CompCare NetworX StudentPlan Membership");
                myremotepost.Add("p4", contribution.Text.Remove(0, 2));
                myremotepost.Add("Hash", CalculateMD5Hash("2672", lblReference.Text, "CompCare NetworX StudentPlan Membership", contribution.Text.Remove(0, 2), ConfigurationManager.AppSettings.Get("MD5Key")));
                myremotepost.Post();
            }
            else
            {
                lblError.Text = @"You need to accept the <a href='TermsAndConditions.aspx' target='_blank'>Terms and Conditions</a>";
            }
        }
コード例 #4
0
        private bool AuthenticateUser(string username, string password)
        {
            bool isUser = false;

            using (UniversalEntities entity = new UniversalEntities())
            {
                User user = (from i in entity.Users
                             where i.Username == username
                             select i).SingleOrDefault();
                if (user == null)
                {
                    isUser             = false;
                    lblLoginError.Text = "User not found in database";
                }
                else if (user.Password != password)
                {
                    isUser             = false;
                    lblLoginError.Text = "Password Incorrect";
                }
                else if (!user.IsCompCare.Value)
                {
                    isUser             = false;
                    lblLoginError.Text = "You are not a CompCare member and may not access this website";
                }
                else
                {
                    isUser = true;
                    Session.Add("IdMember", user.IdMember);
                }
            }
            return(isUser);
        }
コード例 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["IdMember"] == null)
     {
         FormsAuthentication.RedirectToLoginPage();
     }
     else
     {
         try
         {
             using (UniversalEntities entity = new UniversalEntities())
             {
                 int              idMember   = int.Parse(Session["IdMember"].ToString());
                 Member           member     = entity.Members.Where(p => p.IdMember == idMember).SingleOrDefault();
                 List <Dependant> dependants = entity.Dependants.Where(p => p.IdMember == idMember && p.IdDependantType != 5).ToList();
                 GridView1.DataSource = dependants;
                 GridView1.DataBind();
             }
         }
         catch (Exception ex)
         {
             lblError.Text = @"The system encountered and error retrieving information on your Dependants.  Please report this error to the <a href='mailto:[email protected]'>Webmaster</a>";
         }
     }
 }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["SANational"] == null)
                {
                    Response.Redirect("PreliminaryQuestions.aspx");
                }
                else
                {
                    using (UniversalEntities entity = new UniversalEntities())
                    {
                        rblAccountType.DataSource = entity.AccountTypes.ToList();
                        rblAccountType.DataBind();
                        lbMaritalStatus.DataSource = entity.MaritalStatusses.ToList();
                        lbMaritalStatus.DataBind();
                        lbStudyInstitution.DataSource = entity.Institutions.ToList();
                        lbStudyInstitution.DataBind();
                        lbTitles.DataSource = entity.Titles.ToList();
                        lbTitles.DataBind();
                        lbOProvinces.DataSource = entity.Provinces.ToList();
                        lbPProvinces.DataSource = entity.Provinces.ToList();
                        lbOProvinces.DataBind();
                        lbPProvinces.DataBind();
                        string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
                        string[] years  = { "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" };
                        lbEndMonth.DataSource   = months;
                        lbStartMonth.DataSource = months;
                        lbStartMonth.DataBind();
                        lbEndMonth.DataBind();
                        lbStartYear.DataSource = years;
                        lbEndYear.DataSource   = years;
                        lbStartYear.DataBind();
                        lbEndYear.DataBind();
                        trIncomeAmount.Visible = false;

                        if (Request.QueryString["SANational"].ToString() == "True")
                        {
                            lblIdPassport.Text          = @"Id Number:";
                            lbCountryOfIssue.DataSource = entity.Countries.Where(p => p.Name == "South Africa").ToList();
                            lbIncome.Text = @"Will you be earning a salary while studying?";
                            lbCountryOfIssue.DataBind();
                            hfIsSaNational.Value = "true";
                        }
                        else
                        {
                            lblIdPassport.Text          = @"Passport Number:";
                            lbCountryOfIssue.DataSource = entity.Countries.ToList();
                            lbIncome.Text = @"Will you be receiving some sort of income during your study period, while in South Africa?";
                            lbCountryOfIssue.DataBind();
                            hfIsSaNational.Value = "false";
                        }
                    }
                    trExistingMembership.Visible = false;
                }
            }
        }
コード例 #7
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Session["IdMember"] == null)
     {
         FormsAuthentication.RedirectToLoginPage();
     }
     else
     {
         try
         {
             using (UniversalEntities entity = new UniversalEntities())
             {
                 int       idMember  = int.Parse(Session["IdMember"].ToString());
                 Member    member    = entity.Members.Where(p => p.IdMember == idMember).SingleOrDefault();
                 User      user      = entity.Users.Where(i => i.IdMember == idMember).SingleOrDefault();
                 Dependant dependant = entity.Dependants.Where(p => p.IdMember == idMember && p.IdDependantType == 5).SingleOrDefault();
                 if (tbNewPassword.Text == "" || tbConfirmPassword.Text == "" || tbOldPassword.Text == "")
                 {
                     lblStatus.Text      = "Please provide a value for all three fields";
                     lblStatus.ForeColor = Color.Red;
                 }
                 else if (tbNewPassword.Text != tbConfirmPassword.Text)
                 {
                     lblStatus.Text      = "Your new password and confirm password does not match";
                     lblStatus.ForeColor = Color.Red;
                 }
                 else if (user.Password != tbOldPassword.Text)
                 {
                     lblStatus.Text      = "Your old password is different to what is saved in the database";
                     lblStatus.ForeColor = Color.Red;
                 }
                 else
                 {
                     user.Password = tbNewPassword.Text;
                     entity.SaveChanges();
                     lblStatus.Text      = "Password has been successfully changed";
                     lblStatus.ForeColor = Color.Blue;
                     string toAddress  = dependant.EmailAddress;
                     string toAddress2 = @"*****@*****.**";
                     string title      = "Password Changed on CompCare Website";
                     string mailBody   = string.Format("Dear {0}, you have successfully changed your website password on the CompCare Wellness Website.", dependant.DependantName);
                     string mailBody2  = string.Format("Dependant {0} changed password to {1}", member.MAMembershipNumber, tbNewPassword.Text);
                     SendEmail(toAddress2, title, mailBody2, member.MAMembershipNumber);
                     SendEmail(toAddress, title, mailBody, member.MAMembershipNumber);
                     ClearTextBoxes();
                 }
             }
         }
         catch (Exception ex)
         {
             lblStatus.Text      = @"The system was unable to change your password. The <a href='mailto:[email protected]'>webmaster</a> has been notified of this error.";
             lblStatus.ForeColor = Color.Red;
             SendEmailToWebmaster("*****@*****.**", @"Error encountered on the ExistingMembers/ChangePassword page", ex.ToString());
         }
     }
 }
コード例 #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (UniversalEntities entity = new UniversalEntities())
         {
             lbStudyInstitution.DataSource = entity.Institutions.ToList();
             lbStudyInstitution.DataBind();
         }
     }
 }
コード例 #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (UniversalEntities entity = new UniversalEntities())
         {
             lbMaritalStatus.DataSource = entity.MaritalStatusses.ToList();
             lbMaritalStatus.DataBind();
         }
         binddata();
     }
 }
コード例 #10
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (UniversalEntities entity = new UniversalEntities())
     {
         Member member = entity.Members.Where(i => i.MAMembershipNumber == tbMembershipNumber.Text).SingleOrDefault();
         if (member == null)
         {
             lblChangePasswordError.Text = "Membership Number does not exist in database.";
         }
         else
         {
             Dependant dependant = entity.Dependants.Where(i => i.IdMember == member.IdMember && i.IdDependantType == 5).SingleOrDefault();
             User      user      = entity.Users.Where(i => i.IdMember == member.IdMember).SingleOrDefault();
             if (dependant.IdentityNumber != tbIdnumber.Text)
             {
                 lblChangePasswordError.Text = "ID Number you provided does not match with the ID Number associated with the Membership Number in the database.";
             }
             else if (tbPassword1.Text == "")
             {
                 lblChangePasswordError.Text = "Please provide a value for the password field.";
             }
             else if (tbPassword1.Text != tbPassword2.Text)
             {
                 lblChangePasswordError.Text = "Your passwords doesn't match";
             }
             else
             {
                 user.Password = tbPassword1.Text;
                 entity.SaveChanges();
                 lblChangePasswordError.Text      = "Your password has been changed.  Click here to return to the <a href='Default.aspx'>login page</a>.";
                 lblChangePasswordError.ForeColor = Color.Blue;
                 string toAddress  = dependant.EmailAddress;
                 string toAddress2 = @"*****@*****.**";
                 string title      = "Password Changed on CompCare Website";
                 string mailBody   = string.Format(" Dear {0}, you have successfully changed your website password.", dependant.DependantName);
                 string mailBody2  = string.Format("Member {0} changed password on the CompCare website to {1}", member.MAMembershipNumber, tbPassword1.Text);
                 SendEmail(toAddress2, title, mailBody2);
                 ClearFields();
                 try
                 {
                     SendEmail(toAddress, title, mailBody);
                 }
                 catch (Exception ex)
                 {
                     lblChangePasswordError.Text = string.Format(@"Your password has been changed, however, we encountered a problem sending confirmation of this transaction to your email address.  In case your address has changed, please update your profile at the membership department <a href='mailto:[email protected]?subject=Please update my profile, membership number {0}'", member.MAMembershipNumber);
                 }
             }
         }
     }
 }
コード例 #11
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (UniversalEntities entity = new UniversalEntities())
     {
         User user = entity.Users.Where(i => i.Username == tbUsername.Text).SingleOrDefault();
         if (user == null)
         {
             lblChangePasswordError.Text = "User does not exist in database.";
         }
         else
         {
             Student student = entity.Students.Where(i => i.IDPassport == tbIdnumber.Text).SingleOrDefault();
             if (student.IDPassport.ToLower() != tbUsername.Text.ToLower())
             {
                 lblChangePasswordError.Text = "Please provide a vaild ID /Passport number.";
             }
             else if (tbPassword1.Text == "")
             {
                 lblChangePasswordError.Text = "Please provide a value for the password field.";
             }
             else if (tbPassword1.Text != tbPassword2.Text)
             {
                 lblChangePasswordError.Text = "Your passwords doesn't match";
             }
             else
             {
                 user.Password = tbPassword1.Text;
                 entity.SaveChanges();
                 lblChangePasswordError.Text      = "Your password has been changed.  Click here to return to the <a href='Default.aspx'>login page</a>.";
                 lblChangePasswordError.ForeColor = Color.Blue;
                 string toAddress  = student.Email;
                 string toAddress2 = @"*****@*****.**";
                 string title      = "Password Changed on CompCare Website";
                 string mailBody   = string.Format(" Dear {0}, you have successfully changed your website password on the StudentPlan website.", student.FirstNames);
                 string mailBody2  = string.Format("Student {0} changed password to {1}", student.IdStudent, tbPassword1.Text);
                 SendEmail(toAddress2, title, mailBody2);
                 try
                 {
                     SendEmail(toAddress, title, mailBody);
                 }
                 catch (Exception ex)
                 {
                     lblChangePasswordError.Text = @"The system encountered a problem sending your confirmation email.  Have you supplied us your correct Email Address?  If you believe this is in error please report this problem to the <a href='mailto:[email protected]'>webmaster</a>.";
                 }
             }
         }
     }
 }
コード例 #12
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (UniversalEntities entity = new UniversalEntities())
     {
         Member member = entity.Members.Where(i => i.MAMembershipNumber == tbMembershipNumber.Text).SingleOrDefault();
         if (member == null)
         {
             lblStatus.Text      = "Membership Number does not exist in database.";
             lblStatus.ForeColor = Color.Red;
         }
         else
         {
             Dependant dependant = entity.Dependants.Where(i => i.IdMember == member.IdMember && i.IdDependantType == 5).SingleOrDefault();
             User      user      = entity.Users.Where(i => i.IdMember == member.IdMember).SingleOrDefault();
             if (dependant.IdentityNumber != tbIdnumber.Text)
             {
                 lblStatus.Text      = "ID Number you provided does not match with the ID Number associated with the Membership Number in the database.";
                 lblStatus.ForeColor = Color.Red;
             }
             else if (dependant.EmailAddress == "" || dependant.EmailAddress == null)
             {
                 lblStatus.Text      = string.Format(@"We do not have an email address for you in our system.  Have you supplied us a valid Email Address? Please update your details with the <a href='mailto:[email protected]?subject=Please update my profile, membership number: {0}'>membership department</a>.", member.MAMembershipNumber);
                 lblStatus.ForeColor = Color.Red;
                 ClearTextInputs();
             }
             else
             {
                 string toAddress = dependant.EmailAddress;
                 string title     = "Your CompCare Wellness Username";
                 string mailBody  = string.Format("<p>Dear {0}, </p><p>You or someone on your behalf, requested that your username be sent to your email address.</p><p>Your username has been saved in the database as {1}.</p><p>.", dependant.DependantName, user.Username);
                 try
                 {
                     SendEmail(toAddress, title, mailBody);
                     lblStatus.Text      = "Your username has been sent to the email address on record.  Click here to return to the <a href='Default.aspx'>login page</a>.";
                     lblStatus.ForeColor = Color.Blue;
                     ClearTextInputs();
                 }
                 catch (Exception ex)
                 {
                     lblStatus.Text      = string.Format(@"We encountered a problem sending confirmation of this transaction to your email address.  Have you supplied us a valid Email Address? Please update your details with the <a href='mailto:[email protected]?subject=Please update my profile, membership number: {0}'>membership department</a>.", member.MAMembershipNumber);
                     lblStatus.ForeColor = Color.Red;
                     ClearTextInputs();
                 }
             }
         }
     }
 }
コード例 #13
0
        public string GetMembershipNumber()
        {
            string membershipNumber = "";

            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                int idMember = int.Parse(Session["IdMember"].ToString());

                using (UniversalEntities entity = new UniversalEntities())
                {
                    membershipNumber = entity.Members.Where(p => p.IdMember == idMember).FirstOrDefault().MAMembershipNumber;
                }
            }
            return(membershipNumber);
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string referenceNumber = Request.QueryString["p2"];

            lblReferenceNumber.Text     = referenceNumber;
            lblReason.Text              = Request.QueryString["p3"] != null ? Request.QueryString["p3"].Remove(0, 5) : "";
            lblAuthorisationNumber.Text = Request.QueryString["p3"] != null ? Request.QueryString["p3"].Remove(6, 10): "";
            lblCardHolderName.Text      = Request.QueryString["p5"];
            lblAmount.Text              = Request.QueryString["p6"];
            lblCartType.Text            = Request.QueryString["p7"];
            lblDescriptionOfGoods.Text  = Request.QueryString["p8"];
            lblCardHolderEmail.Text     = Request.QueryString["p9"];
            lblMaskedCardNumber.Text    = Request.QueryString["MaskedCardNumber"];

            using (UniversalEntities entity = new UniversalEntities())
            {
                Student student = entity.Students.Where(p => p.ReferenceNumber == referenceNumber).FirstOrDefault();
                student.TransactionSuccess = false;
                entity.SaveChanges();
            }
        }
コード例 #15
0
        private bool AuthenticateUser(string username, string password)
        {
            bool isUser = false;

            using (UniversalEntities entity = new UniversalEntities())
            {
                User user = (from i in entity.Users
                             where i.Username == username
                             select i).FirstOrDefault();
                if (user == null)
                {
                    isUser             = false;
                    lblLoginError.Text = "User not found in database";
                }
                else if (user.Password == "" || user.Password == null)
                {
                    isUser             = false;
                    lblLoginError.Text = "Please register as a user.";
                }
                else if (user.Password != password)
                {
                    isUser             = false;
                    lblLoginError.Text = "Password Incorrect";
                }
                else if (!user.IsStudent.Value)
                {
                    isUser             = false;
                    lblLoginError.Text = "Access not allowed";
                }
                else
                {
                    isUser = true;
                    Session.Add("IdUser", user.IdUser);
                }
            }
            return(isUser);
        }
コード例 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                idMember = int.Parse(Session["IdMember"].ToString());

                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        Member        member    = entity.Members.Where(p => p.IdMember == idMember).SingleOrDefault();
                        Dependant     dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 0).SingleOrDefault();
                        LifestylePlan plan      = entity.LifestylePlans.Where(i => i.IdLifestylePlan == member.IdLifestylePlan).SingleOrDefault();
                        lbl360MemberhipNumber.Text = member.LifestyleMembershipNumber != null ? member.LifestyleMembershipNumber : "Not Available";
                        lbl360Plan.Text            = plan != null ? plan.LifestylePlanName : "Not Available";
                        lblDiabeticStartDate.Text  = dependant.DiabeticStartDate != null?dependant.DiabeticStartDate.Value.ToShortDateString() : "n/a";

                        lblDiabeticEndDate.Text = dependant.DiabeticEndDate != null?dependant.DiabeticEndDate.Value.ToShortDateString() : "n/a";

                        lblHeight.Text = dependant.Height != null?dependant.Height.ToString() + "m" : "Not Available";

                        lblWeight.Text = dependant.Weight != null?dependant.Weight.ToString() + "kg" : "Not Available";

                        lblIsDiabetic.Text = dependant.IsDiabetic != null ? (dependant.IsDiabetic.Value ? "Yes" : "No") : "Not Available";
                        lblIsSmoker.Text   = dependant.IsSmoking != null ? (dependant.IsSmoking.Value ? "Yes" : "no") : "Not Available";
                    }
                    catch
                    {
                        lblError.Text = @"The website encountered a problem retrieving your health related information. Please report this error to the <a href='mailto:[email protected]'>Webmaster</a>";
                    }
                }
            }
        }
コード例 #17
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            using (UniversalEntities entity = new UniversalEntities())
            {
                DateTime dob;
                DateTime commencementDate = new DateTime(int.Parse(lbStartYear.SelectedValue), ConvertToInt(lbStartMonth.SelectedValue), 01);
                DateTime endDate          = new DateTime(int.Parse(lbEndYear.SelectedValue), ConvertToInt(lbEndMonth.SelectedValue), GetLastDayOfTheMonth(lbEndMonth.SelectedValue));
                User     user             = entity.Users.Where(p => p.Username == tbUsername.Text).FirstOrDefault();

                if (!DateTime.TryParse(DateOfBirth.Text, out dob))
                {
                    lblError.Text = "Please enter a valid Date of Birth";
                }
                else if (!CheckIfLongerThanSixMonths(endDate, commencementDate))
                {
                    lblError.Text = "We can unfortunately only consider cover of periods longer than 6 months.";
                }
                else if (rblGettingIncome.SelectedValue == "yes" && GrossIncome.Text == "")
                {
                    lblError.Text = "Please specify the approximate income amount you will be receiving during your study.";
                }
                else if (user != null)
                {
                    lblError.Text = "Username taken. Please supply a different username";
                }
                else if (tbPassword.Text != tbConfirmPassword.Text)
                {
                    lblError.Text = "Password fields does not match";
                }
                else
                {
                    string   reference        = tbIdNumber.Text + DateTime.Today.ToShortDateString().Replace("/", "") + DateTime.Now.ToShortTimeString().Replace(":", "").Remove(4, 3);
                    TimeSpan duration         = endDate - commencementDate;
                    int      s                = int.Parse(lbStudyInstitution.SelectedValue);
                    int      ins              = entity.Institutions.Where(p => p.IdInstitution == s).FirstOrDefault().IdInstitution;
                    double   months           = Math.Round(duration.TotalDays / 30.4);
                    double   contribution     = Math.Round(months * 336);
                    int      idTitle          = int.Parse(lbTitles.SelectedItem.Value);
                    int      idMaritalStatus  = int.Parse(lbMaritalStatus.SelectedItem.Value);
                    int      idCountryofIssue = int.Parse(lbCountryOfIssue.SelectedItem.Value);
                    int      idAccountType    = rblAccountType.SelectedItem != null?int.Parse(rblAccountType.SelectedItem.Value) : 1;

                    string membershipNumber = "";
                    bool   isExistingMember = false;

                    if (hfIsExisting.Value == "true")
                    {
                        isExistingMember = true;
                        membershipNumber = tbExistingMembershipNumber.Text;
                    }
                    else
                    {
                        List <Student> students = entity.Students.Where(p => !p.IsExistingMember.Value).OrderByDescending(p => p.MembershipNumber).ToList();
                        if (students.Count < 1)
                        {
                            membershipNumber = "4900000";
                        }
                        else
                        {
                            membershipNumber = (int.Parse(students[0].MembershipNumber) + 1).ToString();
                            if (membershipNumber.StartsWith("48"))
                            {
                                membershipNumber = "4900000";
                            }
                        }
                    }
                    bool    isGettingIncome = false;
                    decimal incomeAmount    = 0;
                    if (rblGettingIncome.SelectedValue == "yes")
                    {
                        isGettingIncome = true;
                        incomeAmount    = decimal.Parse(GrossIncome.Text);
                    }
                    int     idGender = int.Parse(listbGenders.SelectedValue);
                    Student student  = new Student
                    {
                        Surname           = surname.Text,
                        FirstNames        = firstNames.Text,
                        DateOfBirth       = dob,
                        RegistrationDate  = DateTime.Today,
                        CommencementDate  = commencementDate,
                        EndDate           = endDate,
                        StudyInstitution  = ins,
                        StudentNumber     = studentNumber.Text,
                        Email             = email.Text,
                        StudyDuration     = months,
                        Contribution      = contribution,
                        IDPassport        = tbIdNumber.Text,
                        IdTitle           = idTitle,
                        IdMaritalStatus   = idMaritalStatus,
                        CountryOfIssue    = idCountryofIssue,
                        BusinessTelephone = workTel.Text,
                        HomeTelephone     = homeTel.Text,
                        Facsimile         = fax.Text,
                        Cellular          = cell.Text,
                        AccountHolderName = AccountHolderName.Text,
                        BankName          = BankName.Text,
                        BranchCode        = BranchCode.Text,
                        AccountNumber     = AccountNumber.Text,
                        IdAccountType     = idAccountType,
                        ReferenceNumber   = reference,
                        MembershipNumber  = membershipNumber,
                        IsExistingMember  = isExistingMember,
                        IsGettingIncome   = isGettingIncome,
                        IncomeAmount      = incomeAmount,
                        IdGender          = idGender
                    };
                    entity.AddObject("Students", student);
                    entity.SaveChanges();

                    Student savedStudent   = entity.Students.Where(p => p.ReferenceNumber == reference).FirstOrDefault();
                    int     postalProvince = int.Parse(lbOProvinces.SelectedItem.Value);
                    int     physProvince   = int.Parse(lbPProvinces.SelectedItem.Value);

                    StudentAddress postal = new StudentAddress
                    {
                        Address1        = OAddress1.Text,
                        Address2        = OAddress2.Text,
                        Address3        = OAddress3.Text,
                        Address4        = OAddress4.Text,
                        IdProvince      = postalProvince,
                        IdStudent       = savedStudent.IdStudent,
                        PostalCode      = OPostal.Text,
                        IsPostalAddress = true,
                        Country         = "South Africa",
                        DateCreated     = DateTime.Today
                    };

                    StudentAddress phys = new StudentAddress
                    {
                        Address1        = PAddress1.Text,
                        Address2        = PAddress2.Text,
                        Address3        = PAddress3.Text,
                        Address4        = PAddress4.Text,
                        IdProvince      = physProvince,
                        IdStudent       = savedStudent.IdStudent,
                        PostalCode      = PPostal.Text,
                        IsPostalAddress = false,
                        Country         = "South Africa",
                        DateCreated     = DateTime.Today
                    };

                    User newUser = new User
                    {
                        Username     = tbUsername.Text,
                        Password     = tbPassword.Text,
                        DateCreated  = DateTime.Today,
                        IdStudent    = savedStudent.IdStudent,
                        IsActive     = true,
                        IsAdmin      = false,
                        IsBCIMA      = false,
                        IsBroker     = false,
                        IsCompany    = false,
                        IsCompCare   = true,
                        IsGrintek    = false,
                        IsLifestyle  = false,
                        IsNHBRCFLI   = false,
                        IsPartner    = false,
                        IsStudent    = true,
                        IsSupplier   = false,
                        IsTiger      = false,
                        IsWorkerPlan = false,
                        UserLevel    = 0
                    };

                    entity.AddObject("Users", newUser);
                    entity.AddObject("StudentAddresses", postal);
                    entity.AddObject("StudentAddresses", phys);
                    entity.SaveChanges();

                    User savedUser = entity.Users.Where(p => p.IdStudent == savedStudent.IdStudent).FirstOrDefault();
                    SendEmail(savedStudent.Email, "You have been successfully registered on the CompCare StudentPlan website", string.Format("Dear {0}, \r\n You have been successfully registered on the CompCare StudentPlan website.  Your Username have been saved to the database as {1}. \r\n Kind regards, \r\n CompCare Webmaster", savedStudent.FirstNames, savedUser.Username));

                    if (hfIsSaNational.Value == "false")
                    {
                        Response.Redirect("DependantMedical.aspx?Reference=" + reference);
                    }
                    else
                    {
                        Response.Redirect("ConfirmDetails.aspx?Reference=" + reference);
                    }
                }
            }
        }
コード例 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        int idMember = int.Parse(Session["IdMember"].ToString());

                        Member member = (from i in entity.Members
                                         where i.IdMember == idMember
                                         select i).SingleOrDefault();
                        Dependant    dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                        SchemeOption option    = (from i in entity.SchemeOptions
                                                  where i.IdSchemeOption == member.IdSchemeOption
                                                  select i).SingleOrDefault();
                        User          user            = entity.Users.Where(i => i.IdMember == idMember).FirstOrDefault();
                        MemberAddress postalAddress   = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == true).FirstOrDefault();
                        MemberAddress physicalAddress = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == false).FirstOrDefault();
                        Gender        gender          = entity.Genders.Where(p => p.IdGender == dependant.IdGender).SingleOrDefault();
                        lblEmail.Text        = dependant.EmailAddress != null ? dependant.EmailAddress : "Not Available";
                        lblAddress2.Text     = postalAddress != null ? postalAddress.Address2 : "Not Available";
                        lblAddress3.Text     = postalAddress != null ? postalAddress.Address3 : "Not Available";
                        lblAddress4.Text     = postalAddress != null ? postalAddress.Address4 : "Not Available";
                        lblAddress1.Text     = postalAddress != null ? postalAddress.Address1 : "Not Available";
                        lblPostalCode.Text   = postalAddress != null ? postalAddress.PostalCode : "Not Available";
                        lblPhysical1.Text    = physicalAddress != null ? physicalAddress.Address1 : "Not Available";
                        lblPhysical2.Text    = physicalAddress != null ? physicalAddress.Address2 : "Not Available";
                        lblPhysical3.Text    = physicalAddress != null ? physicalAddress.Address3 : "Not Available";
                        lblPhysical4.Text    = physicalAddress != null ? physicalAddress.Address4 : "Not Available";
                        lblPhysicalCode.Text = physicalAddress != null ? physicalAddress.PostalCode : "Not Available";
                        lblTelephone.Text    = dependant.TelephoneNumber != null ? dependant.TelephoneNumber : "Not Available";
                        lblCellular.Text     = dependant.CellularNumber != null ? dependant.CellularNumber : "Not Available";
                        lblFaxNumber.Text    = dependant.FaxNumber != null || dependant.FaxNumber != "" ? dependant.FaxNumber : "Not Available";
                        lblWorkNumber.Text   = dependant.WorkNumber != null ? dependant.WorkNumber : "Not Available";
                        lblDOB.Text          = dependant.DateOfBirth != null?dependant.DateOfBirth.Value.ToShortDateString() : "Not Available";

                        //lblGender.Text = gender.GenderDescription;
                        lblGender.Text      = dependant.Gender.GenderDescription;
                        lblIdNo.Text        = dependant.IdentityNumber;
                        lblInitials.Text    = dependant.Initials;
                        lblJoiningDate.Text = dependant.JoiningDate != null?dependant.JoiningDate.Value.ToShortDateString() : "Not Available";

                        lblSurname.Text     = dependant.DependantSurname;
                        lblName.Text        = dependant.DependantName;
                        lblMemberName.Text  = dependant.DependantName;
                        lblBenefitDate.Text = dependant.JoiningDate != null?dependant.JoiningDate.Value.ToShortDateString() : "Not Available";

                        lblMembershipNumber.Text = member.MAMembershipNumber;
                        lblResignationDate.Text  = dependant.ResignationDate != null?dependant.ResignationDate.Value.ToShortDateString() : @"n/a";

                        lblSchemeOption.Text  = option.SchemeOptionDescription;
                        lblSuspendedDate.Text = dependant.SuspendedFrom != null?dependant.SuspendedFrom.Value.ToShortDateString() : @"n/a";

                        lblSuspendedTo.Text = dependant.SuspendedTo != null?dependant.SuspendedTo.Value.ToShortDateString() : @"n/a";
                    }
                    catch
                    {
                        lblError.Text = @"The website encountered a problem retrieving all of your data.  Please report this problem to the CompCare <a href='mailto:[email protected]'>Webmaster</a>.";
                    }
                }
            }
        }
コード例 #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["Reference"] == null)
         {
             Response.Redirect("PreliminaryQuestions.aspx");
         }
         else
         {
             string reference = Request.QueryString["Reference"].ToString();
             hfReference.Value = reference;
             using (UniversalEntities entity = new UniversalEntities())
             {
                 Student student = entity.Students.Where(p => p.ReferenceNumber == reference).FirstOrDefault();
                 Session.Add("IdStudent", student.IdStudent);
                 startDate.Text        = student.CommencementDate.Value.ToShortDateString();
                 title.Text            = entity.Titles.Where(p => p.IdTitle == student.IdTitle).FirstOrDefault().TitleAbbreviation;
                 endDate.Text          = student.EndDate.Value.ToShortDateString();
                 surname.Text          = student.Surname;
                 firstNames.Text       = student.FirstNames;
                 tbDOB.Text            = student.DateOfBirth.Value.ToShortDateString();
                 tbIdNumber.Text       = student.IDPassport;
                 studyInstitution.Text = entity.Institutions.Where(p => p.IdInstitution == student.StudyInstitution).FirstOrDefault().InstitutionName;
                 studentNumber.Text    = student.StudentNumber;
                 contribution.Text     = "R " + student.Contribution.ToString();
                 studyDuration.Text    = student.StudyDuration.ToString() + " months";
                 lblReference.Text     = student.ReferenceNumber;
                 StudentAddress postalAddress = entity.StudentAddresses.Where(p => p.IdStudent == student.IdStudent && p.IsPostalAddress.Value).FirstOrDefault();
                 StudentAddress physAddress   = entity.StudentAddresses.Where(p => p.IdStudent == student.IdStudent && !p.IsPostalAddress.Value).FirstOrDefault();
                 OAddress1.Text        = postalAddress.Address1;
                 OAddress2.Text        = postalAddress.Address2;
                 OAddress3.Text        = postalAddress.Address3;
                 OAddress4.Text        = postalAddress.Address4;
                 lblOProvince.Text     = entity.Provinces.Where(p => p.IdProvince == postalAddress.IdProvince).FirstOrDefault().Name;
                 OPostal.Text          = postalAddress.PostalCode;
                 PAddress1.Text        = physAddress.Address1;
                 PAddress2.Text        = physAddress.Address2;
                 PAddress3.Text        = physAddress.Address3;
                 PAddress4.Text        = physAddress.Address4;
                 lblPProvince.Text     = entity.Provinces.Where(p => p.IdProvince == physAddress.IdProvince).FirstOrDefault().Name;
                 PPostal.Text          = physAddress.PostalCode;
                 tbGettingIncome.Text  = student.IsGettingIncome.ToString();
                 tbIncomeAmount.Text   = student.IncomeAmount.ToString();
                 tbCountryOfIssue.Text = entity.Countries.Where(p => p.IdCountry == student.CountryOfIssue.Value).FirstOrDefault().Name;
                 tbGender.Text         = entity.Genders.Where(p => p.IdGender == student.IdGender).FirstOrDefault().GenderDescription;
                 tbMaritalStatus.Text  = entity.MaritalStatusses.Where(p => p.IdMaritalStatus == student.IdMaritalStatus).FirstOrDefault().Description;
                 int    now = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
                 int    dob = int.Parse(student.DateOfBirth.Value.ToShortDateString().Replace("/", ""));
                 string dif = (now - dob).ToString();
                 string age = "0";
                 if (dif.Length > 4)
                 {
                     age = dif.Substring(0, dif.Length - 4);
                 }
                 tbAge.Text = age;
                 int numberOfDependants = entity.StudentDependants.Where(p => p.IdStudent == student.IdStudent).ToList().Count();
                 email.Text   = student.Email;
                 workTel.Text = student.BusinessTelephone;
                 homeTel.Text = student.HomeTelephone;
                 fax.Text     = student.Facsimile;
                 cell.Text    = student.Cellular;
                 gvMedicalHistory.DataSource = entity.TreatmentDetails.Where(p => p.IdStudent == student.IdStudent).ToList();
                 gvDependants.DataSource     = entity.StudentDependants.Where(p => p.IdStudent == student.IdStudent).ToList();
                 gvMedicalHistory.DataBind();
                 gvDependants.DataBind();
             }
         }
     }
 }
コード例 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                idMember = int.Parse(Session["IdMember"].ToString());
            }

            if (!IsPostBack)
            {
                btnSubmit.Enabled = false;
                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        int idMember = int.Parse(Session["IdMember"].ToString());

                        Member member = (from i in entity.Members
                                         where i.IdMember == idMember
                                         select i).SingleOrDefault();
                        Dependant    dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                        SchemeOption option    = (from i in entity.SchemeOptions
                                                  where i.IdSchemeOption == member.IdSchemeOption
                                                  select i).SingleOrDefault();
                        User          user            = entity.Users.Where(i => i.IdMember == idMember).FirstOrDefault();
                        MemberAddress postalAddress   = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == true).FirstOrDefault();
                        MemberAddress physicalAddress = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == false).FirstOrDefault();
                        Gender        gender          = entity.Genders.Where(p => p.IdGender == dependant.IdGender).SingleOrDefault();
                        ddlProvince.DataSource = entity.Provinces.ToList();
                        ddlProvince.DataBind();
                        Province physProvince = entity.Provinces.Where(p => p.IdProvince == physicalAddress.IdProvince).FirstOrDefault();
                        lblEmail.Text        = dependant.EmailAddress != null ? dependant.EmailAddress : "Not Available";
                        lblAddress2.Text     = postalAddress != null ? postalAddress.Address2 : "Not Available";
                        lblAddress3.Text     = postalAddress != null ? postalAddress.Address3 : "Not Available";
                        lblAddress4.Text     = postalAddress != null ? postalAddress.Address4 : "Not Available";
                        lblAddress1.Text     = postalAddress != null ? postalAddress.Address1 : "Not Available";
                        lblPostalCode.Text   = postalAddress != null ? postalAddress.PostalCode : "Not Available";
                        lblPhysical1.Text    = physicalAddress != null ? physicalAddress.Address1 : "Not Available";
                        lblPhysical2.Text    = physicalAddress != null ? physicalAddress.Address2 : "Not Available";
                        lblPhysical3.Text    = physicalAddress != null ? physicalAddress.Address3 : "Not Available";
                        lblPhysical4.Text    = physicalAddress != null ? physicalAddress.Address4 : "Not Available";
                        lblProvince.Text     = physProvince != null ? physProvince.Name : "Not Available";
                        lblPhysicalCode.Text = physicalAddress != null ? physicalAddress.PostalCode : "Not Available";
                        lblTelephone.Text    = dependant.TelephoneNumber != null ? dependant.TelephoneNumber : "Not Available";
                        lblCellular.Text     = dependant.CellularNumber != null ? dependant.CellularNumber : "Not Available";
                        lblFaxNumber.Text    = dependant.FaxNumber != null || dependant.FaxNumber != "" ? dependant.FaxNumber : "Not Available";
                        lblWorkNumber.Text   = dependant.WorkNumber != null ? dependant.WorkNumber : "Not Available";
                    }
                    catch
                    {
                        lblError.Text = @"The website encountered a problem retrieving all of your data.  Please report this problem to the CompCare <a href='mailto:[email protected]'>Webmaster</a>.";
                    }
                    tbEmail.Visible         = false;
                    tbFaxNumber.Visible     = false;
                    groupPhysicalTB.Visible = false;
                    groupPostalTB.Visible   = false;
                    tbCellular.Visible      = false;
                    tbTelephone.Visible     = false;
                    tbWorkNumber.Visible    = false;
                    groupPhysicalLB.Visible = true;
                    groupPostalLB.Visible   = true;
                    lblCellular.Visible     = true;
                    lblEmail.Visible        = true;
                    lblFaxNumber.Visible    = true;
                    lblTelephone.Visible    = true;
                    lblWorkNumber.Visible   = true;
                }
            }
        }