Ejemplo n.º 1
0
        public Reply Buscar_Venta([FromBody] BuscarDoc model)
        {
            Reply or = new Reply();

            or.result = 0;
            Dat_Keos dat_doc = null;

            try
            {
                if (!Verify(model.token))
                {
                    or.messaje = "No autorizado";
                    return(or);
                }
                if (model.num_doc == null)
                {
                    or.messaje = "Ingrese el numero de boleta a buscar";
                    return(or);
                }
                if (model.num_doc.Trim().Length == 0)
                {
                    or.messaje = "Ingrese el numero de boleta a buscar";
                    return(or);
                }

                if (model.num_doc.Trim().Length != 12)
                {
                    or.messaje = "El numero de boleta debe tener 12 de longitud";
                    return(or);
                }

                dat_doc = new Dat_Keos();

                Int32 resultado = 0;
                or.data   = dat_doc.buscar_venta(model.token, model.num_doc, ref resultado);
                or.result = (resultado == 1)? 1:0;// resultado;

                or.data = (resultado == 0 ? null : or.data);

                or.messaje = (resultado == 1) ? "Documento encontrado" : "El Nro de boleta no existe, por favor verificar";
            }
            catch (Exception exc)
            {
                or.messaje = "¡Ocurrio un error en el servidor!";
            }

            return(or);
        }
Ejemplo n.º 2
0
        public BuscarDoc buscar_venta(string token, string numdoc, ref Int32 resultado)
        {
            string    sqlquery = "[USP_BATACLUB_KEOS_CAMBIO]";
            BuscarDoc obj      = null;

            try
            {
                obj         = new BuscarDoc();
                obj.token   = token;
                obj.num_doc = numdoc;
                using (SqlConnection cn = new SqlConnection(Ent_Conexion.conexion))
                {
                    try
                    {
                        if (cn.State == 0)
                        {
                            cn.Open();
                        }
                        using (SqlCommand cmd = new SqlCommand(sqlquery, cn))
                        {
                            cmd.CommandTimeout = 0;
                            cmd.CommandType    = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@NUMDOC", numdoc);

                            cmd.Parameters.Add("@TIPO", SqlDbType.VarChar, 30);
                            cmd.Parameters["@TIPO"].Direction = ParameterDirection.Output;

                            cmd.Parameters.Add("@ESTADO", SqlDbType.Int);
                            cmd.Parameters["@ESTADO"].Direction = ParameterDirection.Output;

                            cmd.ExecuteNonQuery();


                            //string tipo =Convert.ToString(cmd.Parameters["@TIPO"].Value);
                            resultado = Convert.ToInt32(cmd.Parameters["@ESTADO"].Value);
                            List <ListaTiendas> tda = new List <ListaTiendas>();
                            if (resultado == 1 || resultado == 2)
                            {
                                obj.tipo = Convert.ToString(cmd.Parameters["@TIPO"].Value);
                                /*si es online extraer tiendas*/
                                if (resultado == 2)
                                {
                                    SqlDataReader dr = cmd.ExecuteReader();
                                    if (dr.HasRows)
                                    {
                                        while (dr.Read())
                                        {
                                            ListaTiendas t = new ListaTiendas();
                                            t.tienda = dr["Tiendas"].ToString();
                                            tda.Add(t);
                                        }
                                    }

                                    resultado = 1;
                                }
                            }
                            obj.listar_tienda = tda;
                        }
                    }
                    catch
                    {
                    }
                    if (cn.State == ConnectionState.Open)
                    {
                        cn.Close();
                    }
                }
            }
            catch (Exception exc)
            {
            }
            return(obj);
        }