Beispiel #1
0
 public IEnumerable<SelectListItem> GetCodeData()
 {
     if (!CodeVisible)
         return null;
     var cvctl = new CodeValueModel();
     var valtype = "IdValue";
     switch (fieldMap.Type)
     {
         case FieldType.Bit:
         case FieldType.NullBit:
             return ConvertToSelect(BitCodes, valtype);
         case FieldType.EqualBit:
             return ConvertToSelect(EqualBitCodes, valtype);
         case FieldType.Code:
         case FieldType.NullCode:
             if (fieldMap.DataSource == "Campuses")
                 return SelectedList(Campuses());
             return ConvertToSelect(Util.CallMethod(cvctl, fieldMap.DataSource),
                 Util.PickFirst(fieldMap.DataValueField, valtype));
         case FieldType.CodeStr:
             switch (fieldMap.DataSource)
             {
                 case "ExtraValues":
                     return SelectedList(ExtraValueCodes());
                 case "FamilyExtraValues":
                     return SelectedList(FamilyExtraValueCodes());
                 default:
                     return ConvertToSelect(Util.CallMethod(cvctl, fieldMap.DataSource), fieldMap.DataValueField);
             }
         case FieldType.DateField:
             return ConvertToSelect(Util.CallMethod(cvctl, fieldMap.DataSource), fieldMap.DataValueField);
     }
     return null;
 }
Beispiel #2
0
 public IEnumerable<SelectListItem> Tags()
 {
     var cv = new CodeValueModel();
     var tg = CodeValueModel.ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Id").ToList();
     tg.Insert(0, new SelectListItem { Value = "0", Text = "(not specified)" });
     return tg;
 }
Beispiel #3
0
 public static string InterestPointList()
 {
     var m = new CodeValueModel();
     var q = from o in m.InterestPoints()
             select new { value = o.Id, text = o.Value };
     return JsonConvert.SerializeObject(q.ToArray());
 }
 public ActionResult ContactTypeSearchBuilder(int id)
 {
     var qb = DbUtil.Db.QueryBuilderScratchPad();
     qb.CleanSlate(DbUtil.Db);
     var comp = CompareType.Equal;
     var clause = qb.AddNewClause(QueryType.RecentContactType, comp, "1,T");
     clause.Days = 10000;
     var cvc = new CodeValueModel();
     var q = from v in cvc.ContactTypeCodes()
             where v.Id == id
             select v.IdCode;
     clause.CodeIdValue = q.Single();
     DbUtil.Db.SubmitChanges();
     return Redirect("/QueryBuilder/Main/{0}".Fmt(qb.QueryId));
 }
Beispiel #5
0
 public ActionResult ContactTypeSearchBuilder(int id)
 {
     var cc = DbUtil.Db.ScratchPadCondition();
     cc.Reset(DbUtil.Db);
     var comp = CompareType.Equal;
     var clause = cc.AddNewClause(QueryType.RecentContactType, comp, "1,T");
     clause.Days = 10000;
     var cvc = new CodeValueModel();
     var q = from v in cvc.ContactTypeCodes()
             where v.Id == id
             select v.IdCode;
     clause.CodeIdValue = q.Single();
     cc.Save(DbUtil.Db);
     if (ViewExtensions2.UseNewLook())
         return Redirect("/Query/" + cc.Id);
     return Redirect("/QueryBuilder2/Main/{0}".Fmt(cc.Id));
 }
