예제 #1
0
        private string getParentsField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance)
        {
            CmsData.Person person = cacheSet.getPerson(attendance.peopleID);

            if (person == null)
            {
                return("");
            }

            CmsData.Family family = cacheSet.getFamily(person.FamilyId);

            if (family == null)
            {
                return("");
            }

            CmsData.Person head   = cacheSet.getPerson(family.HeadOfHouseholdId ?? 0);
            CmsData.Person spouse = cacheSet.getPerson(family.HeadOfHouseholdSpouseId ?? 0);

            if (head == null && spouse == null)
            {
                return("");
            }

            switch (field)
            {
            case LabelField.PARENTS_NAME:
                List <string> names = new List <string>();

                if (head != null)
                {
                    names.Add(head.FirstName);
                }

                if (spouse != null)
                {
                    names.Add(spouse.FirstName);
                }

                return(string.Format(format, string.Join(", ", names)));

            case LabelField.PARENTS_PHONE:
                List <string> phones = new List <string>();

                if (head != null && !head.CellPhone.IsEmpty())
                {
                    phones.Add(head.FirstName + ": " + head.CellPhone);
                }

                if (spouse != null && !spouse.CellPhone.IsEmpty())
                {
                    phones.Add(spouse.FirstName + ": " + spouse.CellPhone);
                }

                return(string.Format(format, string.Join(", ", phones)));

            default:
                return("");
            }
        }
예제 #2
0
        public ActionResult AddPerson(int id, PersonInfo m)
        {
            if (!Authenticate())
                return Content("not authorized");
            DbUtil.LogActivity("checkin AddPerson {0} {1} ({2})".Fmt(m.first, m.last, m.dob));

            CmsData.Family f;
            if (id > 0)
                f = DbUtil.Db.Families.Single(fam => fam.FamilyId == id);
            else
                f = new CmsData.Family();

            var position = PositionInFamily.Child;
            if (Util.Age0(m.dob) >= 18)
                if (f.People.Count(per =>
                     per.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                     < 2)
                    position = PositionInFamily.PrimaryAdult;
                else
                    position = PositionInFamily.SecondaryAdult;

            var p = Person.Add(f, position,
                null, m.first, m.goesby, m.last, m.dob, false, m.gender,
                    OriginCode.Visit, null);

            UpdatePerson(p, m, isNew: true);
            return Content(f.FamilyId.ToString() + "." + p.PeopleId);
        }
예제 #3
0
        public CheckInFamilyInfo(Family family)
        {
            last = family.HeadOfHousehold.LastName;

            homePhone = family.HomePhone;

            address = family.AddressLineOne;
            address2 = family.AddressLineTwo;
            city = family.CityName;
            state = family.StateCode;
            zip = family.ZipCode;
            country = family.CountryName;
        }
예제 #4
0
        public ActionResult AddPerson(int id, PersonInfo m)
        {
            if (!AccountModel.AuthenticateMobile())
                return Content("not authorized");

            CmsData.Family f;
            if (m.addtofamilyid > 0)
                f = DbUtil.Db.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid));
            else
                f = new CmsData.Family();

            if (m.goesby == "(Null)")
                m.goesby = null;
            var position = PositionInFamily.Child;
            if (m.dob.Age0() >= 18)
                if (f.People.Count(per =>
                     per.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                     < 2)
                    position = PositionInFamily.PrimaryAdult;
                else
                    position = PositionInFamily.SecondaryAdult;

            var p = Person.Add(f, position,
                null, Trim(m.first), Trim(m.goesby), Trim(m.last), m.dob, false, m.gender,
                    OriginCode.Visit, null);

            var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5());
            if (!m.home.HasValue() && m.cell.HasValue())
                m.home = m.cell;

            if (m.addtofamilyid == 0)
            {
                p.Family.HomePhone = m.home.GetDigits();
                p.Family.AddressLineOne = m.addr;
                p.Family.CityName = z != null ? z.City : null;
                p.Family.StateCode = z != null ? z.State : null;
                p.Family.ZipCode = m.zip;
            }
            p.EmailAddress = Trim(m.email);
            if (m.cell.HasValue())
                p.CellPhone = m.cell.GetDigits();
            p.MaritalStatusId = m.marital;
            p.GenderId = m.gender;
            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity("iPhone AddPerson {0}".Fmt(p.PeopleId));
            var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == id);
            Attend.RecordAttendance(p.PeopleId, id, true);
            DbUtil.Db.UpdateMeetingCounters(id);
            return new RollListResult(meeting, p.PeopleId);
        }
예제 #5
0
        public ActionResult AddPerson(int id, PersonInfo m)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }
            DbUtil.LogActivity("checkin AddPerson {0} {1} ({2})".Fmt(m.first, m.last, m.dob));

            CmsData.Family f;
            if (id > 0)
            {
                f = DbUtil.Db.Families.Single(fam => fam.FamilyId == id);
            }
            else
            {
                f = new CmsData.Family();
            }

            var position = PositionInFamily.Child;

            if (Util.Age0(m.dob) >= 18)
            {
                if (f.People.Count(per =>
                                   per.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                    < 2)
                {
                    position = PositionInFamily.PrimaryAdult;
                }
                else
                {
                    position = PositionInFamily.SecondaryAdult;
                }
            }

            var p = Person.Add(f, position,
                               null, m.first, m.goesby, m.last, m.dob, false, m.gender,
                               OriginCode.Visit, null);

            UpdatePerson(p, m);
            return(Content(f.FamilyId.ToString() + "." + p.PeopleId));
        }
