Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string constring = System.Configuration.ConfigurationManager.ConnectionStrings["Restaurant"].ConnectionString;
- SqlConnection konekcija = new SqlConnection(constring);
- public LogIn()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string username = textBox1.Text;
- string password = textBox2.Text;
- string stringServer = "SELECT S.Server_password as pass FROM Server as S WHERE S.Server_username LIKE '"+ username +"'";
- string stringManager = "SELECT M.Manager_password as pass FROM Manager as M WHERE M.Manager_username LIKE '" + username + "'";
- string stringKitchen = "SELECT K.Kitchen_staff_password as pass FROM Kitchen_staff as K WHERE K.Kitchen_staff_username LIKE '" + username + "'";
- string stringHostess = "SELECT H.Hostess_password as pass FROM Hostess as H WHERE H.Hostess_username LIKE '" + username + "'";
- SqlCommand komandaManager = new SqlCommand(stringHostess, konekcija);
- string komanda = "" + stringServer + "; " + stringManager + "; " + stringKitchen + "; " + stringHostess;
- SqlDataAdapter adapter = new SqlDataAdapter(komanda, konekcija);
- adapter.TableMappings.Add("Table", "Server");
- adapter.TableMappings.Add("Table1", "Manager");
- adapter.TableMappings.Add("Table2", "Kitchen");
- adapter.TableMappings.Add("Table3", "Hostess");
- DataSet ds = new DataSet();
- try
- {
- konekcija.Open();
- adapter.Fill(ds);
- if (ds.Tables["Server"].Rows.Count != 0)
- {
- string s = Convert.ToString(ds.Tables["Server"].Rows[0]["pass"]);
- if (password.Equals(s))
- {
- this.Hide();
- Hello_Server f = new Hello_Server();
- f.ShowDialog();
- }
- else
- {
- MessageBox.Show("Невалиднa лозинка!");
- }
- }
- else if (ds.Tables["Manager"].Rows.Count != 0)
- {
- string s = Convert.ToString(ds.Tables["Manager"].Rows[0]["pass"]);
- if (password.Equals(s))
- {
- this.Hide();
- Hello_Server f = new Hello_Server();
- f.ShowDialog();
- }
- else
- {
- MessageBox.Show("Невалиднa лозинка!");
- }
- }
- else if (ds.Tables["Kitchen"].Rows.Count != 0)
- {
- string s = Convert.ToString(ds.Tables["Kitchen"].Rows[0]["pass"]);
- if (password.Equals(s))
- {
- this.Hide();
- Hello_Hostess f = new Hello_Hostess();
- f.ShowDialog();
- }
- else
- {
- MessageBox.Show("Невалиднa лозинка!");
- }
- }
- else if (ds.Tables["Hostess"].Rows.Count != 0)
- {
- string s = Convert.ToString(ds.Tables["Hostess"].Rows[0]["pass"]);
- if (password.Equals(s))
- {
- this.Hide();
- Hello_Server f = new Hello_Server();
- f.ShowDialog();
- }
- else
- {
- MessageBox.Show("Невалиднa лозинка!");
- }
- }
- else if (ds.Tables[0].Rows.Count == 0 || ds.Tables[1].Rows.Count == 0 ||
- ds.Tables[2].Rows.Count == 0 || ds.Tables[3].Rows.Count == 0)
- {
- MessageBox.Show("Невалидни корисничко име и лозинка!");
- }
- }
- catch (Exception err)
- {
- MessageBox.Show(err.Message);
- }
- finally
- {
- konekcija.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement