Example #1
0
 private void LoginButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(passwordTextbox.Text) || string.IsNullOrEmpty(userTextbox.Text))
     {
         MessageBox.Show("Enter Username Or Password", "Invalid operation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         UserInfo ob = new UserInfo();
         ob = sd.GetUserName(username);
         if (ob.UserName == username && ob.UserPassword == password && ob.Status == 1)
         {
             Action frm = new Action();
             frm.Show();
             this.Hide();
         }
         else if (ob.UserName == username && ob.UserPassword == password && ob.Status == 2)
         {
             searchTeacher frm1 = new searchTeacher();
             frm1.Show();
             this.Hide();
         }
         else if (ob.UserName == username && ob.UserPassword == password && ob.Status == 3)
         {
             searchStudent frm2 = new searchStudent();
             frm2.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("Invalid User Name Or Password", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
 private void R_Registerbutton_Click(object sender, EventArgs e)
 {
     if ((string.IsNullOrEmpty(RegisterConfirmPasswordTextbox.Text) || string.IsNullOrEmpty(RegisterUserNameTextbox.Text) || string.IsNullOrEmpty(RegisterPasswordTextbox.Text)) || (!student_Radio.Checked && !teacherRadio.Checked && !AdminRadio.Checked))
     {
         MessageBox.Show("Please Provide All The Information For Registration", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         info = sd.GetUserName(username);
         //int student,teacher,admin=0;
         if (info.UserName == username)
         {
             MessageBox.Show("UserName Already Exists");
         }
         else
         {
             info.UserName = RegisterUserNameTextbox.Text;
             string password, confirmpassword;
             password        = RegisterPasswordTextbox.Text;
             confirmpassword = RegisterConfirmPasswordTextbox.Text;
             if (password == confirmpassword)
             {
                 if (AdminRadio.Checked)
                 {
                     int admin;
                     admin       = 1;
                     info.Status = admin;
                 }
                 else
                 {
                     if (teacherRadio.Checked)
                     {
                         int teacher;
                         teacher     = 2;
                         info.Status = teacher;
                     }
                     else
                     {
                         if (student_Radio.Checked)
                         {
                             int student;
                             student     = 3;
                             info.Status = student;
                         }
                         else
                         {
                             MessageBox.Show("set user status...");
                         }
                     }
                 }
                 info.UserPassword = RegisterPasswordTextbox.Text;
                 cm.Insert(info);
                 MessageBox.Show("Registration Complete", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
             else
             {
                 textLabel.Text = "Password Does Not Match";
             }
         }
     }
 }