public override void Save()
        {
            try
            {
                if (mode == "edit")
                {
                    _employer.employer_name     = txtName.Text;
                    _employer.employer_lastname = txtLastname.Text;
                    _employer.employer_phone    = txtPhone.Text;
                    _employer.employer_email    = txtEmail.Text;
                    _employer.employer_address  = txtAddress.Text;
                    _employer.employer_role     = txtRole.Text;
                    _employer.employer_dln      = txtDLN.Text;

                    if ((bool)ptPicture.Tag == true)
                    {
                        MemoryStream stream = new MemoryStream();
                        ptPicture.BackgroundImage.Save(stream, ImageFormat.Jpeg);
                        _employer.picture = stream.ToArray();
                    }
                    Employer_Data.Update_NewEmployer(_employer);
                    MessageBox.Show("Your changes have been saved!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Mode("info");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public override void Save()
 {
     if (!Security.Validating.validateFields(this))
     {
         if (txtNewPassword.CompareWith(txtConfirmPassword.Text))
         {
             try
             {
                 var  newpassword = Security.Security.Encrypt(txtNewPassword.Text.Trim());
                 bool answer      = Employer_Data.ChangePassword(_employer.id_employer, txtCurentPassword.Text, newpassword);
                 if (!answer)
                 {
                     MessageBox.Show("The current password is wrong.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     MessageBox.Show("Password changed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.Close();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Error: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Passwords in new password field and confirm password field are different.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #3
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         var answer = Employer_Data.Login(txtIdNumber.Text.Trim(), txtPassword.Text.Trim());
         if (answer is Boolean)
         {
             txtPassword.Text = "";
             MessageBox.Show("Password incorrect", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             var            employer   = (answer is EmployerModel) ? answer : new EmployerModel();
             Manager_System frmManager = new Manager_System((EmployerModel)employer, this);
             this.Hide();
             frmManager.Show();
         }
     }
     catch (Exception)
     {
         txtIdNumber.Text = "";
         txtPassword.Text = "";
         MessageBox.Show("Employer number wrong.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #4
0
        public override void Save()
        {
            if (!Security.Validating.validateFields(this))
            {
                try
                {
                    string id       = "E" + new Random().Next(10000, 99999).ToString();
                    string name     = txtName.Text.Trim();
                    string lastname = txtLastname.Text.Trim();
                    string phone    = txtPhone.Text.Trim();
                    string email    = txtEmail.Text.Trim();
                    string address  = (txtApt.Text != "")? txtStreet.Text.Trim() + " Apt#" + txtApt.Text.Trim() + ", " + txtCity.Text.Trim() + ", " + cmbState.Text.Trim() + ", " + txtZipcode.Text.Trim() : txtStreet.Text.Trim() + ", " + txtCity.Text.Trim() + ", " + cmbState.Text.Trim() + ", " + txtZipcode.Text.Trim();
                    string role     = cmbRole.Text.Trim();
                    string dln      = txtDLN.Text.Trim();
                    byte[] picture  = null;
                    if ((bool)ptPicture.Tag == true)
                    {
                        MemoryStream stream = new MemoryStream();
                        ptPicture.BackgroundImage.Save(stream, ImageFormat.Jpeg);
                        picture = stream.ToArray();
                    }

                    EmployerModel employer = new EmployerModel(id, name, lastname, address, phone, email, dln, role, "", picture);
                    Employer_Data.Update_NewEmployer(employer);
                    MessageBox.Show("New employer added.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }
 private void Manager_System_Close(object sender, FormClosedEventArgs e)
 {
     Employer_Data.LogOut(employer.id_employer, employer.id_logged);
     employer = new EmployerModel();
 }