예제 #1
0
파일: CreadorDao.cs 프로젝트: yonvela20/DND
        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);
        }
예제 #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);
            }
        }
예제 #3
0
        private static void insert(Categoria categoria)
        {
            IDbCommand dbCommand = App.Intance.DbConnection.CreateCommand();

            dbCommand.CommandText = insertSql;
            DbCommandHelper.AddParameter(dbCommand, "nombre", categoria.Nombre);
        }
예제 #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");
            }
        }
예제 #5
0
        public static void delete(Object id)
        {
            IDbCommand dbCommand = App.Intance.DbConnection.CreateCommand();

            dbCommand.CommandText = deleteSql;
            DbCommandHelper.AddParameter(dbCommand, "id", id);
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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 = "";
            };
        }
예제 #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();
        }
예제 #11
0
        public static void Delete(object id)
        {
            IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand();

            dbCommand.CommandText = deleteSql;
            DbCommandHelper.AddParameter(dbCommand, "id", id);
            dbCommand.ExecuteNonQuery();
        }
예제 #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();
        }
예제 #13
0
파일: UserDAO.cs 프로젝트: Benito-B/ad
        public static void Delete(User user)
        {
            IDbCommand comm = DbConn.Instance.Connection.CreateCommand();

            comm.CommandText = deleteQuery;
            DbCommandHelper.AddParameter(comm, "@id", user.Id);
            comm.ExecuteNonQuery();
        }
예제 #14
0
파일: ArticleDAO.cs 프로젝트: Benito-B/ad
        public static void Delete(Article a)
        {
            IDbCommand dbCommand = DbConn.Instance.Connection.CreateCommand();

            dbCommand.CommandText = deleteQuery;
            DbCommandHelper.AddParameter(dbCommand, "@id", a.Id);
            dbCommand.ExecuteNonQuery();
        }
예제 #15
0
파일: MainWindow.cs 프로젝트: khadeon/AD
 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 ();
 }
예제 #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);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #20
0
파일: CategoryDAO.cs 프로젝트: Benito-B/ad
        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();
        }
예제 #21
0
파일: UserDAO.cs 프로젝트: Benito-B/ad
        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();
        }
예제 #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();
        }
예제 #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();
    }
예제 #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();
    }
예제 #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();
        }
예제 #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();
        }
예제 #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"]));
        }
예제 #28
0
파일: Program.cs 프로젝트: migboi/ad
        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();
        }
예제 #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");
        }
예제 #30
0
파일: ArticleDAO.cs 프로젝트: Benito-B/ad
        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);
        }