Пример #1
0
        private void btnRegistrar_Click(object sender, RoutedEventArgs e)
        {
            if (cboMotivo.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione un motivo para la visita");
                cboMotivo.Focus();
            }
            else if (!dtpFechaVisita.SelectedDate.HasValue)
            {
                MessageBox.Show("Seleccione una fecha para la visita");
                dtpFechaVisita.Focus();
            }
            else if (cboRutCliente1.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione el RUT del cliente");
                cboRutCliente1.Focus();
            }
            else if (cboRutTrabajador1.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione el RUT del trabajador");
                cboRutTrabajador1.Focus();
            }
            else
            {
                string motivo = cboMotivo.SelectedItem.ToString();
                string fecha  = dtpFechaVisita.SelectedDate.Value.ToString("dd/MM/yyyy").Replace("-", "/");
                string rutcli = cboRutCliente1.SelectedItem.ToString();
                string ruttra = cboRutTrabajador1.SelectedItem.ToString();

                bool result = _mane.SetVisita(motivo, fecha, rutcli, ruttra);
                if (result)
                {
                    MessageBox.Show("Visita programada correctamente", "Éxito");
                }
                else
                {
                    MessageBox.Show("Visita no se programó", "Error");
                }
            }
        }