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
Pramod Kumar Nandagiri
NA
484
0
how to put conditions for this code
Mar 26 2010 8:52 AM
the total code will be in same button control if all these if ,else and foreach conditions are satisfide i want to enter the data into database how to put condition for that
if
(txtcomutedleaves.Text ==
string
.Empty)
lblcomutedleaves.Visible =
true
;
else
lblcomutedleaves.Hide();
if
(txtmaternity.Text ==
string
.Empty)
lblmaternity.Visible =
true
;
else
lblmaternity.Hide();
if
(txtmiscarriage.Text ==
string
.Empty)
lblmaxcarriage.Visible =
true
;
else
lblmaxcarriage.Hide();
if
(txtrhs.Text ==
string
.Empty)
lblmaxrhs.Visible =
true
;
else
lblmaxrhs.Hide();
foreach
(
Control
c
in
this
.Controls)
{
if
(c
is
TextBox
)
{
try
{
int
.Parse(c.Text);
}
catch
{
c.Text=
"Enter Int"
;
}
}
}
/// if above conditions are satisfied then only the bellow code should be executed how to put the condition for this ,please tell me
SqlConnection
con =
new
SqlConnection
();
con.ConnectionString =
ConfigurationSettings
.AppSettings[
"conn"
].ToString();
con.Open();
string
strsql =
"insert into maxleaves values('"
+ txtcls.Text +
"','"
+ txthpls.Text +
"','"
+ txtels.Text +
"','"
+ txtpaternity.Text +
"','"
+ txtsleave.Text +
"','"
+ txtcomutedleaves.Text +
"','"
+ txtmaternity.Text +
"','"
+ txtmiscarriage.Text +
"','"
+ txtrhs.Text +
"')"
;
SqlCommand
cmd =
new
SqlCommand
(strsql, con);
cmd.ExecuteNonQuery();
con.Close();
Reply
Answers (
3
)
how to find the greatest no of n given numbers using c#
how to validate the textbox data is in emailformat or not using errorprovider1 control