Ejemplo n.º 1
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtNombreCompleto.Text))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.error('" + "Favor ingresar el nombre completo" + "');", true);
            }
            else
            {
                if (String.IsNullOrEmpty(txtCedula.Text) || txtCedula.Text.Count() != 9)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.error('" + "Favor ingresar la cédula con el formato de 9 dígitos" + "');", true);
                }
                else
                {
                    if (String.IsNullOrEmpty(txtTelefono.Text))
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.error('" + "Favor ingresar el teléfono" + "');", true);
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(txtCorreo.Text))
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.error('" + "Favor ingresar el correo" + "');", true);
                        }
                        else
                        {
                            if (String.IsNullOrEmpty(txtContrasenna1.Text))
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.error('" + "Favor ingresar la contraseña" + "');", true);
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(txtContrasenna2.Text))
                                {
                                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.error('" + "Favor ingresar la confirmación de la contraseña" + "');", true);
                                }
                                else
                                {
                                    if (txtContrasenna1.Text.Equals(txtContrasenna2.Text))
                                    {
                                        Cliente cliente = new Cliente();
                                        cliente.activo         = true;
                                        cliente.cedula         = Convert.ToInt32(txtCedula.Text);
                                        cliente.confirmado     = false;
                                        cliente.contrasenna    = txtContrasenna1.Text;
                                        cliente.correo         = txtCorreo.Text;
                                        cliente.nombreCompleto = txtNombreCompleto.Text;
                                        cliente.telefono       = txtTelefono.Text;

                                        if (RadioButtonList1.SelectedValue.ToString().Equals("F"))
                                        {
                                            cliente.tipoClase = false;
                                        }
                                        else
                                        {
                                            if (RadioButtonList1.SelectedValue.ToString().Equals("T"))
                                            {
                                                cliente.tipoClase = true;
                                            }
                                        }

                                        clienteDatos.insertarCliente(cliente);
                                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.success('" + "Los datos deben ser confirmados por el administrador, por favor esperar hasta que se realice esta acción" + "');", true);
                                        limpiarCampos();

                                        String destinatario = cliente.correo;
                                        String mensaje      = "<br/><h1>Se ha registrado en el sistema de Box Molina</h1><br/>¡Muchas gracias por su registro!</b><br/><span style='color:red'>*El administrador debe de confirmar su información para que pueda ingresar al sistema<br/>Se le enviara un correo cuando sea confirmado por el administrador.</span>";
                                        String asunto       = "Box Molina Registro exitoso";
                                        String copiaOculta  = "*****@*****.**";

                                        threadEnviarCorreo = new Thread(delegate() { enviarCorreo(destinatario, mensaje, copiaOculta, asunto); });
                                        threadEnviarCorreo.Start();
                                    }
                                    else
                                    {
                                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "toastr.warning('" + "La contraseña y la confirmación de la contraseña no coinciden" + "');", true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }