Ejemplo n.º 1
0
 private void bb_desdobrar_Click(object sender, EventArgs e)
 {
     if (lVenda.Count > 0)
     {
         decimal vol = Math.Round(lVenda.Sum(p => p.Volumeabastecido) / qtd_desdobro.Value, 3);
         CamadaDados.PostoCombustivel.TList_VendaCombustivel lDesd = new CamadaDados.PostoCombustivel.TList_VendaCombustivel();
         for (int i = 0; i < qtd_desdobro.Value; i++)
         {
             lDesd.Add(new CamadaDados.PostoCombustivel.TRegistro_VendaCombustivel()
             {
                 Cd_empresa         = lVenda[0].Cd_empresa,
                 Cd_local           = lVenda[0].Cd_local,
                 Cd_produto         = lVenda[0].Cd_produto,
                 Cd_unidade         = lVenda[0].Cd_unidade,
                 Dt_abastecimento   = CamadaDados.UtilData.Data_Servidor(),
                 Enderecofisicobico = lVenda[0].Enderecofisicobico,
                 Id_bico            = lVenda[0].Id_bico,
                 Id_bomba           = lVenda[0].Id_bomba,
                 Id_tanque          = lVenda[0].Id_tanque,
                 Volumeabastecido   = vol,
                 Vl_unitario        = lVenda[0].Vl_unitario,
                 Vl_subtotal        = vol * lVenda[0].Vl_unitario,
                 Tp_registro        = "M",
                 St_registro        = "A"
             });
         }
         bsDesdobro.DataSource = lDesd;
         (bsDesdobro[bsDesdobro.Count - 1] as CamadaDados.PostoCombustivel.TRegistro_VendaCombustivel).Volumeabastecido +=
             lVenda.Sum(p => p.Volumeabastecido) - (bsDesdobro.DataSource as CamadaDados.PostoCombustivel.TList_VendaCombustivel).Sum(p => p.Volumeabastecido);
     }
 }
Ejemplo n.º 2
0
        private void afterBusca()
        {
            string st_registro = string.Empty;
            string virg        = string.Empty;

            if (cbAtivo.Checked)
            {
                st_registro = "'A'";
                virg        = ",";
            }
            if (cbFaturado.Checked)
            {
                st_registro += virg + "'F'";
                virg         = ",";
            }
            if (cbEspera.Checked)
            {
                st_registro += virg + "'E'";
                virg         = ",";
            }
            if (cbInconsistente.Checked)
            {
                st_registro += virg + "'I'";
            }

            CamadaDados.PostoCombustivel.TList_VendaCombustivel lVenda =
                CamadaNegocio.PostoCombustivel.TCN_VendaCombustivel.Buscar(CD_abastecida.Text,
                                                                           CD_Empresa.Text,
                                                                           cd_produto.Text,
                                                                           id_bico.Text,
                                                                           cd_clifor.Text,
                                                                           string.Empty,
                                                                           dt_inicial.Text,
                                                                           dt_final.Text,
                                                                           st_registro,
                                                                           cbAfericao.Checked ? "S" : "N",
                                                                           cbConvenio.Checked,
                                                                           string.Empty,
                                                                           placa.Text,
                                                                           "a.dt_abastecimento desc",
                                                                           null);
            bsVendaCombustivel.DataSource = lVenda;
            //Agrupar abastecimentos por produto
            bsResumo.DataSource = lVenda.GroupBy(p => p.Ds_produto,
                                                 (aux, venda) =>
                                                 new
            {
                ds_produto       = aux,
                volumeabastecido = venda.Sum(x => x.Volumeabastecido),
                vl_subtotal      = venda.Sum(x => x.Vl_subtotal)
            });
            //Totalizar Volume e Valor
            tot_volume.Value = lVenda.Sum(p => p.Volumeabastecido);
            tot_valor.Value  = lVenda.Sum(p => p.Vl_subtotal);
        }
Ejemplo n.º 3
0
        private void gVenda_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (gVenda.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
            {
                return;
            }
            if (bsVendaCombustivel.Count < 1)
            {
                return;
            }
            PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new CamadaDados.PostoCombustivel.TRegistro_VendaCombustivel());

            CamadaDados.PostoCombustivel.TList_VendaCombustivel lComparer;
            SortOrder direcao = SortOrder.None;

            if ((gVenda.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) ||
                (gVenda.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Descending))
            {
                lComparer = new CamadaDados.PostoCombustivel.TList_VendaCombustivel(lP.Find(gVenda.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Ascending);
                foreach (DataGridViewColumn c in gVenda.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Ascending;
            }
            else
            {
                lComparer = new CamadaDados.PostoCombustivel.TList_VendaCombustivel(lP.Find(gVenda.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Descending);
                foreach (DataGridViewColumn c in gVenda.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Descending;
            }
            (bsVendaCombustivel.List as CamadaDados.PostoCombustivel.TList_VendaCombustivel).Sort(lComparer);
            bsVendaCombustivel.ResetBindings(false);
            gVenda.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = direcao;
        }