예제 #6
0
파일: Family.cs 프로젝트: lightyeare/bvcms
        private void loadPicture(CMSDataContext cmsdb, CMSImageDataContext cmsidb)
        {
            CmsData.Family family = cmsdb.Families.SingleOrDefault(f => f.FamilyId == id);
            int?           ImageId;

            if (family == null || family.Picture == null)
            {
                ImageId = CmsData.Picture.SmallMissingGenericId;
            }
            else
            {
                ImageId = family.Picture.SmallId;
            }

            Image image = cmsidb.Images.SingleOrDefault(i => i.Id == ImageId);

            if (image != null)
            {
                picture = Convert.ToBase64String(image.Bits);
            }
        }
예제 #7
0
 private void UpdateField(List<ChangeDetail> fsb, Family f, string prop, string value)
 {
     f.UpdateValue(fsb, prop, value);
 }
예제 #8
0
 private void SetField(Family f, string[] a, string prop, string s)
 {
     if (names.ContainsKey(s))
         if (a[names[s]].HasValue())
             Util.SetProperty(f, prop, a[names[s]]);
 }
예제 #9
0
        internal void AddPerson(int originid, int? entrypointid, int? campusid)
        {
            Family f;
            string na = "na";
            if (FamilyId > 0)
                f = family;
            else
                f = new Family
                        {
                            HomePhone = HomePhone.GetDigits(),
                            AddressLineOne = AddressInfo.Address1.Disallow(na),
                            AddressLineTwo = AddressInfo.Address2,
                            CityName = AddressInfo.City.Disallow(na),
                            StateCode = AddressInfo.State.Value.Disallow(na),
                            ZipCode = AddressInfo.Zip.Disallow(na),
                            CountryName = AddressInfo.Country.Value,
                        };

            if (GoesBy != null)
                GoesBy = GoesBy.Trim();
            var position = PositionInFamily.Child;
            if (!birthday.HasValue)
                position = PositionInFamily.PrimaryAdult;
            if (age >= 18)
                if (f.People.Count(per =>
                                   per.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                    < 2)
                    position = PositionInFamily.PrimaryAdult;
                else
                    position = PositionInFamily.SecondaryAdult;

            _Person = CmsData.Person.Add(f, position,
                                 null, First.Trim(), GoesBy, Last.Trim(), dob, false, Gender.Value.ToInt(),
                                 originid, entrypointid);
            if (Title.Value.HasValue())
                person.TitleCode = Title.Value;
            person.EmailAddress = Email.Disallow(na);
            person.MaritalStatusId = Marital.Value.ToInt();
            person.SuffixCode = Suffix;
            person.MiddleName = Middle;
            if (campusid == 0)
                campusid = null;
            person.CampusId = Util.PickFirst(campusid.ToString(), DbUtil.Db.Setting("DefaultCampusId", "")).ToInt2();
            if (person.CampusId == 0)
                person.CampusId = null;

            person.CellPhone = Phone.GetDigits();
            DbUtil.Db.SubmitChanges();
            DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, person);
            PeopleId = person.PeopleId;
        }
예제 #10
0
파일: Person.cs 프로젝트: alexserdyuk/bvcms
        public static Person Add(CMSDataContext Db, bool SendNotices, Family fam, int position, Tag tag, string firstname, string nickname, string lastname, string dob, int MarriedCode, int gender, int originId, int? EntryPointId, bool testing = false)
        {
            var p = new Person();
            p.CreatedDate = Util.Now;
            p.CreatedBy = Util.UserId;
            Db.People.InsertOnSubmit(p);
            p.PositionInFamilyId = position;
            p.AddressTypeId = 10;

            if (Util.HasValue(firstname))
                p.FirstName = firstname.Trim().ToProper().Truncate(25);
            else
                p.FirstName = "";

            if (Util.HasValue(nickname))
                p.NickName = nickname.Trim().ToProper().Truncate(15);

            if (Util.HasValue(lastname))
                p.LastName = lastname.Trim().ToProper().Truncate(30);
            else
                p.LastName = "?";

            p.GenderId = gender;
            if (p.GenderId == 99)
                p.GenderId = 0;
            p.MaritalStatusId = MarriedCode;

            DateTime dt;
            if (Util.BirthDateValid(dob, out dt))
            {
                if (dt.Year == Util.SignalNoYear)
                {
                    p.BirthDay = dt.Day;
                    p.BirthMonth = dt.Month;
                    p.BirthYear = null;
                }
                else
                {
                    while (dt.Year < 1900)
                        dt = dt.AddYears(100);
                    if (dt > Util.Now)
                        dt = dt.AddYears(-100);
                    p.BirthDay = dt.Day;
                    p.BirthMonth = dt.Month;
                    p.BirthYear = dt.Year;
                }
                if (p.GetAge() < 18 && MarriedCode == 0)
                    p.MaritalStatusId = MaritalStatusCode.Single;
            }
                // I think this else statement is no longer necessary
            else if (DateTime.TryParse(dob, out dt))
            {
                p.BirthDay = dt.Day;
                p.BirthMonth = dt.Month;
                if (Regex.IsMatch(dob, @"\d+[-/]\d+[-/]\d+"))
                {
                    p.BirthYear = dt.Year;
                    while (p.BirthYear < 1900)
                        p.BirthYear += 100;
                    if (p.GetAge() < 18 && MarriedCode == 0)
                        p.MaritalStatusId = MaritalStatusCode.Single;
                }
            }

            p.MemberStatusId = MemberStatusCode.JustAdded;
            if (fam == null)
            {
                fam = new Family();
                Db.Families.InsertOnSubmit(fam);
                p.Family = fam;
            }
            else
                fam.People.Add(p);

            if (tag != null)
                tag.PersonTags.Add(new TagPerson { Person = p });

            p.OriginId = originId;
            p.EntryPointId = EntryPointId;
            p.FixTitle();
            if(Db.Setting("ElectronicStatementDefault", "false").Equal("true"))
                p.ElectronicStatement = true;
            if (!testing)
                Db.SubmitChanges();
            if (SendNotices)
            {
                if (Util.UserPeopleId.HasValue
                    && Util.UserPeopleId.Value != Db.NewPeopleManagerId
                    && HttpContext.Current.User.IsInRole("Access")
                    && !HttpContext.Current.User.IsInRole("OrgMembersOnly")
                    && !HttpContext.Current.User.IsInRole("OrgLeadersOnly"))
                    Task.AddNewPerson(Db, p.PeopleId);
                else
                {
                    var np = Db.GetNewPeopleManagers();
                    if (np != null)
                        Db.Email(Util.SysFromEmail, np,
                            $"Just Added Person on {Db.Host}",
                            $"<a href='{Db.ServerLink("/Person2/" + p.PeopleId)}'>{p.Name}</a>");
                }
            }
            return p;
        }
