Guest User

Untitled

a guest
Feb 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. DateTime d1;
  2. try
  3. {
  4. string sql = $"select subscribe from dle_users where email = '{textBoxUserEmail.Text}' and password = '{sspass}' ";
  5. MySqlCommand command = new MySqlCommand(sql, conn);
  6. string date = command.ExecuteScalar().ToString();
  7.  
  8. var client = new TcpClient("time.nist.gov", 13);
  9. using (var streamReader = new StreamReader(client.GetStream()))
  10. {
  11. var response = streamReader.ReadToEnd();
  12. var utcDateTimeString = response.Substring(7, 17);
  13. d1 = DateTime.ParseExact(utcDateTimeString, "yy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
  14. }
  15.  
  16. DateTime d2 = Convert.ToDateTime(date);
  17. TimeSpan time = d2 - d1;
  18.  
  19. int days = time.Days;
  20.  
  21. if (days > 0)
  22. {
  23. passlIsPass = true;
  24. if (conn != null && conn.State != ConnectionState.Closed)
  25. conn.Close();
  26. }
  27. if (days < 0)
  28. {
  29. DialogResult result = MessageBox.Show("Продлите подписку !", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  30. }
  31. }
  32.  
  33. catch (Exception ex)
  34. {
  35. passlIsPass = false;
  36. DialogResult result = MessageBox.Show("Логин или пароль введен неверно", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  37.  
  38. }
Add Comment
Please, Sign In to add comment