Exemple #1
0
        internal override void Export(string table)
        {
            var vals = new List <object>
            {
                Name.DBExport(),
                Hf.DBExport(),
                LeaderType.DBExport(LeaderTypes),
                Race.DBExport(),
                Birth.DBExport(true),
                Birth.DBExport(false),
                Death.DBExport(true),
                Death.DBExport(false),
                ReignBegan.DBExport(true),
                Inheritance.DBExport(InheritanceTypes),
                InheritedFromSource.ToString(),
                InheritedFrom.DBExport(),
                Civilization.DBExport(),
                Site.DBExport(),
                Worship == null ? DBNull.Value : Worship.Name.DBExport(),
                WorshipPercent,
                Spouse.DBExport()
            };

            Database.ExportWorldItem(table, vals);
        }
Exemple #2
0
        private void DeleteSpo_Click(object sender, RoutedEventArgs e)
        {
            Member SelectedMember = ((Member)MemGrid.SelectedItem);

            if (SelectedMember != null)
            {
                Spouse Selected = ((Spouse)_context.spouses.FirstOrDefault(s => s.ParentId == SelectedMember.Id));
                if (Selected != null)
                {
                    DeleteConfirmation deleteConfirmation = new DeleteConfirmation();
                    deleteConfirmation.assigner(Selected);
                    deleteConfirmation.Show();
                    Clear_Spouse();
                    SelectedMember.MariageStatus         = false;
                    _context.Entry(SelectedMember).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                }
                else
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Must Select a Member first";
                    er.Show();
                }
            }
        }
Exemple #3
0
        private void UpdateSpo_Click(object sender, RoutedEventArgs e)
        {
            Member SelectedMember = ((Member)MemGrid.SelectedItem);

            if (SelectedMember != null)
            {
                Spouse Selected = ((Spouse)_context.spouses.FirstOrDefault(s => s.ParentId == SelectedMember.Id));
                if (Selected != null)
                {
                    Selected.Name       = SpouName.Text.Trim();
                    Selected.FatherName = SpoFatherName.Text.Trim();
                    Selected.MotherName = SpoMotherName.Text.Trim();

                    _context.Entry(Selected).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                    Clear_Spouse();
                }
                else
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Must Select a Member first";
                    er.Show();
                }
            }
        }
Exemple #4
0
        private List <Person> GetSiblingSpouses(Gender gender, bool getAllSiblingsSpouse = false)
        {
            var result = new List <Person>();

            if (IsRoyalMember)
            {
                var siblings = GetSiblings(gender == Gender.Male ? Gender.Female : Gender.Male);

                foreach (var treeNode in siblings)
                {
                    if (treeNode.Spouse != null)
                    {
                        result.Add(treeNode.Spouse);
                    }
                }

                var cousins = GetCousins(gender == Gender.Male ? Gender.Female : Gender.Male);

                foreach (var treeNode in cousins)
                {
                    if (treeNode.Spouse != null)
                    {
                        result.Add(treeNode.Spouse);
                    }
                }
            }
            else
            {
                result.AddRange(Spouse.GetSiblings(gender));
                result.AddRange(Spouse.GetCousins(gender));
            }

            return(result);
        }
Exemple #5
0
        public static void PlayDemo()
        {
            FamilyHead Adam        = new FamilyHead("Adam");
            Spouse     Eve         = new Spouse("Eve");
            Family     AdamsFamily = new Family(Adam, Eve);

            FamilyHead John       = new FamilyHead("John");
            Spouse     Grace      = new Spouse("Grace");
            Family     JohnFamily = new Family(John, Grace);

            FamilyHead Stacy       = new FamilyHead("Stacy");
            Spouse     Peter       = new Spouse("Peter");
            Family     StacyFamily = new Family(Stacy, Peter);

            JohnFamily.AddKid(StacyFamily);
            JohnFamily.AddKid(new Kid("Bob"));

            AdamsFamily.AddKid(JohnFamily);

            Kid Lily = new Kid("Lily");

            AdamsFamily.AddKid(Lily);

            Kid Murphy = new Kid("Murphy");

            AdamsFamily.AddKid(Murphy);

            AdamsFamily.Display(1);
        }
        public IEnumerable <Person> GetBrothersInLaw()
        {
            var bil = new List <Person>();

            var spouseMaleSiblings =
                Spouse?.First().Relationships.GetSiblings()
                ?.Where(x => x.Gender == Gender.Male);

            if (spouseMaleSiblings?.Any() == true)
            {
                bil.AddRange(spouseMaleSiblings);
            }

            var femaleSiblings = Siblings?.Where(x => x.Gender == Gender.Female) ?? Enumerable.Empty <Person>();

            foreach (var motherFemaleChild in femaleSiblings)
            {
                var spouse = motherFemaleChild.Relationships.GetSpouse();

                if (spouse?.Any() == true)
                {
                    bil.Add(spouse.First());
                }
            }

            return(bil);
        }
        public void AddSpouse(Person person)
        {
            Spouse ??= new List <Person>(SpouseLimit);

            if (Spouse.Count == 1)
            {
                throw new Exception("Spouse already present.");
            }

            Spouse.Add(person);
        }
