|
Generally speaking you do it by making separate GUI and data layers.
In other words, you create a separate class that will retrieve data from the database. When you want to show the data in the GUI, you call the class, when you want to print the data, you call the same class.
You can also implement a OrderDetail class with properties for all details. Assign values to the properties in the GUI layer, and then pass the entire object to your crystal report.
My advice is free, and you may get what you paid for.
|
|
|
|
|
can you explain that in more detail???my billing form is working fine...but i dont want to store the patients billing history in the database...so dynamically when the billing details of the particular patient is being added to the datagrid fields,it has to be added to the crystal report as well,so that i can take the print out that time itself.i would also like to store those reports as seperate file in the drive.i dont know whether this is possible in vb.net.bt right now my concentration is on parameter passing dynamically as it gets added in the form
|
|
|
|
|
The question is, how do you retrieve the data from the database? I assume you use a dataset or datatable. So somewhere in your code there is line that looks a little like this:
DataGrid1.DataSource = DataSet1
The dataset / datatable is an object (in memory) that actually contains all the data. The datagrid is really just a window on that data, it does not actually contain the data itself.
That means you can simply loop through all the rows in the dataset / datatable and build your report when the user pushes the print button (or whatever).
myinstincts wrote: i would also like to store those reports as seperate file in the drive.i dont know whether this is possible in vb.net
Yes, this is possible in vb.net. Look into System.IO and the File method.
My advice is free, and you may get what you paid for.
|
|
|
|
|
i dint use dataset ...i read data using datareader...Below is a portion of my code
If strfee = "consultation fee" Then
cmd1 = New OleDbCommand("select fees from fee_details where type='" + doctorcombobx.SelectedItem + "'", con1)
dr1 = cmd1.ExecuteReader()
If dr1.Read() Then
consult_fee = dr1.Item(0)
End If
consult_count = DataGridView1.Rows.Count()
DataGridView1.Rows.Add()
DataGridView1.Rows(consult_count - 1).Cells(0).Value = billcombobox.SelectedItem
DataGridView1.Rows(consult_count - 1).Cells(1).Value = consult_fee
Else
cmd2 = New OleDbCommand("select fees from fee_details where type='" + billcombobox.SelectedItem + "'", con1)
dr2 = cmd2.ExecuteReader()
If dr2.Read() Then
bill_fee = dr2.Item(0)
End If
bill_count = DataGridView1.Rows.Count()
DataGridView1.Rows.Add()
DataGridView1.Rows(bill_count - 1).Cells(0).Value = billcombobox.SelectedItem
DataGridView1.Rows(bill_count - 1).Cells(1).Value = bill_fee
End If
|
|
|
|
|
Not a big problem. Right now you are storing the data in the DataGrid. All you need to do is store it in a DataTable first (the code will look pretty much the same), and bind the datagrid to this DataTable.
Something like:
Dim BillInfo As DataTable = Nothing
Dim clmn As DataColumn = Nothing
Dim rw As DataRow = Nothing
Try
BillInfo = New DataTable("DataTable1")
clmn = New DataColumn("PatientName")
BillInfo.Columns.Add(clmn)
clmn = New DataColumn("Address")
BillInfo.Columns.Add(clmn)
clmn = New DataColumn("Total")
BillInfo.Columns.Add(clmn)
'etc
rw = BillInfo.NewRow
rw.Item("PatientName") = YourDataReader.Item("NameOfColumn")
'Using the name of the column instead of the index number will
'save you a lot of trouble later on, if you ever want to
'add fields to your query.
BillInfo.Rows.Add(rw)
'etc
'And then when the DataTable is ready:
DataGridView1.DataSource = BillInfo
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Also, in the code you posted, you are not using a loop with the datareader.
Try something like:
dr1 = cmd1.ExecuteReader()
If dr1.HasRows Then
Do while dr1.read()
rw.Item("PatientName") = dr1.Item("NameOfColumn")
Next
End If
My advice is free, and you may get what you paid for.
|
|
|
|
|
thanks johan...its getting dark here..i should go home now ..once i reach home i will try this out
|
|
|
|
|
You can use dataset to store data from Windows Form and then Fatch the data in crystal Report.
If you can think then I Can.
|
|
|
|
|
Hi All,
I am creating control at runtime. so these are overlapping and hiding.
So i want to use Send to Back or Bring to Front for it.
So Please give me idea for implimenting it.
Thanks
If you can think then I Can.
|
|
|
|
|
You'll probably want the BringToFront and SendToBack methods
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Is there something like zindex?
google for that.
Coding C#
www.excitetemplate.com
|
|
|
|
|
Thanks Sir
If you can think then I Can.
|
|
|
|
|
A question I should have probably wondered about a little earlier, but anyway:
Let's say I dim an object, for example a dataset, fill that object with data, and use the object, but do not explicitly clear/empty it after use. Then reuse it like:
MyObject = New Object
Will that automatically clear/empty the data from it, that I filled it with earlier? Or does this depend on the object?
Perhaps the important question here is: what is best practice? Can I get problems by not explicitly clearing/emptying an object before reusing it?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi,
assuming VB.NET, if you do
[1] Dim MyObject As Object
[2] MyObject = New Object ' object 1
[3] MyObject = New Object ' object 2
then object 1 will become collectible when line [3] executes, meaning the garbage collector will collect object 1 the next time it runs (normally it runs when a future memory allocation cannot be satisfied without cleaning up memory first).
And this is fine, unless it is a type that implements Dispose or Close, as in:
[1] Dim MyObject As Font
[2] MyObject = New Font(...) ' object 1
[4] MyObject = New Font(...) ' object 2
now you should insert [3] MyObject.Dispose() to make sure the unmanaged resources that might be held by the object get released right away (or the file or stream or whatever gets closed).
If you don't Close/Dispose objects that support it, your app will use more memory and other system resources, and its behavior may deteriorate. Yes, the garbage collector will still find those objects, and its finalizer thread will eventually Dispose of them, but that typically will be much later.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
Thanks, that is really good to know. So far I just assumed that once I reused the object, it would automatically also dispose of the first object and all related data.
So from your explanation, can I surmise that it would be good practise to change my current code (simplified) from:
Dim ds As DataSet = Nothing
ds = New DataSet("DataSet1")
'Run a query and fill the dataset here
'Run some loops, and do some stuff to the data
ds = New DataSet("DataSet1")
'Run another query and fill the dataset here
'Run some loops, and do some stuff to the data
to
Dim ds As DataSet = Nothing
ds = New DataSet("DataSet1")
'Run a query and fill the dataset here
'Run some loops, and do some stuff to the data
ds.Clear() 'Would this even be necessary ?
ds.Dispose()
ds = New DataSet("DataSet1")
'Run another query and fill the dataset here
'Run some loops, and do some stuff to the data
In other words, my app would at least use less resources while it is running?
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Calling Dispose()/Close() when done with an object that has such method is good.
Calling Clear() or Flush() or ... typically doesn't change a thing when immediately followed by Dispose/Close.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Alright, great !
Thanks a bundle for the enlightenment
My advice is free, and you may get what you paid for.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I have tabcontrol with 5 pages. On some action I want to bring page 3 to the front..
thanks
|
|
|
|
|
Forgive any syntax errors in this, I'm doing it from memory, but something like:
myTabControl.SelectedTab = myTabControl.TabPages(2);
[Edit]
changed indexing from [] to (). Forgot I was in the VB forum.
Anyway Lucs' solution, below, is better more concise.
[/Edit]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Thursday, August 13, 2009 5:54 PM
|
|
|
|
|
or...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yup.
I don't use the TabControl often, and had forgotten that, If I ever knew it!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
myTabControl.SelectedIndex=2;
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I have a DVD with 15,000 word documents (transcribed op reports from doctors).
I need to organize them by date modified into folders, year first, then a month subdirectory.
The filenames have a date string in them after a patient name.
i.e.: smith john -20060415.doc
I'm wondering if it would be easier to use the fileinfo feature to pull the modified date, and then utilize that to make a folder for the month, then drop that in a folder.
I dont have any code yet, I'm in more of a brainstorming mode, but we will have to do this for a few hundred other accounts we have and need to have a working solution for this issue.
Excuse the pseudo-code, but here's my general idea.
I'd just like some guidance as to what commands I should use in this situation
-scan dir for files *.doc
-for loop
-get modified date of file
-does month folder exist
y=copy file
n=create folder
-copy file
next
Am I on the right track?
Thanks for any response, even if its "you're in the wrong forum" =)
-STL
|
|
|
|
|
The logic is pretty basic, but works. But, I'd do some sanity checking first. If you have the date information in the filename, Id start by parsing that out and comparing it to the Modified date on the file. If the two aren't within some arbitrary limit, I'd set the file aside for further review of where it should go, otherwise, I'd follow the logic you already have.
|
|
|
|
|
Thanks! Now to get it out before friday...
|
|
|
|