|
It depends entirely. If you already have a database, and you don't have any other config file, then I guess you could consider it. But, overall, a database is for storing data. This is not data, it's config information.
If the invoice number is just a number that increments, you could get it from the DB by doing a select MAX(invoicenumber). But, otherwise, a config file or the registry is the way to go IMO
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Chris. Your an abosolute champion.
i think after reading what you said i don't neccessarily need to store such information if i can get my app to read last invnum field in INVOICE table using the select MAX you said right. im guessing i can just add a query in my invoice table to read that right ? is this the way most invoice apps would do it.. your suggestive way i mean.
Robbo
|
|
|
|
|
I can't speak for 'all' apps, but that's how I would do it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Depending on how many clients are storing temporary variables and the type of data it can allow for a little more robust coverage. An area I have experienced some discomfort in is related to Lan or user permissions that hang up using localized storage (assuming you need to use it) using smart clients. If I am looking at less that 50 installations or it is a utility application I like the local storage plan better.
As to the table structure I am evolving if you will. I like the user, key, value and timestamp but I am beginning to move away from it. After a heart to heart with the MS rep the other day I am encouraged with the xml datatype. One of the ideas being the use of an object which composes/decomposes configuration or cache data into an xml datatype then caches it in the appropriate table. I hope to try it out and see how it flys.
|
|
|
|
|
Thankyou Kev for a much informative description of what to consider for the type of enviroment.
I really appreciate you sharing your view , experience and knowledge and importantly time to you took to reply in detail.
Many thanks champ,
|
|
|
|
|
I don't know VB .Net at all and I have a class that I used on online converter to ship to VB. The problem is it's now raising a weird error that I don't understand as I don't know VB .Net at all.
Here is the error:
Error 1 Too few type arguments to 'System.Collections.Generic.List(Of T)'. C:\IRONSPEED4.1.0\BOSTONUNIVERSITY\App_Code\Question.vb 34 12 C:\IRONSPEED4.1.0\BOSTONUNIVERSITY\
At line 34. I can hardly understand VB .Net when I look at it. I
ran this code through a C# to VB .Net converter that has always
done a good job but I'm lost as to what syntax VB expects when it
is attempting to cast an inherits...
using System;
using System.Collections.Generic;
[Serializable ()]
public class Question
{
public String QuestionID;
public String QuestionText;
public Question ()
{
}
public Question (String id, String text)
{
QuestionID = id;
QuestionText = text;
}
}
[Serializable ()]
public class QuestionOption
{
public String OptionID;
public String OptionValue;
public QuestionOption ()
{
}
public QuestionOption (String id, String value)
{
OptionID = id;
OptionValue = value;
}
}
'*****
'***** Here is the first error referenced at Line 34
'*****
[Serializable ()]
public class QuestionList : List<Question>
{
public QuestionList ()
: base ()
{
}
public QuestionList (IEnumerable<Question> collection)
: base (collection)
{
}
public QuestionList (Int32 capacity)
: base (capacity)
{
}
}
[Serializable ()]
public class QuestionOptionList : List<QuestionOption>
{
public QuestionOptionList ()
: base ()
{
}
public QuestionOptionList (IEnumerable<QuestionOption> collection)
: base (collection)
{
}
public QuestionOptionList (Int32 capacity)
: base (capacity)
{
}
}
<div class='ForumSig'></div>
|
|
|
|
|
code-frog wrote: public class QuestionList : List<question>
Why are you doing this at all ? Why not just define an alias, if you must ?
Anyhow, I think it's List(Of Question) that you need.
But, I hate VB as well, I'm taking a stab at it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I'll try that. GAWD that is horrible syntax. Who in the hell could work in that? What was wrong with the C++ syntax? It was clear, concise and easy to understand...
|
|
|
|
|
There's a great divide here. Some people think that concise syntax is easy to understand, others want a more English like syntax, so it's more 'natural'. One problem with this: I can't work out how to set a variable in the debugger in VB. myVal = 0 evaluates to an equality check, not an assignment operation.
Another is, VB makes no sense. Using () all the time means that it's hard to work out what's going on.
Dim i as int = Someting(i)
Does that look into an array, or does it call a method and assign the return value ? I don't know.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Yeah, I know... Ever since VB programming has gone straight to hell. I don't mean to slam VB but gosh this is a huge problem. It would be one thing if you could put VB in with C# and just run them side by side in the same project. That would be so nice...
Now watch I'm missing something stupid like using VB or some other equal dumb statement...
|
|
|
|
|
You can put your VB.NET code in a dll and use it from C#.
If you have a using Microsoft.VisualBasic statement anywhere, delete it and fix the code, that's the way they import all the old VB6 hacks.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
(via Instant VB)
Imports System
Imports System.Collections.Generic
<serializable ()=""> _
Public Class Question
Public QuestionID As String
Public QuestionText As String
Public Sub New()
End Sub
Public Sub New(ByVal id As String, ByVal text As String)
QuestionID = id
QuestionText = text
End Sub
End Class
<serializable ()=""> _
Public Class QuestionOption
Public OptionID As String
Public OptionValue As String
Public Sub New()
End Sub
Public Sub New(ByVal id As String, ByVal value As String)
OptionID = id
OptionValue = value
End Sub
End Class
<serializable ()=""> _
Public Class QuestionList
Inherits List(Of Question)
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal collection As IEnumerable(Of Question))
MyBase.New(collection)
End Sub
Public Sub New(ByVal capacity As Int32)
MyBase.New(capacity)
End Sub
End Class
<serializable ()=""> _
Public Class QuestionOptionList
Inherits List(Of QuestionOption)
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal collection As IEnumerable(Of QuestionOption))
MyBase.New(collection)
End Sub
Public Sub New(ByVal capacity As Int32)
MyBase.New(capacity)
End Sub
End Class
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
So are you the author of Instant VB? If so that's cool! You might just have won a customer.
|
|
|
|
|
Yes. But note that the demo edition converts up to 100 line snippets for free (or up to 1000 lines in a project), so give that a whirl first (get the demo from the link in my signature).
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
|
I'm sure this is obvious.
I want to call FormB from FormA
FormB has a button event
I want to return the outcome of that button event to FormA when it occurs
I can create a public variable on FormA and have the FormB event update it, but this seems awkward and I think breaks encapsulation principles.
Isn't there a better way?
tia
|
|
|
|
|
Yes, create a delegate between the two forms, so that FormB sends a message to FormA when the update occurs. Create a custom eventArgs, which contains the data you want to send.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
OK, thanks but I think I need to be more specific:
..and sorry to be dense here.
I’m in a sub and I want to get input from the user before continuing.
Normally I’d use Dim choice = messagebox.show () to get a response and then continue
But I’d like to have more complex messagebox (another whole form)
How can I best stop further processing until a button is checked on that form?
Do I need to loop until an event occurs on the other form?
|
|
|
|
|
Oh, OK. In that case, you should indeed have a read only property, to check the response. Assuming that a DialogResult is not enough.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
A form can easily be turned into a dialog. Think of the OpenFileDialog or the SaveFileDialog if you've ever used them. You can call the ShowDialog method which will load the form and wait for it to exit before your code continues. An explanation will be much easier with some sample code. Here is the code for our simple dialog.
'A simple dialog form.
'You'll need two buttons and a textbox
Public Class Form2
'Expose text the user entered
Public ReadOnly Property TextFromUser() As String
Get
Return TextBox1.Text
End Get
End Property
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Set the DialogResult to Cancel
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Me.Close
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Set the DialogResult to OK
Me.DialogResult = Windows.Forms.DialogResult.OK
Me.Close
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Button1.Text = "Cancel"
Button2.Text = "Ok"
End Sub
End Class Example of how you might use it.
'Requires a button
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New Form2
If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
MsgBox(frm.TextFromUser)
End If
End Sub
End Class
|
|
|
|
|
THanks everyone... I didn't realize that dialogresult and showdialog were so powerful!
|
|
|
|
|
I can see now that you can return the button presses using dialogresult() and showdialog(). But what's the best way to return other non-button values from a shown dialog?
tia
|
|
|
|
|
You mean you want frm.ShowDialog to return something other then then standard values of "OK", "Cancel" etc.? I don't think you can or need to do that. Just create public properties to expose the value's you want. The example I gave you demonstrated that and I believe that's the proper way to do it. Unless I'm not understanding your needs correctly.
|
|
|
|
|
oh, right... gotit. thanks again
|
|
|
|
|
Let me start out by explaining the situation. I have a DataGridView that I am using to read/write to/from a SQL database. The problem I am running into involves the state of each row. When the records are submitted, I need to be able to tell if the row is a new row or not. There is not a PK for the table so I am having trouble figuring this out. I noticed the DataGridView has a 'State' method but it isn't what i'm looking for. I know the DataGrid used to just have a DataRow.RowState, but I am stuck trying to find a counterpart in the DataGridView.
Thanks In Advance.
Nathan Lindley
|
|
|
|