Exemple #8
0
        public void SpouceView()
        {
            Spouse S = _context.spouses.FirstOrDefault(s => s.ParentId == SelParent);

            if (S != null)
            {
                SpouseName.Text  = S.Name;
                SpouseFName.Text = S.FatherName;
                SpouseMName.Text = S.MotherName;
            }
        }
 private void SaveDetails()
 {
     personalInfo.LastName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
     personalInfo.FirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
     if (personalInfo.StatusIndex.Text.Equals("Married") && personalInfo.SpouseName.Text != String.Empty)
     {
         Spouse spouse = new Spouse();
         spouse.LastName  = personalInfo.SpouseName.Text;
         spouse.BirthDate = personalInfo.SpouseBirthDate.SelectedDate;
         spouse.City      = personalInfo.SpouseAddress.Text;
         viewModel.CreateEntity(spouse);
     }
 }
Exemple #10
0
        public virtual void Validate(ValidationResult result)
        {
            Name.ValidateRequired(result, nameof(Name));

            Name.ValidateMaxLength(result, nameof(Name), 50);

            Spouse?.Validate(result);

            foreach (var person in Dependants)
            {
                person.Validate(result);
            }
        }
Exemple #11
0
        private Member ObjectMapper(NewMembersFrom form)
        {
            Member            member     = MemberMapper(form);
            Spouse            spouse     = SpouseMapper(form, member);
            IList <Dependent> dependents = DependentMapper(form, member);
            Payment           payment    = PaymentMapper(form, member);

            if (spouse != null)
            {
                member.Spouse = spouse;
            }
            if (dependents != null && dependents.Count > 0)
            {
                member.Dependents = dependents;
            }
            member.Payments = payment;
            return(member);
        }