Beispiel #6
0
 public SelectList Tags()
 {
     var cv = new CodeValueModel();
     var tg = cv.UserTags(Util.UserPeopleId);
     tg = tg.Select(tt => new CodeValueItem {Value = $"tag: {tt.Id}:{tt.Value}"}).ToList();
     var q = from e in DbUtil.Db.PeopleExtras
             where e.StrValue != null
             group e by e.FieldValue
             into g
             select new CodeValueItem {Value = "exval: " + g.Key};
     tg.AddRange(q);
     if (HttpContext.Current.User.IsInRole("Admin"))
         tg.Insert(0, new CodeValueItem {Value = "last query"});
     tg.Insert(0, new CodeValueItem {Value = "(not specified)"});
     var list = tg.ToSelect("Value");
     var sel = list.SingleOrDefault(mm => mm.Value == Tag);
     if (sel != null)
         sel.Selected = true;
     return list;
 }
        private List GetContacts(int pid)
        {
            var ctl = new CodeValueModel();
            var cts = ctl.ContactTypeCodes();

            var cq = from ce in DbUtil.Db.Contactees
                     where ce.PeopleId == pid
                     where (ce.contact.LimitToRole ?? "") == ""
                     orderby ce.contact.ContactDate descending
                     select new
                     {
                         ce.contact,
                         madeby = ce.contact.contactsMakers.FirstOrDefault().person
                     };
            var list = new List(false, 10);
            list.ListSymbol = new Chunk("\u2022", font);
            var epip = (from p in DbUtil.Db.People
                        where p.PeopleId == pid
                        select new
                        {
                            ep = p.EntryPoint != null ? p.EntryPoint.Description : "",
                            ip = p.InterestPoint != null ? p.InterestPoint.Description : ""
                        }).Single();
            if (epip.ep.HasValue() || epip.ip.HasValue())
                list.Add(new ListItem(1.2f*font.Size, $"Entry, Interest: {epip.ep}, {epip.ip}", font));
            const int maxcontacts = 4;
            foreach (var pc in cq.Take(maxcontacts))
            {
                var cname = "unknown";
                if (pc.madeby != null)
                    cname = pc.madeby.Name;
                var ctyp = cts.SingleOrDefault(ct => ct.Id == pc.contact.ContactTypeId);
                string ctype = null;
                if (ctyp != null)
                    ctype = ctyp.Value;

                string comments = null;
                if (pc.contact.Comments.HasValue())
                    comments = pc.contact.Comments.Replace("\r\n\r\n", "\r\n");
                string s = $"{pc.contact.ContactDate:d}: {ctype} by {cname}\n{comments}";
                list.Add(new ListItem(1.2f*font.Size, s, font));
            }
            if (cq.Count() > maxcontacts)
                list.Add(new ListItem(1.2f*font.Size, $"(showing most recent 10 of {cq.Count()})", font));

            return list;
        }
Beispiel #8
0
 public List<SelectListItem> SavedQueries()
 {
     var cv = new CodeValueModel();
     return CodeValueModel.ConvertToSelect(cv.UserQueries(), "Code");
 }
Beispiel #9
0
 public IEnumerable<CodeValueItem> Tags()
 {
     if (Util.UserPeopleId == null)
         return new List<CodeValueItem>();
     var ctl = new CodeValueModel();
     var list = ctl.UserTags(Util.UserPeopleId);
     return list;
 }
Beispiel #10
0
 public SelectList CampusList()
 {
     var cv = new CodeValueModel();
     return new SelectList(cv.AllCampuses0(), "Id", "Value");
 }
Beispiel #11
0
 public SelectList MaritalStatusList()
 {
     var cv = new CodeValueModel();
     return new SelectList(cv.MaritalStatusCodes(), "Id", "Value");
 }
