Exemple #1
0
        public static Creador Load(object id)
        {
            IDbCommand dbCommand = App.Instance.Connection.CreateCommand();

            dbCommand.CommandText = "select * from personaje where id = @id";
            DbCommandHelper.AddParameter(dbCommand, "id", id);
            IDataReader dataReader = dbCommand.ExecuteReader();

            dataReader.Read();

            string nombre       = (string)dataReader["nombre"];
            string raza         = (string)dataReader["raza"];
            int    fuerza       = (int)dataReader["fuerza"];
            int    destreza     = (int)dataReader["destreza"];
            int    constitucion = (int)dataReader["constitucion"];
            int    inteligencia = (int)dataReader["inteligencia"];
            int    sabiduria    = (int)dataReader["sabiduria"];
            int    carisma      = (int)dataReader["carisma"];

            Creador personaje = new Creador();

            personaje.Id           = Convert.ToInt64(id);
            personaje.Nombre       = nombre;
            personaje.Raza         = raza;
            personaje.Fuerza       = fuerza;
            personaje.Destreza     = destreza;
            personaje.Constitucion = constitucion;
            personaje.Inteligencia = inteligencia;
            personaje.Sabiduria    = sabiduria;
            personaje.Carisma      = carisma;

            dataReader.Close();

            return(personaje);
        }
Exemple #2
0
        private static void ActiveSequenceMarker(DbConnection connection)
        {
#if PgSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
update PH7_SequenceMarker set
  SM_ActiveTime = now()
where SM_Address = @SM_Address"))
#endif
#if MsSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
update PH7_SequenceMarker set
  SM_ActiveTime = getdate()
where SM_Address = @SM_Address"))
#endif
#if MySQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
update PH7_SequenceMarker set
  SM_ActiveTime = now()
where SM_Address = ?SM_Address"))
#endif
#if ORA
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
update PH7_SequenceMarker set
  SM_ActiveTime = sysdate
where SM_Address = :SM_Address"))
#endif
            {
                DbCommandHelper.CreateParameter(command, "SM_Address", NetConfig.LocalAddress);
                DbCommandHelper.ExecuteNonQuery(command, false);
            }
        }
Exemple #3
0
        private static void insert(Categoria categoria)
        {
            IDbCommand dbCommand = App.Intance.DbConnection.CreateCommand();

            dbCommand.CommandText = insertSql;
            DbCommandHelper.AddParameter(dbCommand, "nombre", categoria.Nombre);
        }
Exemple #4
0
        private static void initSql(SQLiteConnection con)
        {
            if (_cmdSearchFlowDocuments == null)
            {
                _cmdSearchFlowDocuments = new DbCommandHelper(con);
                _cmdSearchFlowDocuments.Command.CommandText = @"SELECT 
                                                                    FlowDocument_fts.rowid, 
                                                                    snippet(FlowDocument_fts, -1, '<FTSSearchResult>', '</FTSSearchResult>', '', 25),
                                                                    rank
                                                                FROM 
                                                                    FlowDocument_fts
                                                                WHERE 
                                                                    FlowDocument_fts MATCH @searchTerm;";
                _cmdSearchFlowDocuments.AddParameter("@searchTerm");

                _cmdSearchSceneNames = new DbCommandHelper(con);
                _cmdSearchSceneNames.Command.CommandText = @"SELECT
                                                                Scene_fts.rowid, 
                                                                snippet(Scene_fts, -1, '<FTSSearchResult>', '</FTSSearchResult>', '', 25),
                                                                rank
                                                             FROM 
                                                                Scene_fts
                                                             WHERE 
                                                                Scene_fts MATCH @searchTerm;";
                _cmdSearchSceneNames.AddParameter("@searchTerm");

                _cmdSearchChapterNames = new DbCommandHelper(con);
                _cmdSearchChapterNames.Command.CommandText = @"SELECT
                                                                Chapter_fts.rowid, 
                                                                snippet(Chapter_fts, -1, '<FTSSearchResult>', '</FTSSearchResult>', '', 25),
                                                                rank
                                                             FROM 
                                                                Chapter_fts
                                                             WHERE 
                                                                Chapter_fts MATCH @searchTerm;";
                _cmdSearchChapterNames.AddParameter("@searchTerm");

                _cmdSearchStoryNames = new DbCommandHelper(con);
                _cmdSearchStoryNames.Command.CommandText = @"SELECT
                                                                Story_fts.rowid, 
                                                                snippet(Story_fts, -1, '<FTSSearchResult>', '</FTSSearchResult>', '', 25),
                                                                rank
                                                             FROM 
                                                                Story_fts
                                                             WHERE 
                                                                Story_fts MATCH @searchTerm;";
                _cmdSearchStoryNames.AddParameter("@searchTerm");

                _cmdSearchMarkdownDocuments = new DbCommandHelper(con);
                _cmdSearchMarkdownDocuments.Command.CommandText = @"SELECT
                                                                        MarkdownDocument_fts.rowid, 
                                                                        snippet(MarkdownDocument_fts, -1, '<FTSSearchResult>', '</FTSSearchResult>', '', 25),
                                                                        rank
                                                                    FROM 
                                                                        MarkdownDocument_fts
                                                                    WHERE 
                                                                        MarkdownDocument_fts MATCH @searchTerm;";
                _cmdSearchMarkdownDocuments.AddParameter("@searchTerm");
            }
        }
