Example #1
0
        // partial void selfregistration();

        public void registration()
        {
            Console.WriteLine("Enter Student Name");
            string p_name = Console.ReadLine();

            try
            {
                Console.WriteLine("Enter Student Password");
                string p_pass = Console.ReadLine();
                if (p_pass.Length < 8)
                {
                    throw new PassLengthNotValidException("Password should be more than 8 character");
                }

                Console.WriteLine("Enter Student City");
                string p_city = Console.ReadLine();
                Console.WriteLine("Enter Student Email");
                string p_email = Console.ReadLine();
                Console.WriteLine("Enter Student Contact Number");
                string p_contact = Console.ReadLine();

                SqlCommand cmd1 = new SqlCommand("insert into student(p_name,p_pass,p_city,p_email,p_contact)values(@p_name,@p_pass,@p_city,@p_email,@p_contact)", con);
                cmd1.Parameters.AddWithValue("@p_name", p_name);
                cmd1.Parameters.AddWithValue("@p_pass", p_pass);
                cmd1.Parameters.AddWithValue("@p_city", p_city);
                cmd1.Parameters.AddWithValue("@p_email", p_email);
                cmd1.Parameters.AddWithValue("@p_contact", p_contact);
                con.Open();
                Console.WriteLine("***");
                int i = cmd1.ExecuteNonQuery();
                Console.WriteLine("Student Registered Successfully!");
                Console.WriteLine("New ID for registered user : "******"SELECT MAX(s_enroll) FROM Student", con);

                SqlDataReader dr1 = command.ExecuteReader();
                using (dr1)
                {
                    while (dr1.Read())
                    {
                        Console.WriteLine("ID : " + dr1[0].ToString());
                    }
                }
                Console.WriteLine("Press 1 to login or any other key to exit.");
                int input = Convert.ToInt32(Console.ReadLine());
                if (input == 1)
                {
                    Console.WriteLine("enter user Id and Password to login");
                    int id = int.Parse(Console.ReadLine());
                    Console.WriteLine("enter password");
                    string  pass = Console.ReadLine();
                    teacher t    = new teacher();

                    int j = t.login(id, pass);
                    if (j == 3)
                    {
                        Console.WriteLine("Successfull Logged In");
                        t.selfregistration();
                    }
                    else
                    {
                        Console.WriteLine("Failed");
                    }
                }
            }
            catch (PassLengthNotValidException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                con.Close();
            }
        }