Exemplo n.º 1
0
        private void btnConfirmar_Click(object sender, EventArgs ea)
        {
            //Get the value of the txt boxes and storage in variables with the get and set atributes.
            filtro = new FiltroRelatorio();



            String msgErro = "";

            //Date validation, and error as send to the user, if the date is incorret or invalid.
            try
            {
                if (maskedTextBox1.MaskCompleted)
                {
                    filtro.DateManifesto = DateTime.ParseExact(maskedTextBox1.Text, "dd/MM/yyyy", CultureInfo.CreateSpecificCulture("pt-BR"));
                }
            }catch (Exception e)
            {
                msgErro = "Data Inválida ";
            }

            if (filtro.DateManifesto == DateTime.MinValue)
            {
                msgErro = "Data Inválida";
            }

            if (!String.IsNullOrEmpty(msgErro))
            {
                MessageBox.Show(msgErro, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                filtro = null;
                return;
            }



            if (cbVend.SelectedItem == null)
            {
                MessageBox.Show("Vendedor não encontrado", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var sel = (cbVend.SelectedItem as ItemData <Int64>);

            if (sel.Codigo == -1)
            {
                filtro.VendedorCode = null;
            }
            else
            {
                filtro.VendedorCode = sel.Codigo.ToString();
            }



            //SyncInterativo.Sincronizar();

            this.Close();
        }
Exemplo n.º 2
0
        List <Det> getItens(FiltroRelatorio filtr)
        {
            if (filtr != null)
            {
                var conn = new NpgsqlConnection(ConfigurationManager.AppSettings["ConexaoFch"]);


                String sql = $"select * from fechamento " +
                             $" inner join fechamentodet1220 on fech_transacao = fchd_transacao" +
                             $" left join produtos on prod_codigo = fchd_prod_codigo " +
                             $" where fech_data_fechamento = '{filtr.DateManifesto}' and fech_status = 'N' ";
                if (!String.IsNullOrEmpty(filtr.VendedorCode))
                {
                    sql += $" and fech_vend_codigo = '{filtr.VendedorCode}' ";
                }

                conn.Open();
                var cmd = new NpgsqlCommand(sql, conn);
                var dr  = cmd.ExecuteReader();


                List <Det> itens = new List <Det>();

                //Set the data grid view infos, and convert his values, if needed.
                while (dr.Read())
                {
                    var item = new Det();
                    item.fchTransacao  = dr.GetSafeValue <String>("fchd_transacao");
                    item.prodCodigo    = dr.GetSafeValue <Int64>("fchd_prod_codigo");
                    item.prodCodigoRB  = dr.GetSafeValue <Int64>("prod_codigo_rb");
                    item.fsProdNome    = dr.GetSafeValue <String>("prod_descricao");
                    item.qtdeCarga     = dr.GetSafeValue <Int64>("fchd_qtde_carga");
                    item.prQtdeVenda   = dr.GetSafeValue <Int64>("fchd_pr_qtde_venda");
                    item.prQtdeTroca   = dr.GetSafeValue <Int64>("fchd_pr_qtde_troca");
                    item.prQtdeRetorno = dr.GetSafeValue <Int64>("fchd_pr_qtde_retorno");
                    item.fsQtdeVenda   = dr.GetSafeValue <Int64>("fchd_fr_qtde_venda");
                    item.fsQtdeTroca   = dr.GetSafeValue <Int64>("fchd_fr_qtde_troca");
                    item.fsQtdeRetorno = dr.GetSafeValue <Int64>("fchd_fr_qtde_retorno");
                    item.prValorProd   = dr.GetSafeValue <Decimal>("fchd_pr_valorprod");
                    item.prValorTotal  = dr.GetSafeValue <Decimal>("fchd_pr_valortotal");
                    item.prComissao    = dr.GetSafeValue <Decimal>("fchd_pr_valorcomissao");



                    itens.Add(item);
                }
                conn.Close();
                return(itens);
            }
            else
            {
                List <Det> vazio = new List <Det>();
                return(vazio);
            }
        }
Exemplo n.º 3
0
        //Get the requests where the doct code = 7505.
        public static List <String> getRequests(FiltroRelatorio filtro)
        {
            AbrirConexao();



            List <String> where = new List <String>();


            if (filtro.DateManifesto != null)
            {
                //"yyyy-MM-dd" is the format of the date.
                where.Add($"  pvec_database = '{filtro.DateManifesto.ToString("yyyy-MM-dd")}' ");
            }


            where.Add(" mdoc_status = 'N' ");
            where.Add(" mdoc_dcto_codigo = '7505' ");
            var vendedor = BancoFechamento.getVendedores();

            var sqlVendedor = vendedor.Select(t => t.Key).ToList().JoinArraySQL();

            where.Add($" pvec_vend_codigo in ({sqlVendedor})");

            //Get the tables in postgresql.

            //Get the requests.
            String sql = $" select mdoc_transacao, pvec_vend_codigo, pvec_database from movdctos " +
                         " inner join pedvendac on mdoc_transacao = pvec_transacao ";



            if (where.Count > 0)
            {
                sql += " where ";
            }


            for (int i = 0; i < where.Count; i++)
            {
                sql += " " + where[i];
                if (i != where.Count - 1)
                {
                    sql += " and ";
                }
            }

            //Get the requests and find the manifest.

            var cmd = new NpgsqlCommand(sql, mConexao);
            var dr  = cmd.ExecuteReader();

            List <String> infos = new List <String>();

            //String requestTransation;

            while (dr.Read())
            {
                infos.Add(dr.GetSafeValue <String>("mdoc_transacao"));
            }


            dr.Close();

            return(infos);
        }