Jump to content

[Resolvido] soma de valores de um datagridview


crax15
 Share

Recommended Posts

Boa tarde

Eu gostava de saber como eu posso fazer a soma de uns determinados valores que estao numa celula do datagridview

o programa esta a ir buscar uns determinados valores a uma base de dados cuja tem uma descriçao do produto e um valor, mas existem varias descriçoes iguais e eu queria que o programa para essas descriçoes me fizesse a soma e juntasse tudo numa so descriçao

Por exemplo:

Descriçao Quantidade

fc 100

fc 20

vb 10

vb 30

fc 40

e eu queria que na data grid view apareça assim

Descriçao quantidade

fc 160

vb 40

desde já obrigado pela atençao...

cumps

Pedro'O

Link to comment
Share on other sites

bem eu tenho este codigo

For i = 0 To prod.Length - 1
	 For j = 0 To doc.Length - 1
		 ligacao_externa.Open()
		 'sqltext = "SELECT SaleTransactionDetails.TransDocument, SaleTransactionDetails.CreateDate, SaleTransactionDetails.ItemID, Sum(SaleTransactionDetails.Quantity) AS SomaDeQuantity FROM(SaleTransactionDetails) GROUP BY SaleTransactionDetails.TransDocument, SaleTransactionDetails.CreateDate, SaleTransactionDetails.ItemID HAVING (((SaleTransactionDetails.TransDocument)= '" & doc(i) & "') AND ((SaleTransactionDetails.CreateDate)=#" & dtp_Data.Text & "#) AND ((SaleTransactionDetails.ItemID)='" & prod(j) & "'))"
		 sqltext = "SELECT SaleTransactionDetails.TransSerial, SaleTransactionDetails.TransDocument, SaleTransactionDetails.CreateDate, SaleTransactionDetails.ItemID, Sum(SaleTransactionDetails.Quantity) AS SomaDeQuantity FROM SaleTransactionDetails GROUP BY SaleTransactionDetails.TransSerial, SaleTransactionDetails.TransDocument, SaleTransactionDetails.CreateDate, SaleTransactionDetails.ItemID HAVING (((SaleTransactionDetails.TransDocument)='" & doc(i) & "') AND ((SaleTransactionDetails.CreateDate)=#" & dtp_Data.Text & "#) AND ((SaleTransactionDetails.ItemID)='" & prod(j) & "'))"
		 adaptador = New OleDb.OleDbDataAdapter(sqltext, ligacao_externa)
		 adaptador.Fill(dados, "Pesquisa")
		 DataGridView1.Columns.Add("
		 j = j + 1
	 Next
	 i = i + 1
 Next

so que queria que ele me adicionasse os dados na datagridview mas nao concigo... ainda sou um bocado fresco em base de dados...

cumps

Edited by Caça

Pedro'O

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.