Ejemplo n.º 1
0
 public void Enroll(object sender, RoutedEventArgs e)
 {
     StudentIDTextBox.Text       = (StudentIDTextBox != null) ? StudentIDTextBox.Text.Trim() : "";
     StudentNameTextBox.Text     = (StudentNameTextBox != null) ? StudentNameTextBox.Text.Trim() : "";
     StudentGradeTextBox.Text    = (StudentGradeTextBox != null) ? StudentGradeTextBox.Text.Trim() : "";
     StudentSectionComboBox.Text = (StudentSectionComboBox != null) ? StudentSectionComboBox.Text.Trim() : "";
     if (StudentIDTextBox.Text != "" && StudentNameTextBox.Text != "" && StudentGradeTextBox.Text != "" && StudentSectionComboBox.Text != "")
     {
         int    ID      = int.Parse(StudentIDTextBox.Text);
         string name    = StudentNameTextBox.Text;
         int    grade   = int.Parse(StudentGradeTextBox.Text);
         int    section = int.Parse(StudentSectionComboBox.Text);
         if (ID > 0 && ID < 256 && grade <= 100 && grade >= 0)
         {
             try
             {
                 AssemblyStudentDB.enrollStudent((char)ID, name, (char)name.Length, (char)grade, (char)section);
             }
             catch
             {
                 Console.WriteLine("Error in enrollStudent");
             }
             RefreshList();
         }
         else
         {
             MessageBox.Show("Enter Valid Number between 1 and 255 ");
         }
     }
     else
     {
         MessageBox.Show("No empty Values");
     }
     StudentIDTextBox.Clear();
     StudentNameTextBox.Clear();
     StudentGradeTextBox.Clear();
     StudentSectionComboBox.SelectedIndex = -1;
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            password = ConfirmPassword.Text;
            //string encryptedPassword = Encrypt(password);
            int    phoneNumber = PhoneText.Text.Length;
            int    passLength  = PasswordText.Text.Length;
            string gender      = "";

            if (MaleButton.Checked)
            {
                gender = MaleButton.Text;
            }
            if (FemaleButton.Checked)
            {
                gender = FemaleButton.Text;
            }
            //this.Hide();
            //Home ss = new Home();
            // ss.Show();

            //check field empty or not
            if (string.IsNullOrEmpty(NameTextBox.Text) == true)
            {
                MessageBox.Show("Please enter First Name");
                NameTextBox.Focus();
            }
            else if (string.IsNullOrEmpty(LastNameTextBox.Text) == true)
            {
                MessageBox.Show("Please enter Last Name");
                LastNameTextBox.Focus();
            }
            else if (string.IsNullOrEmpty(EmailTextBox.Text) == true)
            {
                MessageBox.Show("Please enter Email");
                EmailTextBox.Focus();
            }
            else if (Regex.IsMatch(EmailTextBox.Text, emailValStr) == false)
            {
                MessageBox.Show("Invalid email!!");
                EmailTextBox.Focus();
            }

            else if (string.IsNullOrEmpty(StudentIDTextBox.Text) == true)
            {
                MessageBox.Show("Please enter your ID");
                StudentIDTextBox.Focus();
            }
            else if (string.IsNullOrEmpty(PhoneText.Text) == true)
            {
                MessageBox.Show("Please enter Phone Number");
                PhoneText.Focus();
            }

            else if (phoneNumber != 11)
            {
                MessageBox.Show("Please enter valid phone number");
                PhoneText.Focus();
            }
            else if (string.IsNullOrEmpty(gender) == true)
            {
                MessageBox.Show("Please select gender");
                ConfirmPassword.Focus();
            }
            else if (string.IsNullOrEmpty(PasswordText.Text) == true)
            {
                MessageBox.Show("Please type Password");
                PasswordText.Focus();
            }
            else if (passLength <= 8)
            {
                MessageBox.Show(Convert.ToString(passLength));
                MessageBox.Show("Your password should contain minimum 8 characters or numbers");
                PasswordText.Focus();
            }
            else if (string.IsNullOrEmpty(ConfirmPassword.Text) == true)
            {
                MessageBox.Show("Please type Password again");
                ConfirmPassword.Focus();
            }
            else if (PasswordText.Text != ConfirmPassword.Text)
            {
                MessageBox.Show("You typed the wrond password");
                PasswordText.Focus();
            }

            else
            {
                // conn.ConnectionString = @"Data Source=LAPTOP-UDPCMQEF;Initial Catalog=LibraryManagementSystem;Integrated Security=True";
                //  conn.Open();


                SqlCommand cmd = new SqlCommand("insert into Person" + "(first_name,last_name,password,email,student_id,gender,contact_no) values (@first_name,@last_name,aes_encrypt(@password, 'key'),@email,@student_id,@gender,@contact_no)", connDB.getConn());
                cmd.Parameters.AddWithValue("@first_name", NameTextBox.Text);
                cmd.Parameters.AddWithValue("@last_name", LastNameTextBox.Text);
                cmd.Parameters.AddWithValue("@email", EmailTextBox.Text);
                cmd.Parameters.AddWithValue("@student_id", StudentIDTextBox.Text);
                cmd.Parameters.AddWithValue("@gender", gender);
                cmd.Parameters.AddWithValue("@contact_no", PhoneText.Text);
                cmd.Parameters.AddWithValue("@password", password);
                cmd.ExecuteNonQuery();
                MessageBox.Show("You are registered now");
            }
        }