private void btnIAdd_Click(object sender, RoutedEventArgs e) { IndividualBuyer ib=new IndividualBuyer(); // set properties to indiviudaBuyer object ib.Name=txtIName.Text; ib.MobileNo=txtIMobileNo.Text; ib.TelephoneNo = txtITelephoneNo.Text; ib.NIC=txtINic.Text; ib.DateOfBirth = birthdaypicker.SelectedDate.Value; ib.Country =(Country) comboBox1.SelectedItem; ib.City=txtICity.Text; ib.ZipCode=txtIZipCode.Text; ib.Address = txtIAddress.Text; ib.Passport = txtIPassport.Text; ib.Email = txtIEmail.Text; ib.Fax = txtIFax.Text; model.AddToBuyers(ib); Validation v = new Validation();// validation class is used to validate in relevant way if (v.ValidateTextField(txtIName.Text) ) { model.AddToBuyers(ib); model.SaveChanges(); MessageBox.Show("Added to the database successfully"); } else { MessageBox.Show("Need to enter details in required fields", "Error"); } }
/// <summary> /// Create a new IndividualBuyer object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="countryId">Initial value of the CountryId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="city">Initial value of the City property.</param> /// <param name="zipCode">Initial value of the ZipCode property.</param> /// <param name="fax">Initial value of the Fax property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="address">Initial value of the Address property.</param> /// <param name="telephoneNo">Initial value of the TelephoneNo property.</param> /// <param name="nIC">Initial value of the NIC property.</param> /// <param name="mobileNo">Initial value of the MobileNo property.</param> /// <param name="passport">Initial value of the Passport property.</param> public static IndividualBuyer CreateIndividualBuyer(global::System.Int32 id, global::System.Int32 countryId, global::System.String name, global::System.String city, global::System.String zipCode, global::System.String fax, global::System.String email, global::System.String address, global::System.String telephoneNo, global::System.String nIC, global::System.String mobileNo, global::System.String passport) { IndividualBuyer individualBuyer = new IndividualBuyer(); individualBuyer.Id = id; individualBuyer.CountryId = countryId; individualBuyer.Name = name; individualBuyer.City = city; individualBuyer.ZipCode = zipCode; individualBuyer.Fax = fax; individualBuyer.Email = email; individualBuyer.Address = address; individualBuyer.TelephoneNo = telephoneNo; individualBuyer.NIC = nIC; individualBuyer.MobileNo = mobileNo; individualBuyer.Passport = passport; return individualBuyer; }