TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manu xaml
NA
19
0
validate between time start and time end
Apr 24 2009 12:47 PM
I have this class and I need to add an alert in case inspStartTime.TimeID is greater than inspEndTime.TimeID
Each value represents a time e.g. 16:30 if inspStartTime.TimeID = 16:30 and inspEndTime.TimeID = 15.30 then throw exception.
[CODE]
private bool EnumVisual(Visual myVisual)
{
InspectionTime inspStartTime;
InspectionTime inspEndTime;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
{
// Retrieve child visual at specified index value.
Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);
// Do processing of the child visual object.
if (childVisual is TextBox)
{
MaskedTextBox btn = (MaskedTextBox)childVisual;
//Check first to see if the element is null
if (btn.Tag != null)
{
//Check to see if it is the start time textbox i=on the screen
if (btn.Tag.ToString().ToLower()=="starttime")
{
//Fillthe inspection time data
inspStartTime = new InspectionTime();
inspStartTime.TimeID = Convert.ToInt32(btn.Uid);
inspStartTime.StartTime = btn.Text;
//Check to see if it is a valid time
if (IsValidTime(btn.Text))
{
//Update the starttime for the UID TimeID
if (timeManager.UpdateStartTime(inspStartTime, timeManager.GetJobIDViaTimeID(inspStartTime.TimeID)))
{
saveedChanges = false;
//Throw an exception to be handled
throw new Exception("Invalid Time Entry");
}
else //If everything is ok make it so.
{
btn.Background = System.Windows.Media.Brushes.White;
saveedChanges = true;
}
}
else //The invalid time status entry
{
btn.Background = System.Windows.Media.Brushes.Red ;
saveedChanges = false;
//Throw an exception to be handled
throw new Exception("Invalid Time Entry");
}
}
else if (btn.Tag.ToString().ToLower() == "endtime") //The textbox is the end time textbox
{
//Fillthe inspection time data
inspEndTime = new InspectionTime();
inspEndTime.TimeID = Convert.ToInt32(btn.Uid);
inspEndTime.EndTime = btn.Text;
//Check to see if it is a valid time
if (IsValidTime(btn.Text))
{
//Do the update in the Database
if (timeManager.UpdateEndTime(inspEndTime, timeManager.GetJobIDViaTimeID(inspEndTime.TimeID)))
{
saveedChanges = false;
//Throw an exception to be handled
throw new Exception("Invalid Time Entry");
}
else
{
btn.Background = System.Windows.Media.Brushes.White;
saveedChanges = true;
}
}
else
{
btn.Background = System.Windows.Media.Brushes.Red;
saveedChanges = false;
//Throw an exception to be handled
throw new Exception("Invalid Time Entry");
}
}
}
}
// Enumerate children of the child visual object.
EnumVisual(childVisual);
}
return saveedChanges;
}
[/CODE]
Reply
Answers (
0
)
datagrid doubleclick
trying to get 2 separate values in alert box