Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  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 System.Data.SqlClient; //podrucje rada za sql :V
  11.  
  12. namespace NiHT //ime programa
  13. {
  14. public partial class Login : Form
  15. {
  16. public Login()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void button2_Click(object sender, EventArgs e)
  22. {
  23. this.Close(); //dugme za gasenje programa
  24. }
  25.  
  26. private void button1_Click(object sender, EventArgs e)
  27. {
  28. //NEMANJA OVO U ZAGRADI POSLE "new SqlConnection" se samo kopira iz database ne kuca se da se ne uplasis xD
  29. SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Nicky019\Documents\data.mdf; Integrated Security = True; Connect Timeout = 30;"); //povezivanje databaze
  30. SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From [LOGIN] where UserName = '" + textBox1.Text + "' and Password = '" + textBox2.Text + "'", con);//logicki kod po kome radi...
  31. DataTable dt = new DataTable();//uzimanje podataka iz tabele I pisanje u njoj
  32. sda.Fill(dt);//uzimanje podataka iz tabele I pisanje u njoj
  33. if (dt.Rows[0][0].ToString() == "1")
  34. {
  35. this.Hide();//kada je uslov ispunjen sakrice ovaj prozor
  36. Main ss = new Main();//second screen iliti ss je novi main form
  37. ss.Show();//ss se prikazuje aka main form
  38. }
  39. else
  40. {
  41. MessageBox.Show("Please check your username and password!"); //ako uslov nije ispunjen otvori prozor sa obavestenjem
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement