//===========================================================================================================================================
        private void dgvDadosCompra_CellClick(object sender, DataGridViewCellEventArgs e) //Aula 105
        {
            //verifica se uma linha foi clicada:
            if (e.RowIndex >= 0)
            {
                //CONEXÃO:
                DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);

                //-----------------------------------------------------------------------------------------------------------------------------------
                //CARREGA OS ITENS DA COMPRA:
                //-----------------------------------------------------------------------------------------------------------------------------------
                BLLItensCompra bllItens = new BLLItensCompra(cx);
                //localizar itens pelo codigo da compra:
                dgvItens.DataSource = bllItens.Localizar(Convert.ToInt32(dgvDadosCompra.Rows[e.RowIndex].Cells[0].Value));

                //-----------------------------------------------------------------------------------------------------------------------------------
                //PARCELAS DA COMPRA:
                //-----------------------------------------------------------------------------------------------------------------------------------
                BLLParcelasCompra bllParcelas = new BLLParcelasCompra(cx);
                //localizar parcelas pelo codigo da compra:
                dgvParcelas.DataSource = bllParcelas.Localizar(Convert.ToInt32(dgvDadosCompra.Rows[e.RowIndex].Cells[0].Value));

                //Formatar a grid:
                AtualizaCabecalhoDGGridItens();
                AtualizaCabecalhoDGGridParcelas();
            }
        }
 private void ItensCompra()
 {
     if (dgvCompras.RowCount > 0)
     {
         DALConexao     cx   = new DALConexao(DadosDaConexao.StringDeConexão);
         BLLItensCompra ibll = new BLLItensCompra(cx);
         dgvItens.DataSource = ibll.Localizar(Convert.ToInt32(dgvCompras.CurrentRow.Cells["CODIGO"].Value));
         FormatarValoresCores(2);
     }
 }
 private void dgvDados_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
         //itens da compra
         BLLItensCompra bllItens = new BLLItensCompra(cx);
         dgvItens.DataSource = bllItens.Localizar(Convert.ToInt32(dgvDados.Rows[e.RowIndex].Cells[0].Value));
         //parcelas da compra
         BLLParcelasCompra bllParcelas = new BLLParcelasCompra(cx);
         dgvParcelas.DataSource = bllParcelas.Localizar(Convert.ToInt32(dgvDados.Rows[e.RowIndex].Cells[0].Value));
         alteraCabecalhoItensParcelas();
     }
 }
Beispiel #4
0
        private void GridCompra2_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                //itens da compra
                DALConexao     conexao = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLItensCompra compra  = new BLLItensCompra(conexao);
                GridItens.DataSource = compra.Localizar(Convert.ToInt32(GridCompra2.Rows[e.RowIndex].Cells[0].Value));

                //parcela da compra
                BLLParcelasCompra parcela = new BLLParcelasCompra(conexao);
                GridParcela2.DataSource = parcela.Localizar(Convert.ToInt32(GridCompra2.Rows[e.RowIndex].Cells[0].Value));
            }
        }
Beispiel #5
0
        private void CarregaItensCompra()
        {
            DALConexao     cx       = new DALConexao(DadosDaConexao.StringDeConexão);
            BLLItensCompra bllItens = new BLLItensCompra(cx);
            DataTable      tabela   = bllItens.Localizar(codigo);

            for (int i = 0; i < tabela.Rows.Count; i++)
            {
                Double   totalLocal = Convert.ToDouble(tabela.Rows[i]["QUANTIDADE"]) * Convert.ToDouble(tabela.Rows[i]["VALOR_UNITARIO"]);
                string   icod       = tabela.Rows[i]["CODIGO_PRODUTO"].ToString();
                string   inome      = tabela.Rows[i]["NOME_PRODUTO"].ToString();
                string   iqtde      = tabela.Rows[i]["QUANTIDADE"].ToString();
                Double   ivalor     = Convert.ToDouble(tabela.Rows[i]["VALOR_UNITARIO"]);
                String[] it         = new String[] { icod, inome, iqtde, ivalor.ToString("#.00"), totalLocal.ToString("#.00") };
                dgvItensCompra.Rows.Add(it);
            }
        }
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            frmConsultaCompra f = new frmConsultaCompra();

            f.ShowDialog();
            if (f.codigo != 0)
            {
                DALConexao   cx     = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCompra    bll    = new BLLCompra(cx);
                ModeloCompra modelo = bll.CarregaModeloCompra(f.codigo);
                txtCodCom.Text     = modelo.ComCod.ToString();
                txtNFiscal.Text    = modelo.ComNFiscal.ToString();
                dtDataCompra.Value = modelo.ComData;
                txtForCod.Text     = modelo.ForCod.ToString();
                txtForCod_Leave(sender, e);               // para escrever o nome do fornecedor na tela
                txtTotal.Text          = modelo.ComTotal.ToString();
                this.totalCompra       = modelo.ComTotal; //armazena o valor total da compra
                cbTPagto.SelectedValue = modelo.TpaCod;
                cbNParcelas.Text       = modelo.ComNParcelas.ToString();

                //itens da compra
                BLLItensCompra bllitens = new BLLItensCompra(cx);
                DataTable      tabela   = bllitens.Localizar(modelo.ComCod);
                for (int i = 0; i < tabela.Rows.Count; i++)
                {
                    string   icod       = tabela.Rows[i]["pro_cod"].ToString();
                    string   inome      = tabela.Rows[i]["pro_nome"].ToString();
                    string   iqtd       = tabela.Rows[i]["itc_qtde"].ToString();
                    string   ivu        = tabela.Rows[i]["itc_valor"].ToString();
                    Double   TotalLocal = Convert.ToDouble(tabela.Rows[i]["itc_qtde"]) * Convert.ToDouble(tabela.Rows[i]["itc_valor"]);
                    String[] it         = new String[] { icod, inome, iqtd, ivu, TotalLocal.ToString() };
                    this.dgvItens.Rows.Add(it);
                }

                alteraBotoes(3);
            }
            else
            {
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            f.Dispose();
        }
        //=============================================================================================================
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            //exiber o formulario de consulta compra:
            frmConsultaCompra f = new frmConsultaCompra();

            f.ShowDialog();

            //verificar se tem um codigo carregado:{diferente de zero}
            if (f.codigo != 0)
            {
                DALConexao   cx     = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCompra    bll    = new BLLCompra(cx);
                ModeloCompra modelo = bll.CarregaModeloCompra(f.codigo);//carrega o modelo da comprea pelo codigo
                //--------------------------------------------------------------------------------------------------------
                //  CARREGAR OS DADOS DA COMPRA
                //--------------------------------------------------------------------------------------------------------
                txtComCod.Text     = modelo.ComCod.ToString();
                txtNFiscal.Text    = modelo.ComNfiscal.ToString();
                dtDataCompra.Value = modelo.ComData;
                txtForCod.Text     = modelo.ForCod.ToString();
                txtForCod_Leave(sender, e);//evento escrever o nome do fornecedor
                //rodapé:
                cbNParcela.Text     = modelo.ComNparcelas.ToString();
                txtTotalCompra.Text = modelo.ComValorTotal.ToString(); //VALOR TOTAL
                this.totalCompra    = modelo.ComValorTotal;            //armazena o total na variavel

                //fazer um LOCALIZAR - select para trazer o numero de parcela
                //fazer um LOCALIZAR - select para trazer a data da primeira parcela

                //TIPO DE PAGAMENTO.
                cbTPagto.SelectedValue = modelo.TpaCod;


                //carregar itens da compra: https://youtu.be/rMOyapoHTx0?list=PLfvOpw8k80Wqj1a66Qsjh8jj4hlkzKSjA&t=204
                BLLItensCompra bLLIt    = new BLLItensCompra(cx);
                DataTable      tabelaIt = bLLIt.Localizar(modelo.ComCod); //passa os itens da compra para uma tabela:
                for (int i = 0; i < tabelaIt.Rows.Count; i++)             //enquanto i for menos que o numero de linhas retornodo
                {
                    //pega os valores: cada loop vai para a prox. linha = i
                    string icod  = tabelaIt.Rows[i]["pro_cod"].ToString();
                    string inome = tabelaIt.Rows[i]["pro_nome"].ToString();
                    string iqtd  = tabelaIt.Rows[i]["itc_qtde"].ToString();
                    string ivund = tabelaIt.Rows[i]["itc_valor"].ToString();

                    //calcula o valor total de cada intem:
                    Double TotalLocalx = Convert.ToDouble(tabelaIt.Rows[i]["itc_qtde"]) * Convert.ToDouble(tabelaIt.Rows[i]["itc_valor"]);

                    //monta uma matriz da linha com os calores de cada coluna:
                    String[] iten = new String[] { icod, inome, iqtd, ivund, txtTotalCompra.Text, TotalLocalx.ToString() };
                    this.dgvItens.Rows.Add(iten);//adicoina os itens da linha no datagrdi...
                }

                alteraBotoes(3);
            }
            else
            {
                this.LimpaTela();
                this.alteraBotoes(1);
            }

            //destroi o obejto
            f.Dispose();
        }