Click here to Skip to main content
15,917,702 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Business_Logic.Employee objt = new Business_Logic.Employee();

objt.Position_Number = TxtPositionNum.Text;
objt.Grade = Txtgrade.Text;
objt.StartDate = TxtStartDate.Text;

objt.Save_Position();




Business_Logic.Employee obje = new Business_Logic.Employee();
obje.Position_Number = TxtPositionNum.Text;
obje.Cell_Number = TxtCellNumber.Text;
obje.Email = TxtEmail.Text;

obje.Save_Employee();
Posted

Modify the Save_Position method to return a bool value: true for OK, false for "an error occured"
Then check in your code:
C#
objt.Position_Number = TxtPositionNum.Text;
objt.Grade = Txtgrade.Text;
objt.StartDate = TxtStartDate.Text;
 
if (objt.Save_Position())
    {
    Business_Logic.Employee obje = new Business_Logic.Employee(); 
    obje.Position_Number = TxtPositionNum.Text;
    obje.Cell_Number = TxtCellNumber.Text;
    obje.Email = TxtEmail.Text;
    
    obje.Save_Employee();
    }
Alternatively, throw an exception in your Save_Position method, and catch it in the code which calls your fragment. It can then report a problem to the user.
 
Share this answer
 
Use the flag variable to check whether error is occurred or not. If there no error then save the code otherwise ignore it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900