Example #1
0
 public int buscarCliforUltimosFaturamentos(string tpMovimento)
 {
     if (!string.IsNullOrEmpty(cd_Clifor.Text))
     {
         string       tp_Movimento = tpMovimento;
         TList_Pedido lista        = TCN_ConsultaProdutos.buscaCliforUltimosFaturamentos(cd_Clifor.Text,
                                                                                         Convert.ToInt32(top.Value),
                                                                                         tp_Movimento);
         if (lista != null)
         {
             bsConsultaCliforUltimosFaturamentos.DataSource = lista;
             return(lista.Count);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(0);
     }
 }
Example #2
0
        private void g_Consulta_Pedido_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (g_Consulta_Pedido.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
            {
                return;
            }
            if (BS_Pedido.Count < 1)
            {
                return;
            }
            PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new TRegistro_Pedido());
            TList_Pedido lComparer;
            SortOrder    direcao = SortOrder.None;

            if ((g_Consulta_Pedido.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) ||
                (g_Consulta_Pedido.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Descending))
            {
                lComparer = new TList_Pedido(lP.Find(g_Consulta_Pedido.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Ascending);
                foreach (DataGridViewColumn c in g_Consulta_Pedido.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Ascending;
            }
            else
            {
                lComparer = new TList_Pedido(lP.Find(g_Consulta_Pedido.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Descending);
                foreach (DataGridViewColumn c in g_Consulta_Pedido.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Descending;
            }
            (BS_Pedido.List as TList_Pedido).Sort(lComparer);
            BS_Pedido.ResetBindings(false);
            g_Consulta_Pedido.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = direcao;
        }
Example #3
0
        private void Busca_Pedidos()
        {
            Int64 NR_Pedido_Busca = 0;

            if (NR_Pedido.Text != "")
            {
                NR_Pedido_Busca = Convert.ToInt64(NR_Pedido.Text);
            }


            TList_Pedido List_Pedido = TCN_Pedido.Busca(CD_Empresa_Busca.Text, rb_Entrada.Checked,
                                                        rb_Saida.Checked, NR_Pedido_Busca, CD_Clifor_Busca.Text, "", "", "", "", CFG_Pedido_Busca.Text, cck_Cancelado.Checked, cck_Fechado.Checked, cck_Encerrado.Checked, cck_Ativo.Checked, DT_Inicial.Text, DT_Final.Text, "", 0, "");

            if ((List_Pedido != null) && (List_Pedido.Count > 0))
            {
                BS_Pedido.DataSource = List_Pedido;
                Busca_Itens_Pedido();
                Prepara_Botoes(true, false, false, false, false, true, true, true);
            }
            else
            {
                BS_Itens_Pedido.Clear();
            }
        }
Example #4
0
        private void bbDownload_Click(object sender, EventArgs e)
        {
            if (cbLoja.SelectedItem == null)
            {
                MessageBox.Show("Obrigatório selecionar loja.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbLoja.Focus();
                return;
            }
            if (string.IsNullOrEmpty((cbLoja.SelectedItem as TRegistro_LojaVirtual).UserName))
            {
                MessageBox.Show("Não existe USERNAME cadastrado para loja.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (string.IsNullOrEmpty((cbLoja.SelectedItem as TRegistro_LojaVirtual).ApiKey))
            {
                MessageBox.Show("Não existe APIKEY cadastrado para loja.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            MagentoService api    = new MagentoService();
            string         sessao = string.Empty;

            try
            {
                sessao = api.login((cbLoja.SelectedItem as TRegistro_LojaVirtual).UserName, (cbLoja.SelectedItem as TRegistro_LojaVirtual).ApiKey);
                filters         mf  = new filters();
                complexFilter[] cpf = new complexFilter[0];
                if (cbStatus.SelectedIndex > 0)
                {
                    complexFilter mcpf = new complexFilter();
                    mcpf.key = "status";
                    associativeEntity mas = new associativeEntity();
                    mas.key    = "=";
                    mas.value  = cbStatus.SelectedValue.ToString();
                    mcpf.value = mas;
                    Array.Resize(ref cpf, cpf.Length + 1);
                    cpf[cpf.Length - 1] = mcpf;
                }
                if (!string.IsNullOrEmpty(dt_ini.Text.SoNumero()))
                {
                    complexFilter mcpf = new complexFilter();
                    mcpf.key = "created_at";
                    associativeEntity mas = new associativeEntity();
                    mas.key    = "from";
                    mas.value  = DateTime.Parse(dt_ini.Text).ToString("yyyy-MM-dd") + " 00:00:00";
                    mcpf.value = mas;
                    Array.Resize(ref cpf, cpf.Length + 1);
                    cpf[cpf.Length - 1] = mcpf;
                }
                mf.complex_filter = cpf;
                salesOrderListEntity[] lista = api.salesOrderList(sessao, mf);
                if (lista.Length > 0)
                {
                    TList_Pedido lPedido = new TList_Pedido();
                    lista.ToList().ForEach(p =>
                    {
                        object obj = new TCD_Pedido().BuscarEscalar(
                            new TpBusca[]
                        {
                            new TpBusca()
                            {
                                vNM_Campo = "a.Nr_PedidoOrigem",
                                vOperador = "=",
                                vVL_Busca = "'" + p.increment_id.Trim() + "'"
                            }
                        }, "a.nr_pedido");
                        lPedido.Add(new TRegistro_Pedido()
                        {
                            Nr_PedidoOrigem = p.increment_id,
                            Vl_totalpedido  = decimal.Divide(int.Parse(p.grand_total.SoNumero()), 10000),
                            StatusMagento   = p.status,
                            NM_Clifor       = p.firstname.Trim() + " " + p.lastname.Trim(),
                            Nr_pedido       = obj == null ? 0 : decimal.Parse(obj.ToString()),
                            DT_Pedido       = DateTime.Parse(p.created_at)
                        });
                    });
                    bsPedLoja.DataSource = lPedido;
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            finally
            {
                if (!string.IsNullOrWhiteSpace(sessao))
                {
                    api.endSession(sessao);
                }
            }
        }