コード例 #1
0
        private void toolStripMenuItemAddEmployee_Click(object sender, EventArgs e)
        {
            frmAddEmployee form = new frmAddEmployee();

            form.MdiParent = this;
            form.Show();
        }
コード例 #2
0
ファイル: frmAddEmployee.cs プロジェクト: marcusc83/Employees
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Model.MyEmployees emp = new Model.MyEmployees();

                emp.firstName     = this.txtFirstName.Text.Trim();
                emp.lastName      = this.txtLastName.Text.Trim();
                emp.streetAddress = this.txtStreetAddress.Text.Trim();
                emp.city          = this.txtCity.Text.Trim();
                emp.state         = this.cmbStates.Text;
                emp.zipCode       = this.txtZipCode.Text.Trim();
                emp.phoneNumber   = this.txtPhoneNumber.Text.Trim();
                emp.emailAddress  = this.txtEmailAddress.Text.Trim();
                EmployerInfoValidator validator = new EmployerInfoValidator();
                bool infoValid = validator.checkEmpInfo(emp);

                if (infoValid == true)
                {
                    SQLCommands.SQLAddEmployee cmdAddEmp = new SQLCommands.SQLAddEmployee();
                    cmdAddEmp.addEmployee(emp);
                    if (MessageBox.Show("Would you like to add another employee?", "Add another Emplolyee", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        frmAddEmployee form = new frmAddEmployee();
                        form.MdiParent = ActiveForm;
                        form.Show();
                        this.Close();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Make sure all the boxes are filled in", "Info Missing Error");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Add Employee Error");
            }
        }