Ejemplo n.º 1
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            //if (txtRuc.Text.Length == 0)
            //{
            //    string msj = "Ingresa RUC";
            //    ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
            //    return;
            //}

            if (txtCorreo.Text.Length == 0)
            {
                string msj = "Ingresa correo";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
                return;
            }
            if (txtClave.Text.Length == 0)
            {
                string msj = "Ingresa clave";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
                return;
            }

            oLN_Usuario = new LN_Usuario();
            ENT_Usuario oEnt_Usuario = new ENT_Usuario();
            //  oEnt_Usuario.Ruc=txtRuc.Text.Trim();
            oEnt_Usuario.Correo = txtCorreo.Text.Trim();
            oEnt_Usuario.Clave = txtClave.Text.Trim();

            int resultado = -1;
            int perfil = -1;
            string nombrecompleto = "SSS";
            int usuarioid = -1;
            int paquete = -1;
            int downgrade = -1;
            int restriccionip = -1;

            string codigoGenerado = ViewState["codigo"].ToString();
            string codigoIngresado = txtCodigo.Text;
            string ip = "";

            int PerfilUsuarioID = -1;
            int habilitado = -1;
            bool servicio = false;
            string ruc = string.Empty;

            //oLN_Usuario.ValidarUsuario(oEnt_Usuario, ref resultado, ref perfil, ref nombrecompleto, ref usuarioid);

            oLN_Usuario.ValidarUsuario(oEnt_Usuario
                , ref resultado
                , ref perfil
                , ref nombrecompleto
                , ref usuarioid
                , ref PerfilUsuarioID
                , ref habilitado
                , ref servicio
                , ref ruc
                , ref paquete
                , ref downgrade
                , ref restriccionip
                , ref ip
                , ref idioma
                );

            if (idioma.Equals(""))
                idioma = "ES";
            Session["Etiquetas"] = oLN_Idiona.ObtenerEtiquetasPorIdioma(idioma);
            Dictionary<string, string> etiquetas = (Dictionary<string, string>)Session["Etiquetas"];

            if (resultado == 0)
            {
                string msj = "";
                if (perfil == 5000)
                {
                    // msj = "Usuario no existe.";
                    msj = etiquetas["IS04"];
                }
                else
                {
                    if (habilitado == 2)
                    {
                        msj = "La cuenta está deshabilitada. Por favor contacte a su administrador.";
                    }
                    else
                    {
                        //msj = "Datos incorrectos.";
                        msj = etiquetas["IS03"];
                    }
                }
                ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
            }
            else
            {
                Session["Perfil"] = perfil.ToString();
                Session["NombreCompleto"] = nombrecompleto.ToString();
                Session["UsuarioID"] = usuarioid.ToString();
                Session["PerfilUsuarioID"] = PerfilUsuarioID.ToString();
                Session["Servicio"] = servicio;
                Session["RUC"] = ruc;
                Session["Paquete"] = paquete;

                if (codigoGenerado.Equals(codigoIngresado))
                {
                    if (downgrade == 1 && PerfilUsuarioID != 1)
                    {
                        string msj = "No puede iniciar sesión hasta que el administrador configure los parámetros para su empresa.";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
                    }
                    else
                    {
                        if (habilitado == 1)
                        {
                            WebClient wc = new WebClient();
                            string ipAddress = wc.DownloadString("http://icanhazip.com/");
                            int sizecadena = ipAddress.Length;
                            string ipsesion = ipAddress.Substring(0, sizecadena - 1);
                            if (restriccionip == 1 && (ip != ipsesion || !ip.Equals(ipsesion)))
                            {
                                string msj = "No puede iniciar sesión en una ubicación diferente a la indicada por el administrador.";
                                ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
                            }
                            else
                            {
                                string msj = "Bienvenido a AL SISTEMA.";
                                ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);

                                switch (PerfilUsuarioID)
                                {
                                    case 1:

                                        //if (servicio == false)
                                        // {
                                        Response.Redirect("../iAdministrador/Inicio.aspx");
                                        //Server.transfer();
                                        //  }
                                        // else
                                        //  {
                                        //  Response.Redirect("../iAdministradors/Inicio.aspx");
                                        //  }

                                        break;

                                    case 2:
                                        //Response.Redirect("../iSupervisor/Inicio.aspx");
                                        Response.Redirect("../iAdministrador/Inicio.aspx");
                                        break;

                                    case 3:
                                        Response.Redirect("../iAnalista/Inicio.aspx");
                                        break;
                                }
                            }
                        }
                        else if (habilitado == 2)
                        {
                            string msj = "La cuenta está deshabilitada. Por favor contacte a su administrador.";
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
                        }
                    }
                }

                else
                {
                    //string msj = "Error código captcha.";
                    string msj = etiquetas["IS02"];
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
                    crearCaptcha();
                }

            }
        }
