public static List <MhxyAxis> GetIDList(int flag_id, int type) { List <MhxyAxis> ret = new List <MhxyAxis>(); string sql = "select * from mhxy_axis where flag_id=" + flag_id.ToString() + " and type=" + type.ToString(); SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxyAxis ms = new MhxyAxis(); ms.id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString()); ms.flag_id = Convert.ToInt32(ds.Tables[0].Rows[i]["flag_id"].ToString()); ms.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString()); ms.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString()); ms.nx = Convert.ToInt32(ds.Tables[0].Rows[i]["nx"].ToString()); ms.ny = Convert.ToInt32(ds.Tables[0].Rows[i]["ny"].ToString()); ms.remarks = ds.Tables[0].Rows[i]["remarks"].ToString(); ret.Add(ms); } return(ret); }
/// <summary> /// 获取全部数据 /// </summary> /// <returns></returns> public static List <MhxyMapRegion> GetMapAll() { List <MhxyMapRegion> ret = new List <MhxyMapRegion>(); string sql = "select * from mhxy_map_region"; SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxyMapRegion m = new MhxyMapRegion(); m.id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString()); m.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString()); m.name = ds.Tables[0].Rows[i]["name"].ToString(); m.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString()); m.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString()); m.max_x = Convert.ToInt32(ds.Tables[0].Rows[i]["max_x"].ToString()); m.max_y = Convert.ToInt32(ds.Tables[0].Rows[i]["max_y"].ToString()); ret.Add(m); } return(ret); }
/// <summary> /// 保存数据日志 /// </summary> /// <param name="tableName">保存表名称</param> /// <param name="m"></param> public void Save(string tableName) { SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); string sql = "INSERT INTO " + tableName + " (ctime,pkg_type, pkg_len, msg_type, msg_len, body) VALUES(@ctime,@pkg_type, @pkg_len, @msg_type, @msg_len, @body)"; SQLiteParameter[] parameters = { new SQLiteParameter("@ctime", DbType.DateTime2), new SQLiteParameter("@pkg_type", DbType.String), new SQLiteParameter("@pkg_len", DbType.Int32, 4), new SQLiteParameter("@msg_type", DbType.Int32, 4), new SQLiteParameter("@msg_len", DbType.Int32, 4), new SQLiteParameter("@body", DbType.String) }; parameters[0].Value = DateTime.Now; parameters[1].Value = this.pkgType; parameters[2].Value = this.pkgLen; parameters[3].Value = this.msgType; parameters[4].Value = this.msgLen; parameters[5].Value = this.GetBodyByte(); SQLiteCommand cmd = SQLiteHelper.CreateCommand(conn, sql, parameters); cmd.ExecuteNonQuery(); conn.Close(); }
public void Save() { SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); string sql = "INSERT INTO mhxy_map_region (map_id,name,x,y,max_x,max_y) VALUES(@map_id,@name,@x,@y,@max_x,@max_y)"; SQLiteParameter[] parameters = { new SQLiteParameter("@map_id", DbType.Int32, 4), new SQLiteParameter("@name", DbType.String), new SQLiteParameter("@x", DbType.Int32, 4), new SQLiteParameter("@y", DbType.Int32, 4), new SQLiteParameter("@max_x", DbType.Int32, 4), new SQLiteParameter("@max_y", DbType.Int32, 4), }; parameters[0].Value = map_id; parameters[1].Value = name; parameters[2].Value = x; parameters[3].Value = y; parameters[4].Value = max_x; parameters[5].Value = max_y; SQLiteCommand cmd = SQLiteHelper.CreateCommand(conn, sql, parameters); cmd.ExecuteNonQuery(); conn.Close(); }
public static MhxyConfig GetID(int id) { MhxyConfig ret = new MhxyConfig(); string sql = "select * from mhxy_cfg where id=" + id.ToString(); SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ret.id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString()); ret.hp = Convert.ToInt32(ds.Tables[0].Rows[i]["hp"].ToString()); ret.mp = Convert.ToInt32(ds.Tables[0].Rows[i]["mp"].ToString()); ret.hp_mp_auto = Convert.ToInt32(ds.Tables[0].Rows[i]["hp_mp_auto"].ToString()); ret.bb_hp = Convert.ToInt32(ds.Tables[0].Rows[i]["bb_hp"].ToString()); ret.bb_mp = Convert.ToInt32(ds.Tables[0].Rows[i]["bb_mp"].ToString()); ret.bb_hp_mp_auto = Convert.ToInt32(ds.Tables[0].Rows[i]["bb_hp_mp_auto"].ToString()); ret.skill = Convert.ToInt32(ds.Tables[0].Rows[i]["skill"].ToString()); ret.bb_skill = Convert.ToInt32(ds.Tables[0].Rows[i]["bb_skill"].ToString()); ret.skill_auto = Convert.ToInt32(ds.Tables[0].Rows[i]["skill_auto"].ToString()); ret.bb_skill_auto = Convert.ToInt32(ds.Tables[0].Rows[i]["bb_skill_auto"].ToString()); } return(ret); }
public static void Add(MhxyType mt) { SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); string sql = "INSERT INTO mhxy_type (type_id, name, is_show,prefix,filert_rule) VALUES(@type_id, @name, @is_show,@prefix,@filert_rule)"; SQLiteParameter[] parameters = { new SQLiteParameter("@type_id", DbType.Int32, 4), new SQLiteParameter("@name", DbType.String), new SQLiteParameter("@is_show", DbType.Int32, 4), new SQLiteParameter("@prefix", DbType.String), new SQLiteParameter("@filert_rule", DbType.String) }; parameters[0].Value = mt.TypeId; parameters[1].Value = mt.Name; parameters[2].Value = mt.IsShow; parameters[3].Value = mt.prefix; parameters[4].Value = mt.filertRule; SQLiteCommand cmd = SQLiteHelper.CreateCommand(conn, sql, parameters); cmd.ExecuteNonQuery(); conn.Close(); }
/// <summary> /// 获取全部NPC数据 /// </summary> /// <returns></returns> public static List <MhxyNPC> GetAll() { List <MhxyNPC> ret = new List <MhxyNPC>(); string sql = "select * from mhxy_npc"; SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxyNPC mt = new MhxyNPC(); mt.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString()); mt.name = ds.Tables[0].Rows[i]["name"].ToString(); mt.npc_id = Convert.ToInt32(ds.Tables[0].Rows[i]["npc_id"].ToString()); mt.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString()); mt.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString()); ret.Add(mt); } return(ret); }
/// <summary> /// 获取全部数据 /// </summary> /// <returns></returns> public static List <MhxySkill> GetAll() { List <MhxySkill> ret = new List <MhxySkill>(); string sql = "select * from mhxy_skill"; SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxySkill ms = new MhxySkill(); ms.SkillId = Convert.ToInt32(ds.Tables[0].Rows[i]["skill_id"].ToString()); ms.Name = ds.Tables[0].Rows[i]["name"].ToString(); ms.SkillType = Convert.ToInt32(ds.Tables[0].Rows[i]["skill_type"].ToString()); ms.Factions = Convert.ToInt32(ds.Tables[0].Rows[i]["factions"].ToString()); ms.hp = Convert.ToInt32(ds.Tables[0].Rows[i]["hp"].ToString()); ms.mp = Convert.ToInt32(ds.Tables[0].Rows[i]["mp"].ToString()); ret.Add(ms); } return(ret); }
/// <summary> /// 修改状态 /// </summary> /// <param name="typeId"></param> /// <param name="value"></param> /// <returns>返回影响行数</returns> public static int UpdateShow(int typeId, int value) { string sql = "update mhxy_type set is_show=" + value.ToString() + " where type_id=" + typeId.ToString(); SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); SQLiteCommand cmd = SQLiteHelper.CreateCommand(conn, sql); int ret = cmd.ExecuteNonQuery(); conn.Close(); return(ret); }
/// <summary> /// 获取任务全部数据 /// </summary> /// <param name="mapId"></param> /// <param name="targetId"></param> /// <returns></returns> public static List <MhxyRouterRec> GetRouterAll(int mapId, int targetId) { List <MhxyMapExit> exlist = MhxyMapExit.GetAll(); List <MhxyNPC> npcList = MhxyNPC.GetAll(); List <MhxyRouterRec> ret = new List <MhxyRouterRec>(); string sql = "select * from mhxy_router_rec where map_id=" + mapId.ToString() + " and target_id=" + targetId.ToString() + " order by sort asc"; SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxyRouterRec mt = new MhxyRouterRec(); mt.id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString()); mt.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString()); mt.exit_id = Convert.ToInt32(ds.Tables[0].Rows[i]["exit_id"].ToString()); mt.sort = Convert.ToInt32(ds.Tables[0].Rows[i]["sort"].ToString()); mt.is_type = Convert.ToInt32(ds.Tables[0].Rows[i]["is_type"].ToString()); mt.target_id = Convert.ToInt32(ds.Tables[0].Rows[i]["target_id"].ToString()); mt.remarks = ds.Tables[0].Rows[i]["remarks"].ToString(); //装载出口信息 for (int k = 0; k < exlist.Count; k++) { if (mt.exit_id == exlist[k].id) { mt.mapExit = exlist[k]; } } //装载NPC if (mt.is_type == 0) { for (int k = 0; k < npcList.Count; k++) { if (mt.target_id == npcList[k].npc_id) { mt.npc = npcList[k]; } } } ret.Add(mt); } return(ret); }
public static bool CheckTypeId(int typeId) { SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); string sql = "select type_id from mhxy_type where type_id=" + typeId.ToString(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); DataTable dt = ds.Tables[0]; int count = dt.Rows.Count; if (count > 0) { return(true); } return(false); }
public static void Delete(int id) { SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); string sql = "delete from mhxy_map_region where id=@id"; SQLiteParameter[] parameters = { new SQLiteParameter("@id", DbType.Int32, 4), }; parameters[0].Value = id; SQLiteCommand cmd = SQLiteHelper.CreateCommand(conn, sql, parameters); cmd.ExecuteNonQuery(); conn.Close(); }
/// <summary> /// 获取全部数据 /// </summary> /// <returns></returns> public static List <MhxyMapExit> GetAll() { List <MhxyMap> maps = MhxyMap.GetAll(); List <MhxyMapExit> ret = new List <MhxyMapExit>(); string sql = "select * from mhxy_map_exit"; SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxyMapExit mt = new MhxyMapExit(); mt.id = Convert.ToInt32(ds.Tables[0].Rows[i]["id"].ToString()); mt.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString()); mt.to_map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["to_map_id"].ToString()); mt.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString()); mt.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString()); mt.wait_x = Convert.ToInt32(ds.Tables[0].Rows[i]["wait_x"].ToString()); mt.wait_y = Convert.ToInt32(ds.Tables[0].Rows[i]["wait_y"].ToString()); mt.remarks = ds.Tables[0].Rows[i]["remarks"].ToString(); mt.npc_id = Convert.ToInt32(ds.Tables[0].Rows[i]["npc_id"].ToString()); mt.call_npc_option = Convert.ToInt32(ds.Tables[0].Rows[i]["call_npc_option"].ToString()); for (int j = 0; j < maps.Count; j++) { if (mt.map_id == maps[j].id) { mt.myMap = maps[j]; } if (mt.to_map_id == maps[j].id) { mt.toMap = maps[j]; } } ret.Add(mt); } return(ret); }
public static void Save(MhxyConfig mc) { SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); string sql = "INSERT INTO mhxy_cfg (id,hp,mp,hp_mp_auto,bb_hp,bb_mp,bb_hp_mp_auto,skill,skill_auto,bb_skill,bb_skill_auto) VALUES(@id,@hp,@mp,@hp_mp_auto,@bb_hp,@bb_mp,@bb_hp_mp_auto,@skill,@skill_auto,@bb_skill,@bb_skill_auto)"; SQLiteParameter[] parameters = { new SQLiteParameter("@id", DbType.Int32, 4), new SQLiteParameter("@hp", DbType.Int32, 4), new SQLiteParameter("@mp", DbType.Int32, 4), new SQLiteParameter("@hp_mp_auto", DbType.Int32, 4), new SQLiteParameter("@bb_hp", DbType.Int32, 4), new SQLiteParameter("@bb_mp", DbType.Int32, 4), new SQLiteParameter("@bb_hp_mp_auto", DbType.Int32, 4), new SQLiteParameter("@skill", DbType.Int32, 4), new SQLiteParameter("@skill_auto", DbType.Int32, 4), new SQLiteParameter("@bb_skill", DbType.Int32, 4), new SQLiteParameter("@bb_skill_auto", DbType.Int32, 4), }; parameters[0].Value = mc.id; parameters[1].Value = mc.hp; parameters[2].Value = mc.mp; parameters[3].Value = mc.hp_mp_auto; parameters[4].Value = mc.bb_hp; parameters[5].Value = mc.bb_mp; parameters[6].Value = mc.bb_hp_mp_auto; parameters[7].Value = mc.skill; parameters[8].Value = mc.skill_auto; parameters[9].Value = mc.bb_skill; parameters[10].Value = mc.bb_skill_auto; SQLiteCommand cmd = SQLiteHelper.CreateCommand(conn, sql, parameters); cmd.ExecuteNonQuery(); conn.Close(); }
/// <summary> /// 获取全部数据 /// </summary> /// <returns></returns> public static List <MhxyType> GetAll() { string sql = "select * from mhxy_type"; SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); List <MhxyType> ret = new List <MhxyType>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MhxyType mt = new MhxyType(); mt.TypeId = Convert.ToInt32(ds.Tables[0].Rows[i]["type_id"].ToString()); mt.Name = ds.Tables[0].Rows[i]["name"].ToString(); mt.IsShow = Convert.ToInt32(ds.Tables[0].Rows[i]["is_show"].ToString()); mt.prefix = ds.Tables[0].Rows[i]["prefix"].ToString(); mt.filertRule = ds.Tables[0].Rows[i]["filert_rule"].ToString(); ret.Add(mt); } return(ret); }
public static MhxyNPC GetNPCID(int npc_id) { MhxyNPC mt = new MhxyNPC(); string sql = "select * from mhxy_npc where npc_id=" + npc_id.ToString(); SQLiteConnection conn = SQLiteUtil.GetConn(); conn.Open(); DataSet ds = SQLiteHelper.ExecuteDataSet(conn, sql, null); conn.Close(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { mt.map_id = Convert.ToInt32(ds.Tables[0].Rows[i]["map_id"].ToString()); mt.name = ds.Tables[0].Rows[i]["name"].ToString(); mt.npc_id = Convert.ToInt32(ds.Tables[0].Rows[i]["npc_id"].ToString()); mt.x = Convert.ToInt32(ds.Tables[0].Rows[i]["x"].ToString()); mt.y = Convert.ToInt32(ds.Tables[0].Rows[i]["y"].ToString()); } return(mt); }