Esempio n. 1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         var usrname  = this.txtUserName.Text;
         var password = this.txtPassword.Text;
         if (usrname == "")
         {
             MessageBox.Show("username required", "login Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtUserName.Focus();
         }
         else if (password == "")
         {
             MessageBox.Show("password required", "login Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtPassword.Focus();
         }
         else
         {
             manageUsers myU    = new manageUsers();
             Boolean     access = myU.loginUser(usrname, password);
             if (access == true)
             {
                 myU.getUser(myU.userId);
                 sessions.userId   = myU.userId;
                 sessions.userType = myU.userType;
                 MessageBox.Show(myU.userType);
                 MessageBox.Show("Welcome" + usrname, "login Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 if (myU.userType == "A")
                 {
                     frmMainMenuUpdate myMenu = new frmMainMenuUpdate();
                     myMenu.ShowDialog();
                     this.Dispose();
                 }
                 else if (myU.userType == "T")
                 {
                     frmTeacherMainMenu myMenu = new frmTeacherMainMenu();
                     myMenu.ShowDialog();
                     this.Dispose();
                 }
                 else
                 {
                     MessageBox.Show("Invalid Account type contact system admin", "Verification Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     Application.Exit();
                 }
             }
             else
             {
                 MessageBox.Show("Invalid Creditials", "login Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 this.txtUserName.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Applcation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
 private void frmUpdateUser_Load(object sender, EventArgs e)
 {
     try
     {
         if (sessions.userType == "A")
         {
             manageUsers       myU = new manageUsers();
             manageUserDetails myD = new manageUserDetails();
             myD.getUserDetails(this.userId);
             myU.getUser(this.userId);
             MessageBox.Show(myU.userType);
             this.txtFname.Text    = myD.firstName;
             this.txtLastName.Text = myD.lastName;
             if (myU.userType == "A")
             {
                 this.cmbUserTyp.Text = "Admin";
             }
             else if (myU.userType == "T")
             {
                 this.cmbUserTyp.Text = "Teacher";
             }
             else if (myU.userType == "C")
             {
                 this.cmbUserTyp.Text = "Clerk";
             }
             else if (myU.userType == "B")
             {
                 this.cmbUserTyp.Text = "Blocked";
             }
         }
         else
         {
             MessageBox.Show("user type not authorised to perform account management");
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("failed in frmUpdateUser_Load() " + ex.Message);
     }
 }
Esempio n. 3
0
 private void btnSuspend_Click(object sender, EventArgs e)
 {
     try
     {
         manageUsers myU = new manageUsers();
         myU.getUser(this.userId);
         myU.userType = "B";
         if (myU.editUser(this.userId) == true)
         {
             MessageBox.Show("User Account deactivated Success", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("failed to deactivated account ", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("failed in btnSuspend_Click() " + ex.Message);
     }
 }
Esempio n. 4
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         var         userTyp = this.getUserEnum(this.cmbUserTyp.Text);
         manageUsers myU     = new manageUsers();
         myU.getUser(this.userId);
         myU.userType = userTyp;
         if (myU.editUser(this.userId) == true)
         {
             MessageBox.Show("User Update Success", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("failed to Update User ", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("failed in btnUpdate_Click() " + ex.Message);
     }
 }
Esempio n. 5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         manageUsers myU = new manageUsers();
         myU.getUser(this.userId);
         DialogResult dialogResult = MessageBox.Show("All information associated with this account will be lost are you sure you want to proceed", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dialogResult == DialogResult.OK || dialogResult == DialogResult.Yes)
         {
             if (myU.deleteUser(this.userId) == true)
             {
                 MessageBox.Show("account deleted success ", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("failed to delete ", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("failed in btnDelete_Click() " + ex.Message);
     }
 }