Example #1
0
        public void AddRecord(object obj)
        {
            try
            {
                using (RelationEntities dbEntities = new RelationEntities())
                {
                    /*** ADD PERSON **/
                    perObject.Gender     = _selectedGender.GenderName;
                    perObject.Name       = PersonFirstName;
                    perObject.MaidenName = PersonMaidenName;
                    perObject.LastName   = PersonLastName;
                    dbEntities.People.Add(perObject);
                    dbEntities.SaveChanges();
                    /***END***/

                    /***ADD RELATION ***/
                    var relation = new Relationship();
                    relation.RelationTypeID = _selectedRelation.RelationId;
                    relation.FirstPersonID  = perObject.PersonID;
                    relation.SecondPersonID = _selectedPerson.PersonId;
                    dbEntities.Relationships.Add(relation);
                    dbEntities.SaveChanges();
                    /****END**/

                    ClearControls();
                    this.Message = "Person Added Successfully.";
                }
            }
            catch (Exception ex)
            {
                this.Message = ex.Message;
            }
        }
Example #2
0
 private void AddRelation(object obj)
 {
     using (RelationEntities dbEntities = new RelationEntities())
     {
         try
         {
             /***ADD RELATION ***/
             var relation = new Relationship();
             relation.RelationTypeID = _selectedRelation.RelationId;
             relation.FirstPersonID  = _selectedPerson.PersonId;
             relation.SecondPersonID = _secondSelectedPerson.PersonId;
             dbEntities.Relationships.Add(relation);
             dbEntities.SaveChanges();
             /****END**/
             this.Message = "Relation Added Successfully.";
         }
         catch (Exception ex)
         {
             this.Message = ex.Message;
         }
     }
 }