![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#12 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
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 |
|
|
|
|
|
#13 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#14 | ||
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Quote:
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:
Thanks anyhoo. |
||
|
|
|
|
|
#15 | |
|
Expert Programmer
|
Quote:
|
|
|
|
|
|
|
#16 | |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#17 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#18 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#19 |
|
Programmer
Join Date: Feb 2005
Posts: 45
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#20 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
Quote:
![]() 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 |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|