Exemple #12
0
        public async Task UpdateSpouse(Spouse spouse)
        {
            try
            {
                var parameters = new DynamicParameters();
                parameters.Add("PersonId", spouse.PersonId, DbType.Int32);
                parameters.Add("NameOfSpouse", spouse.NameOfSpouse, DbType.String);
                parameters.Add("NameOfChildren", spouse.NameOfChildren, DbType.String);

                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.CnnVal(dbString)))
                {
                    await connection.ExecuteAsync("spSpouse_Update", parameters, commandType : CommandType.StoredProcedure);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error, update spouse", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #13
0
        private void AddSpo_Click(object sender, RoutedEventArgs e)
        {
            Member SelectedMember = ((Member)MemGrid.SelectedItem);

            if (SelectedMember != null)
            {
                Spouse Selected = new Spouse();
                var    Ex       = _context.spouses.FirstOrDefault(m => m.ParentId == SelectedMember.Id);
                if (Ex != null)
                {
                    ErrorMessage Error = new ErrorMessage();
                    Error.MessageText.TextWrapping = TextWrapping.Wrap;
                    Error.MessageText.Text         = "Spouce already registered!";
                    Error.Show();
                }
                else
                {
                    Selected.Name       = SpouName.Text.Trim();
                    Selected.FatherName = SpoFatherName.Text.Trim();
                    Selected.MotherName = SpoMotherName.Text.Trim();
                    Selected.ParentId   = SelectedMember.Id;

                    _context.spouses.Add(Selected);
                    _context.SaveChanges();
                    SelectedMember.MariageStatus         = true;
                    _context.Entry(SelectedMember).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                    Clear_Spouse();
                }
            }
            else
            {
                ErrorMessage er = new ErrorMessage();
                er.MessageText.Text = "Must Select a Member first";
                er.Show();
            }
        }
Exemple #14
0
        public override void BeingRemoved()
        {
            // we need to fix the relationship with other people in the model
            var household       = Family.Household;
            var personsInFamily = Family.Persons;

            Family.RemovePerson(this);
            Family = null;
            Father?.RemoveChild(this);
            Mother?.RemoveChild(this);
            Spouse?.RemoveSpouse(this);
            foreach (var sibling in Siblings)
            {
                sibling.RemoveSibling(this);
            }
            foreach (var child in Children)
            {
                child.RemoveParent(this);
            }
            foreach (var job in Jobs)
            {
                job.OwnerRemoved();
            }
        }
Exemple #15
0
        /// <summary>
        /// Saves the spouse information.
        /// </summary>
        /// <param name="spouseViewModel">The spouse view model.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">spouseViewModel</exception>
        public string SaveSpouseInfo(ISpouseViewModel spouseViewModel)
        {
            if (spouseViewModel == null)
            {
                throw new ArgumentNullException(nameof(spouseViewModel));
            }
            var result    = string.Empty;
            var newRecord = new Spouse
            {
                SpouseName   = spouseViewModel.SpouseName,
                Email        = spouseViewModel.Email,
                Mobile       = spouseViewModel.Mobile,
                DateCreated  = DateTime.Now,
                DateModified = DateTime.Now,
                DateOfBirth  = spouseViewModel.DateOfBirth,
                EmployeeId   = spouseViewModel.EmployeeId,
                Address      = spouseViewModel.Address,
                IsActive     = true,
                IsApproved   = false,
            };

            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    dbContext.Spouses.Add(newRecord);
                    dbContext.SaveChanges();
                }
            }catch (Exception e)
            {
                result = string.Format("SaveSpouseInfo - {0} , {1}", e.Message,
                                       e.InnerException != null ? e.InnerException.InnerException.Message : "");
            }
            return(result);
        }
        public override int GetHashCode()
        {
            int hash = 17;

            hash = hash * 23 + Id.GetHashCode();
            hash = hash * 23 + Name.GetHashCode();
            hash = hash * 23 + Culture.GetHashCode();
            hash = hash * 23 + Titles.GetHashCode();
            hash = hash * 23 + OtherTitles.GetHashCode();
            hash = hash * 23 + Aliases.GetHashCode();
            hash = hash * 23 + Born.GetHashCode();
            hash = hash * 23 + Died.GetHashCode();
            hash = hash * 23 + Father.GetHashCode();
            hash = hash * 23 + Mother.GetHashCode();
            hash = hash * 23 + Spouse.GetHashCode();
            hash = hash * 23 + Children.GetHashCode();
            hash = hash * 23 + Allegiances.GetHashCode();
            hash = hash * 23 + Books.GetHashCode();
            hash = hash * 23 + PovBooks.GetHashCode();
            hash = hash * 23 + PlayedBy.GetHashCode();
            hash = hash * 23 + TvSeries.GetHashCode();

            return(hash);
        }
