public void LoadGateSetting(int id) { MySqlConnection conn = new MySqlConnection(connectionString); MySqlCommand cmd = new MySqlCommand( "select id, gate_class, gate_type, gate_code, gate_name, image_dir from gates where id=" + id, conn); conn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { gateId = reader.GetInt64("id"); int gtClass = reader.GetInt32("gate_class"); switch (gtClass) { case 1: gateClass = GateClass.car; break; case 2: gateClass = GateClass.motor; break; } int type = reader.GetInt32("gate_type"); switch (type) { case 1: gateType = GateType.gatein; break; case 2: gateType = GateType.gateout; break; } gateCode = reader.GetString("gate_code"); gateName = reader.GetString("gate_name"); } reader.Close(); // get tarif based on gate class string sql = "select id, name, initial_price, extended_price, extended_after from tarifs where id = "; switch (gateClass) { case GateClass.car: sql += currentCarTarifId.ToString(); break; case GateClass.motor: sql += currentMotorTarifId.ToString(); break; } cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sql; if (conn.State != System.Data.ConnectionState.Open) conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { tarifId = reader.GetInt32("id"); tarifName = reader.GetString("name"); tarifInitial = reader.GetInt64("initial_price"); tarifExtended = reader.GetInt64("extended_price"); tarifExtendedHour = reader.GetInt32("extended_after"); } reader.Close(); conn.Close(); }
void Awake() { instace = this; }
public void LoadGateSetting(int id) { MySqlConnection conn = new MySqlConnection(connectionString); MySqlCommand cmd = new MySqlCommand( "select id, gate_class, gate_type, gate_code, gate_name, image_dir from gates where id=" + id, conn); conn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { gateId = reader.GetInt64("id"); int gtClass = reader.GetInt32("gate_class"); switch (gtClass) { case 1: gateClass = GateClass.car; break; case 2: gateClass = GateClass.motor; break; } int type = reader.GetInt32("gate_type"); switch (type) { case 1: gateType = GateType.gatein; break; case 2: gateType = GateType.gateout; break; } gateCode = reader.GetString("gate_code"); gateName = reader.GetString("gate_name"); } reader.Close(); // get tarif based on gate class string sql = "select id, name, initial_price, extended_price, extended_after from tarifs where id = "; switch (gateClass) { case GateClass.car: sql += currentCarTarifId.ToString(); break; case GateClass.motor: sql += currentMotorTarifId.ToString(); break; } cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sql; if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } reader = cmd.ExecuteReader(); while (reader.Read()) { tarifId = reader.GetInt32("id"); tarifName = reader.GetString("name"); tarifInitial = reader.GetInt64("initial_price"); tarifExtended = reader.GetInt64("extended_price"); tarifExtendedHour = reader.GetInt32("extended_after"); } reader.Close(); conn.Close(); }