예제 #11
0
        public bool DoUpload(string text, bool testing = false)
        {
            var rt = Db2.UploadPeopleRuns.OrderByDescending(mm => mm.Id).First();
            var csv = new CsvReader(new StringReader(text), false, '\t');
            var list = csv.ToList();

            var list0 = list.First().Select(kk => kk).ToList();
            names = list0.ToDictionary(i => i.TrimEnd(),
                i => list0.FindIndex(s => s == i), StringComparer.OrdinalIgnoreCase);

            if (names.ContainsKey("campus"))
            {
                var campuslist = (from li in list.Skip(1)
                                  where li.Length == names.Count
                                  group li by li[names["campus"]]
                                  into campus
                                  where campus.Key.HasValue()
                                  select campus.Key).ToList();
                var dbc = from c in campuslist
                          join cp in Db.Campus on c equals cp.Description into j
                          from cp in j.DefaultIfEmpty()
                          select new {cp, c};
                var clist = dbc.ToList();
                if (clist.Count > 0)
                {
                    var maxcampusid = 0;
                    if (Db.Campus.Any())
                        maxcampusid = Db.Campus.Max(c => c.Id);
                    foreach (var i in clist)
                        if (i.cp == null)
                        {
                            var cp = new Campu {Description = i.c, Id = ++maxcampusid};
                            if (!testing)
                                Db.Campus.InsertOnSubmit(cp);
                        }
                }
            }
            var now = DateTime.Now;
            if (!testing)
                Db.SubmitChanges();
            Campuses = Db.Campus.ToDictionary(cp => cp.Description, cp => cp.Id);

            var q = (from li in list.Skip(1)
                     where li.Length == names.Count
                     group li by li[names["familyid"]]
                     into fam
                     select fam).ToList();
            rt.Count = q.Sum(ff => ff.Count());
            Db2.SubmitChanges();

            var standardnames = new List<string>
            {
                "familyid", "title", "first", "last", "goesby", "altname", "gender", "marital", "maidenName",
                "address", "address2", "city", "state", "zip", "position", "birthday", "cellphone", "homephone",
                "workphone", "email", "email2", "suffix", "middle", "joindate", "dropdate", "baptismdate", "weddingdate",
                "memberstatus", "employer", "occupation"
            };
            var orgs = new Dictionary<string, int>();
            var membertypes = new Dictionary<string, int>();

            foreach (var fam in q)
            {
                Family f = null;

                FindPerson3 pid;
                Person p = null;
                foreach (var a in fam)
                {
                    var potentialdup = false;
                    var first = a[names["first"]];
                    var last = a[names["last"]];
                    DateTime dt;
                    DateTime? dob = null;
                    if (names.ContainsKey("birthday"))
                        if (DateTime.TryParse(a[names["birthday"]], out dt))
                        {
                            dob = dt;
                            if (dob.Value < SqlDateTime.MinValue)
                                dob = null;
                        }
                    string email = null;
                    string cell = null;
                    string homephone = null;
                    if (names.ContainsKey("email"))
                        email = a[names["email"]].Trim();
                    if (names.ContainsKey("cellphone"))
                        cell = a[names["cellphone"]].GetDigits();
                    if (names.ContainsKey("homephone"))
                        homephone = a[names["homephone"]].GetDigits();
                    pid = Db.FindPerson3(first, last, dob, email, cell, homephone, null).FirstOrDefault();

                    if (noupdate && pid != null)
                    {
                        if (!testing)
                        {
                            var pd = Db.LoadPersonById(pid.PeopleId.Value);
                            pd.AddEditExtraBool("FoundDup", true);
                        }
                        potentialdup = true;
                        pid = null;
                    }

                    if (pid != null) // found
                    {
                        p = Db.LoadPersonById(pid.PeopleId.Value);
                        psb = new List<ChangeDetail>();
                        fsb = new List<ChangeDetail>();

                        UpdateField(p, a, "TitleCode", "title");
                        UpdateField(p, a, "FirstName", "first");
                        UpdateField(p, a, "NickName", "goesby");
                        UpdateField(p, a, "LastName", "last");
                        UpdateField(p, a, "EmailAddress", "email");
                        UpdateField(p, a, "EmailAddress2", "email2");
                        UpdateField(p, a, "DOB", "birthday");
                        UpdateField(p, a, "AltName", "altname");
                        UpdateField(p, a, "SuffixCode", "suffix");
                        UpdateField(p, a, "MiddleName", "middle");

                        UpdateField(p, a, "CellPhone", "cellphone", GetDigits(a, "cellphone"));
                        UpdateField(p, a, "WorkPhone", "workphone", GetDigits(a, "workphone"));
                        UpdateField(p, a, "GenderId", "gender", Gender(a));
                        UpdateField(p, a, "MaritalStatusId", "marital", Marital(a));
                        UpdateField(p, a, "PositionInFamilyId", "position", Position(a));
                        if (!testing)
                            UpdateField(p, a, "CampusId", "campus", Campus(a));

                        UpdateField(p.Family, a, "AddressLineOne", "address");
                        UpdateField(p.Family, a, "AddressLineTwo", "address2");
                        UpdateField(p.Family, a, "CityName", "city");
                        UpdateField(p.Family, a, "StateCode", "state");
                        UpdateField(p.Family, a, "ZipCode", "zip");

                        if (!testing)
                        {
                            p.LogChanges(Db, psb, PeopleId);
                            p.Family.LogChanges(Db, fsb, p.PeopleId, PeopleId);
                            Db.SubmitChanges();
                            p.AddEditExtraBool("InsertPeopleUpdated", true);
                        }
                    }
                    else // new person
                    {
                        if (f == null || !a[names["familyid"]].HasValue())
                        {
                            f = new Family();
                            SetField(f, a, "AddressLineOne", "address");
                            SetField(f, a, "AddressLineTwo", "address2");
                            SetField(f, a, "CityName", "city");
                            SetField(f, a, "StateCode", "state");
                            SetField(f, a, "ZipCode", "zip");
                            SetField(f, a, "HomePhone", "homephone", GetDigits(a, "homephone"));
                            Db.Families.InsertOnSubmit(f);
                            if (!testing)
                                Db.SubmitChanges();
                        }

                        string goesby = null;
                        if (names.ContainsKey("goesby"))
                            goesby = a[names["goesby"]];
                        p = Person.Add(Db, false, f, 10, null,
                            a[names["first"]],
                            goesby,
                            a[names["last"]],
                            dob.FormatDate(),
                            0, 0, 0, null, testing);
                        p.FixTitle();

                        SetField(p, a, "AltName", "altname");
                        SetField(p, a, "SuffixCode", "suffix");
                        SetField(p, a, "MiddleName", "middle");
                        SetField(p, a, "MaidenName", "maidenname");
                        SetField(p, a, "EmployerOther", "employer");
                        SetField(p, a, "OccupationOther", "occupation");
                        SetField(p, a, "CellPhone", "cellphone", GetDigits(a, "cellphone"));
                        SetField(p, a, "WorkPhone", "workphone", GetDigits(a, "workphone"));
                        SetField(p, a, "EmailAddress", "email");
                        SetField(p, a, "EmailAddress2", "email2");
                        SetField(p, a, "GenderId", "gender", Gender(a));
                        SetField(p, a, "MaritalStatusId", "marital", Marital(a));
                        SetField(p, a, "WeddingDate", "weddingdate", GetDate(p, a, "weddingdate"));
                        SetField(p, a, "JoinDate", "joindate", GetDate(p, a, "joindate"));
                        SetField(p, a, "DropDate", "dropdate", GetDate(p, a, "dropdate"));
                        SetField(p, a, "BaptismDate", "baptismdate", GetDate(p, a, "baptismdate"));
                        SetField(p, a, "PositionInFamilyId", "position", Position(a));
                        SetField(p, a, "TitleCode", "title", Title(a));
                        if (!testing)
                            SetField(p, a, "CampusId", "campus", Campus(a));

                        if (names.ContainsKey("memberstatus"))
                        {
                            var ms = a[names["memberstatus"]];
                            var qms = from mm in Db.MemberStatuses
                                      where mm.Description == ms
                                      select mm;
                            var m = qms.SingleOrDefault();
                            if (m == null)
                            {
                                var nx = Db.MemberStatuses.Max(mm => mm.Id) + 1;
                                m = new MemberStatus {Id = nx, Description = ms, Code = nx.ToString()};
                                Db.MemberStatuses.InsertOnSubmit(m);
                            }
                            p.MemberStatusId = m.Id;
                        }
                    }

                    var nq = from name in names.Keys
                             where !standardnames.Contains(name, StringComparer.OrdinalIgnoreCase)
                             select name;
                    foreach (var name in nq)
                    {
                        var b = name.Split('.');
                        if (name.EndsWith(".txt"))
                            p.AddEditExtraText(b[0], a[names[name]].Trim());
                        else if (name.EndsWith(".org"))
                        {
                            if (testing)
                                continue;
                            var d = a[names[name]].Trim().Trim();
                            if (!d.HasValue())
                                continue;
                            var oid = 0;
                            if (orgs.ContainsKey(b[0]))
                                oid = orgs[b[0]];
                            else
                            {
                                var org = Db.Organizations.First();
                                var o = org.CloneOrg(Db);
                                o.OrganizationName = b[0].SplitUpperCaseToString();
                                oid = o.OrganizationId;
                                orgs.Add(b[0], oid);
                            }
                            var mtid = 0;
                            if (membertypes.ContainsKey(d))
                                mtid = membertypes[d];
                            else
                            {
                                var mt = Organization.FetchOrCreateMemberType(Db, d);
                                mtid = mt.Id;
                                membertypes.Add(d, mtid);
                            }
                            OrganizationMember.InsertOrgMembers(Db, oid, p.PeopleId, mtid, DateTime.Today, null, false);
                        }
                        else if (name.EndsWith(".dt"))
                        {
                            var d = a[names[name]].Trim().ToDate();
                            if (d.HasValue)
                                p.AddEditExtraDate(b[0], d.Value);
                        }
                        else if (name.EndsWith(".int"))
                            p.AddEditExtraInt(b[0], a[names[name]].Trim().ToInt());
                        else if (name.EndsWith(".bit"))
                        {
                            var v = a[names[name]];
                            if (v.HasValue())
                                p.AddEditExtraBool(b[0], v.ToInt() == 1);
                        }
                        else
                            p.AddEditExtraCode(name, a[names[name]].Trim());
                    }
                    rt.Processed++;
                    Db2.SubmitChanges();
                    if (!testing)
                    {
                        p.AddEditExtraBool("InsertPeopleAdded", true);
                        if (potentialdup)
                            p.AddEditExtraBool("FoundDup", true);
                        Db.SubmitChanges();
                    }
                }
                if (!testing)
                    Db.SubmitChanges();
            }
            rt.Completed = DateTime.Now;
            Db2.SubmitChanges();
            return true;
        }
