Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make better msg from Data Tier?
Message
 
 
To
28/10/2007 20:01:44
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01263197
Message ID:
01264660
Views:
19
I am still doing 99% of my work in VFP and only about 1% in .NET. I think it is great that you shared your C# code; this will help me to learn C# more and get the VFP code in order. Thank you.

I am also not much of a baseball fan. I am what I think they call "getting on a bang wagon" type fan <g>. Hard to stay away from not watching World Series games when Sox are playing. To be honest, I look forward to the games to be over so that I can get some normal sleep hours <g>.

But the Patriots I watch very religiously; which is easy because it is only once a week.


>Go Sox! (I'm originally from Connecticut, so I guess I have to root for Boston ... although I really don't watch baseball or football anymore).
>
>Sorry about the C# code, Dmitry. I guess I had it in my head that you were doing .NET work, as well as VFP. And since I usually answer questions in the .NET forum, I guess I didn't notice that this was the SQL forum! <g>
>
>~~Bonnie
>
>
>>Bonnie,
>>
>>Thank you very much for the code. I will print and study it tomorrow to see how to "translate" your code into VFP. Right now I can't concentrate on anything but football and baseball <g>. I just finished watching Patriots and in the next 30 minutes will start watching Red Sox. I have so much on my plate today <g>.
>>
>>Again, thank you for your help.
>>
>>>>I am still not convinced that I want to go back to checking duplicate ID in a separate validating routine. The only thing I have against this method is that it requires for me to create this method and to maintain it.
>>>
>>>How about having your base TextBox class do all that? We have our base classes automatically check for Rules compliance (typically in the control's OnValidating method) and set the color of the control accordingly. So, for example, the MyTextBox class would have these two methods, called from OnValidating:
>>>
>>>
>>>public virtual void CheckRule()
>>>{
>>>	try
>>>	{
>>>		if (this.Parent is IMyContainer && this.oBinding != null)
>>>		{
>>>			DataTable table = (DataTable)this.oBinding.DataSource;
>>>			string field = this.oBinding.BindingMemberInfo.BindingField;
>>>			int row = this.BindingContext[table].Position;
>>>
>>>			if (((IMyContainer)this.Parent).CheckRule(table, field, row) > 0)
>>>				this.IsRed = true;
>>>			else
>>>				this.IsRed = false;
>>>		}
>>>		else
>>>			this.IsRed = false;
>>>	}
>>>	catch (Exception)
>>>	{
>>>		this.IsRed = false;
>>>	}
>>>}
>>>public virtual void CheckColors()
>>>{
>>>	if (this.IsRed)
>>>	{
>>>		if (this.Enabled == true)
>>>		{
>>>			this.BackColor = System.Drawing.Color.Red;
>>>			this.ForeColor = System.Drawing.Color.White;
>>>		}
>>>		else
>>>		{
>>>			this.BackColor = System.Drawing.SystemColors.Control;
>>>			this.ForeColor = System.Drawing.Color.Red;
>>>		}
>>>	}
>>>	else
>>>	{
>>>		if (this.Enabled == true)
>>>		{
>>>			this.BackColor = System.Drawing.SystemColors.Window;
>>>			this.ForeColor = System.Drawing.SystemColors.WindowText;
>>>		}
>>>		else
>>>		{
>>>			this.BackColor = System.Drawing.SystemColors.Control;
>>>			this.ForeColor = System.Drawing.SystemColors.WindowText;
>>>		}
>>>	}
>>>}
>>>
>>>
>>>The CheckRule() method in each Parent container basically passes the call up through each Parent (which can be things like Panel, GroupBox, Usercontrol, etc.) until it gets to the top (the Form). The base class for the Form doesn't do anything, that's up to the individual sub-classed Forms. We have a pretty complicated Rules class which contains a RulesCollection that's basically populated from the database from the Form. But, here's an example of how a Form might handle the CheckRule method, using the oRules collection. The RulesCollection.CheckRule() method does all the work.:
>>>
>>>
>>>public override int CheckRule(DataTable data, string field, int row)
>>>{
>>>	return this.oRules.CheckRule(data, field, row);
>>>}
>>>
>>>
>>>You could also loop through every Rule comparing against the DataSet. In our first app, we didn't put this code in the Framework classes, but I've been re-vamping our Framework and this definitely needs to be added:
>>>
>>>protected virtual int CheckRules(DataSet ds, MyRule rule)
>>>{
>>>	int num = 0;
>>>
>>>	if (rule.Table.DataSet.Equals(ds) && ds.HasChanges())
>>>	{
>>>		for (int it = 0; it < ds.Tables.Count; it++)
>>>			if (rule.Table.Equals(ds.Tables[it]))
>>>				for (int ir = 0; ir < ds.Tables[it].Rows.Count; ir++)
>>>					if (ds.Tables[it].Rows[ir].RowState != DataRowState.Unchanged)
>>>						num += this.CheckRule(ds.Tables[it], rule.Field, ir);
>>>	}
>>>
>>>	return num;
>>>}
>>>The above method would be called in your Form's Save method, like this:
>>>
>>>if (this.oData.HasChanges())
>>>{
>>>	for (int i = 0; i < this.oRules.Count; i++)
>>>		num += this.CheckRules(this.oData, this.oRules[i]);
>>>}
>>>
>>>
>>>Anyway, that's enough for now. Enough for you to get the picture I hope.
>>>
>>>~~Bonnie
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform