コード例 #1
0
        private PedidoPesquisa populaPedidoPesquisa(MySqlDataReader dataReader)
        {
            PedidoPesquisa pedido = new PedidoPesquisa();

            pedido.Id        = int.Parse(dataReader["id"].ToString());
            pedido.Cliente   = dataReader["nome"].ToString();
            pedido.Pedido    = dataReader["tipo_pedido"].ToString();
            pedido.Situação  = dataReader["situacao_pedido"].ToString();
            pedido.Pagamento = dataReader["data_pagamento"].ToString().Substring(0, 10);
            pedido.Total     = double.Parse(dataReader["valor_total"].ToString());
            pedido.Entrega   = dataReader["data_entrega"].ToString().Substring(0, 10);

            return(pedido);
        }
コード例 #2
0
        public HttpResponseMessage GetPedidosByForn(HttpRequestMessage request, [FromBody] PedidoPesquisa ped)
        {
            ConfigAppMembers      cf  = Util.ConfigApp.getConfig();
            List <PedidoConsulta> ret = new List <PedidoConsulta>();
            string query = string.Empty;

            try
            {
                ret = Database.PedidosADO.RetornaPedidosForn(ped, cf.cdentifilial, cf.datasource, cf.schema, out query);
                Util.LogUtil.GravaLog(this, "GetPedidosByForn QUERY: " + query, cf.Cnpj, Log.TipoLog.erro);
            }
            catch (Exception e)
            {
                Util.LogUtil.GravaLog(this, "GetPedidosByForn: " + e.ToString(), cf.Cnpj, Log.TipoLog.erro);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "ERRO"));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, ret));
        }
コード例 #3
0
        public static List <PedidoConsulta> RetornaPedidosForn(PedidoPesquisa ped, string cdentifilial, string datasource, string schema, out string queryt)
        {
            List <PedidoConsulta> lstret = new List <PedidoConsulta>();

            StringBuilder query = new StringBuilder();

            query.AppendLine("select * from vw_consultacupom where 1=1 ");

            if (!string.IsNullOrEmpty(ped.datainicio) && !string.IsNullOrEmpty(ped.datafim))
            {
                query.AppendLine(string.Format("and to_date(dataped,'DD/MM/YYYY') between to_date('{0}','DD/MM/YYYY') and to_date('{1}','DD/MM/YYYY')", ped.datainicio, ped.datafim));
            }

            if (!string.IsNullOrEmpty(ped.cpfcnpj))
            {
                var pcpf = ped.cpfcnpj.Replace(".", "").Replace("/", "").Replace("-", "");
                query.AppendLine(string.Format("and cpfcnpj = '{0}'", pcpf));
            }

            if (!string.IsNullOrEmpty(ped.statuspedido))
            {
                query.AppendLine(string.Format("and cdstatpedido = {0}", ped.statuspedido));
            }

            if (!string.IsNullOrEmpty(ped.codigopedido))
            {
                query.AppendLine(string.Format("and cdpedido = {0}", ped.codigopedido));
            }
            if (ped.perfil == "PARCEIRO")
            {
                if (!string.IsNullOrEmpty(ped.cdforn))
                {
                    query.AppendLine(string.Format("and CDFORN = {0}", ped.cdforn));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(ped.cdpai))
                {
                    query.AppendLine(string.Format("and CDFORN = {0}", ped.cdpai));
                }
            }

            if (!string.IsNullOrEmpty(ped.nome))
            {
                query.AppendLine(string.Format("and nmentidade like upper('%{0}%')", ped.nome));
            }

            if (!string.IsNullOrEmpty(cdentifilial))
            {
                query.AppendLine(string.Format("and cdentifilial ={0}", cdentifilial));
            }
            queryt = query.ToString();

            PedidoConsulta pc;

            using (OracleConnection connection = new OracleConnection(Util.OracleHelper.StrConn(schema, datasource)))
            {
                OracleCommand command = new OracleCommand(query.ToString(), connection);
                connection.Open();
                using (OracleDataReader reader = command.ExecuteReader())
                {
                    Produto pr = null;
                    while (reader.Read())
                    {
                        pc = new PedidoConsulta();
                        pc.cdentifilial = reader["CDENTIFILIAL"].ToString();
                        pc.cdpedido     = reader["CDPEDIDO"].ToString();
                        pc.cdstatpedido = reader["CDSTATPEDIDO"].ToString();
                        //pc.cdstatuspedido = reader["cdstatuspedido"].ToString();
                        pc.cpfcnpj           = reader["CPFCNPJ"].ToString();
                        pc.dataped           = reader["DATAPED"].ToString();
                        pc.nmentidade        = reader["NMENTIDADE"].ToString();
                        pc.nmstatus          = reader["NMSTATUS"].ToString();
                        pc.quantidade        = reader["QUANTIDADE"].ToString();
                        pc.statusnfe         = reader["STATUSNFE"].ToString();
                        pc.valortotal        = Convert.ToDouble(reader["VALORTOTAL"].ToString());
                        pc.cdnotafiscalsaida = string.IsNullOrEmpty(reader["CDNOTAFISCALSAIDA"].ToString()) ? "0" : reader["CDNOTAFISCALSAIDA"].ToString();
                        pc.flalteravel       = reader["flalteravel"].ToString();
                        pc.comissao          = Convert.ToDouble(reader["comissao"].ToString());
                        pc.over          = Convert.ToDouble(reader["over"].ToString());
                        pc.totalcomissao = Convert.ToDouble(reader["totalcomissao"].ToString());
                        lstret.Add(pc);
                    }
                }
            }
            return(lstret);
        }