예제 #12
0
파일: Person.cs 프로젝트: alexserdyuk/bvcms
 public void SplitFamily(CMSDataContext db)
 {
     var f = new Family
     {
         CreatedDate = Util.Now,
         CreatedBy = Util.UserId1,
         AddressLineOne = PrimaryAddress,
         AddressLineTwo = PrimaryAddress2,
         CityName = PrimaryCity,
         StateCode = PrimaryState,
         ZipCode = PrimaryZip,
         HomePhone = Family.HomePhone
     };
     var oldf = this.FamilyId;
     f.People.Add(this);
     db.Families.InsertOnSubmit(f);
     db.SubmitChanges();
 }
예제 #13
0
파일: Person.cs 프로젝트: alexserdyuk/bvcms
 public static Person Add(Family fam,
     int position,
     Tag tag,
     string firstname,
     string nickname,
     string lastname,
     string dob,
     int MarriedCode,
     int gender,
     int originId,
     int? EntryPointId)
 {
     return Add(DbUtil.Db, true, fam, position, tag, firstname, nickname, lastname, dob, MarriedCode, gender, originId, EntryPointId);
 }
예제 #14
0
파일: Person.cs 프로젝트: GSBCfamily/bvcms
		private void detach_FamiliesHeaded2(Family entity)
		{
			this.SendPropertyChanging();
			entity.HeadOfHouseholdSpouse = null;
		}
