public void RegisterRetreatant(object sender, EventArgs e)
    {
        string transactionID = "";
        bool cardPayment = false;
        // if user chose to pay with a credit card, set a bool used in the rest of the function
        if (dlPaymentChoice.SelectedIndex == 0)
            cardPayment = true;

        if (cardPayment && DoPaypalTransaction(sender, e, ref transactionID) != 0)
        {
            authStatus.Text = "We are sorry, but your card did not authorize. Please go back to the payment step and review your information.";
            backToPaymentButton.Visible = true;
        }
        else
        {
            // make lists for all tuples to be added to db;
            // is filled from single retreatant info and repeater info
            List<Monks.jkp_Person> personList = new List<Monks.jkp_Person>();
            List<Monks.jkp_PersonAttendingRetreat> PARList = new List<Monks.jkp_PersonAttendingRetreat>();

            //get user matching current logged in user's GUID
            var user = db.aspnet_Memberships.Single(p => p.UserId == UserId);
            var retreat = db.jkp_Retreats.Single(p => p.Ret_ID == RetreatId);

            Monks.jkp_Contribution contribution = new Monks.jkp_Contribution();

            // fill new contribution object with associated info from the person table
            contribution.Cont_ID = Guid.NewGuid();
            contribution.Cont_Off_Per_ID = user.jkp_Person.Per_ID;
            contribution.Cont_Rec_Per_ID = user.jkp_Person.Per_ID;
            contribution.Cont_Date = System.DateTime.Today;
            contribution.Cont_TotalPrice = (decimal)double.Parse(estTotalCost.Text);
            if (dlPaymentChoice.SelectedIndex == 0)
            {
                // credit card payment
                contribution.Cont_Currency = dlCurrency.SelectedValue;
                contribution.Cont_AmountPaid = (decimal)double.Parse(estTotalCost.Text);
                contribution.Cont_Transaction_ID = transactionID;
                contribution.Cont_PaymentMethodTypeId = (int)Monks.Enums.PaymentMethodType.PayPalCreditCard;
            }
            else if (dlPaymentChoice.SelectedIndex == 1)
            {
                // cash payment
                contribution.Cont_AmountPaid = (decimal)0.00;
                contribution.Cont_PaymentMethodTypeId = (int)Monks.Enums.PaymentMethodType.Cash;
            }

            Monks.jkp_PersonAttendingRetreat par;
            // go through every person in review person repeater and make the appropriate
            // PAR entries based on individual room choices
            foreach (RepeaterItem reviewPerson in reviewPersonRepeater.Items)
            {
                Label perName = (Label)reviewPerson.FindControl("personNameList");
                Label perRoomChoice = (Label)reviewPerson.FindControl("personRoomPref");
                Label perArrival = (Label)reviewPerson.FindControl("personArrival");
                Label perDeparture = (Label)reviewPerson.FindControl("personDeparture");

                par = new Monks.jkp_PersonAttendingRetreat();
                par.PAR_ID = Guid.NewGuid();
                par.PAR_ContributionId = contribution.Cont_ID;
                par.PAR_ArrivalTime = DateTime.Parse(perArrival.Text);
                par.PAR_DepartureTime = DateTime.Parse(perDeparture.Text);
                par.PAR_RetId = retreat.Ret_ID;
                par.PAR_RoomTypeId = new Guid(perRoomChoice.Attributes["roomTypeID"]);

                // get person from db using first name, last name, and birthdate
                String[] nameSplit = perName.Text.Split();
                String birthdate = perName.Attributes["per_birthdate"];
                var person = db.jkp_Persons.SingleOrDefault(r => r.Per_FirstName.ToLower() == nameSplit[0].ToLower()
                                                              && r.Per_LastName.ToLower() == nameSplit[1].ToLower()
                                                              && r.Per_Birthdate == DateTime.Parse(perName.Attributes["per_birthdate"]));

                if(person != null) // person was found in db
                    par.PAR_PersonId = person.Per_ID;
                else // person was not found in db, make new person entry
                {
                    Monks.jkp_Person newPerson = new Monks.jkp_Person();
                    newPerson.Per_ID = Guid.NewGuid();
                    newPerson.Per_FirstName = nameSplit[0];
                    newPerson.Per_LastName = nameSplit[1];
                    newPerson.Per_Birthdate = DateTime.Parse(perName.Attributes["per_birthdate"]);

                    foreach (RepeaterItem additionalPerson in rpAdditionalRetreatants.Items)
                    {
                        TextBox fName = (TextBox)additionalPerson.FindControl("txtAddFirstName");
                        TextBox lName = (TextBox)additionalPerson.FindControl("txtAddLastName");

                        if (nameSplit[0] == fName.Text && nameSplit[1] == lName.Text)
                        {
                            DropDownList gender = (DropDownList)additionalPerson.FindControl("dlAddGender");
                            DropDownList firstLangChoice = (DropDownList)additionalPerson.FindControl("dlFirstLangPref");
                            DropDownList secondLangChoice = (DropDownList)additionalPerson.FindControl("dlSecondLangPref");

                            if (gender.SelectedItem.Text == "male" || gender.SelectedItem.Text == "Male")
                                newPerson.Per_Gender = 'M';
                            else
                                newPerson.Per_Gender ='F';
                            newPerson.Per_PrimaryLanguage = firstLangChoice.SelectedItem.Text;
                            newPerson.Per_SecondaryLanguage = secondLangChoice.SelectedItem.Text;
                        }
                    }
                    par.PAR_PersonId = newPerson.Per_ID;
                    personList.Add(newPerson);

                }
                PARList.Add(par);
            }

            //perform inserts
            db.jkp_Persons.InsertAllOnSubmit(personList);
            db.jkp_Contributions.InsertOnSubmit(contribution);
            db.jkp_PersonAttendingRetreats.InsertAllOnSubmit(PARList);

            db.SubmitChanges();
            authStatus.Text = "Success! You have been successfully registered for this retreat";

            string messageSubject = "Deer Park Retreat Registration Confirmation";
            string messageBody = "This email is being sent as a confirmation of your successful retreat registration with Deer Park. Your confirmation number is " + PARList.First().PAR_ID.ToString() + ". Please keep this email for future reference.";
            //MailSender mSender = new MailSender(user.jkp_Person.Per_Email, messageSubject, messageBody);
            //mSender.SendMail();

            //send confirmation email - need smtp info for deer park mail server
            //MailMessage mailConfirm = new MailMessage();
            //mailConfirm.From = new MailAddress("*****@*****.**");
            //mailConfirm.To.Add(user.jkp_Person.Per_Email);
            //mailConfirm.Subject = "Deer Park Retreat Registration Confirmation";
            //mailConfirm.Body = "This email is being sent as a confirmation of your successful retreat registration with Deer Park. Your confirmation number is " + PARList.First().PAR_ID.ToString() + ". Please keep this email for future reference.";
            //mailConfirm.IsBodyHtml = true;
            //mailConfirm.Priority = MailPriority.Normal;
            //SmtpClient mailServer = new SmtpClient("smtp.gmail.com");
            //mailServer.Port = 995;
            //mailServer.Credentials = new NetworkCredential("*****@*****.**", "A0n%3ffk7b*");
            //mailServer.EnableSsl = true;
            //mailServer.Send(mailConfirm);

        }
    }
