private void ButtonSubmit_Click(object sender, EventArgs e) { int exists; int isAdmin; using (SqlConnection con = new SqlConnection( ConfigurationManager.ConnectionStrings["myConnStr"].ConnectionString)) { con.Open(); SqlCommand checkExistance = new SqlCommand("loginMatch", con); checkExistance.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter usrNm = new SqlParameter { ParameterName = "@usrName", Value = this.TextBoxUsrName.Text }; SqlParameter usrPs = new SqlParameter { ParameterName = "@usrPass", Value = this.TextBoxPass.Text }; checkExistance.Parameters.Add(usrNm); checkExistance.Parameters.Add(usrPs); exists = (int)checkExistance.ExecuteScalar(); if (exists == 1) { SqlCommand accessLevel = new SqlCommand("getAccess", con); accessLevel.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter level = new SqlParameter { ParameterName = "@usrName", Value = this.TextBoxUsrName.Text }; accessLevel.Parameters.Add(level); isAdmin = (int)accessLevel.ExecuteScalar(); con.Close(); this.Hide(); if (isAdmin < 3) { if(isAdmin == 0) { CarAdmin child = new CarAdmin(); child.ShowDialog(); this.Show(); } else if (isAdmin == 1) { ServiceAdmin child = new ServiceAdmin(con); child.ShowDialog(); this.Show(); } else if (isAdmin == 2) { UserAdmin child = new UserAdmin(con); child.ShowDialog(); this.Show(); } } else { User child = new User(con, TextBoxUsrName.Text); child.ShowDialog(); this.Show(); } this.ResetForm(); } else if (exists == 0) { this.Hide(); this.ResetForm(); Warning child = new Warning(); child.ShowDialog(); this.Show(); } } }
private void button1_Click(object sender, EventArgs e) { User child = new User(con,"carAdmin"); this.Hide(); child.ShowDialog(); this.Show(); }