Beispiel #12
0
        private void AddRow(PdfPTable t, Person p, int fn, BaseColor color)
        {
            t.DefaultCell.BackgroundColor = color;

            var c1 = new Phrase();
            c1.Add(new Chunk(p.Name, boldfont));
            c1.Add(new Chunk($"  ({p.PeopleId})\n", smallfont));
            var contact = new StringBuilder();
            var cv = new CodeValueModel();
            if (fn == 1)
            {
                AddLine(contact, p.PrimaryAddress);
                AddLine(contact, p.PrimaryAddress2);
                AddLine(contact, $"{p.PrimaryCity}, {p.PrimaryState} {p.PrimaryZip.FmtZip()}");
            }
            AddPhone(contact, p.HomePhone, "h ");
            AddPhone(contact, p.CellPhone, "c ");
            AddPhone(contact, p.WorkPhone, "w ");
            AddLine(contact, p.EmailAddress);
            c1.Add(new Chunk(contact.ToString(), font));
            t.AddCell(c1);

            var c2 = new Phrase($"{p.DOB} ({p.Age}, {(p.GenderId == 1 ? "M" : p.GenderId == 2 ? "F" : "U")})\n", font);
            c2.Add(new Chunk(cv.MemberStatusCodes().ItemValue(p.MemberStatusId), font));
            t.AddCell(c2);


            var c3 = new Phrase((
                p.PositionInFamilyId == 10 ? "Primary Adult" :
                    p.PositionInFamilyId == 20 ? "Secondary Adult" :
                        "Child") + "\n", font);
            if (p.BibleFellowshipClassId.HasValue)
            {
                c3.Add(new Chunk(p.BFClass.OrganizationName, font));
                if (p.BFClass.LeaderName.HasValue())
                    c3.Add(new Chunk($" ({p.BFClass.LeaderName})", smallfont));
            }
            t.AddCell(c3);
        }
Beispiel #13
0
        public ActionResult Select(int id, SearchAddModel m)
        {
            if (m.List.AsEnumerable().Any(li => li.PeopleId == id))
                return View("List", m);

            var cv = new CodeValueModel();
            var p = DbUtil.Db.LoadPersonById(id);
            var s = new SearchPersonModel
            {
                PeopleId = id,
                FamilyId = m.type == "family" ? m.typeid.ToInt() : p.FamilyId,
                First = p.FirstName,
                GoesBy = p.NickName,
                Last = p.LastName,
                Marital = new CodeInfo(p.MaritalStatusId, "Marital"),
                Email = p.EmailAddress,
                Suffix = p.SuffixCode,
                Title = new CodeInfo(p.TitleCode, "Title"),
                dob = p.DOB,
                Gender = new CodeInfo(p.GenderId, "Gender"),
                Phone = p.CellPhone,
                context = m.type,
                EntryPoint = new CodeInfo(p.EntryPointId, "EntryPoint"),
                Campus = new CodeInfo(p.CampusId, "Campus"),
                BeenValidated = true
            };
            s.LoadAddress();
            m.List.Add(s);
            if (m.OnlyOne)
                return CommitAdd(m);
            ModelState.Clear();
            return View("List", m);
        }
Beispiel #14
0
 public IEnumerable<SelectListItem> TaskStatusCodes()
 {
     var c = new CodeValueModel();
     return top.Union(c.TaskStatusCodes().Select(cv =>
         new SelectListItem {Text = cv.Value, Value = cv.Id.ToString()}));
     ;
 }
Beispiel #15
0
 public string JsonStatusCodes()
 {
     var cv = new CodeValueModel();
     var sb = new StringBuilder("{");
     foreach (var c in cv.TaskStatusCodes())
     {
         if (sb.Length > 1)
             sb.Append(",");
         sb.AppendFormat("'{0}':'{1}'", c.Value, c.Value);
     }
     sb.Append("}");
     return sb.ToString();
 }
Beispiel #16
0
 public static IEnumerable<SelectListItem> MemberStatuses()
 {
     var cv = new CodeValueModel();
     return CodeValueModel.ConvertToSelect(cv.MemberStatusCodes(), "Id");
 }
Beispiel #17
0
 public static IEnumerable<SelectListItem> GenderCodes()
 {
     var cv = new CodeValueModel();
     return CodeValueModel.ConvertToSelect(cv.GenderCodes(), "Id");
 }
Beispiel #18
0
 public static IEnumerable<SelectListItem> Campuses()
 {
     var cv = new CodeValueModel();
     return CodeValueModel.ConvertToSelect(cv.AllCampuses0(), "Id");
 }
