Exemplo n.º 1
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            Empleado        cliente = new Empleado();
            EmpleadoNegocio negocio = new EmpleadoNegocio();

            if (txtDni.Text.Length > 0 && txtApellido.Text.Length > 0 && txtNombre.Text.Length > 0 && txtMail.Text.Length > 0 && txtNumTel.Text.Length > 0 && txtTipoTel.Text.Length > 0 && txtCalle.Text.Length > 0 && txtNumero.Text.Length > 0 && txtCodPostal.Text.Length > 0 && txtlocalidad.Text.Length > 0 && txtCuil.Text.Length > 0)
            {
                cliente.DNI      = Convert.ToInt32(txtDni.Text);
                cliente.Apellido = txtApellido.Text;
                cliente.Nombre   = txtNombre.Text;
                cliente.Mail     = txtMail.Text;
                cliente.CUIL     = Convert.ToInt64(txtCuil.Text);
                if (cbbtipoempleado.SelectedItem.ToString() == "GERENTE")
                {
                    cliente.Tipo = "GERENTE";
                }
                if (cbbtipoempleado.SelectedItem.ToString() == "ENCARGADO")
                {
                    cliente.Tipo = "ENCARGADO";
                }
                if (cbbtipoempleado.SelectedItem.ToString() == "VENDEDOR")
                {
                    cliente.Tipo = "VENDEDOR";
                }
                cliente.telefono                = new Telefono();
                cliente.telefono.Id             = Convert.ToInt32(txtIdTel.Text);
                cliente.telefono.Numero         = Convert.ToInt32(txtNumTel.Text);
                cliente.telefono.TipoDeTelefono = txtTipoTel.Text;
                cliente.domicilio               = new Domicilio();
                cliente.domicilio.Id            = Convert.ToInt32(txtId.Text);
                cliente.domicilio.Calle         = txtCalle.Text;
                cliente.domicilio.Altura        = Convert.ToInt32(txtNumero.Text);
                cliente.domicilio.CodigoPostal  = Convert.ToInt32(txtCodPostal.Text);
                cliente.domicilio.Localidad     = txtlocalidad.Text;

                if (cliente.telefono.Id > 0 || cliente.domicilio.Id > 0)
                {
                    negocio.ModificarEmpleado(cliente);
                }
                else
                {
                    MessageBox.Show("EL EMPLEADO NO EXISTE!! INTENTE CON AGREGAR");
                }

                cargarGrilla();
            }
            else
            {
                MessageBox.Show("DEBEN ESTAR TODOS LOS CAMPOS COMPLETOS!!");
            }
        }
Exemplo n.º 2
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (txtNombreMod.Text == "" || txtApellidoMod.Text == "" || txtContactoMod.Text == "")
            {
                MessageBox.Show("Debe completar todos los campos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Empleado        modificado = new Empleado();
                EmpleadoNegocio negocio    = new EmpleadoNegocio();

                modificado.id       = int.Parse(txtIDMod.Text);
                modificado.nombre   = txtNombreMod.Text;
                modificado.apellido = txtApellidoMod.Text;
                modificado.contacto = txtContactoMod.Text;
                modificado.puesto   = (Puesto)cmbPuestoMod.SelectedItem;
                if (rdbPeluqueriaMod.Checked == true)
                {
                    modificado.rubro = rdbPeluqueriaMod.Text;
                }
                else
                {
                    modificado.rubro = rdbVeterinariaMod.Text;
                }

                negocio.ModificarEmpleado(modificado);

                txtNombreMod.Enabled      = false;
                txtApellidoMod.Enabled    = false;
                txtContactoMod.Enabled    = false;
                rdbPeluqueriaMod.Enabled  = false;
                rdbVeterinariaMod.Enabled = false;
                cmbPuestoMod.Enabled      = false;

                txtIDMod.Text          = "";
                txtNombreMod.Text      = "";
                txtApellidoMod.Text    = "";
                txtContactoMod.Text    = "";
                rdbPeluqueriaMod.Text  = "";
                rdbVeterinariaMod.Text = "";
                cmbPuestoMod.Text      = "";

                cargarGrilla();
            }
        }
        private void btnModificarEmpleado_Click(object sender, EventArgs e)
        {
            bool variable = false;

            Empleado empleadoModificado = new Empleado();

            for (int i = 0; i < Negocio.ListaEmpleados.Count; i++)
            {
                if (Convert.ToBoolean(dataGridViewEmpleados.Rows[i].Cells[0].Value) == true)
                {
                    empleadoModificado.IdEmpleado = Convert.ToInt32(txtIdEmpleado.Text);
                    empleadoModificado.Nombre     = txtNombre.Text;
                    empleadoModificado.Apellido   = txtApellido.Text;
                    empleadoModificado.Edad       = Convert.ToInt32(txtEdad.Text);
                    empleadoModificado.Dni        = Convert.ToInt32(txtDni.Text);

                    variable = true;
                }
            }

            if (variable == true)
            {
                empleadoNegocio.ModificarEmpleado(empleadoModificado);
                MessageBox.Show("Empleado/a modificado/a");
                GetDataSource();
                LimpiarDatos();
            }

            else
            {
                MessageBox.Show("Seleccione el/la empleado/a que quiere modificar");
                LimpiarDatos();
            }

            txtIdEmpleado.ReadOnly = false;
        }
