示例#1
0
 private void addButton_Click(object sender, EventArgs e)
 {
     this.ValidateChildren();
     if (FormValidator.IsValidated(this, errorProvider1))
     {
         var       dataContext = new ITSkillsDataContext();
         Employees employee    = new Employees();
         employee.Name     = nameTextBox.Text;
         employee.LastName = lastNameTextBox.Text;
         if (patronymicTextBox.Text == "")
         {
             employee.Patronymic = null;
         }
         else
         {
             employee.Patronymic = patronymicTextBox.Text;
         }
         employee.DateOfBirth = birthDateTimePicker.Value;
         string newProfession = professionComboBox.SelectedItem.ToString();
         employee.ProfessionID = dataContext.Professions.SingleOrDefault(p => p.Profession == newProfession).Id;
         dataContext.Employees.InsertOnSubmit(employee);
         dataContext.SubmitChanges();
         this.Close();
     }
 }
示例#2
0
 private void saveToolStripButton_Click(object sender, EventArgs e)
 {
     this.ValidateChildren();
     if (FormValidator.IsValidated(this, errorProvider1))
     {
         saveToDB();
     }
 }