Beispiel #19
0
 public void SetStatus(int id, string value)
 {
     var task = DbUtil.Db.Tasks.Single(t => t.Id == id);
     var cvc = new CodeValueModel();
     var ts = cvc.TaskStatusCodes();
     var statusid = ts.Single(t => t.Value == value).Id;
     var sb = new StringBuilder();
     ChangeTask(sb, task, "StatusId", statusid);
     NotifyIfNeeded(sb, task);
     DbUtil.Db.SubmitChanges();
 }
Beispiel #20
0
        public void EditCondition()
        {
            var c = Selected;
            if (c == null)
                return;
            SetVisibility();

            ConditionName = c.FieldInfo.Name;
            CompareData = Comparisons().ToList();
            Comparison = c.Comparison;

            if (QuartersVisible)
                QuartersLabel = fieldMap.QuartersTitle;
            if (TagsVisible)
            {
                var cv = new CodeValueModel();
                TagData = CodeValueModel.ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Code");
            }
            if (PmmLabelsVisible)
            {
                PmmLabelData = CodeValueModel.ConvertToSelect(CodeValueModel.PmmLabels(), "Code");
            }

            var cvctl = new CodeValueModel();
            switch (fieldMap.Type)
            {
                case FieldType.Bit:
                case FieldType.NullBit:
                    CodeData = CodeValueModel.ConvertToSelect(BitCodes, fieldMap.DataValueField);
                    break;
                case FieldType.NullCode:
                case FieldType.Code:
                case FieldType.CodeStr:
                    if (fieldMap.DataSource == "ExtraValues")
                    {
                        CodeData = StandardExtraValues.ExtraValueCodes();
                    }
                    else if (fieldMap.DataSource == "FamilyExtraValues")
                        CodeData = StandardExtraValues.FamilyExtraValueCodes();
                    else if (fieldMap.DataSource == "Campuses")
                        CodeData = Campuses();
                    else if (fieldMap.DataSource == "Activities")
                    {
                        var ret = (from e in DbUtil.Db.CheckInActivities select e.Activity).Distinct();
                        CodeData = from e in ret
                                   select new SelectListItem() { Text = e, Value = e };
                    }
                    else
                        CodeData = CodeValueModel.ConvertToSelect(Util.CallMethod(cvctl, fieldMap.DataSource), fieldMap.DataValueField);
                    break;
                case FieldType.DateField:
                    CodeData = CodeValueModel.ConvertToSelect(Util.CallMethod(cvctl, fieldMap.DataSource), fieldMap.DataValueField);
                    break;
            }

            if (fieldMap.Type == FieldType.Group)
            {
                CompareData = Comparisons().ToList();
                UpdateEnabled = c.IsGroup;
            }
            else
            {
                UpdateEnabled = !c.IsGroup && !c.IsFirst;
                AddToGroupEnabled = c.IsGroup;
                AddEnabled = !c.IsFirst;
                RemoveEnabled = !c.IsFirst;
            }
            switch (c.FieldInfo.Type)
            {
                case FieldType.String:
                case FieldType.StringEqual:
                case FieldType.StringEqualOrStartsWith:
                    TextValue = c.TextValue;
                    break;
                case FieldType.Integer:
                case FieldType.IntegerSimple:
                case FieldType.IntegerEqual:
                case FieldType.NullInteger:
                    IntegerValue = c.TextValue;
                    break;
                case FieldType.Number:
                case FieldType.NumberLG:
                case FieldType.NullNumber:
                    NumberValue = c.TextValue;
                    break;
                case FieldType.Date:
                case FieldType.DateSimple:
                    DateValue = DateString(c.DateValue);
                    break;
                case FieldType.Code:
                case FieldType.NullCode:
                case FieldType.CodeStr:
                case FieldType.DateField:
                case FieldType.Bit:
                case FieldType.NullBit:
                    CodeValue = c.CodeIdValue;
                    if (c.HasMultipleCodes && CodeValue.HasValue())
                    {
                        CodeValues = c.CodeIdValue.Split(';');
                        foreach (var i in CodeData)
                            i.Selected = CodeValues.Contains(i.Value);
                    }
                    break;
            }
            Program = c.Program;
            DivisionData = Divisions(Program).ToList();
            Division = c.Division;
            OrganizationData = Organizations(Division).ToList();
            Organization = c.Organization;
            Schedule = c.Schedule;
            Campus = c.Campus;
            OrgType = c.OrgType;
            StartDate = DateString(c.StartDate);
            EndDate = DateString(c.EndDate);
            AddToGroupEnabled = c.IsGroup;
            AddEnabled = !c.IsFirst;
            RemoveEnabled = !c.IsFirst;
            Days = c.Days.ToString();
            Age = c.Age.ToString();
            Quarters = c.Quarters;
            if (TagsVisible)
            {
                if (c.Tags != null)
                    Tags = c.Tags.Split(';');
                var cv = new CodeValueModel();
                TagData = CodeValueModel.ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Code");
                foreach (var i in TagData)
                    i.Selected = Tags.Contains(i.Value);
            }
            if (PmmLabelsVisible)
            {
                if (c.Tags != null)
                    PmmLabels = c.Tags.Split(',').Select(vv => vv).ToArray();
                var cv = new CodeValueModel();
                PmmLabelData = CodeValueModel.ConvertToSelect(CodeValueModel.PmmLabels(), "Id");
                if (PmmLabels != null)
                    foreach (var i in PmmLabelData)
                        i.Selected = PmmLabels.Contains(i.Value);
            }
            if (MinistryVisible)
                Ministry = c.Program;
            //SavedQueryDesc = c.SavedQueryIdDesc;
        }