Exemplo n.º 4
0
        protected void BtnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                bool            Estado;
                string          Extension;
                EmpleadoNegocio EmpleadoNegocio = new EmpleadoNegocio();
                Empleado        Empleado        = new Empleado();
                Empleado = null;
                Empleado = EmpleadoNegocio.BuscarEmpleado(Convert.ToInt32(txtDNI.Text));
                if (Empleado == null)
                {
                    Empleado        = new Empleado();
                    Empleado.Dni    = Convert.ToInt32(txtDNI.Text);
                    Empleado.Nombre = txtNombre.Text;
                    Empleado.Email  = txtEmail.Text;
                    if (Foto.HasFile)
                    {
                        Extension = Path.GetExtension(Foto.FileName).ToLower();
                        if (Extension == ".jpg" || Extension == ".gif" || Extension == ".jpeg")
                        {
                            Foto.SaveAs(Server.MapPath("~/Fotos/" + Foto.FileName));
                            Empleado.Foto = "~/Fotos/" + Foto.FileName;
                        }
                        else
                        {
                            lblMensaje.Text = "El formato de la imagen es incorrecto";
                        }
                    }
                    else
                    {
                        Empleado.Foto = "";
                    }

                    if (txtDNI.Text == "" || txtNombre.Text == "" || txtEmail.Text == "")

                    {
                        lblMensaje.Text = "Hay campos que se encuentran vacios";
                    }

                    else
                    {
                        Estado = EmpleadoNegocio.AgregarEmpleado(Empleado);
                        if (Estado == true)
                        {
                            EmpleadoNegocio.GenerarUsuario(Empleado);
                            EmpleadoNegocio.EnviarCorreo(Empleado);
                            lblMensaje.Text = "Empleado agregado correctamente";
                            txtDNI.Text     = "";
                            txtNombre.Text  = "";
                            txtEmail.Text   = "";
                        }
                        else
                        {
                            lblMensaje.Text = "Error el empleado no fue agregado correctamente";
                        }
                    }
                }
                else if (Empleado != null)
                {
                    Empleado.Dni    = Convert.ToInt32(txtDNI.Text);
                    Empleado.Nombre = txtNombre.Text;
                    Empleado.Email  = txtEmail.Text;

                    if (txtDNI.Text == "" || txtNombre.Text == "" || txtEmail.Text == "")

                    {
                        lblMensaje.Text = "Hay campos que se encuentran vacios";
                    }

                    else
                    {
                        Estado = EmpleadoNegocio.ModificarEmpleado(Empleado);
                        if (Estado == true)
                        {
                            lblMensaje.Text = "Empleado modificado correctamente";
                            txtDNI.Text     = "";
                            txtNombre.Text  = "";
                            txtEmail.Text   = "";
                        }
                        else
                        {
                            lblMensaje.Text = "Error el empleado no fue modificado correctamente";
                        }
                    }
                }
            }
            catch (Exception)
            {
                lblMensaje.Text = "Hay campos que se encuentran vacios o verificar el formato de la imagen";
            }
        }