Connecting Tech Pros Worldwide Help | Site Map

Timeclock application

  #1  
Old June 19th, 2009, 04:23 AM
Familiar Sight
 
Join Date: Feb 2007
Posts: 142
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.
  #2  
Old June 19th, 2009, 04:43 AM
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,690
Provided Answers: 3

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.
  #3  
Old June 19th, 2009, 05:34 AM
Familiar Sight
 
Join Date: Feb 2007
Posts: 142

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
  #4  
Old June 19th, 2009, 07:26 AM
Familiar Sight
 
Join Date: Feb 2007
Posts: 142

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

Last edited by tlhintoq; June 19th, 2009 at 07:29 AM. Reason: [CODE] ... your code here ... [/CODE] tags added
  #5  
Old June 19th, 2009, 07:31 AM
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,690
Provided Answers: 3

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.
  #6  
Old June 19th, 2009, 02:16 PM
Familiar Sight
 
Join Date: Feb 2007
Posts: 142

re: Timeclock application


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

Thanks.....
  #7  
Old June 19th, 2009, 02:39 PM
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North :)
Posts: 4,940
Provided Answers: 8

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.
  #8  
Old June 19th, 2009, 02:40 PM
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North :)
Posts: 4,940
Provided Answers: 8

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 :)
  #9  
Old June 19th, 2009, 02:47 PM
Familiar Sight
 
Join Date: Feb 2007
Posts: 142

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;

Last edited by Frinavale; June 19th, 2009 at 02:56 PM. Reason: Fixed code tags
  #10  
Old June 24th, 2009, 11:32 AM
Administrator
 
Join Date: Sep 2006
Posts: 12,084

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppDomain Kevin L answers 4 June 27th, 2008 09:14 PM
Need Ideas for Storing Time Clock information. Charles May answers 5 January 19th, 2008 12:25 AM
Using NOTIFY... Slow Client Querys Joe Lester answers 4 November 22nd, 2005 09:01 AM
Computing the past monday - Friday when Sunday occurs rock72 answers 1 November 13th, 2005 06:23 AM