コード例 #1
0
ファイル: OtherInfo.cs プロジェクト: sengithub/SenSourcecode
 public bool YesNoChecked(string key, bool value)
 {
     if (YesNoQuestion != null && YesNoQuestion.ContainsKey(key))
     {
         return(YesNoQuestion[key] == value);
     }
     return(false);
 }
コード例 #2
0
 private void ValidateAskYesNoQuestions(Ask ask)
 {
     for (var n = 0; n < ((AskYesNoQuestions)ask).list.Count; n++)
     {
         var a = ((AskYesNoQuestions)ask).list[n];
         if (YesNoQuestion == null || !YesNoQuestion.ContainsKey(a.SmallGroup))
         {
             modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].YesNoQuestion[a.SmallGroup]),
                                      "please select yes or no");
         }
     }
 }
コード例 #3
0
ファイル: Enroll.cs プロジェクト: sengithub/SenSourcecode
        public string PrepareSummaryText(Transaction ti)
        {
            var om = GetOrgMember();
            var sb = new StringBuilder();

            sb.Append("<table>");
            sb.AppendFormat("<tr><td width='50%'>Org:</td><td width='50%'>{0}</td></tr>\n", org.OrganizationName);
            sb.AppendFormat("<tr><td>First:</td><td>{0}</td></tr>\n", person.PreferredName);
            sb.AppendFormat("<tr><td>Last:</td><td>{0}</td></tr>\n", person.LastName);

            if (ti.Amt > 0 && om != null)
            {
                //var omemb = new OrgMemberModel(om.OrganizationId, om.PeopleId);
                var ts = om.TransactionSummary(DbUtil.Db);
                if (ts != null)
                {
                    sb.AppendFormat(@"
<tr><td colspan='2'> 
<table cellpadding=4>
    <tr>
        <td>Registrant Fee</td>
        <td>Amount Paid</td>
        <td>Amount Due</td>
    </tr>
    <tr>
        <td align='right'>{0}</td>
        <td align='right'>{1}</td>
        <td align='right'>{2}</td>
    </tr>
</table>
</td></tr>
    ", ts.IndAmt.ToString2("c"),
                                    om.TotalPaid(DbUtil.Db).ToString("c"),
                                    om.AmountDue(DbUtil.Db).ToString("c"));
                }
            }

            if (Parent.SupportMissionTrip)
            {
                var goer = DbUtil.Db.LoadPersonById(MissionTripGoerId ?? 0);
                if (goer != null)
                {
                    sb.AppendFormat("<tr><td>Support Mission Trip for:</td><td>{0}</td></tr>\n", goer.Name);
                }
                if (MissionTripSupportGeneral > 0)
                {
                    sb.Append("<tr><td>Support Mission Trip:</td><td>Any other participiants</td></tr>\n");
                }
            }
            else if (RecordFamilyAttendance())
            {
                foreach (var m in FamilyAttend.Where(m => m.Attend))
                {
                    if (m.PeopleId != null)
                    {
                        sb.Append("<tr><td colspan=\"2\">{0}{1}</td></tr>\n"
                                  .Fmt(m.Name, (m.Age.HasValue ? " ({0})".Fmt(m.Age) : "")));
                    }
                    else
                    {
                        sb.Append("<tr><td colspan=\"2\">{0}{1}".Fmt(m.Name, (m.Age.HasValue ? " ({0})".Fmt(m.Age) : "")));
                        if (m.Email.HasValue())
                        {
                            sb.Append(", {0}".Fmt(m.Email));
                        }
                        if (m.Birthday.HasValue())
                        {
                            sb.Append(", {0}".Fmt(m.Birthday));
                        }
                        if (m.MaritalId.HasValue)
                        {
                            sb.Append(", {0}".Fmt(m.Marital));
                        }
                        if (m.GenderId.HasValue)
                        {
                            sb.Append(", {0}".Fmt(m.Gender));
                        }
                        sb.Append("</td></tr>\n");
                    }
                }
            }
            else
            {
                var rr = person.RecRegs.Single();

                foreach (var ask in setting.AskItems)
                {
                    switch (ask.Type)
                    {
                    case "AskTickets":
                        sb.AppendFormat("<tr><td>Tickets:</td><td>{0}</td></tr>\n", om.Tickets);
                        break;

                    case "AskSize":
                        sb.AppendFormat("<tr><td>Shirt:</td><td>{0}</td></tr>\n", om.ShirtSize);
                        break;

                    case "AskEmContact":
                        sb.AppendFormat("<tr><td>Emerg Contact:</td><td>{0}</td></tr>\n", rr.Emcontact);
                        sb.AppendFormat("<tr><td>Emerg Phone:</td><td>{0}</td></tr>\n", rr.Emphone);
                        break;

                    case "AskDoctor":
                        sb.AppendFormat("<tr><td>Physician Name:</td><td>{0}</td></tr>\n", rr.Doctor);
                        sb.AppendFormat("<tr><td>Physician Phone:</td><td>{0}</td></tr>\n", rr.Docphone);
                        break;

                    case "AskInsurance":
                        sb.AppendFormat("<tr><td>Insurance Carrier:</td><td>{0}</td></tr>\n", rr.Insurance);
                        sb.AppendFormat("<tr><td>Insurance Policy:</td><td>{0}</td></tr>\n", rr.Policy);
                        break;

                    case "AskRequest":
                        sb.AppendFormat("<tr><td>{1}:</td><td>{0}</td></tr>\n", om.Request, ((AskRequest)ask).Label);
                        break;

                    case "AskHeader":
                        sb.AppendFormat("<tr><td colspan='2'><h4>{0}</h4></td></tr>\n", ((AskHeader)ask).Label);
                        break;

                    case "AskInstruction":
                        break;

                    case "AskAllergies":
                        sb.AppendFormat("<tr><td>Medical:</td><td>{0}</td></tr>\n", rr.MedicalDescription);
                        break;

                    case "AskTylenolEtc":
                        sb.AppendFormat("<tr><td>Tylenol?: {0},", tylenol == true ? "Yes" : tylenol == false ? "No" : "");
                        sb.AppendFormat(" Advil?: {0},", advil == true ? "Yes" : advil == false ? "No" : "");
                        sb.AppendFormat(" Robitussin?: {0},", robitussin == true ? "Yes" : robitussin == false ? "No" : "");
                        sb.AppendFormat(" Maalox?: {0}</td></tr>\n", maalox == true ? "Yes" : maalox == false ? "No" : "");
                        break;

                    case "AskChurch":
                        sb.AppendFormat("<tr><td>Member:</td><td>{0}</td></tr>\n", rr.Member);
                        sb.AppendFormat("<tr><td>OtherChurch:</td><td>{0}</td></tr>\n", rr.ActiveInAnotherChurch);
                        break;

                    case "AskParents":
                        sb.AppendFormat("<tr><td>Mother's name:</td><td>{0}</td></tr>\n", rr.Mname);
                        sb.AppendFormat("<tr><td>Father's name:</td><td>{0}</td></tr>\n", rr.Fname);
                        break;

                    case "AskCoaching":
                        sb.AppendFormat("<tr><td>Coaching:</td><td>{0}</td></tr>\n", rr.Coaching);
                        break;

                    case "AskSMS":
                        sb.AppendFormat("<tr><td>Receive Texts:</td><td>{0}</td></tr>\n", person.ReceiveSMS);
                        break;

                    case "AskDropdown":
                        sb.AppendFormat("<tr><td>{1}:</td><td>{0}</td></tr>\n", ((AskDropdown)ask).SmallGroupChoice(option).Description,
                                        Util.PickFirst(((AskDropdown)ask).Label, "Options"));
                        break;

                    case "AskMenu":
                    {
                        var menulabel = ((AskMenu)ask).Label;
                        foreach (var i in ((AskMenu)ask).MenuItemsChosen(MenuItem[ask.UniqueId]))
                        {
                            string row;
                            if (i.amt > 0)
                            {
                                row = "<tr><td>{0}</td><td>{1} {2} (at {3:N2})</td></tr>\n".Fmt(menulabel, i.number, i.desc, i.amt);
                            }
                            else
                            {
                                row = "<tr><td>{0}</td><td>{1} {2}</td></tr>\n".Fmt(menulabel, i.number, i.desc);
                            }
                            sb.AppendFormat(row);
                            menulabel = string.Empty;
                        }
                    }
                    break;

                    case "AskCheckboxes":
                    {
                        var askcb     = (AskCheckboxes)ask;
                        var menulabel = askcb.Label;
                        foreach (var i in askcb.CheckboxItemsChosen(Checkbox))
                        {
                            string row;
                            if (menulabel.HasValue())
                            {
                                sb.Append("<tr><td colspan='2'><br>{0}</td></tr>\n".Fmt(menulabel));
                            }
                            if (i.Fee > 0)
                            {
                                row = "<tr><td></td><td>{0} (${1:N2})<br>({2})</td></tr>\n".Fmt(i.Description, i.Fee, i.SmallGroup);
                            }
                            else
                            {
                                row = "<tr><td></td><td>{0}<br>({1})</td></tr>\n".Fmt(i.Description, i.SmallGroup);
                            }
                            sb.Append(row);
                            menulabel = string.Empty;
                        }
                    }
                    break;

                    case "AskYesNoQuestions":
                        foreach (var a in ((AskYesNoQuestions)ask).list)
                        {
                            if (YesNoQuestion.ContainsKey(a.SmallGroup))
                            {
                                sb.AppendFormat("<tr><td>{0}:</td><td>{1}</td></tr>\n".Fmt(a.Question,
                                                                                           YesNoQuestion[a.SmallGroup] == true ? "Yes" : "No"));
                            }
                        }
                        break;

                    case "AskExtraQuestions":
                        foreach (var a in ExtraQuestion[ask.UniqueId])
                        {
                            if (a.Value.HasValue())
                            {
                                sb.AppendFormat("<tr><td>{0}:</td><td>{1}</td></tr>\n".Fmt(a.Key, a.Value));
                            }
                        }
                        break;

                    case "AskText":
                        foreach (var a in Text[ask.UniqueId])
                        {
                            if (a.Value.HasValue())
                            {
                                sb.AppendFormat("<tr><td>{0}:</td><td>{1}</td></tr>\n".Fmt(a.Key, a.Value));
                            }
                        }
                        break;

                    case "AskGradeOptions":
                        sb.AppendFormat("<tr><td>GradeOption:</td><td>{0}</td></tr>\n",
                                        GradeOptions(ask).SingleOrDefault(s => s.Value == (gradeoption ?? "00")).Text);
                        break;
                    }
                }
                if (setting.AgeGroups.Count > 0)
                {
                    sb.AppendFormat("<tr><td>AgeGroup:</td><td>{0}</td></tr>\n", AgeGroup());
                }
            }

            sb.Append("</table>");

            return(sb.ToString());
        }