Beispiel #21
0
 public IEnumerable<CodeValueItem> Tags()
 {
     var up = DbUtil.Db.CurrentUserPerson;
     if (up == null)
         return new List<CodeValueItem>();
     var ctl = new CodeValueModel();
     var pid = DbUtil.Db.CurrentUser.PeopleId;
     var list = ctl.UserTags(pid);
     return list;
 }
Beispiel #22
0
        public void SetVisibility()
        {
            CodeData = null;
            ConditionName = ConditionName;
            CompareData = Comparisons().ToList();
            if (QuartersVisible)
                QuartersLabel = fieldMap.QuartersTitle;
            if (TagsVisible)
            {
                var cv = new CodeValueModel();
                TagData = CodeValueModel.ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Code");
            }
            if (PmmLabelsVisible)
            {
                var cv = new CodeValueModel();
                PmmLabelData = CodeValueModel.ConvertToSelect(CodeValueModel.PmmLabels(), "Code");
            }

            var cvctl = new CodeValueModel();
            switch (fieldMap.Type)
            {
                case FieldType.Bit:
                case FieldType.NullBit:
                    CodeData = CodeValueModel.ConvertToSelect(BitCodes, fieldMap.DataValueField);
                    break;
                case FieldType.NullCode:
                case FieldType.Code:
                case FieldType.CodeStr:
                    if (fieldMap.DataSource == "ExtraValues")
                        CodeData = StandardExtraValues.ExtraValueCodes();
                    else if (fieldMap.DataSource == "Campuses")
                        CodeData = Campuses();
                          else if( fieldMap.DataSource == "Activities" )
                          {
                              var ret = ( from e in DbUtil.Db.CheckInActivities select e.Activity ).Distinct();
                              CodeData = from e in ret
                                  select new SelectListItem() {Text = e, Value = e};
                          }
                          else
                              CodeData = CodeValueModel.ConvertToSelect( Util.CallMethod( cvctl, fieldMap.DataSource ), fieldMap.DataValueField );
                    break;
                case FieldType.DateField:
                    CodeData = CodeValueModel.ConvertToSelect(Util.CallMethod(cvctl, fieldMap.DataSource), fieldMap.DataValueField);
                    break;
            }
            var cc = Selected;
            if (cc == null)
                return;

            if (fieldMap.Type == FieldType.Group)
            {
                CompareData = Comparisons().ToList();
                UpdateEnabled = cc.IsGroup;
                return;
            }
            UpdateEnabled = !cc.IsGroup && !cc.IsFirst;
            AddToGroupEnabled = cc.IsGroup;
            AddEnabled = !cc.IsFirst;
            RemoveEnabled = !cc.IsFirst;
        }
 public ActionResult ConvertToQuery(ContactSearchModel m)
 {
     var qb = DbUtil.Db.QueryBuilderScratchPad();
     qb.CleanSlate(DbUtil.Db);
     var comp = CompareType.Equal;
     var clause = qb.AddNewClause(QueryType.MadeContactTypeAsOf, comp, "1,T");
     clause.Program = m.Ministry ?? 0;
     clause.StartDate = m.StartDate ?? DateTime.Parse("1/1/2000");
     clause.EndDate = m.EndDate ?? DateTime.Today;
     var cvc = new CodeValueModel();
     var q = from v in cvc.ContactTypeCodes0()
             where v.Id == m.ContactType
             select v.IdCode;
     var idvalue = q.Single();
     clause.CodeIdValue = idvalue;
     DbUtil.Db.SubmitChanges();
     return Redirect("/QueryBuilder/Main/{0}".Fmt(qb.QueryId));
 }
