Reputation: 325
I want to check the last record of an employee to find it was an enter record or an exit record.I have a stored procedure that returns a single value (true/false). this is my sp code:
PROCEDURE [dbo].[SP_FindLastEnterExit]
@EmpID int = 0,
@recDate Date
AS
Begin
return(Select top 1 EnterOrExit From tblDailyTimes
where EmpID = @EmpID and recDate = @recDate Order By recDate , recTime Desc)
End
how can I use this value in my windows application?
I tried the code below but it returns '-1' .
private void CheckForEnterOrExit()
{
try
{
EmployeeDB3DataSetTableAdapters.tblDailyTimesTableAdapter ta =
new EmployeeDB3DataSetTableAdapters.tblDailyTimesTableAdapter();
DataRow dr = ((DataRowView)tblEmployeesBindingSource.Current).Row;
int id = (int)dr.ItemArray[0];
DateTime dt = new FunctionsClass().milady(txtShamsrDate1.Text);
int r = (int)ta.SP_FindLastEnterExit(id, dt);
int e = Convert.ToInt32(tblDailyTimesTableAdapter1.SP_FindLastEnterExit(id, dt));
rbtnEnter.Checked = Convert.ToBoolean(e);
rbtnExit.Checked = !rbtnEnter.Checked;
}
catch
{
}
finally
{
}
}
Upvotes: 0
Views: 46
Reputation: 196
try declaring an out parameter for the storedprocedure and use that parameter in your code to check the value.
Upvotes: 1