예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Directors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDirectors(Director director)
 {
     base.AddObject("Directors", director);
 }
예제 #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Validation validation = new Validation();
               //validating emails
            if (validation.ValidateTextField(txtEmail.Text) ? validation.ValidateEmail(txtEmail.Text) : true)
            {
                //validating nic
                if(validation.ValidateTextField(txtNIC.Text) ? validation.ValidateNIC(txtNIC.Text) :true)
                {
                    //checking whether nicor passport field fill
                    if (validation.ValidateTextField(txtNIC.Text) || validation.ValidateTextField(txtPassportId.Text))
                    {
                        //addig data to the model
                        Director director = new Director();
                        director.FirstName = txtFirstName.Text;
                        director.LastName = txtLastName.Text;
                        director.NIC = txtNIC.Text;
                        director.PassportNo = txtPassportId.Text;
                        director.JoinedDate = dtPickerJoinedDate.SelectedDate.Value;
                        director.DateOfBirth = dtPickerBirthDay.SelectedDate.Value;
                        director.Gender = txtGender.SelectedValue.ToString();
                        director.TelNo = txtTelNo.Text;
                        director.Type = txtType.SelectedValue.ToString();
                        director.Email = txtEmail.Text;
                        director.Address = txtAddress.Text;
                        model.AddToDirectors(director);
                        //saving changes to the database
                        model.SaveChanges();
                        Exporter expo = model.Exporters.Where(exp => exp.Id == _exporter.Id).First();
                        director.Exporters.Add(expo);
                        model.SaveChanges();

                        //clearing fields
                        txtFirstName.Clear();
                        txtLastName.Clear();
                        txtNIC.Clear();
                        txtPassportId.Clear();
                        dtPickerBirthDay.ClearValue(DatePicker.SelectedDateProperty);
                        dtPickerJoinedDate.ClearValue(DatePicker.SelectedDateProperty);
                        txtGender.ClearValue(ComboBox.SelectedItemProperty);
                        txtTelNo.Clear();
                        txtPassportId.Clear();
                        txtType.ClearValue(ComboBox.SelectedItemProperty);
                        txtAddress.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Either NIC or Passport number is required");

                    }
                }
                else
                {
                    MessageBox.Show("Invalid NIC");

                }

            }
            else
            {
                MessageBox.Show("Email address is invalid");
            }
        }
예제 #3
0
 /// <summary>
 /// Create a new Director object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static Director CreateDirector(global::System.Int32 id)
 {
     Director director = new Director();
     director.Id = id;
     return director;
 }