コード例 #4
0
ファイル: Validate.cs プロジェクト: davidbwire/bvcms
        public void ValidateModelForOther(ModelStateDictionary modelState)
        {
            var i = Index();

            foreach (var ask in setting.AskItems)
            {
                switch (ask.Type)
                {
                case "AskEmContact":
                    if (!emcontact.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].emcontact), "emergency contact required");
                    }
                    if (!emphone.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].emphone), "emergency phone # required");
                    }
                    break;

                case "AskInsurance":
                    if (!insurance.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].insurance), "insurance carrier required");
                    }
                    if (!policy.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].policy), "insurance policy # required");
                    }
                    break;

                case "AskDoctor":
                    if (!doctor.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].doctor), "Doctor's name required");
                    }
                    if (!docphone.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].docphone), "Doctor's phone # required");
                    }
                    break;

                case "AskTylenolEtc":
                    if (!tylenol.HasValue)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].tylenol), "please indicate");
                    }
                    if (!advil.HasValue)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].advil), "please indicate");
                    }
                    if (!maalox.HasValue)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].maalox), "please indicate");
                    }
                    if (!robitussin.HasValue)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].robitussin), "please indicate");
                    }
                    break;

                case "AskSize":
                    if (shirtsize == "0")
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].shirtsize), "please select a shirt size");
                    }
                    break;

                case "AskCoaching":
                    if (!coaching.HasValue)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].coaching), "please indicate");
                    }
                    break;

                case "AskDropdown":
                    string desc;
                    string namedd = Parent.GetNameFor(mm => mm.List[i].option[ask.UniqueId]);
                    if (((AskDropdown)ask).SmallGroupChoice(option) == null)
                    {
                        modelState.AddModelError(namedd, "please select an option");
                    }
                    else if (((AskDropdown)ask).IsSmallGroupFilled(GroupTags, option, out desc))
                    {
                        modelState.AddModelError(namedd, "limit reached for " + desc);
                    }
                    break;

                case "AskParents":
                    if (!mname.HasValue() && !fname.HasValue())
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].fname), "please provide either mother or father name");
                    }
                    else
                    {
                        string mfirst, mlast;
                        Util.NameSplit(mname, out mfirst, out mlast);
                        if (mname.HasValue() && !mfirst.HasValue())
                        {
                            modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].mname), "provide first and last names");
                        }
                        string ffirst, flast;
                        Util.NameSplit(fname, out ffirst, out flast);
                        if (fname.HasValue() && !ffirst.HasValue())
                        {
                            modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].fname), "provide first and last names");
                        }
                    }
                    break;

                case "AskTickets":
                    if ((ntickets ?? 0) == 0)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].ntickets), "please enter a number of tickets");
                    }
                    break;

                case "AskYesNoQuestions":
                    var ynname = Parent.GetNameFor(mm => mm.List[i]);
                    for (int n = 0; n < ((AskYesNoQuestions)ask).list.Count; n++)
                    {
                        var a = ((AskYesNoQuestions)ask).list[n];
                        if (YesNoQuestion == null || !YesNoQuestion.ContainsKey(a.SmallGroup))
                        {
                            modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].YesNoQuestion[a.SmallGroup]), "please select yes or no");
                        }
                    }
                    break;

                case "AskExtraQuestions":
                    var eq = (AskExtraQuestions)ask;
                    for (int n = 0; n < eq.list.Count; n++)
                    {
                        var a = eq.list[n];
                        if (ExtraQuestion == null || !ExtraQuestion[eq.UniqueId].ContainsKey(a.Question) ||
                            !ExtraQuestion[eq.UniqueId][a.Question].HasValue())
                        {
                            modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].ExtraQuestion[eq.UniqueId][a.Question]), "please give some answer");
                        }
                    }
                    break;

                case "AskCheckboxes":
                    string namecb = Parent.GetNameFor(mm => mm.List[i].Checkbox[ask.UniqueId]);
                    var    cb     = ((AskCheckboxes)ask);
                    if (cb.Max > 0 && cb.CheckboxItemsChosen(Checkbox).Count() > cb.Max)
                    {
                        modelState.AddModelError(namecb, "Max of {0} exceded".Fmt(cb.Max));
                    }
                    else if (cb.Min > 0 && (Checkbox == null || Checkbox.Count < cb.Min))
                    {
                        modelState.AddModelError(namecb, "Min of {0} required".Fmt(cb.Min));
                    }
                    break;

                case "AskGradeOptions":
                    if (gradeoption == "00")
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].gradeoption), "please select a grade option");
                    }
                    break;
                }
            }
            var totalAmount = TotalAmount();

            if (setting.Deposit > 0)
            {
                if (!paydeposit.HasValue)
                {
                    modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].paydeposit), "please indicate");
                }
                else
                {
                    var amountToPay = AmountToPay();
                    if (paydeposit == true && amountToPay > totalAmount)
                    {
                        modelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].paydeposit),
                                                 "Cannot use deposit since total due is less");
                    }
                }
            }
            if (OnlineGiving() && totalAmount <= 0)
            {
                modelState.AddModelError("form", "Gift amount required");
            }

            OtherOK = modelState.IsValid;
        }
