public AddUpdateTesauroScjn(TesauroScjn conceptoScjn)
 {
     InitializeComponent();
     this.conceptoScjn = conceptoScjn;
     this.isUpdating   = true;
     this.Header       = "Actualizar concepto del tesauro de la SCJN";
 }
        public ObservableCollection <TesauroScjn> GetRelations(Temas temaTematico, int tipoRelacion)
        {
            OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["Diccionario"].ToString());

            ObservableCollection <TesauroScjn> conceptosRelacionados = new ObservableCollection <TesauroScjn>();

            OleDbCommand    cmd;
            OleDbDataReader reader;

            cmd            = connection.CreateCommand();
            cmd.Connection = connection;

            try
            {
                connection.Open();
                string miQry = "SELECT T.* FROM Relaciones R INNER JOIN TesauroScjn T ON R.IdRelExterna = T.IdTesauroScjn " +
                               " WHERE IdConcepto = @IdConcepto AND TipoRelacion = @TipoRelacion";

                cmd = new OleDbCommand(miQry, connection);
                cmd.Parameters.AddWithValue("@IdConcepto", temaTematico.IDTema);
                cmd.Parameters.AddWithValue("@TipoRelacion", tipoRelacion);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    TesauroScjn tesauro = new TesauroScjn()
                    {
                        Id           = reader["IdTesauroScjn"] as int? ?? 0,
                        ConceptoScjn = reader["Concepto"].ToString(),
                        IsSelected   = false
                    };

                    conceptosRelacionados.Add(tesauro);
                }
            }
            catch (OleDbException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            finally
            {
                connection.Close();
            }

            return(conceptosRelacionados);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Obtiene los términos relacionados a un concepto genérico en concreto
        /// </summary>
        /// <param name="idConceptoScjn">Identificador del concepto del cual se quieren obtener sus relaciones</param>
        /// <returns></returns>
        public ObservableCollection <TesauroScjn> GetTerminosScjn(Genericos terminoGenerico)
        {
            ObservableCollection <TesauroScjn> conceptos = new ObservableCollection <TesauroScjn>();

            OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["Diccionario"].ToString());
            OleDbCommand    cmd;
            OleDbDataReader reader = null;

            try
            {
                connection.Open();

                string sqlCadena = "SELECT T.IdTesauroScjn, T.Concepto, R.IdConcepto, R.IdRelExterna " +
                                   " FROM TesauroScjn T INNER JOIN Relaciones R ON R.IdRelExterna = T.IdTesauroScjn " +
                                   " WHERE IdConcepto = @IdConcepto AND TipoRelacion = 9";

                cmd = new OleDbCommand(sqlCadena, connection);
                cmd.Parameters.AddWithValue("@IdConcepto", terminoGenerico.IdGenerico);
                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TesauroScjn scjn = new TesauroScjn();
                        scjn.Id           = reader["IdTesauroScjn"] as int? ?? 0;
                        scjn.ConceptoScjn = reader["Concepto"].ToString();

                        conceptos.Add(scjn);
                    }
                }
            }
            catch (OleDbException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            finally
            {
                reader.Close();
                connection.Close();
            }

            return(conceptos);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Permite añadir un nuevo concepto del Tesauro de la SCJN
        /// </summary>
        /// <param name="terminoScjn"></param>
        public void SetNewTerminoScjn(TesauroScjn terminoScjn)
        {
            OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["Diccionario"].ToString());

            OleDbDataAdapter dataAdapter;

            DataSet dataSet = new DataSet();
            DataRow dr;

            try
            {
                string sqlCadena = "SELECT * FROM TesauroScjn WHERE IdTesauroScjn = 0";

                dataAdapter = new OleDbDataAdapter();
                dataAdapter.SelectCommand = new OleDbCommand(sqlCadena, connection);

                dataAdapter.Fill(dataSet, "TesauroScjn");

                dr = dataSet.Tables["TesauroScjn"].NewRow();
                dr["IdTesauroScjn"] = terminoScjn.Id;
                dr["Concepto"]      = StringUtilities.ToTitleCase(terminoScjn.ConceptoScjn);

                dataSet.Tables["TesauroScjn"].Rows.Add(dr);

                dataAdapter.InsertCommand = connection.CreateCommand();

                dataAdapter.InsertCommand.CommandText = "INSERT INTO TesauroScjn VALUES (@IdTesauroScjn,@Concepto)";
                dataAdapter.InsertCommand.Parameters.Add("@IdTesauroScjn", OleDbType.Numeric, 0, "IdTesauroScjn");
                dataAdapter.InsertCommand.Parameters.Add("@Concepto", OleDbType.VarChar, 0, "Concepto");

                dataAdapter.Update(dataSet, "TesauroScjn");
                dataSet.Dispose();
                dataAdapter.Dispose();
            }
            catch (OleDbException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <TesauroScjn> GetTerminosScjn()
        {
            OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["Diccionario"].ToString());

            ObservableCollection <TesauroScjn> terminosScjn = new ObservableCollection <TesauroScjn>();

            OleDbCommand    cmd;
            OleDbDataReader reader;

            cmd            = connection.CreateCommand();
            cmd.Connection = connection;

            try
            {
                connection.Open();
                string miQry = "SELECT * FROM TesauroScjn";

                cmd    = new OleDbCommand(miQry, connection);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    TesauroScjn tesauro = new TesauroScjn();
                    tesauro.Id           = reader["IdTesauroScjn"] as int? ?? -1;
                    tesauro.ConceptoScjn = reader["Concepto"].ToString();

                    terminosScjn.Add(tesauro);
                }
            }
            catch (OleDbException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

                MessageBox.Show("Error ({0}) : {1}" + ex.Source + ex.Message, methodName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ErrorUtilities.SetNewErrorMessage(ex, methodName, 0);
            }
            finally
            {
                connection.Close();
            }

            return(terminosScjn);
        }
Exemplo n.º 6
0
        private void BtnAddRelaciona_Click(object sender, RoutedEventArgs e)
        {
            TesauroScjn tesauro = new TesauroScjn()
            {
                Id           = Convert.ToInt32(TxtIdTemaScjn.Text),
                ConceptoScjn = TxtConceptoScjn.Text,
                IsSelected   = false
            };

            new TesauroScjnModel().SetNewTerminoScjn(tesauro);
            new RelacionesModel().SetNewRelation(selectedTema.IDTema, tesauro.Id, selectedMateria.Id + 100);
            TesauroScjnSingleton.ConceptosScjn.Add(tesauro);
            conceptosScjn.Add(tesauro);

            this.BtnLimpiar_Click(null, null);
        }
 public AddUpdateTesauroScjn()
 {
     InitializeComponent();
     this.conceptoScjn = new TesauroScjn();
     this.Header       = "Añadir concepto del tesauro de la SCJN";
 }