Exemple #17
0
        private async void btnAddAnotherPerson_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Haven't you finished register the fingerprint?", "Register Fingerprint", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    // Local date of PC
                    var localDate = DateTime.Now;

                    // Get age of person
                    string birthDate = txtDateOfBirth.Text;
                    int    now       = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
                    int    dob       = int.Parse(birthDate);
                    int    age       = (now - dob) / 10000;

                    // Save additional info
                    var personInfo = new PersonInfo();
                    personInfo.PersonId         = Convert.ToInt32(txtIdFingerprint.Text);
                    personInfo.Nickname         = txtNickName.Text;
                    personInfo.CivilStatus      = cmbCivilStatus.Text;
                    personInfo.BirthPlace       = txtBirthPlace.Text;
                    personInfo.Height           = txtHeight.Text;
                    personInfo.Weight           = txtWeight.Text;
                    personInfo.Religion         = txtReligion.Text;
                    personInfo.IdentifyingMarks = txtIdentifyingMarks.Text;
                    personInfo.DateAdded        = Convert.ToString(localDate);
                    personInfo.Age = age;

                    await db.InsertPersonAdditionalInfo(personInfo);

                    // Save contact to table
                    var contact = new Contact();
                    contact.PersonId     = Convert.ToInt32(txtIdFingerprint.Text);
                    contact.PhoneNumber  = txtPhoneNumber.Text;
                    contact.EmailAddress = txtEmailAddress.Text;

                    await db.InsertContact(contact);

                    // Save address to table
                    var address = new Address();
                    address.PersonId    = Convert.ToInt32(txtIdFingerprint.Text);
                    address.HomeAddress = txtHomeAddress.Text;
                    address.Town        = txtTown.Text;
                    address.Barangay    = txtBarangay.Text;
                    address.Sitio       = txtSitio.Text;
                    address.Province    = txtProvince.Text;
                    address.Country     = txtCountry.Text;
                    address.ZipCode     = txtZipCode.Text;

                    await db.InsertAddress(address);

                    // Save occupation to table
                    var occupation = new Occupation();
                    occupation.PersonId        = Convert.ToInt32(txtIdFingerprint.Text);
                    occupation.Organization    = txtOrganization.Text;
                    occupation.WorkPosition    = txtWorkPosition.Text;
                    occupation.WorkAddress     = txtWorkAddress.Text;
                    occupation.Designation     = cmbDesignation.Text;
                    occupation.OfficeName      = txtOfficeName.Text;
                    occupation.WorkPhoneNumber = txtWorkPhoneNumber.Text;

                    await db.InsertOccupation(occupation);

                    // Save educational to table
                    var educational = new Educational();
                    educational.PersonId         = Convert.ToInt32(txtIdFingerprint.Text);
                    educational.LevelOfEducation = cmbLevelOfEducation.Text;
                    educational.NameOfSchool     = txtNameOfSchool.Text;

                    await db.InsertEducationalQualification(educational);

                    // Save spouse to table
                    var spouse = new Spouse();
                    spouse.PersonId       = Convert.ToInt32(txtIdFingerprint.Text);
                    spouse.NameOfSpouse   = txtNameOfSpouse.Text;
                    spouse.NameOfChildren = txtNameOfChildren.Text;

                    await db.InsertSpouse(spouse);

                    // Change Controls
                    gbPersonalInformation.Enabled = true;
                    gbPhoto.Enabled = true;

                    gbAdditionalInfo.Enabled = false;
                    gbContact.Enabled        = false;
                    gbAddress.Enabled        = false;
                    gbOccupation.Enabled     = false;
                    gbHighestEducationalQualification.Enabled = false;
                    gbIfMarried.Enabled = false;

                    btnSave.Enabled             = false;
                    btnAddAnotherPerson.Enabled = false;
                    btnRegister.Enabled         = false;

                    // Clear Text Boxes
                    Clean();

                    lblNotYetRegistered.BringToFront();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error, insert spouse, address, occupation, & contact", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #18
