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
Murli Jadhav
NA
258
16.2k
return statement in c# class File
Jul 9 2017 7:24 AM
Here Is my class file function when it finds duplicate it shows messagebox but problem is that it does not stop by return statemtnt it also executes next queries on windows form
Code On Class File
public void FindDuplicate(String sql, string message)
{
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
MessageBox.Show(message, "Duplicate Record", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else
{
// MessageBox.Show("No Records Found","No Record Found",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
Code On Windows Form
db.FindDuplicate("Select * from Supplier_Details WHERE Sup_Name='"+txtSupplierName.Text+"'", "Name Already Exist");
If Record Found Then Shows MessageBox But Also Executes Next Statements I want to stop Here till User Enter Non-Duplicate Name
if (txtSupplierName.Text == "" || txtContactNo.Text == "" || txtAddress.Text == "")
{
MessageBox.Show("Please Fill All Details", "Empty TextBoxes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
db.WriteLog("Empty TextBoxes: " + " " + txtSupplierID.Text + " ");
return;
}
Reply
Answers (
2
)
Web Browser History
Print Barcode in Bmp Format Is Right Way Or Not