Example #1
0
        private void BB_AlterarPosVenda_Click(object sender, EventArgs e)
        {
            if (bsPosVendaProposta.Current == null || bsProposta.Current == null)
            {
                return;
            }
            else if (!(bsPosVendaProposta.Current as TRegistro_PosVenda).St_registro.Equals("A"))
            {
                MessageBox.Show("Apenas é possível alterar pós-venda com Sts. ABERTO.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            using (FPosVenda fPosVenda = new FPosVenda())
            {
                fPosVenda._PosVenda = (bsPosVendaProposta.Current as TRegistro_PosVenda);

                if (fPosVenda.ShowDialog() == DialogResult.OK)
                {
                    if (fPosVenda._PosVenda != null)
                    {
                        fPosVenda._PosVenda.lPosVendaProposta = (bsPosVendaProposta.Current as TRegistro_PosVenda).lPosVendaProposta;

                        TCN_PosVenda.Gravar(fPosVenda._PosVenda, null);
                        MessageBox.Show("Pós-venda gravada com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        afterBuscarPos();
                    }
                }
            }
        }
Example #2
0
        private void BB_NovaPostaVenda_Click(object sender, EventArgs e)
        {
            if (bsOrcamento.Current == null)
            {
                return;
            }

            //Validar existencia de proposta selecionada
            if (!(bsOrcamento.DataSource as IEnumerable <TRegistro_Orcamento>).ToList().Exists(r => r.Selecionado))
            {
                MessageBox.Show("Nenhuma proposta selecionada.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //Validar existencia de posvenda aberta para proposta selecionada
            bool parar = false;

            TpBusca[] tpBuscas = null;
            (bsOrcamento.DataSource as IEnumerable <TRegistro_Orcamento>).ToList().FindAll(p => p.Selecionado).ForEach(r =>
            {
                tpBuscas = new TpBusca[0];
                Estruturas.CriarParametro(ref tpBuscas, "a.nr_orcamento", r.Nr_orcamentostr);
                Estruturas.CriarParametro(ref tpBuscas, "isnull(a.st_registro, 'A')", "'C'", "<>");
                if (new TCD_PosVenda_X_Proposta().BuscarEscalar(tpBuscas, "1") != null)
                {
                    parar = true;
                }
            });

            if (parar)
            {
                MessageBox.Show("Orçamento já possui pós-venda.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            using (FPosVenda fPosVenda = new FPosVenda())
            {
                fPosVenda.lOrcamento = (bsOrcamento.DataSource as IEnumerable <TRegistro_Orcamento>).ToList().FindAll(p => p.Selecionado);
                if (fPosVenda.ShowDialog() == DialogResult.OK)
                {
                    if (fPosVenda._PosVenda != null)
                    {
                        fPosVenda._PosVenda.lOrcamento = (bsOrcamento.DataSource as IEnumerable <TRegistro_Orcamento>).ToList().FindAll(p => p.Selecionado);
                        TCN_PosVenda.Gravar(fPosVenda._PosVenda, null);
                        MessageBox.Show("Pós-venda gravada com sucesso.", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        afterBuscarOrc();
                    }
                }
            }
        }