예제 #15
0
 private void detach_Families(Family entity)
 {
     this.SendPropertyChanging();
     entity.Picture = null;
 }
예제 #16
0
파일: AddNew.cs 프로젝트: stevesloka/bvcms
        public void AddPerson(Person p, int entrypoint)
        {
            Family f;
            if (p == null)
                f = new Family
                {
                    AddressLineOne = AddressLineOne,
                    AddressLineTwo = AddressLineTwo,
                    CityName = City,
                    StateCode = State,
                    ZipCode = ZipCode,
                    CountryName = Country,
                    HomePhone = Phone.GetDigits().Truncate(20),
                };
            else
                f = p.Family;
            DbUtil.Db.SubmitChanges();

            var position = DbUtil.Db.ComputePositionInFamily(age, married == 20 , f.FamilyId) ?? 10;
            _person = Person.Add(f, position,
                null, FirstName.Trim(), null, LastName.Trim(), DateOfBirth, married == 20, gender ?? 0,
                    OriginCode.Enrollment, entrypoint);
            person.EmailAddress = EmailAddress.Trim();
            person.SendEmailAddress1 = true;
            person.CampusId = DbUtil.Db.Setting("DefaultCampusId", "").ToInt2();
            if (Campus.ToInt() > 0)
                person.CampusId = Campus.ToInt();
            person.CellPhone = Phone.GetDigits().Truncate(20);

            if (count == 0)
                person.Comments = "Added during online registration because record was not found";
            else if(count > 1)
                person.Comments = "Added during online registration because there was more than 1 match";

            DbUtil.Db.SubmitChanges();
            DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, person);
            PeopleId = person.PeopleId;
            Log("AddPerson");
        }
