Exemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            // INSERTAR EMPLEADO
            if (Editar == false)
            {
                try
                {
                    objetoCE.Id_Empl   = Convert.ToInt32(cbxEmpresa.SelectedValue);
                    objetoCE.Nombre    = txtNombre.Text;
                    objetoCE.Apellido  = txtApellido.Text;
                    objetoCE.Cedula    = txtCedula.Text;
                    objetoCE.Dirrecion = txtDireccion.Text;
                    objetoCE.Telefono  = txtTelefono.Text;
                    objetoCE.Email     = txtEmail.Text;
                    objetoCE.Estado    = cbxEstado.Text;
                    objetoCN.InsertarEmpleado(objetoCE);
                    MessageBox.Show("Se Ingreso correctamente el Empleado");
                    MostrarEmpleado();
                    LimpiarForm();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("No se puede Ingresar el Empleado por  " + ex);
                }

                // EDITAR EMPLEADO
            }
            if (Editar == true)
            {
                {
                    try
                    {
                        objetoCE.Id        = Convert.ToInt32(IdEmpleado);
                        objetoCE.Id_Empl   = Convert.ToInt32(cbxEmpresa.SelectedValue);
                        objetoCE.Nombre    = txtNombre.Text;
                        objetoCE.Apellido  = txtApellido.Text;
                        objetoCE.Cedula    = txtCedula.Text;
                        objetoCE.Dirrecion = txtDireccion.Text;
                        objetoCE.Telefono  = txtTelefono.Text;
                        objetoCE.Email     = txtEmail.Text;
                        objetoCE.Estado    = cbxEstado.Text;
                        objetoCN.EditarEmpleado(objetoCE);
                        MessageBox.Show("Se Editó correctamente el Empleado");
                        MostrarEmpleado();
                        LimpiarForm();
                        Editar = false;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("No se puede Editar el Empleado por  " + ex);
                    }
                }
            }
        }