C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Validations »

Assessment Year validation in WinForms


Posted Date: 17 Apr 2009    Resource Type: Code Snippets    Category: Validations
Author: Deepika HaridasMember Level: Diamond    
Rating: 1 out of 5Points: 5



Validate Assessment Year.
Format for Assessment Year, for example : 2009-10
Multiple Assessment Year possible for example : 2008-09 2009-10 etc
If user enters 2009-11 it will show error. If user enters 0911 it will raise an error.



public bool IsValidYear(String year)
{
Regex objyr = new Regex("^([0-9]{4})-([0-9]{2})");
return objyr.IsMatch(year);
}

public void checkyr()
{
if (IsValidYear(txtassyr.Text))
{
string[] strarry = txtassyr.Text.Split(' ');
string temp;
int i, j;
foreach (string s in strarry)
{
string[] str = s.Split('-');
temp = str[0].Substring(2);
i = Convert.ToInt32(temp);
j = Convert.ToInt32("1");
if (str[1].StartsWith("0"))
{
str[1] = str[1].Replace("0", "");
}
if (str[1].Equals(Convert.ToString(i + j)))
{
//
}
else
{
//MessageBox.Show(Convert.ToString(i + j));
MessageBox.Show("Please enter Ass-Year in following format 2008-09");
txtassyr.Text = "";
txtassyr.Focus();
}
}
}
else
{
MessageBox.Show("Please enter Ass-Year in following format 2008-09");
txtassyr.Text = "";
txtassyr.Focus();
}
}



Responses

Author: D.Jeya kumar(JK)    18 Apr 2009Member Level: Diamond   Points : 1
Hi,


Good one. Please add some description for the Program logic also. it will be help full for the readers like me...

Hope you will do it in your next code snippets

Regards
JK


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Year  .  Winforms  .  Validate  .  Message  .  Assessment  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Validation in WinForms for PAN number
Previous Resource: Validation without button click
Return to Discussion Resource Index
Post New Resource
Category: Validations


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use