Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient; //podrucje rada za sql :V
- namespace NiHT //ime programa
- {
- public partial class Login : Form
- {
- public Login()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close(); //dugme za gasenje programa
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //NEMANJA OVO U ZAGRADI POSLE "new SqlConnection" se samo kopira iz database ne kuca se da se ne uplasis xD
- SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\Nicky019\Documents\data.mdf; Integrated Security = True; Connect Timeout = 30;"); //povezivanje databaze
- SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From [LOGIN] where UserName = '" + textBox1.Text + "' and Password = '" + textBox2.Text + "'", con);//logicki kod po kome radi...
- DataTable dt = new DataTable();//uzimanje podataka iz tabele I pisanje u njoj
- sda.Fill(dt);//uzimanje podataka iz tabele I pisanje u njoj
- if (dt.Rows[0][0].ToString() == "1")
- {
- this.Hide();//kada je uslov ispunjen sakrice ovaj prozor
- Main ss = new Main();//second screen iliti ss je novi main form
- ss.Show();//ss se prikazuje aka main form
- }
- else
- {
- MessageBox.Show("Please check your username and password!"); //ako uslov nije ispunjen otvori prozor sa obavestenjem
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement