Form2.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Npgsql;
  11. namespace pract
  12. {
  13. public partial class Form2 : Form
  14. {
  15. public Form2()
  16. {
  17. InitializeComponent();
  18. }
  19. private void button2_Click(object sender, EventArgs e)
  20. {
  21. string dbUser = textBox1.Text;
  22. string password = textBox2.Text;
  23. var connString = "Host=80.250.189.52;Database=dbwork;Username=goreva_am;Password=qm#J6pyA%K#;";
  24. try
  25. {
  26. using (var conn = new NpgsqlConnection(connString))
  27. {
  28. conn.Open();
  29. }
  30. var isAdmin = ("goreva_am" == textBox1.Text);
  31. Form1 form1 = new Form1(connString, isAdmin);
  32. form1.ShowDialog();
  33. }
  34. catch (Exception ex)
  35. {
  36. MessageBox.Show("Ошибка подключения к БД: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
  37. }
  38. }
  39. }
  40. }