Beispiel #24
0
        private List GetContacts(Person p)
        {
            var ctl = new CodeValueModel();
            var cts = ctl.ContactTypeCodes();

            var cq = from ce in DbUtil.Db.Contactees
                     where ce.PeopleId == p.PeopleId
                     where (ce.contact.LimitToRole ?? "") == ""
                     orderby ce.contact.ContactDate descending
                     select new
                     {
                         ce.contact,
                         madeby = ce.contact.contactsMakers.FirstOrDefault().person,
                     };
            var list = new iTextSharp.text.List(false, 10);
            list.ListSymbol = new Chunk("\u2022", font);
            var ep = p.EntryPoint != null ? p.EntryPoint.Description : "";
            var ip = p.InterestPoint != null ? p.InterestPoint.Description : "";
            if (ep.HasValue() || ip.HasValue())
                list.Add(new iTextSharp.text.ListItem(1.2f * font.Size, "Entry, Interest: {0}, {1}".Fmt(ep, ip), font));
            foreach (var pc in cq.Take(10))
            {
                var cname = "unknown";
                if (pc.madeby != null)
                    cname = pc.madeby.Name;
                string ctype = cts.ItemValue(pc.contact.ContactTypeId);
                string comments = null;
                if (pc.contact.Comments.HasValue())
                {
                    comments = pc.contact.Comments.Replace("\r\n\r\n", "\r\n");
                    var lines = Regex.Split(comments, "\r\n");
                    comments = string.Join("\r\n", lines.Take(6));
                    if (lines.Length > 6)
                        comments += "... (see rest of comment online)";
                }
                string s = "{0:d}: {1} by {2}\n{3}".Fmt(
                        pc.contact.ContactDate, ctype, cname, comments);
                list.Add(new iTextSharp.text.ListItem(1.2f * font.Size, s, font));
            }
            if (cq.Count() > 10)
                list.Add(new ListItem(1.2f * font.Size, "(showing most recent 10 of {0})".Fmt(cq.Count()), font));
            return list;
        }
