Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2004, 02:36 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Mentiri, Muara, Brunei.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default typical logic

HI friends,

   Can u tell the logic for my problem?
I am generating payslip. I have different table to store leaves, attendance,emloyee,holidays. 2 types of employees(Staff and Worker). Staff can avail 6 leaves(paid) for 6 months. It count from the date of join of emp. If he avails more than 6, excess will be deducted from the current salary. If not used, balance will be brought forward to next 6 months.(next 6 months he can avail 6+prev balance). If he didnt utilize 12(total 6+6 or 12-usedleaves), the balance is brought forward to next year. So next year first 6 months he can avail prev year balance+6. This is upto 2 years. We have to follow according to this country labour law.
I think u got it. I am not able to find the logic for counting 6 months from the dateofjoin and if excess(>6 in 6 months) will be deducted on the spot. So, the law states that emp can avail 6 leaves in 6 MONTHS. We have to count leaves for every 6 months from the date of join.

If any reply is highly appreciate. Thanx in advance.

U can send mail to rajani@tom.com.bn



Reply With Quote
  #2 (permalink)  
Old June 11th, 2004, 05:55 AM
Friend of Wrox
Points: 1,288, Level: 14
Points: 1,288, Level: 14 Points: 1,288, Level: 14 Points: 1,288, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Stockholm, Sweden
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

It is just very simple if u r using SQL server because it has the functions of calculating months from where u want
eg
Select * from employee where month(date_of _joining) = 6

Love 4 all
Reply With Quote
  #3 (permalink)  
Old June 11th, 2004, 11:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

You have not mentioned about what database server you use.

If you are using SQL server, you can create a job and schedule it to run everyday. It can be as follows

Create a procedure that
1) Checks if TODAY - 6 months = Date_Of_Joining(DOJ) of any staff.
2) If so populate those rows in a cursor and do the calculations for those staffs and update their remaining leave details.
3) Schedule it to run daily as an SQL job. As staff might have joined on any day.

Within the procedure you may code like this.

If (Select count(Staff) from YOURTABLE where DOJ = '''' + cast(year(getdate()) as char(4)) + '-' + cast(month(getdate())-6 as varchar(2)) + '-' + cast(day(getdate()) as varchar(2)) + '''' > 0)
BEGIN
-- Have a CURSOR Populating rows that satisfy the above condition,
-- because there may be more than one staff memeber joined that day.
-- within the cursor pick row by row and
-- if (6 - staff_availed_Leave) < 0 then calculate (6 - staff_availed_Leave) * Day_Salary and
-- store that in deductions column to be deducted from current salary.
-- if (6 - staff_availed_Leave) > 0 then update add up (6 - staff_availed_Leave) to REMAINING leave for next half year.
-- close the cursor.
END

Follow the same logic for cases of 12 months, 18 months and 24 months within the same procedure using different IF constructs. This can be donw without CURSOR too, provided you derive at a formula that can do all that(calculate deduction, and remaining leaves) in one step for one IF.

Hope that helps.
Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
And/Or Logic??? ninel SQL Server 2000 2 February 9th, 2007 11:33 AM
Typical Algorithm rajanikrishna ASP.NET 1.0 and 1.1 Professional 0 November 20th, 2006 03:05 AM
Displaying null value in a typical combobox - C# momof2 C# 1 August 24th, 2006 12:47 AM
A Typical Book Class Maxood ASP.NET 1.0 and 1.1 Basics 8 March 23rd, 2004 04:57 PM
Mixing Data access logic and business logic polrtex BOOK: Professional Jakarta Struts 0 December 15th, 2003 07:19 PM



All times are GMT -4. The time now is 03:39 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.