Пример #1
0
        internal static void updateHotkey(TbHotKeyEntity entity, bool isUpdateExePath)
        {
            TbHotkey db = new TbHotkey();

            db.Open();
            using (var dr = db.ExeQuerySQL(string.Format("select key from {0} where name='{1}'", db.TB_HOTKEY, entity.name)))
            {
                // 把原来先设置好的快捷键取消
                db.ExeSQL(String.Format("update {0} set key=0 where key={1}", db.TB_HOTKEY, entity.key));
                if (dr.Read())
                {
                    if (isUpdateExePath)
                    {
                        db.ExeSQL(String.Format("update {0} set key={1}, exe_path='{2}' where name='{3}'", db.TB_HOTKEY, entity.key, entity.executablePath, entity.name));
                    }
                    else
                    {
                        db.ExeSQL(String.Format("update {0} set key={1}  where name='{2}'", db.TB_HOTKEY, entity.key, entity.name));
                    }
                }
                else
                {
                    db.ExeSQL(string.Format("insert into {0} (name,key,exe_path) values('{1}',{2},'{3}')", db.TB_HOTKEY, entity.name, entity.key, entity.executablePath));
                }
            }
            db.Close();
        }
Пример #2
0
        internal static void Del(TbHotKeyEntity entity)
        {
            var db = new TbHotkey();

            db.Open();
            db.ExeSQL(string.Format("delete from {0} where name='{1}'", db.TB_HOTKEY, entity.name));
            db.Close();
        }
Пример #3
0
        public static List <TbHotKeyEntity> GetAll()
        {
            List <TbHotKeyEntity> list = new List <TbHotKeyEntity>();
            var db = new TbHotkey();

            db.Open();
            using (var dr = db.ExeQuerySQL(String.Format("select name,key,exe_path from {0}", db.TB_HOTKEY)))
            {
                while (dr.Read())
                {
                    var data = new TbHotKeyEntity(dr.GetString(0), dr.GetInt32(1), dr.GetString(2));
                    list.Add(data);
                }
            }
            db.Close();
            return(list);
        }