private void txtVenCod_Leave(object sender, EventArgs e) { try { if (txtVenCod.Text != null) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLVenda bll = new BLLVenda(cx); ModeloVenda modelo = bll.CarregaModeloVenda(Convert.ToInt32(txtVenCod.Text)); btnLocaliza.Visible = false; txtVenCod.Text = modelo.VenCod.ToString(); txtNomeCli.Text = modelo.VenNome.ToString(); txtNomeAtend.Text = modelo.VenAtend.ToString(); txtVlrPed.Text = modelo.VenTotal.ToString(); txtStatus.Text = modelo.VenStatus.ToString(); txtWint.Text = modelo.VenWinthor.ToString(); txtCart.Text = modelo.VenCartao.ToString(); txtVenCod.ReadOnly = true; BLLItensVenda bllitens = new BLLItensVenda(cx); dgvProdutos.DataSource = bllitens.Localizar(Convert.ToInt32(txtVenCod.Text)); this.AtualizaDGVProdutosVenda(); txtVlrPed.Focus(); //txtWint_Leave(sender, e); } } catch { } }
private void btLocalizar_Click(object sender, EventArgs e) { frmConsultaVenda f = new frmConsultaVenda(); f.ShowDialog(); if (f.codigo != 0) { DaoConexao cx = new DaoConexao(DadosDeConexao.StringDeConexao); BLLVenda bll = new BLLVenda(cx); ModeloVenda modelo = bll.CarregaModeloVenda(f.codigo); txtVenCodigo.Text = modelo.VenCod.ToString(); txtNFiscal.Text = modelo.VenNFiscal.ToString(); dtDataVenda.Value = modelo.VenData; txtCliCod.Text = modelo.CliCod.ToString(); txtCliCod_Leave(sender, e); //para escrever o nome do cliente na tela cbTpagto.SelectedValue = modelo.TpaCod; cbNParcelas.Text = modelo.VenNParcelas.ToString(); if (modelo.VenAvista == 1) { cbVendaAVista.Checked = true; } else { cbVendaAVista.Checked = false; } txtTotalVenda.Text = modelo.VenTotal.ToString(); this.totalVenda = modelo.VenTotal; //armazenar o valor total da venda //itens da venda BLLItensVenda bllItens = new BLLItensVenda(cx); DataTable tabela = bllItens.Localizar(modelo.VenCod); 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]["itv_qtde"].ToString(); string ivu = tabela.Rows[i]["itv_valor"].ToString(); Double TotalLocal = Convert.ToDouble(tabela.Rows[i]["itv_qtde"]) * Convert.ToDouble(tabela.Rows[i]["itv_valor"]); String[] it = new String[] { icod, inome, iqtd, ivu, TotalLocal.ToString() }; this.dgvItens.Rows.Add(it); } this.alteraBotoes(3); lbMsg.Visible = false; if (modelo.VenStatus != "ativa") { //lbMsg.Text = "Venda Cancelada"; lbMsg.Visible = true; btExcluir.Enabled = false; } } else { this.LimpaTela(); this.alteraBotoes(1); } f.Dispose(); }
private void dgvDados_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); //itens da compra BLLItensVenda bllItens = new BLLItensVenda(cx); dgvItens.DataSource = bllItens.Localizar(Convert.ToInt32(dgvDados.Rows[e.RowIndex].Cells[0].Value)); //parcelas da compra BLLParcelasVenda bllParcelas = new BLLParcelasVenda(cx); dgvParcelas.DataSource = bllParcelas.Localizar(Convert.ToInt32(dgvDados.Rows[e.RowIndex].Cells[0].Value)); alteraCabecalhoItensParcelas(); } }