|
-
Nov 11th, 2007, 07:27 PM
#1
Thread Starter
Junior Member
[2005] Help needed in comparing 2 datagrid
i got 2 tables.
Table 1 is the picklist. It have 2 column which are item name and quantity.
Table 2 is the masterlist. It also have 2 columns which are item name and quantity too.
Masterlist is the table that shows how much inventories i have and picklist is the table that shows how much items i need to draw.
what i need to do is to show that if picklist item quantity is more then masterlist item, then it will appear red on the picklist datagrid.
can any1 help me with this?
-
Nov 11th, 2007, 07:49 PM
#2
Re: [2005] Help needed in comparing 2 datagrid
Are you actually using a DataGridView rather than a DataGrid? If not why not?
-
Nov 11th, 2007, 08:20 PM
#3
Thread Starter
Junior Member
Re: [2005] Help needed in comparing 2 datagrid
i'm a total newbie when it comes to programming... i just follow my teachers instruction when it comes to what to use...
Imports System.IO
Imports System.Data.SqlServerCe
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If AppDatabase1DataSet2Util.DesignerUtil.IsRunTime Then
'TODO: Delete this line of code to remove the default AutoFill for 'AppDatabase1DataSet2.Masterlist'.
End If
'TODO: This line of code loads data into the 'AppDatabase1DataSet1.EPCcode' table. You can move, or remove it, as needed.
'Me.EPCcodeTableAdapter.Fill(Me.AppDatabase1DataSet1.EPCcode)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
Me.PicklistTableAdapter.Fill(Me.AppDatabase1DataSet.Picklist, ComboBox1.Text)
Catch ex As Exception
End Try
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub PictureBox2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As SqlCeConnection
Dim dirinfo As New DirectoryInfo("\program files\deviceapplication1\RFID")
Dim files() As FileInfo = dirinfo.GetFiles("*")
Dim str As String
Try
cn = New SqlCeConnection("Data Source = \program files\deviceapplication1\AppDatabase1.sdf")
cn.Open()
Dim cmd As SqlCeCommand = cn.CreateCommand()
cmd.CommandText = "UPDATE Masterlist SET Available = 0"
cmd.ExecuteNonQuery()
Dim i As Integer = files.Length
For y As Integer = 0 To i - 1
str = files(y).Name.Substring(0, 24)
cmd.CommandText = "UPDATE Masterlist SET Available = 1 WHERE Masterlist.EPC = '" & str & "'"
cmd.ExecuteNonQuery()
Next
Dim ds As New Data.DataSet
Dim daFac As New SqlCeDataAdapter("SELECT Item, COUNT(Item) AS Qty FROM Masterlist WHERE Available = 1 GROUP BY Item", cn)
daFac.Fill(ds, "Masterlist")
MasterlistBindingSource.DataSource = ds
cn.Close()
Catch ex As Exception
If Picklist.item >= Masterlist.item Then Text = Color.Red
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ComboBox1.Enabled = False
Button2.Visible = False
Button3.Visible = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ComboBox1.Enabled = True
Button3.Visible = False
Button2.Visible = True
End Sub
Private Sub DataGrid2_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
End Sub
Private Sub DataGrid2_CurrentCellChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid2.CurrentCellChanged
End Sub
End Class
this is the coding that i used
Last edited by Klawz; Nov 11th, 2007 at 08:28 PM.
-
Nov 11th, 2007, 08:30 PM
#4
Re: [2005] Help needed in comparing 2 datagrid
That still doesn't answer my question as to whether you're using a DataGridView or a DataGrid. It looks like you're using a DataGrid from your code but, given that you're using a typed DataSet and a BindingSource that seems strange. They are two different controls and the answer to a question will be different for each in most cases, so you need to confirm which it is.
-
Nov 11th, 2007, 09:36 PM
#5
Thread Starter
Junior Member
Re: [2005] Help needed in comparing 2 datagrid
i simply drag and drop the data grid from the tools and then my teacher asked me to write a SQL statement to bind them.... i'm also not too sure how it works but anyway, is there any specific code on how to compare 2 tables.
-
Nov 11th, 2007, 09:49 PM
#6
Re: [2005] Help needed in comparing 2 datagrid
If you're using VB 2005 then there is no DataGrid in the Toolbox by default. Either you're using a DataGridView and that's what you dragged to the form, or else you must have manually added the DataGrid to the Toolbox first. I don't think that's likely, but it's possible. Can you just answer the question: is it a DataGrid or a DatagridView? Mouse over the icon you used in the Toolbox and it will tell you, or just select the control and open the Properties window and read the contents of the drop-down list at the top.
-
Nov 11th, 2007, 09:55 PM
#7
Re: [2005] Help needed in comparing 2 datagrid
Also, you're not really comparing two tables. You're comparing one value in one row to another value in another row. It's just comparing two numbers really, but you've got to get those numbers from the appropriate rows of the appropriate tables first. You do that the same way you do any other time, whether they're being compared or not.
If you have two different tables, each with ItemID and Quantity columns, you can compare the Quantity values in corresponding rows something like this:
vb.net Code:
If CInt(row1("Quantity")) > CInt(table2.Rows.Find(row1("ItemID"))("Quantity")) Then
'The quantity in row1 is greater than the corresponding quantity in table2.
End If
-
Nov 11th, 2007, 10:25 PM
#8
Thread Starter
Junior Member
Re: [2005] Help needed in comparing 2 datagrid
the codes u provide is it only comparing the rows? or will it automatically find the item to compare like if 'item A' is at other rows... because my teacher told me something about for next loop in which the program will keep on searching for the item, then when the item name match, it will compare the quantity of the item.
-
Nov 11th, 2007, 10:32 PM
#9
Thread Starter
Junior Member
Re: [2005] Help needed in comparing 2 datagrid
i'm using datagrid..... and by the way, i forgot to mention that i use pocket pc 2003 SE emulator to run.
-
Nov 11th, 2007, 10:50 PM
#10
Re: [2005] Help needed in comparing 2 datagrid
Maybe that's something you should have mentioned in the first place or, even better, posted in the Mobile Development forum. That explains why the Toolbox had a DataGrid by default and no DataGridView: because there is no DataGridView in the Compact Framework. I've wasted my time trying to determine which it is when it could only be one. Please post all relevant information in future, and also post in the most appropriate forum. If you post Mobile or ASP.NET questions in the general language forum then people will assume standard WinForms unless you specify otherwise.
-
Nov 11th, 2007, 10:53 PM
#11
Thread Starter
Junior Member
Re: [2005] Help needed in comparing 2 datagrid
oh... i'm sorry for not mentioning it earlier... didn't have expected such effect...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|