private void button1_Click(object sender, EventArgs e) { // validate inputs // add inputs to database // FamilyPerson _family = new FamilyPerson(); ZakahEntities db = new ZakahEntities(); Person _currentPerson = new Person(); FamilyPerson newFamilyRelation = new FamilyPerson(); newFamilyRelation.Husbandid = txtHusbandid.Text; newFamilyRelation.wifeid = txtwifeid.Text; newFamilyRelation.street = txtStreet.Text; newFamilyRelation.CityID = Convert.ToInt32(drpCity.SelectedValue); newFamilyRelation.HomeNumber = txtHomeNum.Text; newFamilyRelation.POBOX = txtPOBOX.Text; newFamilyRelation.mikod = Convert.ToInt32(txtMikod.Text); newFamilyRelation.Telephone = txtTelephone.Text; newFamilyRelation.cellnumber = txtCell.Text; newFamilyRelation.childnumunder18 = Convert.ToInt32(txtChildesUnder18.Text); newFamilyRelation.childNumabove18 = Convert.ToInt32(txtChiledabove18.Text); newFamilyRelation.workType = txtWork.Text; newFamilyRelation.Income = Convert.ToInt32(txtIncome.Text); if (string.Empty != txtOjra.Text) { newFamilyRelation.Mashkanta_Ojra = Convert.ToInt32(txtOjra.Text); } newFamilyRelation.ownHouse = chkOwnHouse.Checked; db.AddToFamilyPersons(newFamilyRelation); db.SaveChanges(); /*db.SaveChanges();*/ _currentPerson.FamilyID = newFamilyRelation.id; _currentPerson.IDnum = txtHusbandid.Text; _currentPerson.FirstName = txtHusFirstname.Text; _currentPerson.FatherName = txtHusFatherName.Text; _currentPerson.LastName = txtHusFamily.Text; db.AddToPersons(_currentPerson); _currentPerson = new Person(); _currentPerson.FamilyID = newFamilyRelation.id; _currentPerson.IDnum = txtwifeid.Text; _currentPerson.FirstName = txtWifeFirstname.Text; _currentPerson.FatherName = txtWifeFatherName.Text; _currentPerson.LastName = txtWifeFamily.Text; db.AddToPersons(_currentPerson); db.AddToPersons(_currentPerson); db.SaveChanges(); btnAddFamily.Enabled =false; MessageBox.Show("تم اضافة العائلة بنجاح"); // we should add id number for husband and wife // this.FillGridMySites(this.oMySites.GetDataList(tblMySitesDB.lists.All, tblMySitesDB.Where.None, tblMySitesDB.Order.ByID)); }