Beispiel #25
0
        public static IEnumerable<ExtraInfo> CodeSummary()
        {
            var NameTypes = Views.GetViewableNameTypes(DbUtil.Db, "People", nocache: true);
            var standardtypes = new CodeValueModel().ExtraValueTypeCodes();
            var adhoctypes = new CodeValueModel().AdhocExtraValueTypeCodes();

            var qcodevalues = (from e in DbUtil.Db.PeopleExtras
                               where e.Type == "Bit" || e.Type == "Code"
                               group e by new
                               {
                                   e.Field,
                                   val = e.StrValue ?? (e.BitValue == true ? "1" : "0"),
                                   e.Type,
                               } into g
                               select new { key = g.Key, count = g.Count() }).ToList();

            var qcodes = from i in qcodevalues
                         join sv in NameTypes on i.key.Field equals sv.Name into j
                         from sv in j.DefaultIfEmpty()
                         let type = sv == null ? i.key.Type : sv.Type
                         let typedisplay = sv == null
                                ? adhoctypes.Single(ee => ee.Code == type).Value
                                : standardtypes.Single(ee => ee.Code == type).Value
                         select new ExtraInfo
                         {
                             Field = i.key.Field,
                             Value = i.key.val,
                             Type = i.key.Type,
                             TypeDisplay = typedisplay,
                             Standard = sv != null,
                             Count = i.count,
                             CanView = sv == null || sv.CanView
                         };

            var qdatavalues = (from e in DbUtil.Db.PeopleExtras
                               where !(e.Type == "Bit" || e.Type == "Code")
                               where e.Type != "CodeText"
                               group e by new
                               {
                                   e.Field,
                                   e.Type,
                               } into g
                               select new { key = g.Key, count = g.Count() }).ToList();

            var qdatums = from i in qdatavalues
                          join sv in NameTypes on i.key.Field equals sv.Name into j
                          from sv in j.DefaultIfEmpty()
                          let type = sv == null ? i.key.Type : sv.Type
                          let typedisplay = sv == null
                                ? adhoctypes.SingleOrDefault(ee => ee.Code == type)
                                : standardtypes.SingleOrDefault(ee => ee.Code == type)
                          select new ExtraInfo
                          {
                              Field = i.key.Field,
                              Value = "(multiple)",
                              Type = i.key.Type,
                              TypeDisplay = typedisplay == null ? (type ?? "unknown") : typedisplay.Value,
                              Standard = sv != null,
                              Count = i.count,
                              CanView = sv == null || sv.CanView
                          };

            return qcodes.Union(qdatums).OrderBy(ee => ee.Field);
        }
Beispiel #26
0
        private List GetContacts(int pid)
        {
            var ctl = new CodeValueModel();
            var cts = ctl.ContactTypeCodes();

            var cq = from ce in DbUtil.Db.Contactees
                     where ce.PeopleId == pid
                     orderby ce.contact.ContactDate descending
                     select new
                     {
                         contact = ce.contact,
                         madeby = ce.contact.contactsMakers.FirstOrDefault().person,
                     };
            var list = new iTextSharp.text.List(false, 10);
            list.ListSymbol = new Chunk("\u2022", font);
            var epip = (from p in DbUtil.Db.People
                       where p.PeopleId == pid
                       select new
                       {
                           ep = p.EntryPoint != null ? p.EntryPoint.Description : "",
                           ip = p.InterestPoint != null ? p.InterestPoint.Description : ""
                       }).Single();
            if (epip.ep.HasValue() || epip.ip.HasValue())
                list.Add(new ListItem(1.2f * font.Size, "Entry, Interest: {0}, {1}".Fmt(epip.ep, epip.ip), font));
            const int maxcontacts = 4;
            foreach (var pc in cq.Take(maxcontacts))
            {
                var cname = "unknown";
                if (pc.madeby != null)
                    cname = pc.madeby.Name;
                string ctype = cts.Single(ct => ct.Id == pc.contact.ContactTypeId).Value;
                string comments = null;
                if (pc.contact.Comments.HasValue())
                    comments = pc.contact.Comments.Replace("\r\n\r\n", "\r\n");
                string s = "{0:d}: {1} by {2}\n{3}".Fmt(
                        pc.contact.ContactDate, ctype, cname, comments);
                list.Add(new iTextSharp.text.ListItem(1.2f * font.Size, s, font));
            }
            if (cq.Count() > maxcontacts)
                list.Add(new ListItem(1.2f * font.Size, "(showing most recent 10 of {0})".Fmt(cq.Count()), font));

            return list;
        }
