コード例 #1
0
        private void btnMantEmpleados_Click(object sender, RoutedEventArgs e)
        {
            MantenimientoEmpleado Window = new MantenimientoEmpleado();

            this.Hide();
            Window.ShowDialog();
            Close();
        }
 private void btnModificar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtNombre.Text == "" || txtApellido.Text == "" || txtFecha.Text == "" || txtSalario.Text == "" || ID <= 0)
         {
             MessageBox.Show("Selecciona un Item");
         }
         else if (txtNombre.Text == string.Empty)
         {
             txtNombre.Focus();
         }
         else if (txtApellido.Text == string.Empty)
         {
             txtApellido.Focus();
         }
         else if (txtApellido.Text == string.Empty)
         {
             txtApellido.Focus();
         }
         else if (txtSalario.Text == string.Empty)
         {
             txtSalario.Focus();
         }
         if (txtNombre.Text != "" && txtApellido.Text != "" && txtFecha.Text != "" && txtSalario.Text != "" && cmbOficina.SelectedValue == null && ID > 0)
         {
             DateTime ThisDay = new DateTime();
             ThisDay              = Convert.ToDateTime(txtFecha.Text);
             _Employee.Code       = Code;
             _Employee.Name       = txtNombre.Text.ToUpper();
             _Employee.LastName   = txtApellido.Text.ToUpper();
             _Employee.DateBirth  = Convert.ToDateTime(ThisDay.ToString("d"));
             _Employee.Date       = Date;
             _Employee.Salary     = Convert.ToDecimal(txtSalario.Text);
             _Employee.OfficeID   = Convert.ToInt64(cmbOficina.SelectedValue);
             _Employee.State      = true;
             _Employee.EmployeeID = ID;
             _EmployeeBL.UpdateItem(_Employee);
             dgvEmpleado.ItemsSource = _EmployeeBL.GetAll();
             Limpiar();
             EstadoBotones(0);
             MantenimientoEmpleado _window = new MantenimientoEmpleado();
             _window.Show();
             Close();
         }
         else if (txtNombre.Text != "" && txtApellido.Text != "" && txtFecha.Text != "" && txtSalario.Text != "" && cmbOficina.SelectedValue != null && ID > 0)
         {
             DateTime ThisDay = new DateTime();
             ThisDay              = Convert.ToDateTime(txtFecha.Text);
             _Employee.Code       = Code;
             _Employee.Name       = txtNombre.Text.ToUpper();
             _Employee.LastName   = txtApellido.Text.ToUpper();
             _Employee.DateBirth  = Convert.ToDateTime(ThisDay.ToString("d"));
             _Employee.Date       = Date;
             _Employee.Salary     = Convert.ToDecimal(txtSalario.Text);
             _Employee.OfficeID   = Convert.ToInt64(cmbOficina.SelectedValue);
             _Employee.State      = true;
             _Employee.EmployeeID = ID;
             _EmployeeBL.UpdateItem(_Employee);
             dgvEmpleado.ItemsSource = _EmployeeBL.GetAll();
             Limpiar();
             EstadoBotones(0);
             MantenimientoEmpleado _window = new MantenimientoEmpleado();
             _window.Show();
             Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Algo anda mal: " + ex.Message, "Error CRVA-EM", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }