Ejemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete employee ", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dialogResult == DialogResult.Yes)
         {
             manageUsers myU = new manageUsers();
             myU.getByEmpId(this.empId);
             myU.deleteUser(myU.userId);
             manageUserDetails myD = new manageUserDetails();
             myD.deleteUser(myU.userId);
             manageEmployees myE = new manageEmployees();
             if (myE.deleteEmployee(this.empId) == true)
             {
                 MessageBox.Show("Employee deleted from system system", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 string sql = "SELECT employeeId,Fname,Sname,Dpt,Email FROM wizemployes";
                 this.fillEmployee(sql);
             }
             else
             {
                 MessageBox.Show(" failed to deleted from system system", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("failed in btnDelete_Click()" + ex.Message);
     }
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
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)
             {
                 MessageBox.Show("Welcome" + usrname, "login Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 /*setup sessions here*/
                 frmMainMenu myMenu = new frmMainMenu();
                 myMenu.ShowDialog();
                 this.Dispose();
             }
             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);
     }
 }
Ejemplo n.º 6
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);
     }
 }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {   //checking that logged in user is no an admin
         if (sessions.userType != "A")
         {
             frmAuthenticate myA    = new frmAuthenticate();
             DialogResult    access = myA.ShowDialog();
             if (access == DialogResult.OK)
             {
                 manageUsers myU = new manageUsers();
                 if (myU.adminAuth(myA.userName, myA.password) == true)
                 {
                     bzlTransactions myTrans = new bzlTransactions();
                     myTrans.tranId    = this.txtRefNumber.Text;
                     myTrans.accountId = this.txtEnrolId.Text;
                     myTrans.DeleteTransacation();
                     if (myTrans.dacCrud == true)
                     {
                         this.txtTranDetails.Text = "";
                         this.txtAmount.Text      = "";
                         manageControl     myC  = new manageControl();
                         managefeesBalance myFb = new managefeesBalance();
                         myFb.getBalance(this.txtEnrolId.Text, sessions.currTerm);
                         this.refNumber          = myC.useTranHeader(this.refNumber);
                         this.txtRefNumber.Text  = "ref" + this.refNumber.ToString();
                         this.txtCurBalance.Text = myFb.CurrentBal.ToString();
                         this.txtOpenBal.Text    = myFb.OpenBal.ToString();
                         this.txtPaid.Text       = myFb.PaymentIn.ToString();
                         this.fillTrans(Convert.ToInt32(this.txtEnrolId.Text));
                         MessageBox.Show("transaction deleted success", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                     else
                     {
                         MessageBox.Show("Failed to delete transaction", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Invalid Adimin Credentials", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
         }
         else
         {
             DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this transaction", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (dialogResult == DialogResult.OK)
             {
                 bzlTransactions myTrans = new bzlTransactions();
                 myTrans.tranId = this.txtRefNumber.Text;
                 myTrans.DeleteTransacation();
                 myTrans.accountId = this.txtEnrolId.Text;
                 if (myTrans.dacCrud == true)
                 {
                     MessageBox.Show("transaction deleted success", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Failed to delete transaction", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
         }
     }
     catch (Exception ex) {
         System.Windows.Forms.MessageBox.Show("Failed to fillTrans()  " + ex);
     }
 }
Ejemplo n.º 9
0
 private void btnAddUser_Click(object sender, EventArgs e)
 {
     try
     {
         var usrname  = this.txtUserName.Text;
         var password = this.txtPassword.Text;
         var usrtyp   = this.txtUserType.Text;
         var email    = this.txtEmail.Text;
         var fname    = this.txtFname.Text;
         var sname    = this.txtLastName.Text;
         var cell     = this.txtMobile.Text;
         var msg      = this.txtMsg.Text;
         /*validate input*/
         if (usrname.Length < 4)
         {
             MessageBox.Show("username should be at least 5 characters", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtUserName.Focus();
         }
         else if (password == "")
         {
             MessageBox.Show("password required", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtPassword.Focus();
         }
         else if (usrtyp == "")
         {
             MessageBox.Show("select a user type", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtUserType.Focus();
         }
         else if (validator.IsValidEmail(email) == false)
         {
             MessageBox.Show("invalid email address", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtEmail.Focus();
         }
         /*enter login information*/
         else
         {
             manageUsers myU = new manageUsers();
             if (myU.checkExist(usrname) == false)
             {
                 if (myU.setUser(usrname, password, getUserEnum(usrtyp), email) == true)
                 {
                     /*enter other info*/
                     manageUserDetails myD = new manageUserDetails();
                     if (myD.setDetails(myU.userId, fname, sname, cell) == true)
                     {
                         /* notification email*/
                         MessageBox.Show("Added User Successfully", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         /*notifly user of creation success*/
                     }
                 }
                 else
                 {
                     MessageBox.Show("failed to add user close the system and retry", "System Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
             else
             {
                 MessageBox.Show("username already in the system", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 this.txtUserName.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Applcation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }