Example #1
0
        private void ModifyEmployee_Load(object sender, EventArgs e)
        {
            Connection.OpenConnection();
            int id = Int32.Parse(idEmployee);

            Class.Employee employee = Class.Employee.searchEmployee(Connection.myConnection, id);
            Connection.CloseConnection();

            idTextBox.Text        = employee.IdEmployee.ToString();
            firstNameTextBox.Text = employee.FirstName;
            lastNameTextBox.Text  = employee.LastName;
            phoneTextBox.Text     = employee.Phone;
            emailTextBox.Text     = employee.Email;
            addressTextBox.Text   = employee.Address;
            passwordTextBox.Text  = employee.Password;

            if (employee.EmployeeType == 0)
            {
                positionComboBox.Text = "Gerente";
            }
            else
            {
                positionComboBox.Text = "Cajero";
            }
        }
Example #2
0
        private void modifyButton_Click(object sender, EventArgs e)
        {
            if (firstNameTextBox.Text == "" || lastNameTextBox.Text == "" || phoneTextBox.Text == "" || emailTextBox.Text == "" ||
                addressTextBox.Text == "" || passwordTextBox.Text == "" || positionComboBox.SelectedItem == null)
            {
                MessageBox.Show("Favor de llenar todos los campos");
            }
            else
            {
                Connection.OpenConnection();
                int position;
                int cellphone;
                cellphone = Int32.Parse(phoneTextBox.Text);

                if (positionComboBox.Text == "Gerente")
                {
                    position = 0;
                }
                else
                {
                    position = 1;
                }

                Class.Employee employee = new Class.Employee(int.Parse(idEmployee), firstNameTextBox.Text, lastNameTextBox.Text, phoneTextBox.Text, emailTextBox.Text, addressTextBox.Text, passwordTextBox.Text, position, true);
                Class.Employee.modifyEmployee(Connection.myConnection, employee);
                Connection.CloseConnection();

                MessageBox.Show("Modificado exitosamente");
                this.Close();
            }
        }
Example #3
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (firstNameTextBox.Text == "" || lastNameTextBox.Text == "" || phoneTextBox.Text == "" ||
                emailTextBox.Text == "" || addressTextBox.Text == "" || positionComboBox.SelectedItem == null)
            {
                MessageBox.Show("Favor de llenar todos los campos");
            }
            else
            {
                if (IsValidEmail(emailTextBox.Text) == true)
                {
                    Connection.OpenConnection();
                    int position;
                    if (positionComboBox.SelectedIndex == 0)
                    {
                        // 0 = gerente
                        position = 0;
                    }
                    else
                    {
                        //1 = empleado
                        position = 1;
                    }

                    Class.Employee newEmploye = new Class.Employee(1, firstNameTextBox.Text, lastNameTextBox.Text, phoneTextBox.Text, emailTextBox.Text, addressTextBox.Text, passwordTextBox.Text, position, true);
                    Class.Employee.addEmployee(Connection.myConnection, newEmploye);
                    Connection.CloseConnection();

                    MessageBox.Show("Empleado registrado\nExitosamente");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("El formato del correo no es correcto");
                }
            }
        }