Exemple #2
0
    private Monks.jkp_Person Create_jkp_Person(ref bool personExists,ref MonkData db)
    {
        // see if a person object already exists in the database based on combination of first name, last name, and birthdate
        Monks.jkp_Person personToAddMembership = db.jkp_Persons.SingleOrDefault(p => p.Per_FirstName == txtFirstName.Text && p.Per_LastName == txtLastName.Text && p.Per_Birthdate.Value == DateTime.Parse(txtBirthdate.Text));

        if (personToAddMembership == null)
        {
            Monks.jkp_Person jPerson = new Monks.jkp_Person();
            jPerson.Per_FirstName = txtFirstName.Text;
            jPerson.Per_LastName = txtLastName.Text;
            jPerson.Per_Birthdate = DateTime.Parse(txtBirthdate.Text);
            jPerson.Per_PrimaryLanguage = dlFirstLang.SelectedItem.Text;
            jPerson.Per_SecondaryLanguage = dlSecondLang.SelectedItem.Text;
            if (ddlGender.SelectedItem.Text == "Male")
                jPerson.Per_Gender = 'M';
            else
                jPerson.Per_Gender = 'F';
            jPerson.Per_Email = txtEmailAddress1.Text;
            jPerson.Per_ID = Guid.NewGuid();

            personExists = false;
            return jPerson;
        }
        else
        {
            personExists = true;
            return personToAddMembership;
        }
    }
Exemple #3
0
		private void detach_jkp_Persons(jkp_Person entity)
		{
			this.SendPropertyChanging();
			entity.jkp_Address = null;
		}
Exemple #4
0
		private void attach_jkp_Persons(jkp_Person entity)
		{
			this.SendPropertyChanging();
			entity.jkp_Sangha = this;
		}
Exemple #5
0
		private void detach_jkp_Persons(jkp_Person entity)
		{
			this.SendPropertyChanging();
			entity.jkp_OrdinationFamily = null;
		}
Exemple #6
0
		private void detach_jkp_Persons(jkp_Person entity)
		{
			this.SendPropertyChanging();
			entity.jkp_FamilyGroup = null;
		}