コード例 #1
0
ファイル: Form1.cs プロジェクト: trase8/kurs
    // Запросы на замену
    public bool send_tables(table_set ts) { 
        DataTable dt = new DataTable();
        MySqlConnectionStringBuilder mysqlCSB;
        mysqlCSB = new MySqlConnectionStringBuilder();
        mysqlCSB.Server = server;
        mysqlCSB.Database = db;
        mysqlCSB.UserID = user;
        mysqlCSB.Password = pass;

        db_adapter db2 = new db_adapter();
        DataTable dt2 = new DataTable();
        dt2 = db2.get_tables();

        for (int i = 0; i < dt2.Rows.Count; i++) {


            int id = ts.table[i].number;
            bool bu = ts.table[i].busy;
            bool re = ts.table[i].reserved;
            DateTime rt = ts.table[i].res_time;

            string queryString = @"UPDATE  table SET busy = ";
            queryString += bu.ToString();
            queryString = @", reserved = ";
            queryString += re.ToString();
            queryString = @", res_time = ";
            queryString += rt.ToString();
            queryString = @" WHERE  id = ";
            queryString += id.ToString();
            queryString = @"  LIMIT 1 ;";
               

            using (MySqlConnection con = new MySqlConnection())
            {
                con.ConnectionString = mysqlCSB.ConnectionString;
                MySqlCommand com = new MySqlCommand(queryString, con);
                try
                {
                    con.Open();
                    using (MySqlDataReader dr = com.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            dt.Load(dr);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }           
        }
        return true;
    }
コード例 #2
0
ファイル: Form1.cs プロジェクト: trase8/kurs
 private void get_data() {
     db_adapter db = new db_adapter();
     DataTable dt = new DataTable();
     dt = db.get_tables();
     for (int i = 0; i < dt.Rows.Count; i++) { 
         table[i].number = i;
         table[i].busy = dt.Rows[i].Field<bool>("busy"); 
         table[i].reserved = dt.Rows[i].Field<bool>("reserved");
         if (table[i].reserved == true) table[i].res_time = dt.Rows[i].Field<DateTime>("res_time");
         else
         { 
             DateTime nullTime = new DateTime();
             table[i].res_time = nullTime;
         } 
     }
 }