Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 18th, 2005, 3:24 PM   #11
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
THANKS!

Aaahh! I love this place! Looks like I'm gonna become a regular here! I know how frustrating it is when you don't know how to do something and you wana be shown! So I'll try answer some easy questions so you gurus don't get annoyed with all the easy questions lol.
gj15987 is offline   Reply With Quote
Old Aug 18th, 2005, 4:08 PM   #12
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8 Ooble is on a distinguished road
w00tness! Another regular!

BTW, why not just have Date_Time_In and Date_Time_Out? You can take advantage of SQL's DATETIME datatype, and if you get a rampant coder like me that might wanna work from 9am to 5pm the next day, you can cater for him. :p
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 18th, 2005, 4:43 PM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Time in, time out, and time worked introduces a redundancy, which is not good. Anything you can derive from other fields you don't need in the table. So long as they haven't clocked out (time out blank), time worked is zero. Otherwise, it's time out minus time in minus cumulative breaks. You need to sit down and think about the data. That's part of the design, and comes before coding. If you use the proper modern DB design techniques or revert to the older normalization procedures, you will have a robust system that isn't likely to come back and bite you in the azz. I realize that this is a classroom project and not a commercial venture, but if you can hack the time/effort required, it'll pay off in real life later.

This may well belong in the Delphi forum if it gets down to a coding issue, but, really, design is key, and language is chosen for appropriateness or because it's otherwise required by the client (who may be your teacher).

You're the one to consider all these issues and make the decision, ultimately. Any advice you need, ask for. It's one more set of inputs to think about.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 18th, 2005, 7:04 PM   #14
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Quote:
Originally Posted by Ooble
w00tness! Another regular!

BTW, why not just have Date_Time_In and Date_Time_Out? You can take advantage of SQL's DATETIME datatype, and if you get a rampant coder like me that might wanna work from 9am to 5pm the next day, you can cater for him. :p
Thats a good idea. But I'll have to write myself a specification. So i'm doing this as the client, and as the coder lol. So in the spec i might as well just write "Employees can work from 9am to 8pm", cus I was having my own work place, Iceland (supermarket), in mind when thinkin about it. Cus if i make it too fool proof then there wont be much for me to specify in the spec.

I was also thinkin I'll need to see if there are any active acounts at the end of the day where an employee has forgotten to clock out, and to close them...ooorrr I could again just say in the spec that an employee cannot exit the workplace without clocking out....don't know why i'm typing all this. I'm just thinking out loud, lol.

Really I'm just trying to think of a way to stop employees from "forgetting" to clock out, i spose most emloyers just trust the workers. When i haven't clocked out at work i still just get paid my basic hours so i guess they just look for an overly large shift and just set it to the appropriate time.

I was thinking of setting designated hours for each employee and making it show whether they've clocked out too soon or in too late, but i recon thats far too advanced for A level.

On a random note I got my AS results back today and i got an A in computing! yay!

Quote:
Time in, time out, and time worked introduces a redundancy, which is not good. Anything you can derive from other fields you don't need in the table
Yeah i noticed that after i posted it but was too lazy to correct it. Thanks anyhoo.
gj15987 is offline   Reply With Quote
Old Aug 18th, 2005, 7:10 PM   #15
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 3 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
Quote:
On a random note I got my AS results back today and i got an A in computing! yay!
gj man =)
coldDeath is offline   Reply With Quote
Old Aug 18th, 2005, 7:39 PM   #16
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Quote:
Originally Posted by coldDeath
gj man =)
Erm...yeah thats me. I'm scared, you say it like you know me...? lol This is quickly becoming off topic, sowwi!
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 6:16 AM   #17
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Ok now I think this needs to be moved to the delphi forum.

I have this code

procedure Tfrm_clock_In.btn_enterClick(Sender: TObject);
var
          Today:TDateTime;
          Executed:boolean;
begin
Executed:= false;
Today:= Date;
tbl_employees.Open;
tbl_employees.First;
Repeat
        if strtoint(Edit_Employee_ID.text) = tbl_employeesEmployee_ID.value then
           begin
                tbl_shift.Open;
                tbl_shift.Last;
                repeat
                        if (strtoint(Edit_Employee_ID.text) = tbl_shiftEmployee_ID.value) and (tbl_shiftDate_.Value = Today) then
                           begin
                                if Datetostr(tbl_shiftTime_Out.value)='' then
                                        begin
                                                //sql to updae file with clock out time
                                                Executed:=true;
                                                showmessage('Clocked Out')
                                        end;
                           end
                        else tbl_shift.Prior;
                Until (Executed=true) or (tbl_shift.Bof); //until record update or no shift found
           end
        else tbl_employees.Next;
