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 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(); }
private void FrmMenu_Load(object sender, EventArgs e) { //lv_map.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); this.loadMap(); //处理配置好的值 if (Global.mh_cfg.ContainsKey(hwnd)) { mhcfg = Global.mh_cfg[hwnd]; //赋值开始 txt_hp.Text = mhcfg.hp.ToString(); txt_mp.Text = mhcfg.mp.ToString(); cbx_hm.Checked = mhcfg.hp_mp_auto == 1; txt_bb_hp.Text = mhcfg.bb_hp.ToString(); txt_bb_mp.Text = mhcfg.bb_mp.ToString(); cbx_bb_hm.Checked = mhcfg.bb_hp_mp_auto == 1; cbx_skill_auto.Checked = mhcfg.skill_auto == 1; } else { mhcfg = new model.MhxyConfig(); } if (people_id > 0) { mhcfg.id = people_id; } List <model.MhxySkill> skills = model.MhxySkill.GetAll(); int people_idx = -1; int bb_idx = -1; for (int i = 0; i < skills.Count; i++) { model.MhxySkill s = skills[i]; //人物技能 if (s.SkillType == 0) { cbx_skill.Items.Add(new util.ComboxItem(s.Name, s.SkillId.ToString())); if (mhcfg.skill == s.SkillId) { people_idx = cbx_skill.Items.Count - 1; } } //宝宝技能 if (s.SkillType == 1) { cbx_bb_skill.Items.Add(new util.ComboxItem(s.Name, s.SkillId.ToString())); if (mhcfg.bb_skill == s.SkillId) { bb_idx = cbx_bb_skill.Items.Count - 1; } } //共有技能 if (s.SkillType == -1) { cbx_skill.Items.Add(new util.ComboxItem(s.Name, s.SkillId.ToString())); cbx_bb_skill.Items.Add(new util.ComboxItem(s.Name, s.SkillId.ToString())); } } cbx_bb_skill.SelectedIndex = 0; cbx_skill.SelectedIndex = 0; if (bb_idx > -1) { cbx_bb_skill.SelectedIndex = bb_idx; } if (people_idx > -1) { cbx_skill.SelectedIndex = people_idx; } }