private void ValidateUser(string login, string password) { /* SqlConnection conn = new SqlConnection(connectionString); * conn.Open(); * string passEncrypted = PassEncryption(password); * * String query = "SELECT LoginUser, PasswordUser FROM tbLoginAndPassword WHERE (LoginUser = '******') AND (PasswordUser = '******');"; * * SqlCommand cmd = new SqlCommand(query, conn); * SqlDataReader sqldr = cmd.ExecuteReader(); * if (sqldr.Read()) * { * this.Close(); * MainMenu mm = new MainMenu(); * mm.ShowDialog(); * * } * else * { * MessageBox.Show("Password or login incorrect!"); * } * * conn.Close(); */ // DataSet ds = new DataSet("tbLoginAndPassword"); comm = new SqlCommand("LoginUser", con); this.comm.Parameters.AddWithValue("@UserName", login); this.comm.Parameters.AddWithValue("@PasswordUser", password); this.comm.CommandType = CommandType.StoredProcedure; con.Open(); SqlParameter returnParameter = comm.Parameters.Add("@Variable", SqlDbType.Int); returnParameter.Direction = ParameterDirection.ReturnValue; comm.ExecuteNonQuery(); int isTrue = (int)returnParameter.Value; if (isTrue == 1 && login == "NameUserAdmin") { this.Close(); MainMenu mm = new MainMenu(); mm.ShowDialog(); } else if (isTrue == 0) { MessageBox.Show("Brak użytkownika o takich danych!"); } else { this.Close(); StudentMenu sm = new StudentMenu(login, password); sm.ShowDialog(); } con.Close(); }
static void Main(string[] args) { Students st = new Students(); StudentService sts = new StudentService(); AdminMenu am = new AdminMenu(); CompanyMenu ComMeny = new CompanyMenu(); StudentMenu StsMenu = new StudentMenu(); AdminService adm = new AdminService(); adm.GenerStudents(); Company com = new Company(); CompanyService comser = new CompanyService(); comser.GenerateCompanies(); comser.FindCandidate(ref adm.st); comser.PrintCompany(); comser.RegistCompany(); //adm.PrintStudent(); /*while (true) * { * * Console.WriteLine("========== Menu =========="); * Console.WriteLine(); * Console.WriteLine("1. Administrator"); * Console.WriteLine("2. Student"); * Console.WriteLine("3.Company"); * Console.WriteLine("4. Exit"); * * Console.WriteLine(); * Console.WriteLine("=========================="); * Console.WriteLine(); * * Console.Write("Choose the position: "); * int choice = int.Parse(Console.ReadLine()); * Console.Clear(); * Console.WriteLine(); * * switch (choice) * { * case 1: * Console.WriteLine("Administrator"); * am.AdMenu(adm); * Console.WriteLine(); * break; * case 2: * Console.WriteLine("Student"); * StsMenu.StMenu(adm); * break; * * case 3: * Console.WriteLine("Company"); * ComMeny.ComMenu(adm); * Console.WriteLine(); * break; * case 4: * break; * * } * * }*/ }