Exemple #1
0
        public static List <BusClass> all()
        {
            MySqlConnection conn = new MySqlConnection(MYSQLConnection.connectionString);
            MySqlCommand    cmd  = new MySqlCommand("SELECT * FROM tbl_bus_class", conn);

            try
            {
                conn.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            MySqlDataReader rdr        = cmd.ExecuteReader();
            List <BusClass> busClasses = new List <BusClass>();

            while (rdr.Read())
            {
                var busClass = new BusClass();
                busClass.id   = int.Parse(rdr["id"].ToString());
                busClass.name = rdr["name"].ToString();
                busClasses.Add(busClass);
            }
            return(busClasses);
        }
Exemple #2
0
 public frm_new_bus()
 {
     InitializeComponent();
     this.stations   = Station.all();
     this.busClasses = BusClass.all();
     this.companies  = Company.all();
     foreach (var x in this.stations)
     {
         cb_routefrom.Items.Add(x.name);
         cb_routeto.Items.Add(x.name);
     }
     foreach (var x in this.busClasses)
     {
         cb_class.Items.Add(x.name);
     }
     foreach (var x in this.companies)
     {
         cb_company.Items.Add(x.name);
     }
 }
Exemple #3
0
        public BusClass getBusClass()
        {
            MySqlConnection conn = new MySqlConnection(MYSQLConnection.connectionString);
            MySqlCommand    cmd  = new MySqlCommand("SELECT * FROM tbl_bus_class WHERE id='" + this.bus_class + "'", conn);

            try
            {
                conn.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            MySqlDataReader rdr      = cmd.ExecuteReader();
            BusClass        busClass = new BusClass();

            while (rdr.Read())
            {
                busClass.id   = int.Parse(rdr["id"].ToString());
                busClass.name = rdr["name"].ToString();
            }
            return(busClass);
        }