0
        private async void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show($"Are your sure you want to update {txtFirstName.Text} {txtLastName.Text}?", "Update personal data", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    // Remove "-" to date of birth textbox
                    txtDateOfBirth.Text = txtDateOfBirth.Text.Remove(4, 1);
                    txtDateOfBirth.Text = txtDateOfBirth.Text.Remove(6, 1);

                    string dateOfBirth = txtDateOfBirth.Text;

                    int now = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
                    int dob = int.Parse(dateOfBirth);
                    int age = (now - dob) / 10000;

                    // Get file name of the image & default image path
                    string defaultPathImage = @"\Images\Persons\";
                    string correctFileName  = Path.GetFileName(ofd.FileName);

                    int id = Convert.ToInt32(txtIdFingerprint.Text);

                    // Get the values from User Form | Person table
                    var person = new Person();
                    person.Id            = id;
                    person.FirstName     = txtFirstName.Text;
                    person.MiddleName    = txtMiddleName.Text;
                    person.LastName      = txtLastName.Text;
                    person.ExtensionName = txtExtensionName.Text;
                    person.DateOfBirth   = dateOfBirth;
                    person.Gender        = Convert.ToString(cmbGender.SelectedItem);
                    person.Remarks       = txtRemarks.Text;

                    if (btnBrowseWasClick == true)
                    {
                        person.StringImage = defaultPathImage + correctFileName;
                    }
                    else if (btnBrowseWasClick == false)
                    {
                        person.StringImage = txtPathImage.Text;
                    }
                    btnBrowseWasClick = false;

                    await db.UpdatePerson(person);

                    // Get the values from User Form | PersonInfo table
                    var personInfo = new PersonInfo();
                    personInfo.PersonId         = id;
                    personInfo.Nickname         = txtNickName.Text;
                    personInfo.CivilStatus      = Convert.ToString(cmbCivilStatus.SelectedItem);
                    personInfo.BirthPlace       = txtBirthPlace.Text;
                    personInfo.Height           = txtHeight.Text;
                    personInfo.Weight           = txtWeight.Text;
                    personInfo.Religion         = txtReligion.Text;
                    personInfo.IdentifyingMarks = txtIdentifyingMarks.Text;
                    personInfo.DateAdded        = lblDateAdded.Text;
                    personInfo.Age = Convert.ToInt32(lblAge.Text);

                    await db.UpdatePersonInfo(personInfo);

                    // Get the values from User Form | Contact table
                    var contact = new Contact();
                    contact.PersonId     = id;
                    contact.PhoneNumber  = txtPhoneNumber.Text;
                    contact.EmailAddress = txtEmailAddress.Text;

                    await db.UpdateContact(contact);

                    // Get the values from User Form | Address table
                    var address = new Address();
                    address.PersonId    = id;
                    address.HomeAddress = txtHomeAddress.Text;
                    address.Town        = txtTown.Text;
                    address.Barangay    = txtBarangay.Text;
                    address.Sitio       = txtSitio.Text;
                    address.Province    = txtProvince.Text;
                    address.Country     = txtCountry.Text;
                    address.ZipCode     = txtZipCode.Text;

                    await db.UpdateAddress(address);

                    // Get the values from User Form | Occupation table
                    var occupation = new Occupation();
                    occupation.PersonId        = id;
                    occupation.WorkPosition    = txtWorkPosition.Text;
                    occupation.WorkAddress     = txtWorkAddress.Text;
                    occupation.WorkPhoneNumber = txtWorkPhoneNumber.Text;
                    occupation.Organization    = txtOrganization.Text;
                    occupation.Designation     = Convert.ToString(cmbDesignation.SelectedItem);
                    occupation.OfficeName      = txtOfficeName.Text;

                    await db.UpdateOccupation(occupation);

                    // Get the values from User Form | Educational table
                    var educational = new Educational();
                    educational.PersonId         = id;
                    educational.LevelOfEducation = Convert.ToString(cmbLevelOfEducation.SelectedItem);
                    educational.NameOfSchool     = txtNameOfSchool.Text;

                    await db.UpdateEducational(educational);

                    // Get the values from User Form | Spouse table
                    var spouse = new Spouse();
                    spouse.PersonId       = id;
                    spouse.NameOfSpouse   = txtNameOfSpouse.Text;
                    spouse.NameOfChildren = txtNameOfChildren.Text;

                    await db.UpdateSpouse(spouse);

                    // Insert "-" date of birth textbox
                    txtDateOfBirth.Text = txtDateOfBirth.Text.Insert(4, "-");
                    txtDateOfBirth.Text = txtDateOfBirth.Text.Insert(7, "-");

                    MessageBox.Show($"Update successfully for {txtFirstName.Text} {txtLastName.Text}", "Update successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    txtFirstName.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error, update person data", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #19
0
        private void ReportBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Fundamental.IsChecked.GetValueOrDefault() == true)
            {
                Member Descised = ((Member)MemGrid.SelectedItem);
                if (Descised != null)
                {
                    try
                    {
                        _context.Losses.Add(Loss);
                        _context.Entry(Descised).State = System.Data.Entity.EntityState.Deleted;
                        //Descised.Children = _context.Childs.Where(c => c.ParentId == Descised.Id).ToList();
                        //Descised.Siblings = _context.Siblings.Where(c => c.ParentId == Descised.Id).ToList();
                        //Descised.SpouseSiblings = _context.SpouseSiblings.Where(c => c.ParentId == Descised.Id).ToList();
                        //foreach (var child in Descised.Children)
                        //{
                        //    _context.Entry(child).State = EntityState.Modified;

                        //}
                        //foreach (var child in Descised.Siblings)
                        //{
                        //    _context.Entry(child).State = EntityState.Modified;
                        //}
                        //foreach (var child in Descised.SpouseSiblings)
                        //{
                        //    _context.Entry(child).State = EntityState.Modified;
                        //}
                        //Spouse spo = _context.spouses.FirstOrDefault(s => s.ParentId == Descised.Id);
                        //if(spo != null)
                        //{
                        //_context.Entry(spo).State = EntityState.Modified;
                        //}
                        _context.SaveChanges();
                    }
                    catch (Exception msg)
                    {
                        Console.WriteLine(msg.Message);
                    }
                }
            }
            long Type = Convert.ToInt64(LossType.SelectedIndex);

            if (Type == 1)
            {
                Child Descised = (Child)(AliveFamilyMembers.SelectedItem);
                Loss.Description = Description.Text.Trim();
                Member Selected = ((Member)MemGrid.SelectedItem);
                Loss.ParentId  = Selected.Id;
                Loss.PaidMoney = PayChild;
                Edir.Capital  -= PayChild;
                if (Edir.Capital < 0)
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Can not provide such amount";
                    er.Show();
                    Loss.PaidMoney = -1 * Edir.Capital;
                    Edir.Capital   = 0;
                }
                Loss.Date = Convert.ToDateTime(DateOfDeath.Text);
                _context.Losses.Add(Loss);
                _context.Entry(Descised).State = System.Data.Entity.EntityState.Deleted;
                _context.Entry(Edir).State     = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
                Condolence();
            }
            else if (Type == 0)
            {
                Member Selected = ((Member)MemGrid.SelectedItem);
                Spouse Descised = _context.spouses.FirstOrDefault(s => s.ParentId == Selected.Id);
                Loss.Description = Description.Text.Trim();
                if (Edir.Capital - PaySpou < 0)
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Can not provide such amount";
                    er.Show();
                    Loss.PaidMoney = Edir.Capital;
                    Edir.Capital   = 0;
                }
                else
                {
                    Edir.Capital  -= PaySpou;
                    Loss.PaidMoney = PaySpou;
                }
                Loss.ParentId = Selected.Id;
                Loss.Date     = Convert.ToDateTime(DateOfDeath.Text);
                _context.Losses.Add(Loss);
                _context.Entry(Descised).State = System.Data.Entity.EntityState.Deleted;
                _context.SaveChanges();
                _context.Entry(Edir).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();

                Condolence();
            }
            else if (Type == 2)
            {
                Sibling Descised = (Sibling)(AliveFamilyMembers.SelectedItem);
                Loss.Description = Description.Text.Trim();
                Member Selected = ((Member)MemGrid.SelectedItem);
                if (Edir.Capital - PaySib < 0)
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Can not provide such amount";
                    er.Show();
                    Loss.PaidMoney = Edir.Capital;
                    Edir.Capital   = 0;
                }
                else
                {
                    Loss.PaidMoney = PaySib;
                    Edir.Capital  -= PaySib;
                }

                Loss.ParentId = Selected.Id;
                Loss.Date     = Convert.ToDateTime(DateOfDeath.Text);
                _context.Losses.Add(Loss);
                _context.Entry(Descised).State = System.Data.Entity.EntityState.Deleted;
                _context.Entry(Edir).State     = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();

                Condolence();
            }
            else if (Type == 3)
            {
                SpouseSibling Descised = (SpouseSibling)(AliveFamilyMembers.SelectedItem);
                Loss.Description = Description.Text.Trim();
                Member Selected = ((Member)MemGrid.SelectedItem);
                if (Edir.Capital - PaySib < 0)
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Can not provide such amount";
                    er.Show();
                    Loss.PaidMoney = Edir.Capital;
                    Edir.Capital   = 0;
                }
                else
                {
                    Loss.PaidMoney = PaySib;
                    Edir.Capital  -= PaySib;
                }

                Loss.ParentId = Selected.Id;
                Loss.Date     = Convert.ToDateTime(DateOfDeath.Text);
                _context.Losses.Add(Loss);
                _context.Entry(Edir).State     = System.Data.Entity.EntityState.Modified;
                _context.Entry(Descised).State = System.Data.Entity.EntityState.Deleted;
                _context.SaveChanges();
                Condolence();
            }
            else if (Type == 4)
            {
                Loss.Description = Description.Text.Trim();
                Member Selected = ((Member)MemGrid.SelectedItem);
                if (Edir.Capital - PayParents < 0)
                {
                    ErrorMessage er = new ErrorMessage();
                    er.MessageText.Text = "Can not provide such amount";
                    er.Show();
                    Loss.PaidMoney = Edir.Capital;
                    Edir.Capital   = 0;
                }
                else
                {
                    Edir.Capital  -= PayParents;
                    Loss.PaidMoney = PayParents;
                }

                Loss.ParentId = Selected.Id;
                Loss.Date     = Convert.ToDateTime(DateOfDeath.Text);
                _context.Entry(Edir).State = System.Data.Entity.EntityState.Modified;
                _context.Losses.Add(Loss);
                _context.SaveChanges();
                Condolence();
            }
        }
Exemple #20
0
        private void MemGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Member SelectedMember = ((Member)MemGrid.SelectedItem);

            if (SelectedMember != null)
            {
                LossType.IsEnabled = true;
                if (SelectedMember.MariageStatus)
                {
                    Spouse s = ((Spouse)_context.spouses.FirstOrDefault(d => d.ParentId == SelectedMember.Id));
                    if (s != null)
                    {
                        SpouName.Text      = s.Name;
                        SpoFatherName.Text = s.FatherName;
                        SpoMotherName.Text = s.MotherName;
                    }
                }
                else
                {
                    SpouName.Text      = "";
                    SpoFatherName.Text = "";
                    SpoMotherName.Text = "";
                }
                MemName.Text       = SelectedMember.FirstName.ToString();
                MemLastName.Text   = SelectedMember.LastName.ToString();
                MemMotherName.Text = SelectedMember.MotherName.ToString();
                Woreda.Text        = SelectedMember.Woreda.ToString();
                Kebele.Text        = SelectedMember.Kebele.ToString();
                HouseNum.Text      = SelectedMember.HouseNummber.ToString();
                Phone.Text         = SelectedMember.PhoneNumber.ToString();
                if (SelectedMember.Gender == "female")
                {
                    GenderBtn.IsChecked = false;
                }
                else
                {
                    GenderBtn.IsChecked = true;
                }
                if (SelectedMember.MariageStatus == true)
                {
                    MarriageStat.IsChecked = true;
                }
                else
                {
                    MarriageStat.IsChecked = false;
                }
                if (SelectedMember.SubCity == "Arada")
                {
                    Subcity.SelectedIndex = 0;
                }
                else if (SelectedMember.SubCity == "Akaki / Kality")
                {
                    Subcity.SelectedIndex = 1;
                }
                else if (SelectedMember.SubCity == "Bole")
                {
                    Subcity.SelectedIndex = 2;
                }
                else if (SelectedMember.SubCity == "Kolfe Keraniyo")
                {
                    Subcity.SelectedIndex = 3;
                }
                else if (SelectedMember.SubCity == "Yeka")
                {
                    Subcity.SelectedIndex = 4;
                }
                else if (SelectedMember.SubCity == "Gulele")
                {
                    Subcity.SelectedIndex = 5;
                }
                else if (SelectedMember.SubCity == "Ledeta")
                {
                    Subcity.SelectedIndex = 6;
                }
                else if (SelectedMember.SubCity == "Nefas Silk")
                {
                    Subcity.SelectedIndex = 7;
                }
                else if (SelectedMember.SubCity == "Kirkos")
                {
                    Subcity.SelectedIndex = 8;
                }
                else if (SelectedMember.SubCity == "Addis Ketema")
                {
                    Subcity.SelectedIndex = 9;
                }
            }
            ChildMenu_Click();
            SpouseMenu_Click();
            SibMenu_Click();
            SpouSibMenu_Click();
            if (SelectedMember != null)
            {
                ViolationsView.ItemsSource = _context.Violations.Where(v => v.MemberId == SelectedMember.Id).ToList();
                LossesView.ItemsSource     = _context.Losses.Where(v => v.ParentId == SelectedMember.Id).ToList();
            }
        }