protected void ok_Click(object sender, EventArgs e) { if (dojoSeminarRegistrationID == 0) { editDojoSeminarRegistration = new DojoSeminarRegistration(); editDojoSeminarRegistration.Contact = new GreyFoxContact("kitTessen_SeminarRegistrations_Contacts"); } else { editDojoSeminarRegistration = new DojoSeminarRegistration(dojoSeminarRegistrationID); } editDojoSeminarRegistration.Contact.ParseName(tbName.Text); editDojoSeminarRegistration.Contact.ParseAddress(tbAddress1.Text, tbAddress2.Text, tbCity.Text, tbStateProvince.Text, tbPostalCode.Text, tbCountry.Text); editDojoSeminarRegistration.Contact.ParsePhones(tbHomePhone.Text, tbWorkPhone.Text, string.Empty, tbPager.Text, tbMobilePhone.Text); editDojoSeminarRegistration.Contact.Email1 = tbEmail1.Text; editDojoSeminarRegistration.Contact.Email2 = tbEmail2.Text; editDojoSeminarRegistration.Contact.Url = tbUrl.Text; editDojoSeminarRegistration.Contact.MemoText = tbMemoText.Text; editDojoSeminarRegistration.Contact.Save(); editDojoSeminarRegistration.Status = byte.Parse(msStatus.SelectedValue); editDojoSeminarRegistration.RegistrationDate = deRegistrationDate.Date; editDojoSeminarRegistration.ClassUnits = int.Parse(tbClassUnits.Text); editDojoSeminarRegistration.TotalFee = decimal.Parse(tbTotalFee.Text); editDojoSeminarRegistration.PaymentDate = dePaymentDate.Date; editDojoSeminarRegistration.PaymentReference = tbPaymentReference.Text; editDojoSeminarRegistration.PaymentAmount = decimal.Parse(tbPaymentAmount.Text); if (msParentSeminar.SelectedItem != null) { editDojoSeminarRegistration.ParentSeminar = DojoSeminar.NewPlaceHolder( int.Parse(msParentSeminar.SelectedItem.Value)); } else { editDojoSeminarRegistration.ParentSeminar = null; } if (editOnAdd) { dojoSeminarRegistrationID = editDojoSeminarRegistration.Save(); } else { editDojoSeminarRegistration.Save(); } if (resetOnAdd) { tbName.Text = string.Empty; tbAddress1.Text = string.Empty; tbAddress2.Text = string.Empty; tbCity.Text = string.Empty; tbStateProvince.Text = string.Empty; tbPostalCode.Text = string.Empty; tbCountry.Text = string.Empty; tbHomePhone.Text = string.Empty; tbWorkPhone.Text = string.Empty; tbMobilePhone.Text = string.Empty; tbPager.Text = string.Empty; tbEmail1.Text = string.Empty; tbEmail2.Text = string.Empty; tbUrl.Text = string.Empty; tbMemoText.Text = string.Empty; deRegistrationDate.Date = DateTime.Now; tbClassUnits.Text = "-1"; tbTotalFee.Text = "0"; dePaymentDate.Date = DateTime.Now; tbPaymentReference.Text = string.Empty; tbPaymentAmount.Text = "0"; msParentSeminar.SelectedIndex = 0; msStatus.SelectedIndex = 0; } OnUpdated(EventArgs.Empty); }
public void CreateInvoice(DojoSeminarRegistration registration, RHCustomer customer) { DojoSeminar seminar = registration.ParentSeminar; // Create Invoice and set the duedate according to the seminar // registration settings. RHInvoice invoice = new RHInvoice(); invoice.Customer = customer; if (seminar.EarlyEndDate > DateTime.Now) { invoice.DueDate = seminar.EarlyEndDate; } else if (seminar.EndDate > DateTime.Now) { invoice.DueDate = seminar.LateStartDate; } else { invoice.DueDate = seminar.StartDate; } invoice.FOB = seminar.Location.BusinessName; invoice.ReceivableAccount = seminar.Item.SalesIncomeAccount; invoice.BillingContact = new GreyFoxContact(RHInvoiceManager.BillingContactTable); invoice.BillingContact.Prefix = customer.PrivateContact.Prefix; invoice.BillingContact.FirstName = customer.PrivateContact.FirstName; invoice.BillingContact.MiddleName = customer.PrivateContact.MiddleName; invoice.BillingContact.LastName = customer.PrivateContact.LastName; invoice.BillingContact.Suffix = customer.PrivateContact.Suffix; invoice.BillingContact.Address1 = customer.PrivateContact.Address1; invoice.BillingContact.Address2 = customer.PrivateContact.Address2; invoice.BillingContact.City = customer.PrivateContact.City; invoice.BillingContact.StateProvince = customer.PrivateContact.StateProvince; invoice.BillingContact.PostalCode = customer.PrivateContact.PostalCode; invoice.BillingContact.Country = customer.PrivateContact.Country; invoice.ShipContact = new GreyFoxContact(RHInvoiceManager.ShipContactTable); invoice.ShipContact.Prefix = registration.Contact.Prefix; invoice.ShipContact.FirstName = registration.Contact.FirstName; invoice.ShipContact.MiddleName = registration.Contact.MiddleName; invoice.ShipContact.LastName = registration.Contact.LastName; invoice.ShipContact.Suffix = registration.Contact.Suffix; invoice.ShipContact.Address1 = registration.Contact.Address1; invoice.ShipContact.Address2 = registration.Contact.Address2; invoice.ShipContact.City = registration.Contact.City; invoice.ShipContact.StateProvince = registration.Contact.StateProvince; invoice.ShipContact.PostalCode = registration.Contact.PostalCode; invoice.ShipContact.Country = registration.Contact.Country; invoice.Subtotal = registration.TotalFee; // TODO: Handle Taxes invoice.BalanceRemaining = registration.TotalFee; invoice.Save(); // Create Invoice Line RHInvoiceLine line = new RHInvoiceLine(); line.Invoice = invoice; line.Description = "Seminar Registration - " + seminar.Name + "\r\n"; line.Item = seminar.Item; line.OrderNum = 1; line.Quantity = 1; line.Amount = registration.TotalFee; line.Rate = registration.TotalFee; line.Save(); registration.InvoiceLine = line; registration.Save(); }
protected void ok_Click(object sender, EventArgs e) { if (dojoSeminarRegistrationID == 0) { obj = new DojoSeminarRegistration(); } else { obj = new DojoSeminarRegistration(dojoSeminarRegistrationID); } obj.Status = byte.Parse(tbStatus.Text); obj.RegistrationDate = deRegistrationDate.Date; obj.ClassUnits = int.Parse(tbClassUnits.Text); obj.TotalFee = decimal.Parse(tbTotalFee.Text); obj.PaymentDate = dePaymentDate.Date; obj.PaymentReference = tbPaymentReference.Text; obj.PaymentAmount = decimal.Parse(tbPaymentAmount.Text); if (msContact.SelectedItem != null && msContact.SelectedItem.Value != "Null") { obj.Contact = GreyFoxContact.NewPlaceHolder("kitTessen_SeminarRegistrations_Contacts", int.Parse(msContact.SelectedItem.Value)); } else { obj.Contact = null; } if (msCustomer.SelectedItem != null && msCustomer.SelectedItem.Value != "Null") { obj.Customer = RHCustomer.NewPlaceHolder( int.Parse(msCustomer.SelectedItem.Value)); } else { obj.Customer = null; } if (msInvoiceLine.SelectedItem != null && msInvoiceLine.SelectedItem.Value != "Null") { obj.InvoiceLine = RHInvoiceLine.NewPlaceHolder( int.Parse(msInvoiceLine.SelectedItem.Value)); } else { obj.InvoiceLine = null; } if (msSalesOrderLine.SelectedItem != null && msSalesOrderLine.SelectedItem.Value != "Null") { obj.SalesOrderLine = RHSalesOrderLine.NewPlaceHolder( int.Parse(msSalesOrderLine.SelectedItem.Value)); } else { obj.SalesOrderLine = null; } if (editOnAdd) { dojoSeminarRegistrationID = obj.Save(); } else { obj.Save(); } if (resetOnAdd) { tbStatus.Text = string.Empty; deRegistrationDate.Date = DateTime.Now; tbClassUnits.Text = string.Empty; tbTotalFee.Text = string.Empty; dePaymentDate.Date = DateTime.Now; tbPaymentReference.Text = string.Empty; tbPaymentAmount.Text = string.Empty; msContact.SelectedIndex = 0; msCustomer.SelectedIndex = 0; msInvoiceLine.SelectedIndex = 0; msSalesOrderLine.SelectedIndex = 0; } OnUpdated(EventArgs.Empty); }
private void create() { setValidators(Tab.Create); Page.Validate(); if (!Page.IsValid) { return; } // Create a new registration if it does not already exist. Be sure to create // the registration in proper order; contact, registration, options. If // Rappahanock is enabled, create the sales order for the item. SeminarRegistrationBuilder builder = null; if (registrationID == 0) { builder = new SeminarRegistrationBuilder(); registration = builder.Registration; registrationOptions = builder.Options; registration.Contact = new GreyFoxContact(DojoSeminarRegistrationManager.ContactTable); // Set a SessionID for security using either the username // or ASP.net SessionID if (Page.User.Identity.Name != string.Empty) { registration.SessionID = Page.User.Identity.Name; } else { registration.SessionID = Page.Session.SessionID; } } else { // Be sure to remove the registration from the cart if // Rappahanock processing is activated. try { builder = new SeminarRegistrationBuilder(registrationID); } catch { selectedTab = Tab.Locked; return; } registration = builder.Registration; registrationOptions = builder.Options; // Check for SessionID for Security if (registration.SessionID != Page.Session.SessionID & registration.SessionID != Page.User.Identity.Name) { selectedTab = Tab.Locked; return; } // If the registration has a payment amount over zero, // be sure to lock it to remove a vulnerability. if (registration.PaymentAmount > 0) { selectedTab = Tab.Locked; return; } if (paymentMode == RegistrationPaymentMode.Rappahanock) { builder.RemoveFromCart(); } } registration.RegistrationDate = DateTime.Now; registration.Status = 0; registration.Contact.ParseName(tbName.Text); registration.Contact.ParseAddress(tbAddress1.Text, tbAddress2.Text, tbCity.Text, tbStateProvince.Text, tbPostalCode.Text, tbCountry.Text); registration.Contact.ParsePhones(tbHomePhone.Text, tbWorkPhone.Text, string.Empty, string.Empty, string.Empty); registration.Contact.Email1 = tbEmail1.Text; registration.Contact.Save(); registration.ParentSeminar = seminar; registration.classUnits = int.Parse(ddClassUnits.SelectedItem.Value); registrationID = registration.Save(); // Set options for the registration by first clearing the options // already associated with the registration then recreating them // from current selections. DojoSeminarRegistrationOptionManager.ClearOptions(registration); registrationOptions.Clear(); // Loop through the form's post back data looking for the lineOption // and quantity keys. Setup the associated options with the // current registration only if selected or the quantity is not // zero. string[] allKeys = Context.Request.Form.AllKeys; int optionId; int quantity = 0; for (int x = 0; x < allKeys.Length; x++) { if (!allKeys[x].StartsWith(ClientID + "___option") & !allKeys[x].StartsWith(ClientID + "___qty")) { continue; } if (allKeys[x].StartsWith(ClientID + "___option")) { // Parse OptionID Selected optionId = int.Parse(allKeys[x].Substring( ClientID.Length + 9, allKeys[x].Length - (ClientID.Length + 9))); quantity = 1; } else { // Parse OptionID and Quantity Selected and be sure // to ignore quantities less than 1, otherwise some // clever registrants will get some discounts! optionId = int.Parse(allKeys[x].Substring( ClientID.Length + 6, allKeys[x].Length - (ClientID.Length + 6))); quantity = int.Parse(Context.Request.Form[ClientID + "___qty" + optionId.ToString()]); if (quantity < 1) { continue; } } // Find the lineOption in the seminar's list of available options then // add the lineOption and save it. foreach (DojoSeminarOption seminarOption in seminar.Options) { if (optionId == seminarOption.iD) { DojoSeminarRegistrationOption registrationOption = new DojoSeminarRegistrationOption(); registrationOption.ParentRegistration = registration; registrationOption.ParentOption = seminarOption; registrationOption.CostPerItem = seminarOption.Fee; registrationOption.Quantity = quantity; registrationOption.TotalFee = seminarOption.Fee * registrationOption.Quantity; registrationOption.Save(); registrationOptions.Add(registrationOption); break; } } } // Save the registration again to update quantities and fees. registration.CalculateFee(registrationOptions); registration.Save(); if (paymentMode == RegistrationPaymentMode.Rappahanock) { builder.AddToCart(); } selectedTab = Tab.Verify; }