PosleVHODA.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Data.SqlClient;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace proba
  12. {
  13. public partial class PosleVHODA : Form
  14. {
  15. public PosleVHODA()
  16. {
  17. InitializeComponent();
  18. }
  19. private void PosleVHODA_Load(object sender, EventArgs e)
  20. {
  21. this.Size = new Size(500, 300);
  22. this.MaximumSize = new Size(500, 300);
  23. this.MinimumSize = new Size(500, 300);
  24. }
  25. private void buttonlogin(object sender, EventArgs e)
  26. {
  27. SqlConnection sqlconn = new SqlConnection(@"Data Source=ngknn.ru;Initial Catalog=Progect_MPGG1;Persist Security Info=True;User ID=31П;Password=12357");
  28. string query = "Select *from Users where login = '" + polelogina.Text.Trim() + "' and password = '" + polePassword.Text.Trim() + "'";
  29. SqlDataAdapter sda = new SqlDataAdapter(query, sqlconn);
  30. DataTable dtbl = new DataTable();
  31. sda.Fill(dtbl);
  32. if(dtbl.Rows.Count ==1)
  33. {
  34. this.Hide();
  35. MainMenu mainmenu = new MainMenu();
  36. mainmenu.ShowDialog();
  37. }
  38. else
  39. {
  40. MessageBox.Show("Неверный логин и/или пароль");
  41. }
  42. }
  43. private void button_back_Click(object sender, EventArgs e)
  44. {
  45. this.Hide();
  46. Autorization autorization = new Autorization();
  47. autorization.ShowDialog();
  48. }
  49. public void global_FormClosed(object sender, EventArgs e)
  50. {
  51. Application.Exit();
  52. }
  53. }
  54. }