Esempio n. 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dataGridView1.Columns[e.ColumnIndex].HeaderText.Equals("Action"))
            {
                int Matricula = Convert.ToInt32(TablaProfesionales.Rows[e.RowIndex]["Matricula"].ToString());


                if (PedirTurno)
                {
                    DataRow[] Rows = TablaEspecialidades.Select("Descripcion = '" +
                                                                TablaProfesionales.Rows[e.RowIndex]["Especialidad"].ToString().Trim() +
                                                                "'");
                    int Cod_Especialidad;
                    if (Rows.Length != 1)
                    {
                        return;
                    }

                    Cod_Especialidad = Convert.ToInt32(Rows[0][0].ToString().Trim());
                    menuPedirTurno.SetProfesional(Matricula,
                                                  Cod_Especialidad,
                                                  TablaProfesionales.Rows[e.RowIndex]["Nombre"].ToString() + " " +
                                                  TablaProfesionales.Rows[e.RowIndex]["Apellido"].ToString());
                    menuPedirTurno.Visible = true;
                    this.Dispose();
                    return;
                }

                if (CancelarTurno)
                {
                    menuCancelarTurno.SetProfesional(Matricula,
                                                     TablaProfesionales.Rows[e.RowIndex]["Nombre"].ToString() + " " +
                                                     TablaProfesionales.Rows[e.RowIndex]["Apellido"].ToString());

                    menuCancelarTurno.Visible = true;
                    this.Dispose();
                    return;
                }

                string myQuery = "SELECT FechaInicio, FechaFinal FROM ORACLE_FANS.Cartilla_Medica " +
                                 "WHERE Matricula =  " + Matricula.ToString();

                SqlConnection myConnection;
                myConnection = SQL_Methods.IniciarConnection();

                if (SQL_Methods.DBConnectStatus)
                {
                    DataTable Aux = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
                    if (Aux.Rows.Count > 0)
                    {
                        DateTime FechaInicio = Convert.ToDateTime(Aux.Rows[0][0].ToString());
                        DateTime FechaFinal  = Convert.ToDateTime(Aux.Rows[0][1].ToString());

                        MessageBox.Show("Este profesional ya tiene una Agenda Profesional en Progreso" + System.Environment.NewLine +
                                        "Fecha Desde = " + FechaInicio.ToShortDateString() + System.Environment.NewLine +
                                        "Fecha Hasta = " + FechaFinal.ToShortDateString());
                        return;
                    }
                }

                new RegistrarAgendaForm(menu, Matricula);
                this.Dispose();
            }
        }