예제 #17
0
파일: Person.cs 프로젝트: hkouns/bvcms
        public static Person Add(CMSDataContext Db, bool SendNotices, Family fam, int position, Tag tag, string firstname, string nickname, string lastname, string dob, int MarriedCode, int gender, int originId, int? EntryPointId, bool testing = false)
        {
            var p = new Person();
            p.CreatedDate = Util.Now;
            p.CreatedBy = Util.UserId;
            Db.People.InsertOnSubmit(p);
            p.PositionInFamilyId = position;
            p.AddressTypeId = 10;

            if (firstname.HasValue())
                p.FirstName = firstname.Trim().ToProper().Truncate(25);
            else
                p.FirstName = "";

            if (nickname.HasValue())
                p.NickName = nickname.Trim().ToProper().Truncate(15);

            if (lastname.HasValue())
                p.LastName = lastname.Trim().ToProper().Truncate(30);
            else
                p.LastName = "?";

            p.GenderId = gender;
            if (p.GenderId == 99)
                p.GenderId = 0;
            p.MaritalStatusId = MarriedCode;

            DateTime dt;
            if (Util.DateValid(dob, out dt))
            {
                while (dt.Year < 1900)
                    dt = dt.AddYears(100);
                if (dt > Util.Now)
                    dt = dt.AddYears(-100);
                p.BirthDay = dt.Day;
                p.BirthMonth = dt.Month;
                p.BirthYear = dt.Year;
                if (p.GetAge() < 18 && MarriedCode == 0)
                    p.MaritalStatusId = MaritalStatusCode.Single;
            }
            else if (DateTime.TryParse(dob, out dt))
            {
                p.BirthDay = dt.Day;
                p.BirthMonth = dt.Month;
                if (Regex.IsMatch(dob, @"\d+[-/]\d+[-/]\d+"))
                {
                    p.BirthYear = dt.Year;
                    while (p.BirthYear < 1900)
                        p.BirthYear += 100;
                    if (p.GetAge() < 18 && MarriedCode == 0)
                        p.MaritalStatusId = MaritalStatusCode.Single;
                }
            }

            p.MemberStatusId = MemberStatusCode.JustAdded;
            if (fam == null)
            {
                fam = new Family();
                Db.Families.InsertOnSubmit(fam);
                p.Family = fam;
            }
            else
                fam.People.Add(p);

            var PrimaryCount = fam.People.Where(c => c.PositionInFamilyId == PositionInFamily.PrimaryAdult).Count();
            if (PrimaryCount > 2 && p.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                p.PositionInFamilyId = PositionInFamily.SecondaryAdult;

            if (tag != null)
                tag.PersonTags.Add(new TagPerson { Person = p });

            p.OriginId = originId;
            p.EntryPointId = EntryPointId;
            p.FixTitle();
            if (!testing)
                Db.SubmitChanges();
            if (SendNotices)
            {
                if (Util.UserPeopleId.HasValue
                        && Util.UserPeopleId.Value != Db.NewPeopleManagerId
                        && HttpContext.Current.User.IsInRole("Access")
                        && !HttpContext.Current.User.IsInRole("OrgMembersOnly")
                        && !HttpContext.Current.User.IsInRole("OrgLeadersOnly"))
                    Task.AddNewPerson(p.PeopleId);
                else
                    Db.Email(Util.SysFromEmail, Db.GetNewPeopleManagers(),
                            "Just Added Person on " + Db.Host, "{0} ({1})".Fmt(p.Name, p.PeopleId));
            }
            return p;
        }
예제 #18
0
 private void UpdateValue(Family f, string field, object value)
 {
     var o = Util.GetProperty(f, field);
     if (o == null && value == null)
         return;
     if (o != null && o.Equals(value))
         return;
     fsb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", field, o, value ?? "(null)");
     Util.SetProperty(f, field, value);
 }
예제 #19
0
파일: Person.cs 프로젝트: GSBCfamily/bvcms
		private void attach_FamiliesHeaded(Family entity)
		{
			this.SendPropertyChanging();
			entity.HeadOfHousehold = this;
		}
예제 #20
0
 private void UpdateField(StringBuilder fsb, Family f, string prop, string value)
 {
     f.UpdateValue(fsb, prop, value);
 }
예제 #21
0
        public void AddPerson(Person p, int entrypoint)
        {
            Family f;
            if (p == null)
                f = new Family
                {
                    AddressLineOne = address,
                    AddressLineTwo = address2,
                    CityName = city,
                    StateCode = state,
                    ZipCode = zip,
                    CountryName = country,
                    HomePhone = homephone,
                };
            else
                f = p.Family;

            _Person = Person.Add(f, PositionInFamily.Child,
                null, first.Trim(), null, last.Trim(), dob, married == 20, gender ?? 0,
                    OriginCode.Enrollment, entrypoint);
            person.EmailAddress = email.Trim();
            person.SendEmailAddress1 = true;
            person.SuffixCode = suffix;
            person.MiddleName = middle;
            person.CampusId = DbUtil.Db.Setting("DefaultCampusId", "").ToInt2();
            if (person.Age >= 18)
                person.PositionInFamilyId = PositionInFamily.PrimaryAdult;
            person.CellPhone = phone.GetDigits();

            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity("OnlineReg AddPerson {0}".Fmt(person.PeopleId));
            DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, person);
            PeopleId = person.PeopleId;
        }
예제 #22
0
 public ContentResult Split(int id)
 {
     var p = DbUtil.Db.LoadPersonById(id);
     var f = new Family
     {
         CreatedDate = Util.Now,
         CreatedBy = Util.UserId1,
         AddressLineOne = p.PrimaryAddress,
         AddressLineTwo = p.PrimaryAddress2,
         CityName = p.PrimaryCity,
         StateCode = p.PrimaryState,
         ZipCode = p.PrimaryZip,
         HomePhone = p.Family.HomePhone
     };
     f.People.Add(p);
     DbUtil.Db.Families.InsertOnSubmit(f);
     DbUtil.Db.SubmitChanges();
     DbUtil.LogActivity("Splitting Family for {0}".Fmt(p.Name));
     if (p == null)
         return Content("/");
     return Content("/Person2/" + id);
 }
예제 #23
0
파일: Person.cs 프로젝트: alexserdyuk/bvcms
 public static Person Add(Family fam, int position, Tag tag, string name, string dob, bool Married, int gender, int originId, int? EntryPointId)
 {
     string First, Last;
     NameSplit(name, out First, out Last);
     if (!Util.HasValue(First) || Married)
         switch (gender)
         {
             case 0: First = "A"; break;
             case 1: if (!Util.HasValue(First)) First = "Husbander"; break;
             case 2: First = "Wifey"; break;
         }
     return Add(fam, position, tag, First, null, Last, dob, Married, gender, originId, EntryPointId);
 }
예제 #24
0
        internal void AddPerson(int originid, int? entrypointid, int? campusid)
        {
            Family f;
            if (FamilyId > 0)
                f = Family;
            else
            {
                f = new Family();
                AddressInfo.CopyPropertiesTo(f);
                f.ResCodeId = AddressInfo.ResCode.Value.ToInt2();
                f.HomePhone = HomePhone.GetDigits();
            }
            NickName = NickName?.Trim();

            var position = DbUtil.Db.ComputePositionInFamily(Age ?? -1, MaritalStatus.Value == "20", FamilyId) ?? 10;

            FirstName = FirstName.Trim();
            if (FirstName == "na")
                FirstName = "";
            person = Person.Add(f, position,
                                 null, FirstName.Trim(), NickName, LastName.Trim(), DOB, false, Gender.Value.ToInt(),
                                 originid, entrypointid);

            this.CopyPropertiesTo(Person);
            Person.CellPhone = CellPhone.GetDigits();

            if (campusid == 0)
                campusid = null;
            Person.CampusId = Util.PickFirst(campusid.ToString(), DbUtil.Db.Setting("DefaultCampusId", "")).ToInt2();
            if (Person.CampusId == 0)
                Person.CampusId = null;

            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity($"AddPerson {person.PeopleId}");
            DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, Person);
            PeopleId = Person.PeopleId;
        }