Until (Executed=true) or (tbl_employees.Eof);

if tbl_employees.Eof then showmessage('Invalid User ID'); //if don't find a matching employee number then invalid

If tbl_shift.Bof then //if don't find a record to update then create new one
        begin
                //sql to create a new record
        end;
        
end;

And for some reason it freezes the program and i have to reset it. I'm thinking its going to be one of those repeats that's freezing it. Can anyone see my error?

Also I couldn't use DATETIME in sql because i don't have sql server 2005.

Hmm...and i'm not sure what one is but i've heard about memory leaks, and after a while it tells me there is not sufficient memory to run the program, am i leaking memory?

Last edited by gj15987; Aug 19th, 2005 at 6:30 AM.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 7:09 AM   #18
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Simplification: Memory leaks come about when a program requests additional memory from the system at run time. This comes from the heap or free-store. If the request is granted you get a pointer to that area and use it. When you've finished with it you return it, using the same pointer (or a copy) to indicate what you're returning. If you fail in that, the memory remains unallocated and is unavailable for further use. Some allocations may be recovered by the system under certain conditions, at certain times, even if you fail to handle it properly. At the extreme, for example, it is ALL recovered when you reboot. You have no overt allocation showing in the code. There's not much telling what the DB operations do under the covers.

I can read your program, of course, though I'd make plenty of syntactical errors and trips to the reference material if I were writing it. It seems straightforward enough.

If you don't find the employee in the inner loop, you do a MovePrior and check the preceding record. If you DO find the employee, but you don't clock 'im out and set Executed to true, you DON'T do a MovePrior, so you're locked up there.

If MoveNexts or MovePriors or EOFs or BOFs aren't working properly or invoked, you won't exit the loops.

Do you not have a debugger so that you can step through?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 19th, 2005, 7:12 AM   #19
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
I use Delphi 6. I'm not sure of all the features, its just what they taught us at college (i'm learning c++ on the side), so I think there is a debugger in there, but i'm not sure how to use it.

and wow, i'm impressed, you found that quick. Man i hope i'm that good one day! lol

Hmmm...i have changed the if inside the inner loop to go to the prior record like you said, yet It still freezes.

Man i'm such a pain.

Repeat
        if strtoint(Edit_Employee_ID.text) = tbl_employeesEmployee_ID.value then
           begin
                tbl_shift.Open;
                tbl_shift.Last;
                repeat
                        if (strtoint(Edit_Employee_ID.text) = tbl_shiftEmployee_ID.value) and (tbl_shiftDate_.Value = Today) then
                           begin
                                if Datetostr(tbl_shiftTime_Out.value)='' then
                                        begin
                                                //sql to updae file with clock out time
                                                showmessage('Clocked Out');
                                                Executed:=true;
                                        end
                                else Tbl_shift.Prior;
                           end
                        else tbl_shift.Prior;
                Until (Executed=true) or (tbl_shift.Bof); //until record update or no shift found
           end
        else tbl_employees.Next;
Until (Executed=true) or (tbl_employees.Eof);

Last edited by gj15987; Aug 19th, 2005 at 7:31 AM.
gj15987 is offline   Reply With Quote
Old Aug 19th, 2005, 7:31 AM   #20
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8 Ooble is on a distinguished road
Quote:
Originally Posted by gj15987
On a random note I got my AS results back today and i got an A in computing! yay!
Good to hear it man. I did too. Man, I was crapping myself yesterday morning...

Delphi 6 does have a debugger. Simply set a breakpoint (I can't remember how), and hit the Start button. The application will run until it hits the breakpoint, at which point it will throw you back to the code (but the app will still be running). You can then use the Step Into and Step Over functions in the Debug menu (I think) to step through the program one line at a time.

Step Into will go into a function when it's called and let you step through that function; Step Over will skip over it. Use Step Into only when you want to go through the function.

If I recall correctly, at any point, you can hover over variable names and a tooltip will tell you what that variable contains. Of course, if I don't recall correctly, you're gonna have to figure it out yourself. :p
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC