private void AttQtde(int qtde, int cod) { ClassProduto cp = new ClassProduto(); cp.VProdFill(cod); int e = cp.QtdeProd; cp.VProdUpdate(e - qtde, cod); }
private void dgvProduto_CellContentClick(object sender, DataGridViewCellEventArgs e) { ClassProduto cp = new ClassProduto(); bool a = cp.VProdFill((int)dgvProduto.SelectedRows[0].Cells[0].Value); if (a) { int Estq, Qtde; bool tem = lstCarrinho.Any(c => c.Produto == (int)dgvProduto.SelectedRows[0].Cells[0].Value); if (tem) { int linha = -1; foreach (DataGridViewRow row in dgvItens.Rows) { if (row.Cells[0].Value.ToString().Equals(dgvProduto.SelectedRows[0].Cells[0].Value.ToString())) { linha = row.Index; break; } } Estq = cp.QtdeProd - Convert.ToInt32(dgvItens.Rows[linha].Cells[2].Value); if (Estq == 0) { Qtde = 0; } else { Qtde = 1; } } else { Estq = cp.QtdeProd; Qtde = 1; } txtProduto.Text = cp.NomeProd; txtEstoque.Text = Estq.ToString(); txtValor.Text = cp.PrecoProd.ToString("n2"); txtQtde.Text = Qtde.ToString(); txtQtde.Select(); txtQtde_TextChanged(this, new EventArgs()); CodLastProd = cp.CodProd; QtdeN = 0; } }