Exemplo n.º 1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            dbcon.connect();

            if (string.IsNullOrWhiteSpace(textBoxUsername.Text) || string.IsNullOrWhiteSpace(textBoxNewPassword.Text) || string.IsNullOrWhiteSpace(textBoxConfirmPasssword.Text))
            {
                MessageBox.Show("Invalid Input!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                Staff staff = new Staff();
                staff.Username = textBoxUsername.Text;
                staff.Password = textBoxConfirmPasssword.Text;

                StaffHandler stafHandlr = new StaffHandler();
                stafHandlr.resetPassword(dbcon.getConn(), staff);

                if (textBoxUsername.Text == staff.Username && textBoxConfirmPasssword.Text == staff.Password)
                {
                    Login lgn = new Login();
                    lgn.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("The password does not match.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DBConn.connect();
            Staff        stff        = new Staff();
            StaffHandler staffHandlr = new StaffHandler();

            stff.FirstName     = fnameTextBox.Text;
            stff.LastName      = lnameTextBox.Text;
            stff.Age           = int.Parse(ageTextBox.Text);
            stff.Sex           = sexComboBox.Text;
            stff.Address       = addressRichTextBox.Text;
            stff.ZipCode       = zipTextBox.Text;
            stff.ContactNumber = contactTextBox.Text;
            stff.StaffRole     = roleComboBox.Text;
            stff.LoginStatus   = statusComboBox.Text;
            stff.DateOfHire    = hiredDateTimePicker.Value.Date;
            stff.HourlyWage    = Decimal.Parse(wageTextBox.Text);
            stff.Username      = usernameTextBox.Text;
            stff.Password      = passwordTextBox.Text;

            staffHandlr.addNewStaff(DBConn.getConn(), stff);
            MessageBox.Show("A new staff has been added!");

            this.Hide();
            StaffManagement stf = new StaffManagement();

            stf.Show();
        }