private void getemployeeaddress() { t_EmpAddress empaddress = new t_EmpAddress(); var selectQuery = db.t_EmpAddress.Where(x => x.EmpID == EmpID.Text); foreach (var item in selectQuery) { try { t_EmpAddress myData = item as t_EmpAddress; CountryName.SelectedValue = myData.PresCountryID; PermanentCountryName.SelectedValue = myData.PermCountryID; PresentCountry(); ProvName.SelectedValue = myData.PresProvinceID; PermanenttCountry(); PermanentProvName.SelectedValue = myData.PermProvinceID; PresentProvince(); CityName.SelectedValue = myData.PresCityID; Street.Text = myData.PresStreet; PermanentCityName.SelectedValue = myData.PermCityID; PermanentProvince(); PermanentStreet.Text = myData.PermStreet; } catch { } } }
private void SaveEmpAddress() { t_EmpAddress address = new t_EmpAddress(); address.EmpID = NewEmpID; address.PresCountryID = Convert.ToInt32(CountryName.SelectedValue.ToString()); address.PresProvinceID = Convert.ToInt32(ProvName.SelectedValue.ToString()); address.PresCityID = Convert.ToInt32(CityName.SelectedValue.ToString()); address.PresStreet = Street.Text; if (setpermanent.IsChecked == true) { address.PermCountryID = Convert.ToInt32(CountryName.SelectedValue.ToString()); address.PermProvinceID = Convert.ToInt32(ProvName.SelectedValue.ToString()); address.PermCityID = Convert.ToInt32(CityName.SelectedValue.ToString()); address.PermStreet = Street.Text; } else { address.PermCountryID = Convert.ToInt32(PermanentCountryName.SelectedValue.ToString()); address.PermProvinceID = Convert.ToInt32(PermanentProvName.SelectedValue.ToString()); address.PermCityID = Convert.ToInt32(PermanentCityName.SelectedValue.ToString()); address.PermStreet = PermanentStreet.Text; } address.LastUpdate = DateTime.Now; db.t_EmpAddress.Add(address); db.SaveChanges(); }