protected void btnPesquisa_Click(object sender, EventArgs e) { ModNotaFiscal modNotaFiscal = new ModNotaFiscal(); NotaFicalNEG negNota = new NotaFicalNEG(); modNotaFiscal = negNota.PesquisaNota(Convert.ToInt32(txtPesquias.Text)); txtId.Text = modNotaFiscal.Id.ToString(); txtNumeroDaNota.Text = modNotaFiscal.Numero; ddlProduto.Text = modNotaFiscal.IdProduto.ToString(); txtValor.Text = modNotaFiscal.Valor.ToString(); ddlRazaoSocial.SelectedValue = modNotaFiscal.RazaoSocial.ToString(); if (modNotaFiscal.Numero == txtNumeroDaNota.Text) { MessageBox.Show("Pesquisa realizada com sucesso!"); } else { MessageBox.Show("CNPJ não cadastrado!"); } //txtId.Text = Convert.ToInt32(modNotaFiscal.Id).ToString(); //txtNumeroDaNota.Text = modNotaFiscal.Numero; //ddlProduto.Text = Convert.ToInt32(modNotaFiscal.IdProduto).ToString(); //txtValor.Text = modNotaFiscal.Valor.ToString(); //ddlRazaoSocial.DataValueField = "Id"; //ddlRazaoSocial.DataTextField = "Nome"; //ddlRazaoSocial.DataBind(); }
protected void btnSalvar_Click(object sender, EventArgs e) { ModNotaFiscal modNotaFiscal = new ModNotaFiscal(); NotaFicalNEG negNota = new NotaFicalNEG(); modNotaFiscal.Numero = txtNumeroDaNota.Text; modNotaFiscal.IdProduto = Convert.ToInt32(ddlProduto.SelectedValue); modNotaFiscal.Valor = Convert.ToDouble(Regex.Replace(txtValor.Text, "[^0-9,]+", "")); modNotaFiscal.RazaoSocial = Convert.ToInt32(ddlRazaoSocial.Text); if (!ValidarNota(modNotaFiscal)) { return; } try { negNota.AdicionarNota(modNotaFiscal); MessageBox.Show("Dados inserido com sucesso!"); //grupoBoxNotaFical(); limparCampos(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AdicionarNota(ModNotaFiscal modNotaFiscal) { if (!ValidaNota(Convert.ToInt32(modNotaFiscal.Numero))) { throw new Exception("Nota já cadastrado"); } notaF.Adicionar(modNotaFiscal); }
protected void btnExclui_Click(object sender, EventArgs e) { ModNotaFiscal modNotaFiscal = new ModNotaFiscal(); NotaFicalNEG negNota = new NotaFicalNEG(); modNotaFiscal.Id = Convert.ToInt32(txtId.Text); negNota.ExcluirNota(modNotaFiscal); MessageBox.Show("Excluido com sucesso!"); grupoBoxFornecedor(); grupoBoxProduto(); }
private void BtnPesquisar_Click(object sender, EventArgs e) { ModNotaFiscal modNotaFiscal = new ModNotaFiscal(); NotaFicalNEG negNota = new NotaFicalNEG(); negNota.PesquisaNota(Convert.ToInt32(modNotaFiscal)); txtId.Text = Convert.ToInt32(modNotaFiscal.Id).ToString(); txtNumeroDaNota.Text = modNotaFiscal.Numero; cboProduto.Text = Convert.ToInt32(modNotaFiscal.IdProduto).ToString(); txtValor.Text = modNotaFiscal.Valor.ToString(); cboRazaoSocial.Text = Convert.ToInt32(modNotaFiscal.RazaoSocial).ToString(); }
private void btnEditar_Click(object sender, EventArgs e) { ModNotaFiscal modNotaFiscal = new ModNotaFiscal(); NotaFicalNEG negNota = new NotaFicalNEG(); modNotaFiscal.Numero = txtNumeroDaNota.Text; modNotaFiscal.IdProduto = Convert.ToInt32(cboProduto.SelectedValue); modNotaFiscal.Valor = Convert.ToDouble(Regex.Replace(txtValor.Text, "[^0-9,]+", "")); modNotaFiscal.RazaoSocial = Convert.ToInt32(cboRazaoSocial.Text); if (!ValidarNota(modNotaFiscal)) { return; } negNota.EditarNota(modNotaFiscal); MessageBox.Show("Formulario atualizado com sucesso!"); limparCampos(); }
public List <ModItemNotaFiscal> SelecionarTodos() { List <ModItemNotaFiscal> lst = new List <ModItemNotaFiscal>(); ComandoSQL = @"SELECT TAB_PRODUTO.PRO_NOME,TAB_NOTA_FISCAL.NUMERO,TAB_ITEM_NOTA_FISCAL.* FROM TAB_ITEM_NOTA_FISCAL INNER JOIN TAB_PRODUTO ON TAB_ITEM_NOTA_FISCAL.ID_PRODUTO = TAB_PRODUTO.ID INNER JOIN TAB_NOTA_FISCAL ON TAB_ITEM_NOTA_FISCAL.ID_NOTA_FISCAL = TAB_NOTA_FISCAL.ID"; //Conexão com o banco AcessoABase acesso = new AcessoABase(connectionString); using (SqlDataReader dr = acesso.ComandoSelecao(ComandoSQL, new List <SqlParameter>())) { while (dr.Read()) { ModNotaFiscal nota = new ModNotaFiscal(); nota.Id = Convert.ToInt32(dr["ID_NOTA_FISCAL"]); nota.Numero = dr["NUMERO"].ToString(); ModProduto produto = new ModProduto(); produto.Id = Convert.ToInt32(dr["ID_PRODUTO"]); produto.Pro_Nome = dr["PRO_NOME"].ToString(); lst.Add(new ModItemNotaFiscal { Produto = produto, NotaFiscal = nota, Id = Convert.ToInt32(dr["ID"]), IdNotaFiscal = Convert.ToInt32(dr["ID_NOTA_FISCAL"]), IdProduto = Convert.ToInt32(dr["ID_PRODUTO"]), Quantidade = Convert.ToInt32(dr["QTDE"]), Valor = Convert.ToDouble(dr["VALOR"]) }); } return(lst); } }
public void ExcluirNota(ModNotaFiscal modNotaFiscal) { modNotaFiscal.Id = Convert.ToInt32(modNotaFiscal.Id); notaF.Deletar(modNotaFiscal.Id); }
public void EditarNota(ModNotaFiscal modNotaFiscal) { modNotaFiscal.Id = Convert.ToInt32(modNotaFiscal.Id); notaF.Atualizar(modNotaFiscal); }