Пример #1
0
        public DataTable Buscar(DTermino Termino)
        {
            DataTable     dtResultado = new DataTable("Termino");
            SqlConnection sqlCon      = new SqlConnection();

            try
            {
                sqlCon.ConnectionString = Conexion.cn;
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.Connection  = sqlCon;
                sqlCmd.CommandText = "sp_buscarTermino";
                sqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParTextoBuscar = new SqlParameter();
                ParTextoBuscar.ParameterName = "@textoBuscar";
                ParTextoBuscar.SqlDbType     = SqlDbType.VarChar;
                ParTextoBuscar.Size          = 50;
                ParTextoBuscar.Value         = Termino.TextoBuscar;

                sqlCmd.Parameters.Add(ParTextoBuscar);

                SqlDataAdapter sqlDat = new SqlDataAdapter(sqlCmd);
                sqlDat.Fill(dtResultado);
            }
            catch (Exception ex)
            {
                dtResultado = null;
            }

            return(dtResultado);
        }
Пример #2
0
        public string Editar(DTermino Termino)
        {
            string        rpta   = "";
            SqlConnection sqlCon = new SqlConnection();

            try
            {
                sqlCon.ConnectionString = Conexion.cn;
                sqlCon.Open();
                //Comandos
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.Connection  = sqlCon;
                sqlCmd.CommandText = "sp_editarTermino";
                sqlCmd.CommandType = CommandType.StoredProcedure;


                SqlParameter ParIdTermino = new SqlParameter();
                ParIdTermino.ParameterName = "@idTermino";
                ParIdTermino.SqlDbType     = SqlDbType.Int;
                ParIdTermino.Value         = Termino.IdTermino;
                sqlCmd.Parameters.Add(ParIdTermino);

                SqlParameter ParNomTermino = new SqlParameter();
                ParNomTermino.ParameterName = "@nomTermino";
                ParNomTermino.SqlDbType     = SqlDbType.VarChar;
                ParNomTermino.Size          = 50;
                ParNomTermino.Value         = Termino.Nombre;
                sqlCmd.Parameters.Add(ParNomTermino);

                SqlParameter ParEstTermino = new SqlParameter();
                ParEstTermino.ParameterName = "@estTermino";
                ParEstTermino.SqlDbType     = SqlDbType.Char;
                ParEstTermino.Size          = 1;
                ParEstTermino.Value         = Termino.Estado;
                sqlCmd.Parameters.Add(ParEstTermino);

                rpta = sqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se editó el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (sqlCon.State == ConnectionState.Open)
                {
                    sqlCon.Close();
                }
            }
            return(rpta);
        }