예제 #25
0
파일: Person.cs 프로젝트: alexserdyuk/bvcms
 // Used for Conversions
 public static Person Add(CMSDataContext Db, Family fam, string firstname, string nickname, string lastname, DateTime? dob)
 {
     return Add(Db, false, fam, 20, null, firstname, nickname, lastname, dob.FormatDate(), 0, 0, 0, 0);
 }
예제 #26
0
파일: Picture.cs 프로젝트: hkouns/bvcms
 private void attach_Families(Family entity)
 {
     this.SendPropertyChanging();
     entity.Picture = this;
 }
예제 #27
0
파일: Person.cs 프로젝트: alexserdyuk/bvcms
 public static Person Add(Family fam, int position, Tag tag, string firstname, string nickname, string lastname, string dob, bool Married, int gender, int originId, int? EntryPointId)
 {
     return Add(fam, position, tag, firstname, nickname, lastname, dob, Married ? 20 : 10, gender, originId, EntryPointId);
 }
예제 #28
0
파일: Picture.cs 프로젝트: hkouns/bvcms
 private void detach_Families(Family entity)
 {
     this.SendPropertyChanging();
     entity.Picture = null;
 }
예제 #29
0
 private void UpdateField(Family f, string[] a, string prop, string s)
 {
     if (names.ContainsKey(s))
         if (a[names[s]].HasValue())
             f.UpdateValue(fsb, prop, a[names[s]]);
 }
예제 #30
0
 public bool FieldEqual(Family f, string field, string value)
 {
     if (value is string)
         value = ((string)value).TrimEnd();
     if (!Util.HasProperty(f, field))
         return false;
     var o = Util.GetProperty(f, field);
     if (o is string)
         o = ((string)o).TrimEnd();
     var f2 = new Family();
     Util.SetPropertyFromText(f2, field, value);
     var o2 = Util.GetProperty(f2, field);
     if (o == o2)
         return true;
     if (o.IsNull() && o2.IsNotNull())
         return false;
     return o.Equals(o2);
 }
예제 #31
0
 private void SetField(Family f, string[] a, string prop, string s, object value)
 {
     if (names.ContainsKey(s))
         if (value != null)
             Util.SetProperty(f, prop, value);
 }
예제 #32
0
        public void AddPerson(Person p, int entrypoint)
        {
            Family f;
            if (p == null)
                f = new Family
                {
                    AddressLineOne = AddressLineOne,
                    AddressLineTwo = AddressLineTwo,
                    CityName = City,
                    StateCode = State,
                    ZipCode = ZipCode,
                    CountryName = Country,
                    HomePhone = HomePhone,
                };
            else
                f = p.Family;

            var position = DbUtil.Db.ComputePositionInFamily(age, false, f.FamilyId) ?? 10;
            _Person = Person.Add(f, position,
                null, FirstName.Trim(), null, LastName.Trim(), DateOfBirth, married == 20, gender ?? 0,
                    OriginCode.Enrollment, entrypoint);
            person.EmailAddress = EmailAddress.Trim();
            person.SendEmailAddress1 = true;
            person.SuffixCode = Suffix;
            person.MiddleName = MiddleName;
            person.CampusId = DbUtil.Db.Setting("DefaultCampusId", "").ToInt2();
            //            if (person.Age >= 18)
            //                person.PositionInFamilyId = PositionInFamily.PrimaryAdult;
            person.CellPhone = Phone.GetDigits();

            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity("OnlineReg AddPerson {0}".Fmt(person.PeopleId));
            DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, person);
            PeopleId = person.PeopleId;
        }
예제 #33
0
        internal void AddPerson(int originid, int? entrypointid, int? campusid)
        {
            Family f;
            string na = "na";
            if (FamilyId > 0)
                f = family;
            else
                f = new Family
                        {
                            HomePhone = homephone.GetDigits(),
                            AddressLineOne = address.Disallow(na),
                            AddressLineTwo = address2,
                            CityName = city.Disallow(na),
                            StateCode = state.Disallow(na),
                            ZipCode = zip.Disallow(na),
                            CountryName = country,
                        };

            if (goesby != null)
                goesby = goesby.Trim();
            var position = PositionInFamily.Child;
            if (!birthday.HasValue)
                position = PositionInFamily.PrimaryAdult;
            if (age >= 18)
                if (f.People.Count(per =>
                                   per.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                    < 2)
                    position = PositionInFamily.PrimaryAdult;
                else
                    position = PositionInFamily.SecondaryAdult;

            _Person = Person.Add(f, position,
                                 null, first.Trim(), goesby, last.Trim(), dob, false, gender,
                                 originid, entrypointid);
            if (title.HasValue())
                person.TitleCode = title;
            person.EmailAddress = email.Disallow(na);
            person.MaritalStatusId = marital;
            person.SuffixCode = suffix;
            person.MiddleName = middle;
            if (campusid == 0)
                campusid = null;
            person.CampusId = Util.PickFirst(campusid.ToString(), DbUtil.Db.Setting("DefaultCampusId", "")).ToInt2();
            if (person.CampusId == 0)
                person.CampusId = null;

            person.CellPhone = phone.GetDigits();
            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity("OldUI AddPerson {0}".Fmt(person.PeopleId));
            DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, person);
            PeopleId = person.PeopleId;
        }
