Ejemplo n.º 1
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (!this.IsInputValid())
            {
                e.Handled = true;
                return;
            }

            var employee = new Employee
            {
                FirstName        = this.FirstNameTextBox.Text,
                LastName         = this.LastNameTextBox.Text,
                Surname          = this.SurnameNameTextBox.Text,
                Gender           = this.GenderComboBox.SelectedValue.ToString() == "Female",
                Birthday         = this.BirthdayDatePicker.SelectedDate.Value,
                PlaceOfResidence = this.PlaceOfResidenceTextBox.Text,
                PlaceOfBirth     = this.PlaceOfBirthTextBox.Text,
                PassportData     = this.PassportDataTextBox.Text,
                Code             = int.Parse(this.CodeTextBox.Text),
                ArmyServed       = this.ArmyServedComboBox.SelectedValue.ToString() == "No",
                FitForArmyServe  = this.FitForArmyServeComboBox.SelectedValue.ToString() == "No"
            };

            string query = QueryManager.Employee.Insert(employee);

            int executionResult = DbContext.Instance.ExecuteCommandNonQuery(query);

            if (executionResult == 1)
            {
                InputHelper.DisplayInformation("Success", "New employee has been added.");
            }
        }