Ejemplo n.º 2
0
        protected void btnFinalizar_Click(object sender, EventArgs e)
        {
            if (chkAceptar.Checked)
            { }
            else
            {
                string msj = msj_checkregister; // "Para poder finalizar el registro estar de acuerdo con los términos y condiciones";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "RechazaContrato", "alert('" + msj + "');", true);
                return;
            }

            ENT_Empresa oEnt_Empresa = new ENT_Empresa();
            ENT_Usuario oEnt_Usuario = new ENT_Usuario();

            LN_Empresa oLN_Empresa = new LN_Empresa();
            LN_Usuario oLN_Usuario = new LN_Usuario();

            oEnt_Empresa.Ruc = txtRuc.Text.Trim();
            oEnt_Empresa.RazonSocial = txtRazonSocial.Text.Trim();
            //oEnt_Empresa.PaisID = Int32.Parse(ddlPais.SelectedValue.ToString());
            //oEnt_Empresa.PaisID = ddlPais.SelectedValue.ToString();
            oEnt_Empresa.PaisID = ddlPais.SelectedItem.ToString();
            //oEnt_Empresa.CiudadID = Int32.Parse(ddlCiudad2.Text.ToString());
            oEnt_Empresa.CiudadID = ddlCiudad2.Text.ToString();
            oEnt_Empresa.Direccion = txtDireccion.Text.Trim();
            //oEnt_Empresa.RubroID = Int32.Parse(ddlRubro.SelectedValue.ToString());
            oEnt_Empresa.RubroID = ddlRubro.SelectedValue.ToString();
            oEnt_Empresa.nomLab = "Laboratorio";
            oEnt_Empresa.ubicacion = txtDireccion.Text;

            switch (ddlRubro.SelectedValue.ToString())
            {
                case "alimentos animal":
                    oEnt_Empresa.segmento = segmento1.SelectedValue.ToString(); break;
                case "alimentos consumo":
                    oEnt_Empresa.segmento = segmento2.SelectedValue.ToString(); break;
                case "alimentos insumos":
                    oEnt_Empresa.segmento = segmento3.SelectedValue.ToString(); break;
                case "industrial extraccion":
                    oEnt_Empresa.segmento = segmento4.SelectedValue.ToString(); break;
                case "industrial farma":
                    oEnt_Empresa.segmento = segmento5.SelectedValue.ToString(); break;
                case "industrial maquilado":
                    oEnt_Empresa.segmento = segmento6.SelectedValue.ToString(); break;
                case "industrial quimico":
                    oEnt_Empresa.segmento = segmento7.SelectedValue.ToString(); break;
                case "industrial vestido":
                    oEnt_Empresa.segmento = segmento8.SelectedValue.ToString(); break;
            }

            oEnt_Empresa.Dominio = txtDominio.Text.Trim();
            oEnt_Empresa.Correo = txtCorreo.Text.Trim();

            oEnt_Usuario.Nombre = txtNombre.Text.Trim();
            oEnt_Usuario.Correo = txtCorreoE.Text.Trim();
            oEnt_Usuario.Clave = txtClave.Text.Trim();
            oEnt_Empresa.Idioma = ddlIdioma.SelectedValue.ToString();

            if (rbEmpresa.Checked)
            {
                oEnt_Usuario.Servicio = false;
            }
            else
            {
                oEnt_Usuario.Servicio = true;
            }

            int resultado = -1;
            oLN_Empresa.InsertarNuevaEmpresa(oEnt_Empresa, oEnt_Usuario, ref resultado);

            if (resultado == 0)
            {
                string msj = msj_registerok; // "Registro almacenado correctamente.";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "RegistroCompletado", "alert('" + msj + "');", true);

                txtRuc.Text = "";
                txtRazonSocial.Text = "";
                txtDireccion.Text = "";
                txtDominio.Text = "";
                txtCorreo.Text = "";

                txtNombre.Text = "";
                txtCorreoE.Text = "";
                txtClave.Text = "";
                txtClaveConf.Text = "";

                Response.Redirect("../iRegistro/Login.aspx");
            }
            else
            {
                string msj = msj_registerincomplete; // "No se completo el registro. Se ha detectado que el numero de RUC ya se encuentra registrado en el sistema";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "MostrarMensaje", "alert('" + msj + "');", true);
            }
        }