protected void btnModificarMec_Click(object sender, EventArgs e)
        {
            string nombre   = txtNombre.Text;
            int    registro = 0;

            int.TryParse(txtRegistroActual.Text, out registro);
            string calle     = txtCalle.Text;
            string numPuerta = txtNumero.Text;
            string ciudad    = txtCiudad.Text;
            string telefono  = txtTelefono.Text;
            double jornal    = 0;

            double.TryParse(txtJornal.Text, out jornal);
            string capExtra = txtCapaExtra.Text;
            bool   extra    = false;

            if (capExtra.ToLower() == "si")
            {
                extra = true;
            }
            string foto = "";

            if (Foto.HasFile)
            {
                foto = "~/imagenes/" + Foto.FileName;
                Foto.SaveAs(Server.MapPath(
                                foto));
            }
            if (nombre != "" && registro != 0 && calle != "" && numPuerta != "" && ciudad != "" && telefono != "" && jornal != 0 && foto != "")
            {
                lblMensaje.Text = EmpNaviera.Instancia.modicarMecanico(nombre, registro, calle, numPuerta, ciudad, telefono, jornal, extra, foto);
            }
            if (calle != "" && numPuerta != "" && ciudad != "" && registro != 0)
            {
                lblMensaje.Text = EmpNaviera.Instancia.modificarDireccion(calle, numPuerta, ciudad, registro);
            }
            if (foto != "" && registro != 0)
            {
                lblMensaje.Text = EmpNaviera.Instancia.actualizarFoto(foto, registro);
            }
            GridView1.DataSource = EmpNaviera.Instancia.Mecanicos;

            GridView1.DataBind();
        }
Exemple #2
0
        protected void btnAgregarMecanico_Click(object sender, EventArgs e)
        {
            string nombre    = txtNombre.Text;
            string calle     = txtCalle.Text;
            string numPuerta = txtNumero.Text;
            string ciudad    = txtCiudad.Text;
            string telefono  = txtTelefono.Text;
            int    registro  = 0;

            int.TryParse(txtRegistro.Text, out registro);
            double jornal = 0;

            double.TryParse(txtJornal.Text, out jornal);
            string capaExtra = txtCapaExtra.Text;
            string foto      = "";

            if (Foto.HasFile)
            {
                foto = "~/imagenes/" + Foto.FileName;
                Foto.SaveAs(Server.MapPath(foto));
            }
            else
            {
                lblMensaje.Text = "Debe Seleccionar una foto";
            }

            if (nombre == "")
            {
                lblMensaje.Text += "debe Ingresar un Nombre,";
            }
            else
            {
                if (calle == "")
                {
                    lblMensaje.Text += "debe Ingresar una Calle,";
                }
                else
                {
                    if (numPuerta == "")
                    {
                        lblMensaje.Text += "debe Ingresar Numero de puerta,";
                    }
                    else
                    {
                        if (ciudad == "")
                        {
                            lblMensaje.Text += "debe Ingresar una Ciudad,";
                        }
                        else
                        {
                            if (telefono == "")
                            {
                                lblMensaje.Text += "debe Ingresar un Telefono,";
                            }
                            else
                            {
                                if (registro <= 0)
                                {
                                    lblMensaje.Text += "debe Ingresar un Registro,";
                                }
                                else
                                {
                                    if (jornal <= 0)
                                    {
                                        lblMensaje.Text += "debe Ingresar un jornal,";
                                    }
                                    else
                                    {
                                        bool capacitacion = false;
                                        if (capaExtra.ToLower() == "si")
                                        {
                                            capacitacion = true;
                                        }

                                        lblMensaje.Text = EmpNaviera.Instancia.ingresoMecanico(nombre, telefono, registro, jornal, capacitacion, calle, numPuerta, ciudad, foto);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
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";
            }
        }