|
Dave,
thanks for the detailed prompt response, i will disect my code and implement your recommendations, and hopefully it will work!
Thanks again,
dave
|
|
|
|
|
Hi,
I have textbox that takes only a fully characters string for example person name.
If the user enter something like (paul123) or (1234),it should get an invalid input.
I try this:
Integer.parse(me.nametextbox.text)
msgbox("invalid")
me.nametextbox.lostfocus
it works when the user types an integer first, it gives the message but user types a character first it goes through..
that is not what I want..
Any idea
Best regard
|
|
|
|
|
It's possible that the test is being interpreted as a hexadecimal number. Instead of using TryParse to determine if it's a good number, use a regular expression instead.
|
|
|
|
|
Thanks,
Can You provide me with an example of relax expression and how to apply?
Thanks again
|
|
|
|
|
Hi,
as you replied that to yourself, you got the notification, Dave didn't.
Anyway, it is regex, not relax.
FYI: you can prevent some characters from being entered through the keyboard by overriding Control.IsInputChar; or overriding Control.KeyDown and setting SuppressKeyPress true.
However, when you allow for editing, including pasting, you always have to validate the Text itself,
for which a regex could be fine.
I'm not a regex specialist nor regex fan, however IMO
^[0-9]+$ would match a sequence of digits only (^ is start, $ is end, [x-y] is a range of acceptable characters, and + indicates "one or more".
This[^] is supposed to be a very informative site on regexes).
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 am developing the billing module of a clinical management system in vb.net.i have a data grid in my windows form in which the bill details are generated automatically..i want to pass some of the person details and the datagridvalues to the crystal report so that i can take the printout.how can i pass the values to crystal reports from the windowsform.The datagrid values are taken from seperate seperate tables in the database
|
|
|
|
|
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
|
|
|
|