コード例 #5
0
ファイル: Enroll.cs プロジェクト: davidbwire/bvcms
        public string PrepareSummaryText(Transaction ti)
        {
            var om = GetOrgMember();
            var sb = new StringBuilder();

            sb.Append("<table>");
            sb.AppendFormat("<tr><td>Org:</td><td>{0}</td></tr>\n", org.OrganizationName);
            sb.AppendFormat("<tr><td>First:</td><td>{0}</td></tr>\n", person.PreferredName);
            sb.AppendFormat("<tr><td>Last:</td><td>{0}</td></tr>\n", person.LastName);

            var rr = person.RecRegs.Single();

            foreach (var ask in setting.AskItems)
            {
                switch (ask.Type)
                {
                case "AskTickets":
                    sb.AppendFormat("<tr><td>Tickets:</td><td>{0}</td></tr>\n", om.Tickets);
                    break;

                case "AskSize":
                    sb.AppendFormat("<tr><td>Shirt:</td><td>{0}</td></tr>\n", om.ShirtSize);
                    break;

                case "AskEmContact":
                    sb.AppendFormat("<tr><td>Emerg Contact:</td><td>{0}</td></tr>\n", rr.Emcontact);
                    sb.AppendFormat("<tr><td>Emerg Phone:</td><td>{0}</td></tr>\n", rr.Emphone);
                    break;

                case "AskDoctor":
                    sb.AppendFormat("<tr><td>Physician Name:</td><td>{0}</td></tr>\n", rr.Doctor);
                    sb.AppendFormat("<tr><td>Physician Phone:</td><td>{0}</td></tr>\n", rr.Docphone);
                    break;

                case "AskInsurance":
                    sb.AppendFormat("<tr><td>Insurance Carrier:</td><td>{0}</td></tr>\n", rr.Insurance);
                    sb.AppendFormat("<tr><td>Insurance Policy:</td><td>{0}</td></tr>\n", rr.Policy);
                    break;

                case "AskRequest":
                    sb.AppendFormat("<tr><td>{1}:</td><td>{0}</td></tr>\n", om.Request, ((AskRequest)ask).Label);
                    break;

                case "AskHeader":
                    sb.AppendFormat("<tr><td colspan='2'><h4>{0}</h4></td></tr>\n", ((AskHeader)ask).Label);
                    break;

                case "AskInstruction":
                    break;

                case "AskAllergies":
                    sb.AppendFormat("<tr><td>Medical:</td><td>{0}</td></tr>\n", rr.MedicalDescription);
                    break;

                case "AskTylenolEtc":
                    sb.AppendFormat("<tr><td>Tylenol?: {0},", tylenol == true ? "Yes" : tylenol == false ? "No" : "");
                    sb.AppendFormat(" Advil?: {0},", advil == true ? "Yes" : advil == false ? "No" : "");
                    sb.AppendFormat(" Robitussin?: {0},", robitussin == true ? "Yes" : robitussin == false ? "No" : "");
                    sb.AppendFormat(" Maalox?: {0}</td></tr>\n", maalox == true ? "Yes" : maalox == false ? "No" : "");
                    break;

                case "AskChurch":
                    sb.AppendFormat("<tr><td>Member:</td><td>{0}</td></tr>\n", rr.Member);
                    sb.AppendFormat("<tr><td>OtherChurch:</td><td>{0}</td></tr>\n", rr.ActiveInAnotherChurch);
                    break;

                case "AskParents":
                    sb.AppendFormat("<tr><td>Mother's name:</td><td>{0}</td></tr>\n", rr.Mname);
                    sb.AppendFormat("<tr><td>Father's name:</td><td>{0}</td></tr>\n", rr.Fname);
                    break;

                case "AskCoaching":
                    sb.AppendFormat("<tr><td>Coaching:</td><td>{0}</td></tr>\n", rr.Coaching);
                    break;

                case "AskDropdown":
                    sb.AppendFormat("<tr><td>{1}:</td><td>{0}</td></tr>\n", ((AskDropdown)ask).SmallGroupChoice(option).Description,
                                    Util.PickFirst(((AskDropdown)ask).Label, "Options"));
                    break;

                case "AskMenu":
                {
                    var menulabel = "Menu Items";
                    foreach (var i in ((AskMenu)ask).MenuItemsChosen(MenuItem))
                    {
                        string row;
                        if (i.amt > 0)
                        {
                            row = "<tr><td>{0}</td><td>{1} {2} (at {3:N2})</td></tr>\n".Fmt(menulabel, i.number, i.desc, i.amt);
                        }
                        else
                        {
                            row = "<tr><td>{0}</td><td>{1} {2}</td></tr>\n".Fmt(menulabel, i.number, i.desc);
                        }
                        sb.AppendFormat(row);
                        menulabel = string.Empty;
                    }
                }
                break;

                case "AskCheckboxes":
                {
                    var askcb     = (AskCheckboxes)ask;
                    var menulabel = askcb.Label;
                    foreach (var i in askcb.CheckboxItemsChosen(Checkbox))
                    {
                        string row;
                        if (menulabel.HasValue())
                        {
                            sb.Append("<tr><td colspan='2'><br>{0}</td></tr>\n".Fmt(menulabel));
                        }
                        if (i.Fee > 0)
                        {
                            row = "<tr><td></td><td>{0} (${1:N2})<br>({2})</td></tr>\n".Fmt(i.Description, i.Fee, i.SmallGroup);
                        }
                        else
                        {
                            row = "<tr><td></td><td>{0}<br>({1})</td></tr>\n".Fmt(i.Description, i.SmallGroup);
                        }
                        sb.Append(row);
                        menulabel = string.Empty;
                    }
                }
                break;

                case "AskYesNoQuestions":
                    foreach (var a in ((AskYesNoQuestions)ask).list)
                    {
                        if (YesNoQuestion.ContainsKey(a.SmallGroup))
                        {
                            sb.AppendFormat("<tr><td>{0}:</td><td>{1}</td></tr>\n".Fmt(a.Question,
                                                                                       YesNoQuestion[a.SmallGroup] == true ? "Yes" : "No"));
                        }
                    }
                    break;

                case "AskExtraQuestions":
                    foreach (var a in ExtraQuestion[ask.UniqueId])
                    {
                        if (a.Value.HasValue())
                        {
                            sb.AppendFormat("<tr><td>{0}:</td><td>{1}</td></tr>\n".Fmt(a.Key, a.Value));
                        }
                    }
                    break;

                case "AskGradeOptions":
                    sb.AppendFormat("<tr><td>GradeOption:</td><td>{0}</td></tr>\n",
                                    GradeOptions(ask).SingleOrDefault(s => s.Value == (gradeoption ?? "00")).Text);
                    break;
                }
            }
            if (setting.AgeGroups.Count > 0)
            {
                sb.AppendFormat("<tr><td>AgeGroup:</td><td>{0}</td></tr>\n", AgeGroup());
            }

            sb.Append("</table>");

            return(sb.ToString());
        }