Connecting Tech Pros Worldwide Forums | Help | Site Map

Timeclock application

Familiar Sight
 
Join Date: Feb 2007
Posts: 145
#1: Jun 19 '09
I have a web form where I am about to put 4 buttons (time in, lunch out, lunch in, time out). When an emploee good enough and click all 4 buttons in a day then system should only create 2 records. (time in and time out goes together in a same record)

1. Employee will come in the morning and click on Time In button.
>>> Good, Simple insert into table
2. Employee will click on Lunch Out button.
>>> need to make sure my UPDATE (not insert) is updating the moring record when employee timed in.
3. Employee will clock in upon arriving from Lunch "Lunch In".
>>> Another insert statement however I need to make sure the prior record has lunch out punched in and also calculate hours and plug it in the first record. If "lunch out" is missing then flag the record (update status column "AUDIT") and display a message (response.write "something")
4. time out. Very critical. an employee may be going home early so he/she is not taking lunch. so "time out" then should check whether employee has a record with time in only and no time out and then update the record with the new time out value. another scenerio, employee took lunch but forgot to lunch out, and came back and just did lunch in. in that case you will have 2 records both with time in value populated and time out value empty. in that case the lunch in record's timeout column will be update.

I hope this makes sense. I need few ideas where should I write these business logic. In sql server or .net (create a class with bool factor and create object out of it). LOST. PLEASE suggest.

tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 2,304
#2: Jun 19 '09

re: Timeclock application


I do desktop apps, not web apps so this may be useless but...

I did a security app that included a digital camera and employee badge readers. It had to have the same sort of thing, plus photos at clock-in and out as theft prevention. No buttons, just a reader for 'in' and a reader for 'out'. It was client/server not web.

In that case the clients just reported the times to the server, to do all the heavy thinking.
Familiar Sight
 
Join Date: Feb 2007
Posts: 145
#3: Jun 19 '09

re: Timeclock application


Thanks for your respond. Can you please share some code related to the business logic I posted? Also, client wants web based due to maintenance reasons.
Again, Thanks
Familiar Sight
 
Join Date: Feb 2007
Posts: 145
#4: Jun 19 '09

re: Timeclock application


so far i have this but it has some serious glitch.

Expand|Select|Wrap|Line Numbers
  1. set ANSI_NULLS ON
  2. set QUOTED_IDENTIFIER ON
  3. go
  4.  
  5. alter PROCEDURE [dbo].[sp_timeOut] 
  6.     -- Add the parameters for the stored procedure here
  7. @emp_id int,
  8. @clocking_date datetime,
  9. @time_out datetime,
  10. @record_status varchar(15),
  11. @rec_operator varchar(30)
  12.  
  13. AS
  14. BEGIN
  15.     -- SET NOCOUNT ON added to prevent extra result sets from
  16.     -- interfering with SELECT statements.
  17.     SET NOCOUNT ON;
  18.  
  19.     -- Insert statements for procedure here
  20.  
  21.  
  22. IF EXISTS(
  23. select * from clocking_details
  24. where emp_id=@emp_id and clocking_date = @clocking_date and time_out is null
  25. )
  26.     IF(select count(1)  from clocking_details
  27.         where emp_id=@emp_id and 
  28.         clocking_date = @clocking_date and time_out is null) =1
  29.         update clocking_details
  30.         set time_out=@time_out
  31.         where (emp_id=@emp_id and clocking_date = @clocking_date and time_out is null)
  32.     ELSE
  33.     IF(select count(1)  from clocking_details
  34.         where emp_id=@emp_id and 
  35.         clocking_date = @clocking_date and time_out is null) >1
  36.         update clocking_details
  37.         set time_out=@time_out
  38.         where DETAIL_NUMBER = (SELECT MAX(DETAIL_NUMBER) FROM CLOCKING_DETAILS
  39.         where emp_id=@emp_id and clocking_date = @clocking_date    and time_out is null)
  40.     RETURN
  41.  
  42.  
  43. END
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 2,304
#5: Jun 19 '09

re: Timeclock application


Quote:

Originally Posted by tlhintoq View Post

I do desktop apps, not web apps so this may be useless but...

I did a security app that included a digital camera and employee badge readers. It had to have the same sort of thing, plus photos at clock-in and out as theft prevention. No buttons, just a reader for 'in' and a reader for 'out'. It was client/server not web.

In that case the clients just reported the times to the server, to do all the heavy thinking.

I'm afraid not: Its production code and in place at a customer site. My boss is really particular about such things.

Besides, it probably wouldn't do much good. There is no database to query along the format you have in your example.
Familiar Sight
 
Join Date: Feb 2007
Posts: 145
#6: Jun 19 '09

re: Timeclock application


That's kool. I was just going to get an idea. But it's kool. I am progressing.

Thanks.....
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,720
#7: Jun 19 '09

re: Timeclock application


What database management system are you using?

I would recommend creating all of your stored procedures before attempting to do the web portion of the application. You should test them thoroughly before using them in your app.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,720
#8: Jun 19 '09

re: Timeclock application


Quote:

Originally Posted by tlhintoq View Post

I did a security app that included a digital camera and employee badge readers. It had to have the same sort of thing, plus photos at clock-in and out as theft prevention. No buttons, just a reader for 'in' and a reader for 'out'. It was client/server not web.

In that case the clients just reported the times to the server, to do all the heavy thinking.

I do that every day :)
For the web even :)
Familiar Sight
 
Join Date: Feb 2007
Posts: 145
#9: Jun 19 '09

re: Timeclock application


Only 2 buttons are required: PunchIn and PunchOut.

The table would look something like this.

Expand|Select|Wrap|Line Numbers
  1. PunchCard
  2. ----------
  3. Id (PK)
  4. UserId (FK)
  5. TimeIn
  6. TimeOut
  7.  
the logic would be simple.

Expand|Select|Wrap|Line Numbers
  1. sqlCommand.CommandText = @"select count(1) from PunchCard where UserId = @user and TimeOut is null";
  2. //set user id
  3. var result = (int)sqlCommand.ExecuteScalar();
  4. PunchInButton.Enabled = result == 0;
  5. PunchOutButton.Enabled = result == 1;
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#10: Jun 24 '09

re: Timeclock application


Why should there be two records?
Why not just one record for the whole process and have the four columns time in, lunch out, lunch in and time out in the table?
Reply