private void button2_Click(object sender, EventArgs e)
        {
            profeAdapter = new GD2C2016DataSetTableAdapters.ProfesionalTableAdapter();

            dataGridView1.Rows.Clear();

            if (comboBox1.Text == "")
            {
                MessageBox.Show("Seleccione alguna especialidad");
            }
            else
            {
                profeData = profeAdapter.obtenerProfesionalesPorEspecialidad(comboBox1.Text);

                foreach (DataRow profesional in profeData.Rows)
                {
                    dataGridView1.Rows.Add(profesional.Field <decimal>("id"),
                                           profesional.Field <string>("nombre"),
                                           profesional.Field <string>("apellido"));
                }
            }
        }
Beispiel #2
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            int outPut;

            profeAdapter = new GD2C2016DataSetTableAdapters.ProfesionalTableAdapter();

            dataGridView1.Rows.Clear();

            if (string.IsNullOrWhiteSpace(textBox1.Text) && string.IsNullOrWhiteSpace(textBox2.Text) &&
                string.IsNullOrWhiteSpace(textBox3.Text))
            {
                MessageBox.Show("Complete los filtros de búsqueda");
            }
            else
            {
                if (((!string.IsNullOrWhiteSpace(textBox1.Text) && string.IsNullOrWhiteSpace(textBox2.Text)) &&
                     (!string.IsNullOrWhiteSpace(textBox3.Text) || string.IsNullOrWhiteSpace(textBox3.Text))) ||
                    ((string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text)) &&
                     (!string.IsNullOrWhiteSpace(textBox3.Text) || string.IsNullOrWhiteSpace(textBox3.Text))))
                {
                    MessageBox.Show("Nombre y apellido deben estar completos");
                }

                else
                {
                    if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) &&
                        !string.IsNullOrWhiteSpace(textBox3.Text))
                    {
                        MessageBox.Show("Busque por nombre y apellido o por especialidad");
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(textBox3.Text))
                        {
                            if (int.TryParse(textBox1.Text, out outPut) || int.TryParse(textBox2.Text, out outPut))
                            {
                                MessageBox.Show("El nombre y apellido no pueden ser numéricos");
                            }
                            else
                            {
                                try
                                {
                                    nombre   = textBox1.Text;
                                    apellido = textBox2.Text;


                                    profeData = profeAdapter.obtenerProfesionalesPorNyA(nombre, apellido);


                                    foreach (DataRow profesional in profeData.Rows)
                                    {
                                        dataGridView1.Rows.Add(profesional.Field <decimal>("id"),
                                                               profesional.Field <string>("nombre"),
                                                               profesional.Field <string>("apellido"),
                                                               profesional.Field <string>("descripcion"));
                                    }
                                }
                                catch (SqlException ex) {
                                    switch (ex.Number)
                                    {
                                    case 40008: MessageBox.Show("No existen profesionales con ese nombre y apellido");
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            especialidad = textBox3.Text;

                            profeData = profeAdapter.obtenerProfesionalesPorEspecialidad(especialidad);


                            foreach (DataRow profesional in profeData.Rows)
                            {
                                dataGridView1.Rows.Add(profesional.Field <decimal>("id"),
                                                       profesional.Field <string>("nombre"),
                                                       profesional.Field <string>("apellido"),
                                                       especialidad);
                            }
                        }
                    }
                }
            }
        }