public void loadPlayerMoney(int id) { Player player = new PlayerList()[id]; var licenseIdentifier = player.Identifiers["steam"]; MYSQL.FetchAll($"SELECT * FROM playermoney WHERE steamid = '{licenseIdentifier}'", null, (List <dynamic> list) => { Debug.WriteLine("3"); int money_ = 1000; int bank_ = 5000; int dirtyMoney_ = 0; int count = (list == null) ? 0 : list.Count; if (count == 0) { MYSQL.execute($"INSERT INTO playermoney (steamid,money,bank,dirty_money) VALUES ('{licenseIdentifier}','{money_}','{bank_}','{dirtyMoney_}');"); Debug.WriteLine($"Vytvarim hrace: {player.Name} [MONEYSYSTEM]"); } else { money_ = list[0].money; bank_ = list[0].bank; dirtyMoney_ = list[0].dirty_money; Debug.WriteLine($"Nacitam hrace: {player.Name} [MONEYSYSTEM]"); } PlayerMoney money = new PlayerMoney(); money.setPlayer(player); money.setMoney(money_); money.setBankMoney(bank_); money.setDirtyMoney(dirtyMoney_); PlayerMoneyHolder.saveMoneyPlayerToList(id, money); }); }
private void submit_Click(object sender, EventArgs e) { string ac = account.Text; string passwd = password.Text; string rep = repasswd.Text; if (passwd == rep) { MYSQL mYSQL = new MYSQL(); MySqlConnection conn = mYSQL.Connection(); conn.Open(); string sql = string.Format("INSERT INTO Login VALUES('{0}', 'kkk', '{1}', 'User');", ac, passwd); MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); MessageBox.Show("注册成功,即将返回登陆界面..."); login login = new login(); this.Dispose(); login.ShowDialog(); } else { MessageBox.Show("密码不一致,请重新输入!"); } }
public static void loadPlayerJob(int source) { Player player = new PlayerList()[source]; string job = "unemployed"; string grade = "unemployed"; var licenseIdentifier = player.Identifiers["steam"]; MYSQL.FetchAll($"SELECT * FROM playerjob WHERE steamid = '{licenseIdentifier}'", null, (List <dynamic> list) => { int count = (list == null) ? 0 : list.Count; if (count == 0) { MYSQL.execute($"INSERT INTO playerjob (name,grade,steamid) VALUES ('{job}','{grade}','{licenseIdentifier}');"); Debug.WriteLine("Zapisuju nového hráče do tabulky 'PlayerJob'"); } else { job = list[0].name; grade = list[0].grade; } player.TriggerEvent("xCore:client:LoadJob", job, grade); PlayerJob pJob = new PlayerJob(); pJob.setPlayer(player); pJob.setPlayerJob(job, grade); PlayerJobHolder.savePlayerToList(source, pJob); }); }
private void search_Click(object sender, EventArgs e) { MYSQL mYSQL = new MYSQL(); string sql; string province, city, risklevel; if (searchType.Text == "省(简称)") { province = searchCondition.Text; sql = string.Format("SELECT Situation.City, Area, RiskLevel FROM Situation, Map WHERE Situation.City = Map.City AND Province = '{0}';", province); DataTable dataTable = mYSQL.GetMessage(sql); esearchTable.DataSource = dataTable; } else if (searchType.Text == "城市") { city = searchCondition.Text; sql = string.Format("SELECT * FROM Situation WHERE City = '{0}';", city); DataTable dataTable = mYSQL.GetMessage(sql); esearchTable.DataSource = dataTable; } else if (searchType.Text == "风险等级") { risklevel = searchRiskLevel.Text; sql = string.Format("SELECT * FROM Situation WHERE RiskLevel = '{0}';", risklevel); DataTable dataTable = mYSQL.GetMessage(sql); esearchTable.DataSource = dataTable; } else { MessageBox.Show("请选择查询关键字!"); } }
private void Add_Click(object sender, EventArgs e) { string id = actpID.Text; string name = actpName.Text; string sex = actpSex.Text; string hs = actpState.Text; string st = actpDate.Text; string sql; if (hs == "Health") { sql = string.Format("INSERT INTO Person VALUES('{0}', '{1}', '{2}', '{3}', NULL);", id, name, sex, hs); } else { sql = string.Format("INSERT INTO Person VALUES('{0}', '{1}', '{2}', '{3}', '{4}');", id, name, sex, hs, st); } Exec_SQL(sql); sql = string.Format("SELECT * FROM Person WHERE Pid = '{0}';", id); MYSQL mYSQL = new MYSQL(); DataTable table = mYSQL.GetMessage(sql); actpTable.DataSource = table; MessageBox.Show("Add Done!"); }
private void modify_Click(object sender, EventArgs e) { string id = actpID.Text; string name = actpName.Text; string sex = actpSex.Text; string hs = actpState.Text; string st = actpDate.Text; string sql; if (hs == "Health") { sql = string.Format("UPDATE HealthStatus = '{0}', SickTime = NULL FROM Person WHERE Pid = '{1}';", hs, id); } else { //update 的sql语句居然写错了。。。。 sql = string.Format("UPDATE Person SET HealthStatus = '{0}', SickTime = '{1}' WHERE Pid = '{2}';", hs, st, id); } Exec_SQL(sql); sql = string.Format("SELECT * FROM Person WHERE Pid = '{0}';", id); MYSQL mYSQL = new MYSQL(); DataTable table = mYSQL.GetMessage(sql); actpTable.DataSource = table; MessageBox.Show("Update Done!"); }
private void admindex_Load(object sender, EventArgs e) { AdminIndexTable.Enabled = false; AdminIndexTable.Visible = false; MYSQL mYSQL = new MYSQL(); MySqlConnection conn = mYSQL.Connection(); conn.Open(); string [] sql = { "SELECT COUNT(*) Num FROM Person WHERE HealthStatus = 'Sick';", "SELECT COUNT(*) Num FROM Person WHERE HealthStatus = 'Fever';", "SELECT COUNT(*) Num FROM Situation WHERE RiskLevel = 'L1';", "SELECT COUNT(*) Num FROM Login WHERE Type = 'Admin';" }; string[] res = new string[4]; for (int i = 0; i < 4; i++) { MySqlCommand cmd = new MySqlCommand(sql[i], conn); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); DataSet dataSet = new DataSet(); adapter.Fill(dataSet); res[i] = dataSet.Tables[0].Rows[0]["Num"].ToString(); } conn.Close(); ConfirmedCases.Text += res[0]; LikelyInfection.Text += res[1]; HighRiskArea.Text += res[2]; AdminCounts.Text += res[3]; }
public static void LOAD() { if (FormCalling.frm1.checkBox1.Checked) { return; } try { DataTable Serv = MYSQL.runRead("SELECT * FROM servers WHERE visible='1' ORDER BY serverid ASC"); for (int i = 0; i < Serv.Rows.Count; i++) { DataRow row = Serv.Rows[i]; int serverId = int.Parse(row["serverid"].ToString()); string name = row["name"].ToString(); string ip = row["ip"].ToString(); int flag = int.Parse(row["flag"].ToString()); int minrank = int.Parse(row["minrank"].ToString()); int slot = int.Parse(row["slot"].ToString()); Servers s = new Servers(serverId, name, ip, flag, minrank, slot); collected.Add(i, s); } Log.AppendText("Loaded " + Serv.Rows.Count + " servers!"); } catch { Log.AppendError("Can't Read Server Infos Check Server Table On DataBase"); } }
private void refresh_Click(object sender, EventArgs e) { MYSQL mYSQL = new MYSQL(); string sql = "SELECT Account, Name FROM Login WHERE Type = 'User';"; DataTable dataTable = mYSQL.GetMessage(sql); userTable.DataSource = dataTable; }
private void refresh_Click(object sender, EventArgs e) { MYSQL mYSQL = new MYSQL(); string sql = "SELECT * FROM Person;"; DataTable table = mYSQL.GetMessage(sql); actpTable.DataSource = table; }
private void button1_Click(object sender, EventArgs e) { MYSQL mYSQL = new MYSQL(); //MySqlConnection conn = mYSQL.Connection(); string sql = "SELECT * FROM Person;"; DataTable table = mYSQL.GetMessage(sql); //dataGridView1.DataSource = table; // ID.Visible = false; //Refresh(); }
public static void playerDisconnectFromGame([FromSource] Player player, string reason) { var licenseIdentifier = player.Identifiers["steam"]; //===================== PlayerJob job = PlayerJobHolder.getPlayerJob(player); if (job != null) { MYSQL.execute($"UPDATE playerjob " + $"SET name = '{job.getJobName()}'," + $"grade = '{job.getJobGrade()}' " + $"WHERE steamid = '{licenseIdentifier}'; "); PlayerJobHolder.removePlayerFromJobList(player); } //===================== PlayerMoney money = PlayerMoneyHolder.getPlayerMoney(player); if (money != null) { MYSQL.execute($"UPDATE playermoney " + $"SET money = '{money.getMoney()}'," + $"bank = '{money.getBankMoney()}'," + $"dirty_money='{money.getDirtyMoney()}'" + $"WHERE steamid = '{licenseIdentifier}'; "); PlayerMoneyHolder.removePlayerFromMoneyList(player); } //===================== PlayerGroup group = PlayerGroupHolder.getPlayerGroup(player); if (group != null) { List <string> gp = group.playerGroups(); StringBuilder sb = new StringBuilder(); if (gp.Count != 0) { for (int i = 0; i < gp.Count; i++) { sb.Append($"('{licenseIdentifier}', '{gp[i]}'),"); } MYSQL.execute($"DELETE FROM `groupusers` WHERE steamid = '{licenseIdentifier}';" + $"INSERT INTO `groupusers` (`steamid`, `group`) VALUES {sb.ToString().Remove(sb.Length - 1)}"); } PlayerGroupHolder.removePlayerFromGroupList(player); } //===================== //===================== //===================== Debug.WriteLine($"Player {player.Name} has disconnected! ================================== :("); }
private void search_Click(object sender, EventArgs e) { MYSQL mYSQL = new MYSQL(); string name; string cityArea; string st, et; string sql; if (searchType.Text == "姓名") { name = searchCondition.Text;//另外显示该人的信息 sql = string.Format("SELECT City, Area, StartTime, EndTime FROM Person, Record " + "WHERE Person.Pid = Record.Pid AND Person.Pname = '{0}' ORDER BY(StartTime);", name); DataTable dataTable = mYSQL.GetMessage(sql); if (!EmptyTable(dataTable)) { searchTable.DataSource = dataTable; } } else if (searchType.Text == "地点(城市-区域)") { cityArea = searchCondition.Text; string[] array1 = cityArea.Split('-'); //另外显示该区域的情况 sql = string.Format("SELECT Pname, HealthStatus, StartTime, EndTime FROM Person, Record " + "WHERE Person.Pid = Record.Pid AND City = '{0}' AND Area = '{1}';", array1[0], array1[1]); // DataTable dataTable = mYSQL.GetMessage(sql); if (!EmptyTable(dataTable)) { searchTable.DataSource = dataTable; } } else if (searchType.Text == "地点-时间段") { cityArea = searchCondition.Text; st = searchSt.Text; et = searchEt.Text; string[] array2 = cityArea.Split('-'); sql = string.Format("SELECT Pname, HealthStatus, StartTime, EndTime FROM Person, Record " + "WHERE Person.Pid = Record.Pid AND City = '{0}' AND Area = '{1}' " + "AND StartTime >= '{2}' AND EndTime <= '{3}';", array2[0], array2[1], st, et); DataTable dataTable = mYSQL.GetMessage(sql); if (!EmptyTable(dataTable)) { searchTable.DataSource = dataTable; } } else { MessageBox.Show("请选择查询关键字!"); } }
private void Exec_SQL(string sql) { MYSQL mYSQL = new MYSQL(); MySqlConnection conn = mYSQL.Connection(); conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); conn.Close(); }
private int Exec_SQL(string sql) { MYSQL mYSQL = new MYSQL(); MySqlConnection conn = mYSQL.Connection(); conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, conn); int res = cmd.ExecuteNonQuery(); conn.Close(); return(res); }
public bool Is_fever(MYSQL mYSQL, string id) { string sql = string.Format("SELECT * FROM Fever WHERE Pid = '{0}';", id); DataTable table = mYSQL.GetMessage(sql); if (table.Rows.Count > 0) { Stable.DataSource = table; return(true); } else { return(false); } }
public bool Is_likely(MYSQL mYSQL, string city, string area, string st, string et) //看是否有与确诊病例接触的可能 { string sql = string.Format("SELECT Pname, City, Area, StartTime, EndTime, SickTime FROM Patient_Record WHERE City = '{0}' AND Area = '{1}' AND StartTime <= '{2}' AND EndTime > '{3}';", city, area, st, st); DataTable table = mYSQL.GetMessage(sql); if (table.Rows.Count > 0) { Stable.DataSource = table; return(true); } else { return(false); } }
private void Delete_Click(object sender, EventArgs e) { string id = actpID.Text; string sql = string.Format("DELETE FROM Person WHERE Pid = '{0}';", id); Exec_SQL(sql); sql = string.Format("SELECT * FROM Person WHERE Pid = '{0}';", id); MYSQL mYSQL = new MYSQL(); DataTable table = mYSQL.GetMessage(sql); actpTable.DataSource = table; MessageBox.Show("Delete Done!"); }
public DBController(ISynchronizeInvoke syncObj) { Server = new pServer(); BaseMob = new STRUCT_MOB[4]; AccountList = new STRUCT_PUSUER[BaseDef.MAX_MAXUSER]; ItemDayLog = new STRUCT_ITEMLOG[BaseDef.MAX_ITEMLIST]; ChargedGuildList = new int[BaseDef.MAX_CHANNEL, BaseDef.MAX_GUILDZONE]; SinceInit = DateTime.Now; PlayerCount = 0; MySQL = new MYSQL(); g_pGuildWar = new short[BaseDef.MAX_GUILD]; g_pGuildAlly = new short[BaseDef.MAX_GUILD]; g_pGuildInfo = new STRUCT_GUILDINFO[BaseDef.MAX_GUILD]; Config = new ConfigServer(); onTask(); }
public void setJobCommand(int id, string name, int grade, dynamic result) { MYSQL.FetchAll($"SELECT * FROM jobgrades WHERE name = '{name}' AND grade ='{grade}'", null, (List <dynamic> list) => { int count = (list == null) ? 0 : list.Count; if (count == 0) { result(false); } else { Debug.WriteLine($"{ list[0].name},{list[0].position}"); TriggerEvent("xCore:Server:setJob", id, list[0].name, list[0].position); result(true); } }); }
private void LikelyInfection_Click(object sender, EventArgs e) { if (state) { AdminIndexTable.Enabled = true; AdminIndexTable.Visible = true; MYSQL mYSQL = new MYSQL(); string sql = "SELECT Pname, HealthStatus, SickTime FROM Person WHERE HealthStatus = 'Fever' LIMIT 0, 10;"; DataTable dataTable = mYSQL.GetMessage(sql); AdminIndexTable.DataSource = dataTable; } else { AdminIndexTable.Enabled = false; AdminIndexTable.Visible = false; } state = !state; }
private void HighRiskArea_Click(object sender, EventArgs e) { if (state) { AdminIndexTable.Enabled = true; AdminIndexTable.Visible = true; MYSQL mYSQL = new MYSQL(); string sql = "SELECT City, Area, RiskLevel FROM Situation WHERE RiskLevel = 'L1';"; DataTable dataTable = mYSQL.GetMessage(sql); AdminIndexTable.DataSource = dataTable; } else { AdminIndexTable.Enabled = false; AdminIndexTable.Visible = false; } state = !state; }
private void AdminCounts_Click(object sender, EventArgs e) { if (state) { AdminIndexTable.Enabled = true; AdminIndexTable.Visible = true; MYSQL mYSQL = new MYSQL(); string sql = "SELECT Account, Name FROM Login WHERE Type = 'Admin';"; DataTable dataTable = mYSQL.GetMessage(sql); AdminIndexTable.DataSource = dataTable; } else { AdminIndexTable.Enabled = false; AdminIndexTable.Visible = false; } state = !state; }
private void Search_Click(object sender, EventArgs e) { MYSQL mYSQL = new MYSQL(); string id = searchCondition.Text; string name = searchCondition.Text; string sicktime = psearchDate.Text; string sql; DataTable dataTable; if (searchType.Text == "身份证号") { sql = string.Format("SELECT * FROM Patient WHERE Pid = '{0}';", id); dataTable = mYSQL.GetMessage(sql); if (!EmptyTable(dataTable)) { psearchTable.DataSource = dataTable; } } else if (searchType.Text == "姓名") { sql = string.Format("SELECT * FROM Patient WHERE Pname = '{0}';", name); dataTable = mYSQL.GetMessage(sql); if (!EmptyTable(dataTable)) { psearchTable.DataSource = dataTable; } } else if (searchType.Text == "确诊时间") { sql = string.Format("SELECT * FROM Patient WHERE SickTime = '{0}';", sicktime); dataTable = mYSQL.GetMessage(sql); if (!EmptyTable(dataTable)) { psearchTable.DataSource = dataTable; } } else { MessageBox.Show("请选择查询关键字!"); } }
private void Delete_Click(object sender, EventArgs e) { string id = actID.Text; string city = actCity.Text; string area = actArea.Text; string st = Ast.Text; string et = Aet.Text; string sql = string.Format("DELETE FROM Record WHERE Pid = '{0}' AND City = '{1}' AND Area = '{2}' AND StartTime >= '{3}' AND EndTime <= '{4}';", id, city, area, st, et); Exec_SQL(sql); sql = string.Format("SELECT * FROM Record WHERE Pid = '{0}' AND City = '{1}' AND Area = '{2}' AND StartTime >= '{3}' AND EndTime <= '{4}'; ", id, city, area, st, et); MYSQL mYSQL = new MYSQL(); DataTable table = mYSQL.GetMessage(sql); ActRecordTable.DataSource = table; MessageBox.Show("Delete Done!"); }
public static void loadPlayerGroup(int source) { Player player = new PlayerList()[source]; var licenseIdentifier = player.Identifiers["steam"]; MYSQL.FetchAll($"SELECT * FROM groupusers WHERE steamid = '{licenseIdentifier}'", null, (List <dynamic> list) => { PlayerGroup pGroup = new PlayerGroup(); pGroup.setPlayer(player); int count = (list == null) ? 0 : list.Count; if (count != 0) { for (int i = 0; i < count; i++) { pGroup.add(list[i].group); } } PlayerGroupHolder.saveGroupToList(player, pGroup); }); }
public override void Handle(LoginServer.Virtual.User.User Connection) { int ClientVersion = int.Parse(getBlock(0)); int LauncherVersion = int.Parse(getBlock(1)); int Type = int.Parse(getBlock(2)); int UserID = 0; if (Type == 1) //FreeWar Account Status { string Username = getBlock(3); string Password = getBlock(4); try { UserID = int.Parse(MYSQL.runReadOnce("id", "SELECT * FROM users WHERE username='******'").ToString()); } catch { UserID = 0; } if (UserID > 0) { MYSQL.runQuery("UPDATE users SET lastipaddress='" + Connection.IPAddress + "' WHERE id='" + UserID + "'"); DataTable dt = MYSQL.runRead("SELECT id, username, password, salt, nickname, dinar, cash, rank, premium, banned FROM users WHERE id=" + UserID.ToString()); DataRow row = dt.Rows[0]; string Salt = row["salt"].ToString(); string md5Password = Structure.convertToMD5(Structure.convertToMD5(Password) + Structure.convertToMD5(Salt)); if (row["password"].ToString() == md5Password) { string Nickname = row["nickname"].ToString(); int Dinar = int.Parse(row["dinar"].ToString()); int Cash = int.Parse(row["cash"].ToString()); int Premium = int.Parse(row["premium"].ToString()); int Rank = int.Parse(row["rank"].ToString()); bool Status = true; Structure.LogFromLauncher.TryAdd(Connection.IPAddress.ToString(), Connection); Connection.send(new PACKET_LAUNCHER_INIT(Nickname, Dinar, Cash, Status, Premium, Rank)); } } } }
private void modify_Click(object sender, EventArgs e) { //怎么实现全码的更改? string id = actID.Text; string city = actCity.Text; string area = actArea.Text; string st = Ast.Text; string et = Aet.Text; //string sql = string.Format("UPDATE Record WHERE Pid = '{0}' AND City = '{1}' AND Area = '{2}' AND StartTime = '{3}' AND EndTime = '{4}';", id, city, area, st, et); string sql = string.Format("INSERT INTO Record VALUES('{0}', '{1}', '{2}', '{3}', '{4}');", id, city, area, st, et); Exec_SQL(sql); sql = string.Format("SELECT * FROM Record WHERE Pid = '{0}' AND City = '{1}' AND Area = '{2}' AND StartTime >= '{3}' AND EndTime <= '{4}'; ", id, city, area, st, et); MYSQL mYSQL = new MYSQL(); DataTable table = mYSQL.GetMessage(sql); ActRecordTable.DataSource = table; MessageBox.Show("Update Done!"); }
//登陆 private void button1_Click(object sender, EventArgs e) { string account = textBox1.Text; string type = loginType.Text; string passwd = textBox2.Text; MYSQL mYSQL = new MYSQL(); MySqlConnection conn = mYSQL.Connection(); conn.Open(); string sql = string.Format("SELECT * FROM Login WHERE Account='{0}' AND Passwd='{1}';", account, passwd); MySqlCommand cmd = new MySqlCommand(sql, conn); object result = cmd.ExecuteScalar(); if (result != null) { if (type == "User") { user user = new user(); this.Dispose(); user.ShowDialog(); } else if (type == "Admin") { admin admin = new admin(); this.Dispose(); admin.ShowDialog(); } else { MessageBox.Show("请选择账户类型!"); } } else { MessageBox.Show("账号或密码错误,请重新输入!"); } conn.Close(); }
private void button1_Click(object sender, EventArgs e) { string UserName = textBox1.Text.ToString(); string Password = textBox2.Text.ToString(); int UserID = 0; try { UserID = int.Parse(MYSQL.runReadOnce("id", "SELECT * FROM users WHERE username='******'").ToString()); } catch { UserID = 0; MessageBox.Show("UserName Not Found", "Error LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (UserID > 0) { DataTable dt = MYSQL.runRead("SELECT id, username, password, salt, rank FROM users WHERE id=" + UserID.ToString()); DataRow row = dt.Rows[0]; string Salt = row["salt"].ToString(); string md5Password = Structure.convertToMD5(Structure.convertToMD5(Password) + Structure.convertToMD5(Salt)); if (row["password"].ToString() == md5Password) { if (int.Parse(row["rank"].ToString()) == 6) { this.Visible = false; FormCalling.frm1.Show(); FormCalling.frm1.Enabled = true; } else { MessageBox.Show("Insufficient Rank To Log In The Core Panel", "Error LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Wrong Password", "Error LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }