예제 #1
0
        /// <summary>
        /// Saves the DojoSeminar object state to the database.
        /// </summary>
        public int Save()
        {
            if (location != null)
            {
                location.Save();
            }
            if (options != null)
            {
                foreach (DojoSeminarOption item in options)
                {
                    item.Save();
                }
            }

            if (isSynced)
            {
                return(iD);
            }

            if (iD == -1)
            {
                throw (new Exception("Invalid record; cannot be saved."));
            }
            if (iD == 0)
            {
                iD = DojoSeminarManager._insert(this);
            }
            else
            {
                DojoSeminarManager._update(this);
            }
            isSynced = iD != -1;
            return(iD);
        }
예제 #2
0
        protected void ok_Click(object sender, EventArgs e)
        {
            if (dojoSeminarID == 0)
            {
                editDojoSeminar = new DojoSeminar();
            }
            else
            {
                editDojoSeminar = new DojoSeminar(dojoSeminarID);
            }

            editDojoSeminar.Name                = tbName.Text;
            editDojoSeminar.StartDate           = calStartP.SelectedDate;
            editDojoSeminar.EndDate             = calEndP.SelectedDate;
            editDojoSeminar.Description         = tbDescription.Text;
            editDojoSeminar.PdfUrl              = tbPdfUrl.Text;
            editDojoSeminar.ClassUnitFee        = decimal.Parse(tbClassUnitFee.Text);
            editDojoSeminar.BaseRegistrationFee = decimal.Parse(tbBaseRegistrationFee.Text);
            editDojoSeminar.RegistrationEnabled = cbRegistrationEnabled.Checked;

            editDojoSeminar.RegistrationStart        = calRegStartP.SelectedDate;
            editDojoSeminar.FullEarlyRegistrationFee = decimal.Parse(tbFullEarlyRegistrationFee.Text);
            editDojoSeminar.EarlyEndDate             = calEarlyEndP.SelectedDate;
            editDojoSeminar.FullRegistrationFee      = decimal.Parse(tbFullRegistrationFee.Text);
            editDojoSeminar.LateStartDate            = calLateStartP.SelectedDate;
            editDojoSeminar.FullLateRegistrationFee  = decimal.Parse(tbFullLateRegistrationFee.Text);
            editDojoSeminar.RegistrationEnd          = calRegEndP.SelectedDate;

            editDojoSeminar.DetailsOverrideUrl = tbDetailsOverrideUrl.Text;

            editDojoSeminar.ClassUnitType = (DojoSeminarClassUnitType)
                                            Enum.Parse(typeof(DojoSeminarClassUnitType), ddClassUnitType.SelectedItem.Value);
            editDojoSeminar.Details = tbDetails.Text;
            editDojoSeminar.IsLocal = cbIsLocal.Checked;

            if (msOptions.IsChanged)
            {
                editDojoSeminar.Options = new DojoSeminarOptionCollection();
                foreach (ListItem i in msOptions.Items)
                {
                    if (i.Selected)
                    {
                        editDojoSeminar.Options.Add(DojoSeminarOption.NewPlaceHolder(int.Parse(i.Value)));
                    }
                }
            }

            /// Selects the specified location, otherwise
            /// creates a new location.
            if (comboLocation.SelectedItem != null)
            {
                editDojoSeminar.Location =
                    GreyFoxContact.NewPlaceHolder(DojoSeminarManager.LocationTable,
                                                  int.Parse(comboLocation.SelectedValue));
            }
            else
            {
                if (comboLocation.Text != string.Empty)
                {
                    GreyFoxContact location =
                        new GreyFoxContact(DojoSeminarManager.LocationTable);
                    location.BusinessName = comboLocation.Text;
                    location.Save();
                    editDojoSeminar.Location = location;
                }
                else
                {
                    editDojoSeminar.Location = null;
                }
            }

            // Set the Rappahanock Item, otherwise create a new
            // item in Rappahanock that is tied to the seminar.
            // This is for SalesOrder and invoicing.
            if (comboRappahanockItem.SelectedItem != null)
            {
                editDojoSeminar.Item =
                    RHItem.NewPlaceHolder(
                        int.Parse(comboRappahanockItem.SelectedValue));
            }
            else
            {
                if (comboRappahanockItem.Text != string.Empty)
                {
                    RHItem newItem = RHFactory.ServiceItem(
                        comboRappahanockItem.Text,
                        tbDescription.Text,
                        decimal.Parse(tbFullRegistrationFee.Text),
                        null);
                    newItem.Save();
                    editDojoSeminar.Item = newItem;
                }
                else
                {
                    editDojoSeminar.Item = null;
                }
            }

            if (editOnAdd)
            {
                dojoSeminarID = editDojoSeminar.Save();
            }
            else
            {
                editDojoSeminar.Save();
            }

            if (resetOnAdd)
            {
                tbName.Text                   = string.Empty;
                calStartP.SelectedDate        = DateTime.Now;
                calEndP.SelectedDate          = DateTime.Now;
                tbDescription.Text            = string.Empty;
                tbPdfUrl.Text                 = string.Empty;
                tbClassUnitFee.Text           = string.Empty;
                tbBaseRegistrationFee.Text    = string.Empty;
                cbRegistrationEnabled.Checked = false;

                calRegStartP.SelectedDate       = DateTime.Now;
                tbFullEarlyRegistrationFee.Text = "0";
                calEarlyEndP.SelectedDate       = DateTime.Now;
                tbFullRegistrationFee.Text      = "0";
                calLateStartP.SelectedDate      = DateTime.Now;
                tbFullLateRegistrationFee.Text  = "0";
                calRegEndP.SelectedDate         = DateTime.Now;

                tbDetailsOverrideUrl.Text = string.Empty;

                ddClassUnitType.SelectedIndex = 0;
                tbDetails.Text     = string.Empty;
                cbIsLocal.Checked  = false;
                comboLocation.Text = string.Empty;
            }

            OnUpdated(EventArgs.Empty);
        }