Exemple #5
0
        public static void delete(Object id)
        {
            IDbCommand dbCommand = App.Intance.DbConnection.CreateCommand();

            dbCommand.CommandText = deleteSql;
            DbCommandHelper.AddParameter(dbCommand, "id", id);
        }
Exemple #6
0
        /// <summary>
        /// 确认收到
        /// </summary>
        /// <param name="transaction">DbTransaction</param>
        /// <param name="id">消息ID</param>
        /// <param name="burn">是否销毁</param>
        public static void AffirmReceived(DbTransaction transaction, long id, bool burn)
        {
            if (burn)
#if PgSQL
                using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
delete from PH7_UserMessage
where UM_ID = @UM_ID and UM_SendTime is null"))
#endif
#if MsSQL
                using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
delete from PH7_UserMessage
where UM_ID = @UM_ID and UM_SendTime is null"))
#endif
#if MySQL
                using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
delete from PH7_UserMessage
where UM_ID = ?UM_ID and UM_SendTime is null"))
#endif
#if ORA
                using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
delete from PH7_UserMessage
where UM_ID = :UM_ID and UM_SendTime is null"))
#endif
            {
                DbCommandHelper.CreateParameter(command, "UM_ID", id);
                if (DbCommandHelper.ExecuteNonQuery(command, false) == 1)
                {
                    return;
                }
            }
#if PgSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
update PH7_UserMessage set
  UM_ReceivedTime = now()
where UM_ID = @UM_ID and UM_SendTime is null or UM_SendTime = @UM_SendTime and UM_SendTime is not null"))
#endif
#if MsSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
update PH7_UserMessage set
  UM_ReceivedTime = getdate()
where UM_ID = @UM_ID and UM_SendTime is null or UM_SendTime = @UM_SendTime and UM_SendTime is not null"))
#endif
#if MySQL
            using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
update PH7_UserMessage set
  UM_ReceivedTime = now()
where UM_ID = ?UM_ID and UM_SendTime is null or UM_SendTime = ?UM_SendTime and UM_SendTime is not null"))
#endif
#if ORA
            using (DbCommand command = DbCommandHelper.CreateCommand(transaction, @"
update PH7_UserMessage set
  UM_ReceivedTime = sysdate
where UM_ID = :UM_ID and UM_SendTime is null or UM_SendTime = :UM_SendTime and UM_SendTime is not null"))
#endif
            {
                DbCommandHelper.CreateParameter(command, "UM_ID", id);
                DbCommandHelper.CreateParameter(command, "UM_SendTime", new DateTime(id));
                DbCommandHelper.ExecuteNonQuery(command, false);
            }
        }
Exemple #7
0
        /// <summary>
        /// 清理报文
        /// </summary>
        /// <param name="connection">DbConnection</param>
        /// <param name="sender">发送用户</param>
        /// <param name="clearMessageDeferMonths">清理几个月前的消息</param>
        public static void Clear(DbConnection connection, string sender, int clearMessageDeferMonths)
        {
#if PgSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_UserMessage
where UM_Sender = @UM_Sender and UM_CreateTime <= @UM_CreateTime"))
#endif
#if MsSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_UserMessage
where UM_Sender = @UM_Sender and UM_CreateTime <= @UM_CreateTime"))
#endif
#if MySQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_UserMessage
where UM_Sender = ?UM_Sender and UM_CreateTime <= ?UM_CreateTime"))
#endif
#if ORA
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_UserMessage
where UM_Sender = :UM_Sender and UM_CreateTime <= :UM_CreateTime"))
#endif
            {
                DbCommandHelper.CreateParameter(command, "UM_Sender", sender);
                DbCommandHelper.CreateParameter(command, "UM_CreateTime", DateTime.Now.AddMonths(-clearMessageDeferMonths));
                DbCommandHelper.ExecuteNonQuery(command, false);
            }
        }
Exemple #8
0
        private void ClearSequenceMarker(DbConnection connection)
        {
#if PgSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_SequenceMarker
where SM_ActiveTime <= @SM_ActiveTime"))
#endif
#if MsSQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_SequenceMarker
where SM_ActiveTime <= @SM_ActiveTime"))
#endif
#if MySQL
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_SequenceMarker
where SM_ActiveTime <= ?SM_ActiveTime"))
#endif
#if ORA
            using (DbCommand command = DbCommandHelper.CreateCommand(connection, @"
delete from PH7_SequenceMarker
where SM_ActiveTime <= :SM_ActiveTime"))
#endif
            {
                DbCommandHelper.CreateParameter(command, "SM_ActiveTime", DateTime.Now.AddMonths(-ClearMarkerDeferMonths));
                DbCommandHelper.ExecuteNonQuery(command, false);
            }
        }
Exemple #9
0
        public categoria_create_w() :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();


            saveAction.Activated += delegate
            {
                string     aux       = edit_nombre.Text;
                IDbCommand dbCommand = SingletonConnection.Connection.CreateCommand();
                dbCommand.CommandText = "insert into categoria (nombre) values (@nombre)";
                DbCommandHelper.addParameter(dbCommand, "nombre", aux);
                dbCommand.ExecuteNonQuery();
                edit_nombre.Text = "";
                this.Hide();
            };

            DeleteEvent += delegate(object o, DeleteEventArgs args)  {
                Hide();
                args.RetVal = true;
            };

            // Cuando se oculte debe borrar el texto
            this.Hidden += delegate {
                edit_nombre.Text = "";
            };
        }
Exemple #10
0
        private static void insert(Categoria categoria)
        {
            IDbCommand dbCommand = App.Instance.Connection.CreateCommand();

            dbCommand.CommandText = "insert into categoria (nombre) values (@nombre)";
            DbCommandHelper.AddParameter(dbCommand, "nombre", categoria.Nombre);
            dbCommand.ExecuteNonQuery();
        }
Exemple #11
0
        public static void Delete(object id)
        {
            IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand();

            dbCommand.CommandText = deleteSql;
            DbCommandHelper.AddParameter(dbCommand, "id", id);
            dbCommand.ExecuteNonQuery();
        }
Exemple #12
0
        public static void Delete(object id)
        {
            IDbCommand dbCommand = App.Instance.Connection.CreateCommand();

            dbCommand.CommandText = "delete from categoria where id = @id";
            DbCommandHelper.AddParameter(dbCommand, "id", id);
            dbCommand.ExecuteNonQuery();
        }
Exemple #13
0
        public static void Delete(User user)
        {
            IDbCommand comm = DbConn.Instance.Connection.CreateCommand();

            comm.CommandText = deleteQuery;
            DbCommandHelper.AddParameter(comm, "@id", user.Id);
            comm.ExecuteNonQuery();
        }
Exemple #14
0
        public static void Delete(Article a)
        {
            IDbCommand dbCommand = DbConn.Instance.Connection.CreateCommand();

            dbCommand.CommandText = deleteQuery;
            DbCommandHelper.AddParameter(dbCommand, "@id", a.Id);
            dbCommand.ExecuteNonQuery();
        }
Exemple #15
0
 private void delete(object id)
 {
     if (!WindowHelper.confirmDelete (this))
         return;
     IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand ();
     dbCommand.CommandText = "delete from articulo where id = @id";
     DbCommandHelper.AddParameter (dbCommand, "id", id);
     dbCommand.ExecuteNonQuery ();
 }
Exemple #16
0
        private static void update(Categoria c)
        {
            IDbConnection dbConn    = DbConn.GetInstance().GetConnection();
            IDbCommand    dbCommand = dbConn.CreateCommand();

            dbCommand.CommandText = updateQuery;
            DbCommandHelper.AddParameter(dbCommand, "@nombre", c.Name);
            DbCommandHelper.AddParameter(dbCommand, "@id", c.Id);
        }
Exemple #17
0
        private static void update(Categoria categoria)
        {
            IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand();

            dbCommand.CommandText = updateSql;
            DbCommandHelper.AddParameter(dbCommand, "nombre", categoria.Nombre);
            DbCommandHelper.AddParameter(dbCommand, "id", categoria.Id);
            dbCommand.ExecuteNonQuery();
        }
Exemple #18
0
        private static void insert(Categoria c)
        {
            IDbConnection dbConn    = DbConn.GetInstance().GetConnection();
            IDbCommand    dbCommand = dbConn.CreateCommand();

            dbCommand.CommandText = insertQuery;
            DbCommandHelper.AddParameter(dbCommand, "@nombre", c.Name);
            dbCommand.ExecuteNonQuery();
        }
Exemple #19
0
        private void insert()
        {
            IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand();

            dbCommand.CommandText = "insert into categoria (nombre) values (@nombre)";
            nombre = entryNombre.Text;
            DbCommandHelper.AddParameter(dbCommand, "nombre", nombre);
            dbCommand.ExecuteNonQuery();
            Destroy();
        }
Exemple #20
0
        private static void update(Category c)
        {
            IDbConnection dbConn    = DbConn.Instance.Connection;
            IDbCommand    dbCommand = dbConn.CreateCommand();

            dbCommand.CommandText = updateQuery;
            DbCommandHelper.AddParameter(dbCommand, "@name", c.Name);
            DbCommandHelper.AddParameter(dbCommand, "@id", c.Id);
            dbCommand.ExecuteNonQuery();
        }
Exemple #21
0
        private static void insert(User user)
        {
            IDbCommand comm = DbConn.Instance.Connection.CreateCommand();

            comm.CommandText = insertQuery;
            DbCommandHelper.AddParameter(comm, "@name", user.Name);
            DbCommandHelper.AddParameter(comm, "@isAdmin", user.IsAdmin);
            DbCommandHelper.AddParameter(comm, "@pass", Hasher.SHA256(user.Password));
            comm.ExecuteNonQuery();
        }
Exemple #22
0
        public static void Save(Movement m)
        {
            IDbCommand dbCommand = DbConn.Instance.Connection.CreateCommand();

            dbCommand.CommandText = insertQuery;
            DbCommandHelper.AddParameter(dbCommand, "@articleId", m.Article.Id);
            DbCommandHelper.AddParameter(dbCommand, "@type", m.Type);
            DbCommandHelper.AddParameter(dbCommand, "@ammount", m.Ammount);
            dbCommand.ExecuteNonQuery();
        }
Exemple #23
0
    public static void insertValue(String name)
    {
        IDbCommand dbCommand = dbConnection.CreateCommand();
        string     nombre    = name;

        dbCommand.CommandText = "insert into categoria (nombre) values (@nombre)";
        DbCommandHelper.AddParameter(dbCommand, "nombre", nombre);

        dbCommand.ExecuteNonQuery();
    }
Exemple #24
0
    protected void categoria(object id)
    {
        IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand();

        dbCommand.CommandText = "delete from categoria where id=@id";

        DbCommandHelper.AddParameter(dbCommand, "id", id);
        Console.Write(id + " id");
        dbCommand.ExecuteNonQuery();
        fill();
    }
Exemple #25
0
        private void update()
        {
            IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand();

            dbCommand.CommandText = "update categoria set nombre=@nombre where id=@id";
            nombre = entryNombre.Text;
            DbCommandHelper.AddParameter(dbCommand, "nombre", nombre);
            DbCommandHelper.AddParameter(dbCommand, "id", id);
            dbCommand.ExecuteNonQuery();
            Destroy();
        }
Exemple #26
0
        public static void Update(Stock s)
        {
            IDbConnection dbConn    = DbConn.Instance.Connection;
            IDbCommand    dbCommand = dbConn.CreateCommand();

            dbCommand.CommandText = updateQuery;
            DbCommandHelper.AddParameter(dbCommand, "@currentStock", s.CurrentStock);
            DbCommandHelper.AddParameter(dbCommand, "@minStock", s.MinStock);
            DbCommandHelper.AddParameter(dbCommand, "@maxStock", s.MaxStock);
            DbCommandHelper.AddParameter(dbCommand, "@articleId", s.ArticleId);
            dbCommand.ExecuteNonQuery();
        }
Exemple #27
0
        public static Categoria GetCategory(ulong id)
        {
            IDbConnection dbConn    = DbConn.GetInstance().GetConnection();
            IDbCommand    dbCommand = dbConn.CreateCommand();

            dbCommand.CommandText = getQuery;
            DbCommandHelper.AddParameter(dbCommand, "@id", id);
            IDataReader dataReader = dbCommand.ExecuteReader();

            dataReader.Read();
            dataReader.Close();
            return(new Categoria((string)dataReader["nombre"], (ulong)dataReader["id"]));
        }
Exemple #28
0
        public static void delete()
        {
            IDbCommand dbCommand = dbConnection.CreateCommand();

            Console.Write("id del elemento a eliminar");
            var numero = Console.ReadLine();

            dbCommand.CommandText = "delete from categoria where id=(@numero)";

            DbCommandHelper.AddParameter(dbCommand, "numero", numero);

            dbCommand.ExecuteNonQuery();
        }
Exemple #29
0
        public Metadata(SQLiteConnection connection)
        {
            _connection = connection;

            _selectKeyCommand = new DbCommandHelper(_connection);
            _selectKeyCommand.Command.CommandText = "SELECT Value FROM Metadata WHERE Key = @key;";
            _selectKeyCommand.AddParameter("@key");

            _setKeyCommand = new DbCommandHelper(_connection);
            _setKeyCommand.Command.CommandText = "UPDATE Metadata SET Value = @value WHERE Key = @key;";
            _setKeyCommand.AddParameter("@key");
            _setKeyCommand.AddParameter("@value");
        }
Exemple #30
0
        private static void update(Article a)
        {
            IDbConnection dbConn    = DbConn.Instance.Connection;
            IDbCommand    dbCommand = dbConn.CreateCommand();

            dbCommand.CommandText = updateQuery;
            DbCommandHelper.AddParameter(dbCommand, "@name", a.Name);
            DbCommandHelper.AddParameter(dbCommand, "@categoryid", a.Category);
            DbCommandHelper.AddParameter(dbCommand, "@price", a.Price);
            DbCommandHelper.AddParameter(dbCommand, "@id", a.Id);
            dbCommand.ExecuteNonQuery();
            StockDAO.Update(a.Stock);
        }