private void Login_Click(object sender, EventArgs e) { var passMd5 = Cnst.ToMd5(txtPassword.Text.Trim()); // pass pakeistas i md5 hash var query = "Select * from tblLogin Where username = '******' and password = '******'"; var sda = new SqlDataAdapter(query, Cnst.SqlCon); var dtbl = new DataTable(); sda.Fill(dtbl); if (dtbl.Rows.Count == 0) { MessageBox.Show("Check username and (or) password"); } else { Cnst.User = txtUserName.Text.Trim(); Cnst.alevel = Int32.Parse(dtbl.Rows[0]["level"].ToString()); // authorization level switch (Cnst.alevel) { case 0: { var redirect = new PardavejoMeniu(); Hide(); redirect.Show(); break; } case 1: { var redirect = new SandelininkoMeniu(); Hide(); redirect.Show(); break; } case 2: { var redirect = new AdministratoriausMeniu(); Hide(); redirect.Show(); break; } } } }
private void button1_Click(object sender, EventArgs e) { switch (Cnst.alevel) { case 0: { var redirect = new PardavejoMeniu(); Hide(); redirect.Show(); break; } case 1: { var redirect = new SandelininkoMeniu(); Hide(); redirect.Show(); break; } case 2: { var redirect = new AdministratoriausMeniu(); Hide(); redirect.Show(); break; } default: { var redirect = new Prisijungimas(); Hide(); redirect.Show(); break; } } }