private void dgvClassInfo_SelectionChanged(object sender, EventArgs e) { try { if (this.startIntract == true && this.dgvClassInfo.SelectedRows.Count > 0) { this.swapTeacher = false; this.txtClassName.Enabled = false; this.cmbClassGrade.Enabled = false; this.btnAdd.Enabled = false; this.btnUpdate.Enabled = true; var classId = dgvClassInfo.SelectedRows[0].Cells[0].Value.ToString(); manageClassrooms myC = new manageClassrooms(); myC.getClass(Convert.ToInt32(classId)); this.txtClassDes.Text = myC.classDetails; this.txtClassName.Text = myC.className; this.cmbClassGrade.Text = myC.classGrade.ToString(); manageUserDetails myU = new manageUserDetails(); myU.getUserDetails(myC.teacherId); cmbTeacher.Text = myU.lastName; cmbTeacher.SelectedValue = myC.teacherId; this.classId = myC.classRoomId; this.teacherId = myC.teacherId; } } catch (Exception ex) { MessageBox.Show("Failed on dgvClassInfo_SelectionChange" + ex, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
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); } }
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); } }
private void txtEnrolId_Leave(object sender, EventArgs e) { try { /*get student information*/ manageStudent myS = new manageStudent(); myS.getStudentId(Convert.ToInt32(this.txtEnrolId.Text)); if (myS.dacFound == true) { this.txtFname.Text = myS.firstName; this.btnProcess.Enabled = true; this.txtLastName.Text = myS.lastName; manageClassrooms myClass = new manageClassrooms(); myClass.getClass(myS.classId); this.txtClass.Text = myClass.className; /*get balance information*/ managefeesBalance myB = new managefeesBalance(); myB.getBalance(this.txtEnrolId.Text, sessions.currTerm); this.txtCurBalance.Text = myB.ClosingBal.ToString(); this.txtOpenBal.Text = myB.OpenBal.ToString(); this.txtPaid.Text = myB.PaymentIn.ToString(); /*populate transactions*/ this.fillTrans(Convert.ToInt32(this.txtEnrolId.Text)); /*gather invoice information*/ manageUserDetails myU = new manageUserDetails(); myU.getUserDetails(sessions.userId); //this.dictInvoice.Add("receiptTeller", myU.firstName + " " + myU.lastName); //this.dictInvoice.Add("studentName", myS.firstName + " " + myS.lastName); } else { MessageBox.Show("Enrolment id not registered in system", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show("failed in txtEnrolId_Leave() " + ex, "system error"); } }
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); } }