private void Return_Click(object sender, EventArgs e) { switch (Cnst.alevel) { case 0: { var redirect = new FormMain0(); Hide(); redirect.Show(); break; } case 1: { var redirect = new FormMain1(); Hide(); redirect.Show(); break; } case 2: { var redirect = new FormMain2(); Hide(); redirect.Show(); break; } } }
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.alevel = Int32.Parse(dtbl.Rows[0]["level"].ToString()); // authorization level switch (Cnst.alevel) { case 0: { var redirect = new FormMain0(); Hide(); redirect.Show(); break; } case 1: { var redirect = new FormMain1(); Hide(); redirect.Show(); break; } case 2: { var redirect = new FormMain2(); Hide(); redirect.Show(); break; } } } }