コード例 #1
0
        private void UpdatePartnersComboBox()
        {
            EnumerablePartners = SourceFamily.GetEnumerableMembers().Where(
                m => m.Id != SourceMember.Id &&
                m.BirthDate <= SinceDateTime &&
                (m.DeathDate == null || SinceDateTime <= m.DeathDate) &&
                !m.Refs.PartnerId.Value(SinceDateTime).HasValue
                ).OrderBy(m => m.BirthDate - SourceMember.BirthDate);

            PartnersComboBox.Items.Clear();

            if (SourceMember.HadPartner(SinceDateTime))
            {
                PartnersComboBox.Items.Add("The partner that time");
            }
            else
            {
                PartnersComboBox.Items.Add("No partner selected");
            }

            PartnersComboBox.SelectedIndex = 0;

            foreach (Member member in EnumerablePartners)
            {
                PartnersComboBox.Items.Add(member);
            }
        }
コード例 #2
0
        private void WithPartnerBtnOnClick(object sender, EventArgs e)
        {
            if (PartnersComboBox.SelectedIndex < 1)
            {
                PartnersComboBox.Focus();
                return;
            }

            try
            {
                SourceMember.WithPartner(
                    EnumerablePartners.ElementAt(PartnersComboBox.SelectedIndex - 1),
                    SinceDateTimePicker.Value
                    );
                UpdatePartnersListBox();
                UpdatePartnersComboBox();
                UpdateButtons();
                SinceDateTimePicker.Focus();
            }
            catch (Exception ex)
            {
                if (new ValidationFailedDialog(ex.Message).ShowDialog() == DialogResult.OK)
                {
                    PartnersComboBox.Focus();
                }
            }
        }
コード例 #3
0
        private void GotMarriedBtnOnClick(object sender, EventArgs e)
        {
            if (PartnersComboBox.SelectedIndex == -1 || (
                    PartnersComboBox.SelectedIndex == 0 &&
                    !SourceMember.HadPartner(SinceDateTime)
                    ))
            {
                PartnersComboBox.Focus();
                return;
            }

            try
            {
                SourceMember.GotMarried(
                    SinceDateTimePicker.Value,
                    PartnersComboBox.SelectedIndex > 0 ?
                    EnumerablePartners.ElementAt(PartnersComboBox.SelectedIndex - 1)
                        :
                    null
                    );

                UpdatePartnersListBox();
                UpdateStatusesListBox();
                UpdatePartnersComboBox();
                UpdateButtons();
                SinceDateTimePicker.Focus();
            }
            catch (Exception ex)
            {
                if (new ValidationFailedDialog(ex.Message).ShowDialog() == DialogResult.OK)
                {
                    PartnersComboBox.Focus();
                }
            }
        }
コード例 #4
0
        private Expression GetCondition(Expression nestedAccessChecks, IMemberMapperData mapperData)
        {
            if (nestedAccessChecks == null)
            {
                return(null);
            }

            if (IsNotOptionalEntityMemberId(mapperData))
            {
                return(nestedAccessChecks);
            }

            var sourceMemberValue = SourceMember.GetQualifiedAccess(mapperData);
            var sourceValueType   = sourceMemberValue.Type.GetNonNullableType();

            if (!sourceValueType.IsNumeric())
            {
                return(nestedAccessChecks);
            }

            if (sourceMemberValue.Type.IsNullableType())
            {
                sourceMemberValue = sourceMemberValue.GetNullableValueAccess();
            }

            var zero = 0.ToConstantExpression(sourceValueType);
            var sourceValueNonZero = Expression.NotEqual(sourceMemberValue, zero);

            return(Expression.AndAlso(nestedAccessChecks, sourceValueNonZero));
        }
コード例 #5
0
 public IParameter[] GetParameters()
 {
     if (_parameters == null)
     {
         _parameters = GenericMapping.MapParameters(SourceMember.GetParameters());
     }
     return(_parameters);
 }
コード例 #6
0
 private void UpdateButtons()
 {
     WithoutPartnerBtn.Enabled = SourceMember.HadPartner(SinceDateTime);
     GotUnmarriedBtn.Enabled   = SourceMember.WasMarried(SinceDateTime);
     GotMarriedBtn.Enabled     = !GotUnmarriedBtn.Enabled && (
         EnumerablePartners.Any() || SourceMember.HadPartner(SinceDateTime)
         );
     WithPartnerBtn.Enabled            = !WithoutPartnerBtn.Enabled && EnumerablePartners.Any();
     ClearPartnersHistoryBtn.Enabled   = EnumerablePartnersHistory.Count() > 1;
     RemoveSelectedFullNameBtn.Enabled = FullNamesListBox.SelectedIndex > 0;
 }
コード例 #7
0
        private void Initialize()
        {
            SinceDateTime = DateTime.Now;
            SinceDateTimePicker.MinDate = SourceMember.BirthDate;
            SinceDateTimePicker.MaxDate = SinceDateTime;
            MemberTitle.Text            = SourceMember.ToString();

            UpdatePartnersComboBox();
            UpdatePartnersListBox();
            UpdateStatusesListBox();
            UpdateFullNamesListBox();
            UpdateChooseChildren();
            UpdateButtons();
        }
コード例 #8
0
        private void ChangedFullNameBtnOnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(FullNameTxtBox.Text))
            {
                FullNameTxtBox.Focus();
                return;
            }

            SourceMember.ChangedFullName(
                FullNameTxtBox.Text,
                SinceDateTimePicker.Value
                );

            UpdateFullNamesListBox();
            SinceDateTimePicker.Focus();
        }
コード例 #9
0
        public IDataSource CreateDataSource()
        {
            var mapperData = ContextMappingData.MapperData;

            var sourceMemberValue = SourceMember
                                    .GetRelativeQualifiedAccess(mapperData, out var relativeSourceMember)
                                    .GetConversionTo(relativeSourceMember.Type);

            var sourceMemberDataSource = new SourceMemberDataSource(
                relativeSourceMember,
                sourceMemberValue,
                Condition,
                mapperData);

            return(sourceMemberDataSource);
        }
コード例 #10
0
 public static void ObjectToConfiguration(Object Source, Object Configuration)
 {
     foreach (var SourceMember in Source.GetType().GetFields())
     {
         foreach (var FieldMappingAttribute in SourceMember.GetCustomAttributes(typeof(FieldMapping), true).Cast <FieldMapping>())
         {
             ObjectFieldSet(
                 Configuration,
                 FieldMappingAttribute.ConfigurationField,
                 ObjectFieldGet(
                     ObjectFieldGet(Source, SourceMember.Name),
                     FieldMappingAttribute.ThisField
                     )
                 );
         }
     }
 }
コード例 #11
0
 private void WithoutPartnerBtnOnClick(object sender, EventArgs e)
 {
     try
     {
         SourceMember.WithoutPartner(SinceDateTimePicker.Value);
         UpdatePartnersListBox();
         UpdateStatusesListBox();
         UpdatePartnersComboBox();
         UpdateButtons();
     }
     catch (Exception ex)
     {
         if (new ValidationFailedDialog(ex.Message).ShowDialog() == DialogResult.OK)
         {
             SinceDateTimePicker.Focus();
         }
     }
 }
コード例 #12
0
        private void ChooseChildrenSaveChangesBtnOnClick(object sender, EventArgs e)
        {
            if (EnumerableChildren.Any() || EnumerableOwnChildren.Any())
            {
                EnumerableOwnChildren = EnumerableOwnChildren.ToArray();

                for (int i = 0; i < EnumerableOwnChildren.Count(); i++)
                {
                    if (!ChooseChildren.CheckedIndices.Contains(i))
                    {
                        SourceMember.Refs.RemoveChild(EnumerableOwnChildren.ElementAt(i));
                    }
                }

                try
                {
                    EnumerableChildren = EnumerableChildren.ToArray();

                    foreach (int i in ChooseChildren.CheckedIndices)
                    {
                        if (i >= EnumerableOwnChildren.Count())
                        {
                            SourceMember.HadChild(EnumerableChildren.ElementAt(
                                                      i - EnumerableOwnChildren.Count()
                                                      ));
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (new ValidationFailedDialog(ex.Message).ShowDialog() == DialogResult.OK)
                    {
                    }
                }
            }

            UpdateChooseChildren();
            ChooseChildrenSaveChangesBtn.Enabled = false;
        }
コード例 #13
0
 public IMethod GetRaiseMethod()
 {
     return(GenericMapping.Map(SourceMember.GetRemoveMethod()));
 }
コード例 #14
0
 public IMethod GetAddMethod()
 {
     return(GenericMapping.Map(SourceMember.GetAddMethod()));
 }
コード例 #15
0
 public IParameter[] GetParameters()
 {
     return(_parameters ?? (_parameters = GenericMapping.MapParameters(SourceMember.GetParameters())));
 }