Beispiel #27
0
 public SelectList GenderList()
 {
     var cv = new CodeValueModel();
     return new SelectList(cv.GenderCodes(), "Id", "Value");
 }
Beispiel #28
0
 public IEnumerable<SelectListItem> StateCodes()
 {
     var cv = new CodeValueModel();
     return CodeValueModel.ConvertToSelect(cv.GetStateListUnknown(), "Code");
 }
Beispiel #29
0
 public static IEnumerable<SelectListItem> Tags()
 {
     var cv = new CodeValueModel();
     var tg = ConvertToSelect(cv.UserTags(Util.UserPeopleId), "Id").ToList();
     if (HttpContext.Current.User.IsInRole("Edit"))
         tg.Insert(0, new SelectListItem {Value = "-1", Text = "(last query)"});
     tg.Insert(0, new SelectListItem {Value = "0", Text = "(not specified)"});
     return tg;
 }
Beispiel #30
0
        private static void UpdatePeople(DbConnection cn, CMSDataContext Db, int userPeopleId)
        {
            var cv = new CodeValueModel();
            var pcmd = cn.CreateCommand();
            pcmd.CommandText = "select * from [Sheet1$]";
            var rd = pcmd.ExecuteReader();
            while (rd.Read())
            {
                var i = Util.GetAs(rd, typeof(UpdatePeopleItem)) as UpdatePeopleItem;
                var p = Db.LoadPersonById(i.PeopleId);

                //var psb = new StringBuilder();
                var psb = new List<ChangeDetail>();

                p.UpdateValue(psb, "TitleCode", i.Title);
                p.UpdateValue(psb, "FirstName", i.First);
                p.UpdateValue(psb, "NickName", i.GoesBy);
                p.UpdateValue(psb, "LastName", i.Last);
                p.UpdateValue(psb, "SuffixCode", i.Suffix);
                p.UpdateValue(psb, "EmailAddress", i.Email1);
                p.UpdateValue(psb, "EmailAddress2", i.Email2);
                p.UpdateValue(psb, "DOB", i.BirthDate.FormatDate());
                p.UpdateValue(psb, "WeddingDate", i.Anniversary);
                p.UpdateValue(psb, "JoinDate", i.Joined);
                p.UpdateValue(psb, "CellPhone", i.Cell.GetDigits());
                p.UpdateValue(psb, "WorkPhone", i.Work.GetDigits());
                p.UpdateValue(psb, "AltName", i.AltName);
                p.UpdateValue(psb, "SchoolOther", i.School);
                p.UpdateValue(psb, "OccupationOther", i.Occupation);
                p.UpdateValue(psb, "EmployerOther", i.Employer);
                p.UpdateValue(psb, "Grade", i.Grade);
                p.UpdateValue(psb, "DeceasedDate", i.Deceased);

                p.UpdateValue(psb, "MemberStatusId", CviOrNull(cv.MemberStatusCodes().SingleOrDefault(c => c.Value == i.Member)) ?? 20);
                p.UpdateValue(psb, "GenderId", CviOrNull(cv.GenderCodes().SingleOrDefault(c => c.Value == i.Gender)) ?? 0);
                p.UpdateValue(psb, "MaritalStatusId", CviOrNull(cv.MaritalStatusCodes().SingleOrDefault(c => c.Value == i.Marital)) ?? 0);
                p.UpdateValue(psb, "PositionInFamilyId", CviOrNull(cv.FamilyPositionCodes().SingleOrDefault(c => c.Value == i.FamilyPos)) ?? 0);
                p.UpdateValue(psb, "CampusId", CviOrNull(cv.AllCampuses().SingleOrDefault(c => c.Value == i.Campus)));
               
                p.LogChanges(Db, psb);
                Db.SubmitChanges();
            }
        }