private void Button_Update(object sender, RoutedEventArgs e) { string bikeNumber = tb_bikeNumber.Text; string bikeUser = tb_user.Text; string timeStart = tb_timeStart.Text; string timeEnd = tb_timeEnd.Text; bool isPaid = cb_isPaid.IsChecked.Value; //bool isAvailable = cb_isAvailable.IsChecked.Value; var comboBoxTime = ComboBox_Time.SelectedValue.ToString(); var comboBoxType = ComboBox_Type.SelectedValue.ToString(); string time = comboBoxTime; Debug.Write("mainWindow: bikeNumber : " + bikeNumber + "\n"); Debug.Write("mainWindow: bikeUser : "******"\n"); Debug.Write("mainWindow: time : " + time + "\n"); Debug.Write("mainWindow: timeStart : " + timeStart + "\n"); Debug.Write("mainWindow: timeEnd : " + timeEnd + "\n"); Debug.Write("mainWindow: isPaid : " + isPaid + "\n"); //Debug.Write("mainWindow: isAvailable : " + isAvailable + "\n"); Debug.Write("mainWindow: comboBoxValue : " + comboBoxTime + "\n"); bool isAvailable; if (isPaid) { isAvailable = false; } else { isAvailable = true; } sqlAdapter = new SQLAdapter(); sqlAdapter.updateRow(bikeNumber, bikeUser, time, timeStart, timeEnd, isAvailable, isPaid, comboBoxType); InitListView(); }
private void InitListView() { sqlAdapter = new SQLAdapter(); List <Model_RentalSystem> listModelRentalSystem = new List <Model_RentalSystem>(); string queryBikeNumber = "SELECT * FROM " + SQLAdapter.sql_table + ""; MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySql.Data.MySqlClient.MySqlCommand(queryBikeNumber, SQLAdapter.mySqlConnection); MySql.Data.MySqlClient.MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); try { while (mySqlDataReader.Read()) { //listModelRentalSystem.Add(new Model_RentalSystem() //{ // BikeNumber = mySqlDataReader["bike_number"].ToString(), // BikeUser = mySqlDataReader["user_name"].ToString(), // TimeLeft = mySqlDataReader["time_left"].ToString(), // TimeStart = mySqlDataReader["time_start"].ToString(), // TimeEnd = mySqlDataReader["time_end"].ToString(), // IsPaid = mySqlDataReader["isPaid"].ToString(), // Status = mySqlDataReader["isAvailable"].ToString() //}); Model_RentalSystem model_RentalSystem = new Model_RentalSystem(); model_RentalSystem.BikeNumber = mySqlDataReader["bike_number"].ToString(); model_RentalSystem.BikeUser = mySqlDataReader["user_name"].ToString(); model_RentalSystem.Time = mySqlDataReader["time_time"].ToString(); model_RentalSystem.TimeStart = mySqlDataReader["time_start"].ToString(); model_RentalSystem.TimeEnd = mySqlDataReader["time_end"].ToString(); model_RentalSystem.Type = mySqlDataReader["bike_type"].ToString(); string isPaid = null; string isAvailable = null; if (mySqlDataReader["isPaid"].ToString().Equals("True")) { isPaid = "Yes"; } else { isPaid = "No"; } if (mySqlDataReader["isAvailable"].ToString().Equals("True")) { isAvailable = "Available"; } else { isAvailable = "Rented"; } model_RentalSystem.IsPaid = isPaid; model_RentalSystem.Status = isAvailable; listModelRentalSystem.Add(model_RentalSystem); } Listview_Main.ItemsSource = listModelRentalSystem; mySqlDataReader.Close(); } catch (Exception e) { } }