473,441 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Parse and Format

Hi all!

I have a windows form that is bound to a dataset. Using VS 2005 & .NET
Framework Beta 2.

In my dataset I have a colum called Warranty that is a smallint on SQL
Server 2000(SP4).

What I am trying to do is Parse and Format the value based on choice from
radio buttons and enetered period.

The 4 radio buttons are to determin period of warranty

Unknown, Lifetime, Months, Years

Unknown is DBNull
Lifetime is 0
any negative value means months
Years are posotive values

Here is the code I have hooked up so far for the Parse and Format Events:

#region Warranty Format and Parse Events

private void FormatWarranty(object sender, ConvertEventArgs cevent)
{
if (cevent.DesiredType != typeof(System.Decimal))
{
return;
}

if (cevent.Value == System.DBNull.Value)

{
this.radioButtonUnknown.Checked = true;
this.numericUpDownWarranty.Enabled = false;
cevent.Value = System.DBNull.Value;
}

else if (Convert.ToDecimal(cevent.Value) < 0)

{
cevent.Value = Convert.ToDecimal(Math.Abs(
Convert.ToInt16(cevent.Value)));
this.radioButtonMonths.Checked = true;
this.numericUpDownWarranty.Enabled = true;
}

else if (Convert.ToDecimal(cevent.Value) == 0)
{
this.radioButtonLifetime.Checked = true;
this.numericUpDownWarranty.Enabled = false;
cevent.Value = Convert.ToDecimal(cevent.Value);
}

else

{
this.radioButtonYears.Checked = true;
this.numericUpDownWarranty.Enabled = true;
cevent.Value = Convert.ToDecimal(cevent.Value);
}

}

private void ParseWarranty(object sender, ConvertEventArgs cevent)
{
if (cevent.DesiredType != typeof(System.Int16))
{
return;
}

if (this.radioButtonUnknown.Checked)
{
cevent.Value = System.DBNull.Value;
}

else if (this.radioButtonLifetime.Checked)
{
cevent.Value = Convert.ToInt16(0);
}

else if (this.radioButtonMonths.Checked)
{
cevent.Value = Convert.ToInt16("-" +
this.numericUpDownWarranty.Value.ToString());
}

else if (this.radioButtonYears.Checked)
{
cevent.Value = Convert.ToInt16(this.numericUpDownWarranty.Value);
}

}

#endregion

When setting cevent.Value property the data is not being updated when I do
the call the dataset update method.

Any ideas, have I done this all wrong?

Paul
Nov 17 '05 #1
0 1076

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matteo | last post by:
Hy everybody. I'm not a html writer, but a sysadmin who's trying to help a user able to compile an online form with IE but not with Mozilla (Moz1.6, Ns7.1, Firefox 0.8+) due to a javascript date...
4
by: Muscha | last post by:
Hello, I have a date string in the following format: "2003-10-29T17:44+00:00" When I put it to DateTime.Parse() method it throws an exception, how do I parse this date format? Thanks, /m
21
by: William Stacey [MVP] | last post by:
Anyone know of some library that will parse files like following: options { directory "/etc"; allow-query { any; }; // This is the default recursion no; listen-on { 192.168.0.225;...
1
by: vooose | last post by:
Consider an application which has *many* references to DateTime.Parse(string); Is there a way, say when the application first starts up to force this method to use a specific IFormatProvider,...
3
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New...
1
by: Mythran | last post by:
Dim value As Decimal = 1234.56 Dim format As String = _ "Positive $#,##0.00;Negative $#,##0.00;" Dim s As String = value.ToString(format) Dim d As Decimal = Decimal.Parse(s) The last line...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
29
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
4
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am having a problem formatting a string when the time is in format hh.mm.ss - used in Europe Parse seems ok when the date uses "/" or "." as seperator but I get an exception when time...
3
by: Peter Duniho | last post by:
I'm sure there's a good explanation for this, but I can't figure it out. I tried using DateTime.Parse() with a custom DateTimeFormatInfo instance, in which I'd replaced the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.