コード例 #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);
     }
 }
コード例 #2
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     try
     {
         frmSystemSearch mySearch = new frmSystemSearch();
         mySearch.searchType = "employees";
         DialogResult myD = mySearch.ShowDialog();
         if (myD == DialogResult.OK)
         {
             this.txtempId.Text    = mySearch.searchedId;
             this.txtempId.Enabled = false;
             manageEmployees myE = new manageEmployees();
             myE.getEmpDetails(mySearch.searchedId);
             if (myE.dacFound == true)
             {
                 this.txtEmail.Text    = myE.Email;
                 this.txtFname.Text    = myE.Fname;
                 this.txtLastName.Text = myE.Sname;
                 this.txtUserName.Text = myE.Sname + myE.Fname;
                 this.txtMobile.Text   = myE.Mobile;
                 this.txtMsg.Text      = "SchWiz account created";
             }
             else
             {
                 MessageBox.Show("you cannot add non-employees as users", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("failed in  btnSearch_Click() " + ex.Message);
     }
 }
コード例 #3
0
        private void txtStaffId_Leave(object sender, EventArgs e)
        {
            try
            {
                var             empId = this.txtStaffId.Text;
                manageEmployees myE   = new manageEmployees();

                myE.getEmpDetails(empId);
                if (myE.dacFound == true)
                {
                    this.btnAdd.Enabled         = false;
                    this.btnUpdate.Enabled      = true;
                    this.ckbStatus.Checked      = false;
                    this.txtAdress.Text         = myE.address;
                    this.txtDob.Value           = Convert.ToDateTime(myE.DOB);
                    this.txtempCell.Text        = myE.Mobile;
                    this.txtempDate.Value       = Convert.ToDateTime(myE.EmpDate);
                    this.txtEmpEmail.Text       = myE.Email;
                    this.txtGndr.Text           = myE.gender;
                    this.txtFname.Text          = myE.Fname;
                    this.txtnatId.Text          = myE.nationalId;
                    this.txtNextOfKeenCell.Text = myE.iceContact;
                    this.txtNextOfKeenName.Text = myE.iceName;
                    this.txtRel.Text            = myE.iceRelationship;
                    this.txtSname.Text          = myE.Sname;
                    if (myE.Status == "A")
                    {
                        this.ckbStatus.Checked = true;
                    }
                    this.cmbDpt.Text          = myE.Dpt;
                    this.txtSname.Text        = myE.Sname;
                    this.txtSupervisorId.Text = myE.supervisorId;
                }
                else
                {
                    MessageBox.Show("Employee Id not registered in system", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.btnUpdate.Enabled = false;
                    this.btnAdd.Enabled    = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("failed in txtStaffId_Leave() " + ex.Message);
            }
        }
コード例 #4
0
 private void frmStaffDetails_Load(object sender, EventArgs e)
 {
     try
     {
         manageControl myC = new manageControl();
         myC.getCntrl();
         this.empId           = myC.empId;
         this.txtStaffId.Text = "emp" + this.empId;
         this.txtStaffId.Focus();
         if (this.isEdit == true)
         {
             manageEmployees myE = new manageEmployees();
             myE.getEmpDetails(this.empIdStr);
             this.btnAdd.Enabled         = false;
             this.btnUpdate.Enabled      = true;
             this.ckbStatus.Checked      = false;
             this.txtAdress.Text         = myE.address;
             this.txtDob.Value           = Convert.ToDateTime(myE.DOB);
             this.txtempCell.Text        = myE.Mobile;
             this.txtempDate.Value       = Convert.ToDateTime(myE.EmpDate);
             this.txtEmpEmail.Text       = myE.Email;
             this.txtGndr.Text           = myE.gender;
             this.txtFname.Text          = myE.Fname;
             this.txtnatId.Text          = myE.nationalId;
             this.txtNextOfKeenCell.Text = myE.iceContact;
             this.txtNextOfKeenName.Text = myE.iceName;
             this.txtRel.Text            = myE.iceRelationship;
             this.txtSname.Text          = myE.Sname;
             if (myE.Status == "A")
             {
                 this.ckbStatus.Checked = true;
             }
             this.cmbDpt.Text          = myE.Dpt;
             this.txtSname.Text        = myE.Sname;
             this.txtSupervisorId.Text = myE.supervisorId;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed in frmStaffDetails_Load() " + ex.Message);
     }
 }
コード例 #5
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.txtFname.Text == "")
         {
             MessageBox.Show("firstname required", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtFname.Focus();
         }
         else if (this.txtSname.Text == "")
         {
             MessageBox.Show("Surname required", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtSname.Focus();
         }
         else if (this.txtStaffId.Text == "")
         {
             MessageBox.Show("Staff id number required required", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.txtStaffId.Focus();
         }
         else
         {
             manageEmployees myE = new manageEmployees();
             myE.getEmpDetails(this.txtStaffId.Text);
             myE.employeeId      = this.txtStaffId.Text;
             myE.Fname           = this.txtFname.Text;
             myE.address         = this.txtAdress.Text;
             myE.DOB             = this.txtDob.Value.ToShortDateString();
             myE.Mobile          = this.txtempCell.Text;
             myE.EmpDate         = this.txtempDate.Value.ToShortDateString();
             myE.Email           = this.txtEmpEmail.Text;
             myE.Fname           = this.txtFname.Text;
             myE.gender          = this.txtGndr.Text;
             myE.nationalId      = this.txtnatId.Text;
             myE.iceContact      = this.txtNextOfKeenCell.Text;
             myE.iceName         = this.txtNextOfKeenName.Text;
             myE.iceRelationship = this.txtRel.Text;
             myE.Sname           = this.txtSname.Text;
             if (this.ckbStatus.Checked == true)
             {
                 myE.Status = "A";
             }
             else
             {
                 myE.Status = "D";
             }
             myE.Dpt          = this.cmbDpt.Text;
             myE.supervisorId = this.txtSupervisorId.Text;
             if (myE.updateEmplyee(this.txtStaffId.Text) == true)
             {
                 MessageBox.Show("Employee updated success", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Refresh();
             }
             else
             {
                 MessageBox.Show("failed to update employee", "System Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("faltes in refresh() " + ex.Message);
     }
 }