예제 #1
0
파일: VendaBD.cs 프로젝트: 4nub1s/infoGym
 public void estoqueRestaurar(Venda ven)
 {
     ven.setItensVenda(getItensVendaById(ven.Cod));
     foreach (ItensVenda p in ven.getItens())
     {
         sql = "UPDATE produto SET prod_estatual = prod_estatual + @1 WHERE prod_id = @2";
         sql = sql.Replace("@1", p.Qtde);
         sql = sql.Replace("@2", p.ProdId);
         bco.executeNonQuery(sql);
     }
 }
예제 #2
0
 public frmVendaNova(Usuario user, String venCod)
 {
     InitializeComponent();
     Caixa cai = new Caixa();
     cai.CaiData = DateTime.Today.ToShortDateString();
     cai = cai.getCaixaByData();
     if (cai.CaiAbert == "")
     {
         MessageBox.Show("Caixa não foi aberto!", "Venda não permitida!", MessageBoxButtons.OK,
             MessageBoxIcon.Exclamation);
         this.Close();
     }
     inicializaItensVenda();
     this.user = user;
     lblUserOn.Text = user.Login;
     if (venCod != "")
     {
         ven = new Venda();
         ven.Cod = venCod;
         ven = ven.getById();
         btnConfirmar.Visible = false;
         gpbProduto.Visible = false;
         Usuario userAux = new Usuario();
         userAux.Id = Convert.ToInt32(ven.AcessId);
         userAux = userAux.getUserById();
         lblQuemRealizou.Text = userAux.Login;
         lblDataVenda.Text = Convert.ToDateTime(ven.Data).ToShortDateString();
         btnAluAdd.Visible = false;
         btnClear.Visible = false;
         btnConfirmar.Visible = false;
         btnRemoveItem.Visible = false;
         cbbFormaPgmto.Enabled = false;
         foreach (ItensVenda p in ven.getItens())
         {
             DataRow linha = dttItensVenda.NewRow();
             linha["prod_id"] = p.ProdId;
             Produto prod = new Produto();
             prod.Id = p.ProdId;
             prod = prod.getById();
             linha["nome"] = prod.Desc;
             linha["qtde"] = p.Qtde;
             linha["valor"] = p.Valor;
             linha["preco_unit"] = Convert.ToDecimal(p.Valor) / Convert.ToInt32(p.Qtde);
             qtdeTotal += Convert.ToInt32(p.Qtde);
             dttItensVenda.Rows.Add(linha);
         }
         if (ven.AluId != "")
         {
             Aluno aluAux = new Aluno();
             aluAux.Id = Convert.ToInt32(ven.AluId);
             aluAux = aluAux.getAlunoById();
             ttbAluNome.Text = aluAux.Nome;
         }
         else
             ttbAluNome.Text = "---";
         lblQtdeItens.Text = "" + qtdeTotal;
         lblValorTotal.Text = ven.Valor;
         cbbFormaPgmto.Text = ven.FormaPgmto;
     }
     else
     {
         ttbQtde.Enabled = false;
         lblDataVenda.Text = DateTime.Today.ToShortDateString();
         lblQuemRealizou.Text = user.Login;
         valor = 0;
         qtde = 1;
         valorTotal = 0;
         qtdeTotal = 0;
         lblValorTotal.Text = "R$" + valorTotal;
         lblQtdeItens.Text = "" + qtdeTotal;
         lblSubTotal.Text = "R$" + qtde * valor;
         btnClear.Enabled = false;
         btnRemoveItem.Enabled = false;
         cbbFormaPgmto.Text = "À vista";
         cbbFormaPgmto.Enabled = false;
     }
 }
예제 #3
0
파일: VendaBD.cs 프로젝트: 4nub1s/infoGym
 private bool gravaItens(Venda ven)
 {
     List<ItensVenda> itens = ven.getItens();
     foreach (ItensVenda p in itens)
     {
         sql = "INSERT INTO venda_produto(ven_cod, prod_id, item_valor, item_qtde)" +
           " VALUES ('@1', '@2', '@3', '@4')";
         sql = sql.Replace("@1", ven.Cod);
         sql = sql.Replace("@2", p.ProdId);
         sql = sql.Replace("@3", p.Valor);
         sql = sql.Replace("@4", p.Qtde);
         result = bco.executeNonQuery(sql);
         //baixa estoque
         sql = "UPDATE produto SET prod_estatual = prod_estatual - '@1' WHERE prod_id = @2";
         sql = sql.Replace("@1", p.Qtde);
         sql = sql.Replace("@2", p.ProdId);
         result = bco.executeNonQuery(sql);
     }
     return result;
 }