private void setTime(object sender, EventArgs e) { try { connectDB conn = new connectDB(); string sqlDate = null; //Send actual time to textBlock actualTimeBlock.Text = getTime().ToString(); //Get Time from DB sqlDate = conn.selectTimeDB().Rows[0][0].ToString(); DateTime time = DateTime.Parse(sqlDate); //Porównanie tylko w sekundach bo bedzie problem z godiznami 15:03 != 14:30 if ((Convert.ToInt32(getTime().ToString("mm"))) >= (Convert.ToInt32(time.ToString("mm")))) { startTime(true); //Set enable button to start enterEg.IsEnabled = true; tabGame.Visibility = Visibility.Visible; } }catch (Exception xe) { } }
private void loginBtn_Click(object sender, RoutedEventArgs e) { connectDB conn = new connectDB(); player p = new player(); string sqlDate = null; if (loginBox.Text.ToString() != null && emailBox.Text.ToString() != null && passwordBox.Password != null) { try { p.game(loginBox.Text.ToString(), emailBox.Text.ToString()); conn.decodeConnection(passwordBox.Password); MessageBox.Show("Pomyslnie zarejestrowano uzytkownika! Czekaj na start matury!"); loginBtn.IsEnabled = false; timeToStartBlock.Visibility = Visibility.Visible; sqlDate = conn.selectTimeDB().Rows[0][0].ToString(); DateTime time = DateTime.Parse(sqlDate); //When start? timeToStartBlock.Text = time.ToString(); //MessageBox.Show(time.ToString()); startTime(false); } catch (Exception xe) { MessageBox.Show("Error: " + xe.Message); } } }