Example #1
0
        public int GetSoRsoci(int soc_cont, int sbe_cont, int soc_cing, short emp_codi)
        {
            int retorno = 1;

            TOSoRsoci toSoRsoci = new TOSoRsoci();

            toSoRsoci.Emp_codi = emp_codi;
            toSoRsoci.Soc_cont = soc_cont;
            toSoRsoci.Sbe_cont = sbe_cont;
            toSoRsoci.Soc_cing = soc_cing;

            var rsoci = daoSoSocio.GetSoRsociValido(toSoRsoci);

            if (rsoci != null)
            {
                retorno = 0;

                if (rsoci.Soc_cont == 0)
                {
                    return(retorno = 1);
                }

                DateTime ahora = DateTime.Now;
                if (rsoci.Soc_cfec < ahora)
                {
                    return(retorno = 1);
                }
            }


            return(retorno);
        }
Example #2
0
        public int UpdSoRsoci(TOSoRsoci toSoRsoci)
        {
            List <Parameter> listAux = new List <Parameter>();

            try
            {
                StringBuilder sql = new StringBuilder();

                sql.Append(" UPDATE SO_SBENE ");
                sql.Append(" SET  ");
                //Actualiza el código de verificación y la fecha máxima de uso del código si el usuario está intentando actualizar los datos
                if (string.IsNullOrEmpty(toSoRsoci.Sbe_pass))
                {
                    sql.Append(" SBE_CING = @P_SBE_CING, ");
                    sql.Append(" SBE_CFEC = @P_SBE_CFEC ");
                    listAux.Add(new Parameter("@P_SBE_CING", toSoRsoci.Soc_cing));
                    listAux.Add(new Parameter("@P_SBE_CFEC", toSoRsoci.Soc_cfec));
                }
                //Actualiza el password si el usuario ya recibió el codigo de seguridad y confirmó su constraseña
                if (!string.IsNullOrEmpty(toSoRsoci.Sbe_pass))
                {
                    sql.Append(" SBE_PASS = @P_SBE_PASS ");
                    listAux.Add(new Parameter("@P_SBE_PASS", Encrypta.EncriptarClave(toSoRsoci.Sbe_pass)));
                }

                sql.Append(" WHERE EMP_CODI = @P_EMP_CODI ");
                sql.Append(" AND SBE_NCAR = @P_SBE_NCAR ");
                sql.Append(" AND SOC_CONT = @P_SOC_CONT ");
                sql.Append(" AND SBE_CONT = @P_SBE_CONT ");


                listAux.Add(new Parameter("@P_EMP_CODI", toSoRsoci.Emp_codi));
                listAux.Add(new Parameter("@P_SBE_NCAR", toSoRsoci.Sbe_ncar));
                listAux.Add(new Parameter("@P_SOC_CONT", toSoRsoci.Soc_cont));
                listAux.Add(new Parameter("@P_SBE_CONT", toSoRsoci.Sbe_cont));


                Parameter[] oParameter = listAux.ToArray();
                OTOContext  pTOContext = new OTOContext();

                var conection = DBFactory.GetDB(pTOContext);
                var objeto    = conection.Update(pTOContext, sql.ToString(), oParameter);
                return(objeto.AsInt());
            }
            catch (Exception ex)
            {
                BOException.Throw(this.GetType().ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(-1);
            }
        }
Example #3
0
        public TOSoRsoci GetSoRsoci(TOSoRsoci toSoRsoci)
        {
            List <Parameter> listAux = new List <Parameter>();

            try
            {
                StringBuilder sql = new StringBuilder();

                sql.Append(" SELECT SO_SOCIO.SOC_CONT, SO_SBENE.SBE_CONT, SO_SBENE.SBE_CFEC, SO_SBENE.SBE_PASS ");
                sql.Append(" FROM SO_SOCIO, SO_SBENE ");
                sql.Append(" WHERE SO_SOCIO.EMP_CODI = SO_SBENE.EMP_CODI ");
                sql.Append(" AND SO_SOCIO.SOC_CONT = SO_SBENE.SOC_CONT ");
                sql.Append(" AND SO_SOCIO.EMP_CODI = @P_EMP_CODI ");
                sql.Append(" AND SO_SOCIO.SOC_ESTA = 'A' ");
                sql.Append(" AND SO_SBENE.SBE_ESTA = 'A' ");
                //sql.Append(" AND SO_SBENE.SBE_CONT = 1 ");

                sql.Append(" AND SO_SBENE.SBE_NCAR = @P_SBE_NCAR ");
                sql.Append(" AND SO_SBENE.SBE_MAIL = @P_SBE_MAIL ");
                sql.Append(" AND SO_SBENE.SBE_NCEL = @P_SBE_NCEL ");


                listAux.Add(new Parameter("@P_EMP_CODI", toSoRsoci.Emp_codi));
                listAux.Add(new Parameter("@P_SBE_NCAR", toSoRsoci.Sbe_ncar));
                listAux.Add(new Parameter("@P_SBE_MAIL", toSoRsoci.Sbe_mail));
                listAux.Add(new Parameter("@P_SBE_NCEL", toSoRsoci.Sbe_ncel));

                Parameter[] oParameter = listAux.ToArray();
                OTOContext  pTOContext = new OTOContext();

                var conection = DBFactory.GetDB(pTOContext);
                var objeto    = conection.Read(pTOContext, sql.ToString(), MakeRsoci, oParameter);
                return(objeto);
            }
            catch (Exception ex)
            {
                BOException.Throw(this.GetType().ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                return(null);
            }
        }
Example #4
0
        public TOTransaction <TOSoRsoci> Post(TOSoRsoci toSoRsoci)
        {
            var socio = boSoSocio.GetSoRsoci(toSoRsoci);

            return(socio);
        }
Example #5
0
        public TOTransaction <TOSoRsoci> GetSoRsoci(TOSoRsoci toSoRsoci)
        {
            try
            {
                var retorno = daoSoSocio.GetSoRsoci(toSoRsoci);
                if (retorno == null)
                {
                    return new TOTransaction <TOSoRsoci>()
                           {
                               ObjTransaction = null, Retorno = 1, TxtError = "Datos incorrectos. Verifique por favor"
                           }
                }
                ;
                int r = 0;
                if (string.IsNullOrEmpty(toSoRsoci.Sbe_pass))
                {
                    Random generator = new Random();

                    r = generator.Next(0, 1000000);
                    toSoRsoci.Soc_cing = r;
                    toSoRsoci.Soc_cfec = DateTime.Now.AddHours(2);
                }
                else
                {
                    if (DateTime.Now > toSoRsoci.Soc_cfec)
                    {
                        throw new Exception("El código de seguridad ha expirado.");
                    }
                }
                //Si el socio ya esta registrado por el app
                //genera el mensaje que ya esta registrado
                //por el app
                toSoRsoci.Soc_cont = retorno.Soc_cont;
                toSoRsoci.Sbe_cont = retorno.Sbe_cont;
                var updsoci = daoSoSocio.UpdSoRsoci(toSoRsoci);
                if (updsoci != 0 && r != 0)
                {
                    //Ophelia.Email e = new Ophelia.Email();
                    //Ophelia.TOEmail te = new Ophelia.TOEmail();
                    //
                    //te.ema_asun = "Codigo de registro";
                    //te.ema_dest = toSoRsoci.Sbe_mail;
                    //te.ema_nomb = "luis";
                    //te.ema_remi = "*****@*****.**";
                    //te.ema_assl = true;
                    //
                    //te.ema_desc = "Su código de registro es: " + r.ToString();
                    //te.ema_iden = "*****@*****.**";
                    //
                    //e.EnviarEmail(te);

                    EnviarCorreo c = new EnviarCorreo();
                    c.SendMail(toSoRsoci.Soc_cing.ToString(), toSoRsoci.Sbe_mail);
                }
                //envia correo electronico
                return(new TOTransaction <TOSoRsoci>()
                {
                    ObjTransaction = toSoRsoci, TxtError = "", Retorno = 0
                });
            }
            catch (Exception ex)
            {
                return(new TOTransaction <TOSoRsoci>()
                {
                    ObjTransaction = null, TxtError = ex.Message, Retorno = 1
                });
            }
        }