コード例 #1
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);
 }
コード例 #2
0
ファイル: QueryModel.cs プロジェクト: bvcms/bvcms
 public void TagAll(Tag tag = null)
 {
     Db.SetNoLock();
     var q = Db.People.Where(TopClause.Predicate(Db));
     if (TopClause.ParentsOf)
         q = Db.PersonQueryParents(q);
     if(TopClause.FirstPersonSameEmail)
         q = Db.PersonQueryFirstPersonSameEmail(q);
     if (tag != null)
         Db.TagAll(q, tag);
     else
         Db.TagAll(q);
 }
コード例 #3
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);
 }
コード例 #4
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;
        }
コード例 #5
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);
 }
コード例 #6
0
ファイル: Person.cs プロジェクト: GSBCfamily/bvcms
		private void detach_TagsOwned(Tag entity)
		{
			this.SendPropertyChanging();
			entity.PersonOwner = null;
		}
コード例 #7
0
ファイル: QueryModel2.cs プロジェクト: vs06/bvcms
 public void TagAll(Tag tag = null)
 {
     var q = PersonQuery();
     if (tag != null)
         Db.TagAll(q, tag);
     else
         Db.TagAll(q);
 }
コード例 #8
0
ファイル: QueryModel.cs プロジェクト: rossspoon/bvcms
 public void TagAll(Tag tag = null)
 {
     if (Qb == null)
         LoadScratchPad();
     Db.SetNoLock();
     var q = Db.People.Where(Qb.Predicate(Db));
     if (Qb.ParentsOf)
         q = Db.PersonQueryParents(q);
     if (tag != null)
         Db.TagAll(q, tag);
     else
         Db.TagAll(q);
 }
コード例 #9
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;
        }