예제 #34
0
        public ActionResult AddPerson(int id, PersonInfo m)
        {
            if (!AccountModel.AuthenticateMobile())
            {
                return(Content("not authorized"));
            }

            CmsData.Family f;
            if (m.addtofamilyid > 0)
            {
                f = DbUtil.Db.Families.First(fam => fam.People.Any(pp => pp.PeopleId == m.addtofamilyid));
            }
            else
            {
                f = new CmsData.Family();
            }

            if (m.goesby == "(Null)")
            {
                m.goesby = null;
            }
            var position = PositionInFamily.Child;

            if (m.dob.Age0() >= 18)
            {
                if (f.People.Count(per =>
                                   per.PositionInFamilyId == PositionInFamily.PrimaryAdult)
                    < 2)
                {
                    position = PositionInFamily.PrimaryAdult;
                }
                else
                {
                    position = PositionInFamily.SecondaryAdult;
                }
            }

            var p = Person.Add(f, position,
                               null, Trim(m.first), Trim(m.goesby), Trim(m.last), m.dob, false, m.gender,
                               OriginCode.Visit, null);

            var z = DbUtil.Db.ZipCodes.SingleOrDefault(zc => zc.Zip == m.zip.Zip5());

            if (!m.home.HasValue() && m.cell.HasValue())
            {
                m.home = m.cell;
            }

            if (m.addtofamilyid == 0)
            {
                p.Family.HomePhone      = m.home.GetDigits();
                p.Family.AddressLineOne = m.addr;
                p.Family.CityName       = z != null ? z.City : null;
                p.Family.StateCode      = z != null ? z.State : null;
                p.Family.ZipCode        = m.zip;
            }
            p.EmailAddress = Trim(m.email);
            if (m.cell.HasValue())
            {
                p.CellPhone = m.cell.GetDigits();
            }
            p.MaritalStatusId = m.marital;
            p.GenderId        = m.gender;
            DbUtil.Db.SubmitChanges();
            var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == id);

            Attend.RecordAttendance(p.PeopleId, id, true);
            DbUtil.Db.UpdateMeetingCounters(id);
            return(new RollListResult(meeting, p.PeopleId));
        }
예제 #35
0
        public ActionResult AddPerson(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();
            if (!result.IsValid) return AuthorizationError(result);

            // Check Role
            if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance"))
                return BaseMessage.createErrorReturn("Attendance role is required to take attendance for organizations.");

            BaseMessage dataIn = BaseMessage.createFromString(data);
            MobilePostAddPerson mpap = JsonConvert.DeserializeObject<MobilePostAddPerson>(dataIn.data);
            mpap.clean();

            var p = new Person();

            p.CreatedDate = Util.Now;
            p.CreatedBy = Util.UserId;

            p.MemberStatusId = MemberStatusCode.JustAdded;
            p.AddressTypeId = 10;

            p.FirstName = mpap.firstName;
            p.LastName = mpap.lastName;
            p.Name = "";

            if (mpap.goesBy.Length > 0)
                p.NickName = mpap.goesBy;

            if (mpap.birthday != null)
            {
                p.BirthDay = mpap.birthday.Value.Day;
                p.BirthMonth = mpap.birthday.Value.Month;
                p.BirthYear = mpap.birthday.Value.Year;
            }

            p.GenderId = mpap.genderID;
            p.MaritalStatusId = mpap.maritalStatusID;

            Family f;

            if (mpap.familyID > 0)
            {
                f = DbUtil.Db.Families.First(fam => fam.FamilyId == mpap.familyID);
            }
            else
            {
                f = new Family();

                if (mpap.homePhone.Length > 0)
                    f.HomePhone = mpap.homePhone;

                if (mpap.address.Length > 0)
                    f.AddressLineOne = mpap.address;

                if (mpap.address2.Length > 0)
                    f.AddressLineTwo = mpap.address2;

                if (mpap.city.Length > 0)
                    f.CityName = mpap.city;

                if (mpap.state.Length > 0)
                    f.StateCode = mpap.state;

                if (mpap.zipcode.Length > 0)
                    f.ZipCode = mpap.zipcode;

                if (mpap.country.Length > 0)
                    f.CountryName = mpap.country;

                DbUtil.Db.Families.InsertOnSubmit(f);
            }

            f.People.Add(p);

            p.PositionInFamilyId = PositionInFamily.Child;

            if (mpap.birthday != null && p.GetAge() >= 18)
            {
                if (f.People.Count(per => per.PositionInFamilyId == PositionInFamily.PrimaryAdult) < 2)
                    p.PositionInFamilyId = PositionInFamily.PrimaryAdult;
                else
                    p.PositionInFamilyId = PositionInFamily.SecondaryAdult;
            }

            p.OriginId = OriginCode.Visit;
            p.FixTitle();

            if (mpap.eMail.Length > 0)
                p.EmailAddress = mpap.eMail;

            if (mpap.cellPhone.Length > 0)
                p.CellPhone = mpap.cellPhone;

            if (mpap.homePhone.Length > 0)
                p.HomePhone = mpap.homePhone;

            p.MaritalStatusId = mpap.maritalStatusID;
            p.GenderId = mpap.genderID;

            DbUtil.Db.SubmitChanges();

            if (mpap.visitMeeting > 0)
            {
                var meeting = DbUtil.Db.Meetings.Single(mm => mm.MeetingId == mpap.visitMeeting);
                Attend.RecordAttendance(p.PeopleId, mpap.visitMeeting, true);
                DbUtil.Db.UpdateMeetingCounters(mpap.visitMeeting);
                p.CampusId = meeting.Organization.CampusId;
                DbUtil.Db.SubmitChanges();
            }

            BaseMessage br = new BaseMessage();
            br.setNoError();
            br.id = p.PeopleId;
            br.count = 1;

            return br;
        }
예제 #36
0
 private void attach_Families(Family entity)
 {
     this.SendPropertyChanging();
     entity.Picture = this;
 }