Files
sryang 577060bc78 chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
2026-09-10 09:42:37 +08:00

931 lines
27 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Data;
using System.Configuration;
using System.Data.Common;
using Wellan.Common;
using Wellan.Data;
/// <summary>
/// 計算加班費
/// 1. 取出這個年月的這個人員的加班紀錄
/// 2. 若要累積補休(11),就累加進累積補休
/// 3. 若要請領加班費(12),就看那天是不是假日
/// 4. 是假日:假日加班費率 * 8 * 時薪
/// 5. 不是假日:區分出 前二時數 與 後二時數
/// 6. 前二加班:前二加班費率 * 前二時數 * 時薪
/// 7. 後二加班:後二加班費率 * 後二時數 * 時薪
/// 8. 累加加班費、前二時數、後二時數、假日時數
/// </summary>
public class ExtraWork
{
private BhrdDAC bhrd = new BhrdDAC();
private static Calculate calc = new Calculate();
/// <summary>
/// 累積補休時數
/// </summary>
public int RelaxationAllowance = 0;
/// <summary>
/// 前二加班時數
/// </summary>
public int RPTC1 = 0;
private double _RPTA1 = 0d;
/// <summary>
/// 前二加班費
/// </summary>
public int RPTA1
{
get
{
return (Int32)Math.Round(_RPTA1, MidpointRounding.AwayFromZero);
}
set
{
_RPTA1 = value;
}
}
/// <summary>
/// 後二加班時數
/// </summary>
public int RPTC2 = 0;
private double _RPTA2 = 0d;
/// <summary>
/// 後二加班費
/// </summary>
public int RPTA2
{
get
{
return (Int32)Math.Round(_RPTA2, MidpointRounding.AwayFromZero);
}
set
{
_RPTA2 = value;
}
}
/// <summary>
/// 假日加班時數
/// </summary>
public int RPTC3 = 0;
private double _RPTA3 = 0d;
/// <summary>
/// 假日加班費
/// </summary>
public int RPTA3
{
get
{
return (Int32)Math.Round(_RPTA3, MidpointRounding.AwayFromZero);
}
set
{
_RPTA3 = value;
}
}
/// <summary>
/// 休息日加班超過 8 小時時數
/// </summary>
public int RPTC4 = 0;
private double _RPTA4 = 0d;
/// <summary>
/// 休息日加班超過 8 小時加班費
/// </summary>
public int RPTA4
{
get
{
return (Int32)Math.Round(_RPTA4, MidpointRounding.AwayFromZero);
}
set
{
_RPTA4 = value;
}
}
/// <summary>
/// 例假日加班超過 8 小時時數
/// </summary>
public int RPTC5 = 0;
private double _RPTA5 = 0d;
/// <summary>
/// 例假日加班超過 8 小時加班費
/// </summary>
public int RPTA5
{
get
{
return (Int32)Math.Round(_RPTA5, MidpointRounding.AwayFromZero);
}
set
{
_RPTA5 = value;
}
}
public RASNRecord RasnRecord;
public ExtraWork()
{
}
public void Clear()
{
RelaxationAllowance = 0;
RPTC1 = 0;
RPTC2 = 0;
RPTC3 = 0;
RPTC4 = 0;
RPTC5 = 0;
RPTA1 = 0;
RPTA2 = 0;
RPTA3 = 0;
RPTA4 = 0;
RPTA5 = 0;
}
/// <summary>
/// 計算加班費
/// </summary>
/// <param name="bpsrm">月薪</param>
/// <param name="bpp02">伙食津貼</param>
/// <param name="hours">時數</param>
/// <param name="ratio">比例</param>
/// <param name="bpovr">計算公式</param>
/// <param name="bpott">加班費計算方式</param>
public static int CalculateOverTimeInt(int bpsrm, int bpp02, int hours, double ratio, string bpovr, string bpott)
{
return (Int32)Math.Round(CalculateOverTime(bpsrm, bpp02, hours, ratio, 1D, bpovr), MidpointRounding.AwayFromZero);
}
/// <summary>
/// 計算加班費
/// </summary>
/// <param name="bpsrm">月薪</param>
/// <param name="bpp02">伙食津貼</param>
/// <param name="hours">時數</param>
/// <param name="overtimeRatio">加班費比例</param>
/// <param name="leaveRatio">請假扣款比例</param>
/// <param name="bpovr">計算公式</param>
/// <param name="bpott">加班費計算方式</param>
/// <returns></returns>
public static double CalculateOverTime(int bpsrm, int bpp02, int hours, double overtimeRatio, double leaveRatio, string bpovr)
{
return calc.CalcOverTime(bpsrm, bpp02, hours, overtimeRatio, leaveRatio, bpovr);
}
/// <summary>
/// 區分加班時數(支援累積模式)
/// </summary>
/// <param name="加班類型">加班類型</param>
/// <param name="本筆分鐘數">本次加班分鐘數</param>
/// <param name="含本筆累計分鐘數">處理前累計時數(用於多張加班單累積計算)</param>
/// <param name="tc1">加班分鐘數(1.34)</param>
/// <param name="tc2">加班分鐘數(1.67)</param>
/// <param name="tc3">加班分鐘數(1.00)</param>
/// <param name="tc4">加班分鐘數(2.67)</param>
/// <param name="tc5">加班分鐘數(2.00)</param>
public void SplitOverTime(string 加班類型, int 本筆分鐘數, int 含本筆累計分鐘數,
out int tc1, out int tc2, out int tc3, out int tc4, out int tc5)
{
tc1 = 0;
tc2 = 0;
tc3 = 0;
tc4 = 0;
tc5 = 0;
int minBefore = 含本筆累計分鐘數 - 本筆分鐘數;
int minAfter = 含本筆累計分鐘數;
switch (加班類型)
{
case RPAR_TYPE.T11_非休息日累積補休時數:
case RPAR_TYPE.T12_非休息日請領加班費:
分配非休息日時數(本筆分鐘數, minBefore, minAfter, out tc1, out tc2);
break;
case RPAR_TYPE.T13_休息日累積補休時數:
case RPAR_TYPE.T14_休息日請領加班費:
分配休息日時數(本筆分鐘數, minBefore, minAfter, out tc1, out tc2, out tc4);
break;
case RPAR_TYPE.T15_國定假日累積補休時數:
case RPAR_TYPE.T16_國定假日請領加班費:
分配國定假日時數(本筆分鐘數, minBefore, minAfter, out tc1, out tc2, out tc3);
break;
case RPAR_TYPE.T17_例假日累積補休時數:
case RPAR_TYPE.T18_例假日請領加班費:
分配例假日時數(本筆分鐘數, minBefore, minAfter, out tc3, out tc5);
break;
}
}
/// <summary>
/// 分配非休息日加班時數
/// 規則:前 120 分鐘為 tc1(1.34),超過部分為 tc2(1.67)
/// </summary>
private void 分配非休息日時數(int 本次時數, int 處理前累計, int 處理後累計,
out int tc1, out int tc2)
{
const int 門檻 = 120;
tc1 = 0;
tc2 = 0;
if (處理後累計 <= 門檻)
{
// 未超過門檻:全部算入 tc1
tc1 = 本次時數;
}
else if (處理前累計 >= 門檻)
{
// 之前已超過門檻:全部算入 tc2
tc2 = 本次時數;
}
else
{
// 本筆跨越門檻:分配至 tc1 和 tc2
tc1 = 門檻 - 處理前累計;
tc2 = 本次時數 - tc1;
}
}
/// <summary>
/// 分配休息日加班時數
/// 規則:0-120 分鐘為 tc1(1.34)120-480 分鐘為 tc2(1.67),超過 480 分鐘為 tc4(2.67)
/// </summary>
private void 分配休息日時數(int 本次時數, int 處理前累計, int 處理後累計,
out int tc1, out int tc2, out int tc4)
{
const int 第一門檻 = 120;
const int 第二門檻 = 480;
tc1 = 0;
tc2 = 0;
tc4 = 0;
if (處理後累計 <= 第一門檻)
{
// 未超過第一門檻
tc1 = 本次時數;
}
else if (處理後累計 <= 第二門檻)
{
// 在第一和第二門檻之間
if (處理前累計 >= 第一門檻)
{
tc2 = 本次時數;
}
else
{
tc1 = 第一門檻 - 處理前累計;
tc2 = 本次時數 - tc1;
}
}
else
{
// 超過第二門檻
if (處理前累計 >= 第二門檻)
{
tc4 = 本次時數;
}
else if (處理前累計 >= 第一門檻)
{
tc2 = 第二門檻 - 處理前累計;
tc4 = 本次時數 - tc2;
}
else
{
tc1 = 第一門檻 - 處理前累計;
tc2 = 第二門檻 - 第一門檻;
tc4 = 本次時數 - tc1 - tc2;
}
}
}
/// <summary>
/// 分配國定假日加班時數
/// 規則:0-480 分鐘為 tc3(1.00)480-600 分鐘為 tc1(1.34),超過 600 分鐘為 tc2(1.67)
/// </summary>
private void 分配國定假日時數(int 本次時數, int 處理前累計, int 處理後累計,
out int tc1, out int tc2, out int tc3)
{
const int 第一門檻 = 480;
const int 第二門檻 = 600;
tc1 = 0;
tc2 = 0;
tc3 = 0;
if (處理後累計 <= 第一門檻)
{
// 未超過第一門檻:全部算入 tc3
tc3 = 本次時數;
}
else if (處理後累計 <= 第二門檻)
{
// 在第一和第二門檻之間
if (處理前累計 >= 第一門檻)
{
tc1 = 本次時數;
}
else
{
tc3 = 第一門檻 - 處理前累計;
tc1 = 本次時數 - tc3;
}
}
else
{
// 超過第二門檻
if (處理前累計 >= 第二門檻)
{
tc2 = 本次時數;
}
else if (處理前累計 >= 第一門檻)
{
tc1 = 第二門檻 - 處理前累計;
tc2 = 本次時數 - tc1;
}
else
{
tc3 = 第一門檻 - 處理前累計;
tc1 = 第二門檻 - 第一門檻;
tc2 = 本次時數 - tc3 - tc1;
}
}
}
/// <summary>
/// 分配例假日加班時數
/// 規則:0-480 分鐘為 tc3(1.00),超過 480 分鐘為 tc5(2.00)
/// </summary>
private void 分配例假日時數(int 本次時數, int 處理前累計, int 處理後累計,
out int tc3, out int tc5)
{
const int 門檻 = 480;
tc3 = 0;
tc5 = 0;
if (處理後累計 <= 門檻)
{
// 未超過門檻:全部算入 tc3
tc3 = 本次時數;
}
else if (處理前累計 >= 門檻)
{
// 之前已超過門檻:全部算入 tc5
tc5 = 本次時數;
}
else
{
// 本筆跨越門檻:分配至 tc3 和 tc5
tc3 = 門檻 - 處理前累計;
tc5 = 本次時數 - tc3;
}
}
/// <summary>
/// 增加加班時數
/// </summary>
/// <param name="rptyp">類別</param>
/// <param name="rprdt">加班日期</param>
/// <param name="rptct">當日加班時數(分鐘)</param>
/// <param name="bpsrm">月薪</param>
/// <param name="bpp02">伙食津貼</param>
/// <param name="bpbft">前二比例</param>
/// <param name="bpaft">後二比例</param>
/// <param name="bphol">假日比例</param>
/// <param name="formula">計算公式</param>
/// <param name="bpott">加班時數計算方式</param>
/// <param name="rptc1">前段加班時數(分鐘)</param>
/// <param name="rptc2">後段加班時數(分鐘)</param>
/// <param name="rptc3">假日加班時數(分鐘)</param>
public ExtraWorkData Add(string rptyp, DateTime rprdt, int rptct, int bpsrm, int bpp02,
double bpbft, double bpaft, double bphol, string formula, string bpott,
int rptc1, int rptc2, int rptc3, int rptc4, int rptc5
/*string 上班時間, string 下班時間*/)
{
ExtraWorkData result = new ExtraWorkData();
switch (rptyp)
{
case RPAR_TYPE.T11_非休息日累積補休時數:
case RPAR_TYPE.T13_休息日累積補休時數:
case RPAR_TYPE.T15_國定假日累積補休時數:
case RPAR_TYPE.T17_例假日累積補休時數:
result.RelaxationAllowance = rptct;
RelaxationAllowance += rptct;
break;
//if (rprdt < new DateTime(2018, 3, 1))
//{
// decimal calcMin = Math.Ceiling((decimal)rptct / 240m) * 240m;
// result.RelaxationAllowance = (int)calcMin;
// RelaxationAllowance += (int)calcMin;
//}
//else
//{
// result.RelaxationAllowance = rptct;
// RelaxationAllowance += rptct;
//}
//break;
case RPAR_TYPE.T12_非休息日請領加班費:
case RPAR_TYPE.T14_休息日請領加班費:
case RPAR_TYPE.T16_國定假日請領加班費:
case RPAR_TYPE.T18_例假日請領加班費:
// 1.34時數
result.RPTC1 = rptc1;
result.RPTA1 = CalculateOverTime(bpsrm, bpp02, rptc1, bpbft, 1D, formula);
RPTC1 += rptc1;
_RPTA1 += result.RPTA1;
// 1.67時數
result.RPTC2 = rptc2;
result.RPTA2 = CalculateOverTime(bpsrm, bpp02, rptc2, bpaft, 1D, formula);
RPTC2 += rptc2;
_RPTA2 += result.RPTA2;
// 1.00時數
result.RPTC3 = rptc3;
result.RPTA3 = CalculateOverTime(bpsrm, bpp02, rptc3, bphol, 1D, formula);
RPTC3 += rptc3;
_RPTA3 += result.RPTA3;
// 2.67時數
result.RPTC4 = rptc4;
result.RPTA4 = CalculateOverTime(bpsrm, bpp02, rptc4, bpaft + 1D, 1D, formula);
RPTC4 += rptc4;
_RPTA4 += result.RPTA4;
// 2.00時數
result.RPTC5 = rptc5;
result.RPTA5 = CalculateOverTime(bpsrm, bpp02, rptc5, bphol + 1D, 1D, formula);
RPTC5 += rptc5;
_RPTA5 += result.RPTA5;
break;
}
return result;
}
public void Add(ROWKRecord rowkRecord)
{
this.RPTC1 += rowkRecord.ROT01;
this.RPTC2 += rowkRecord.ROT02;
this.RPTC3 += rowkRecord.ROT03;
this.RPTC4 += rowkRecord.ROT05;
this.RPTC5 += rowkRecord.ROT06;
this.RPTA1 += rowkRecord.ROA01;
this.RPTA2 += rowkRecord.ROA02;
this.RPTA3 += rowkRecord.ROA03;
this.RPTA4 += rowkRecord.ROA05;
this.RPTA5 += rowkRecord.ROA06;
this.RelaxationAllowance += rowkRecord.ROT04;
}
}
public class ExtraWorkData
{
/// <summary>
/// 1.34 加班時數
/// </summary>
public int RPTC1 = 0;
/// <summary>
/// 1.67 加班時數
/// </summary>
public int RPTC2 = 0;
/// <summary>
/// 1.00 加班時數
/// </summary>
public int RPTC3 = 0;
/// <summary>
/// 2.67 加班時數
/// </summary>
public int RPTC4 = 0;
/// <summary>
/// 2.00 加班時數
/// </summary>
public int RPTC5 = 0;
/// <summary>
/// 累積補休
/// </summary>
public int RelaxationAllowance = 0;
/// <summary>
/// 1.34 加班費
/// </summary>
public Double RPTA1 = 0;
/// <summary>
/// 1.67 加班費
/// </summary>
public Double RPTA2 = 0;
/// <summary>
/// 1.00 加班費
/// </summary>
public Double RPTA3 = 0;
/// <summary>
/// 2.67 加班費
/// </summary>
public Double RPTA4 = 0;
/// <summary>
/// 2.00 加班費
/// </summary>
public Double RPTA5 = 0;
}
/*
2. 計算缺勤扣款
1. 取出這個年月的這個人員的請假紀錄
2. 區分出扣薪假與不扣薪假
3. 扣薪假:事假:時數 * 時薪
病假:(時數 * 時薪) / 2
4. 累加各假別時數、扣薪金額
*/
public class Absent
{
private Calculate calc = new Calculate();
public Absent()
{
}
/// <summary>
/// 月薪
/// </summary>
public int bpsrm;
/// <summary>
/// 伙食津貼
/// </summary>
public int bpp02;
/// <summary>
/// 計算公式
/// </summary>
public string Formula;
/// <summary>
/// 補休請假時數
/// </summary>
public int SST05 = 0;
/// <summary>
/// 特休時數
/// </summary>
public int SST06 = 0;
/// <summary>
/// 事假時數
/// </summary>
public int SST07 = 0;
/// <summary>
/// 病假時數
/// </summary>
public int SST08 = 0;
/// <summary>
/// 喪假時數,不影響全勤
/// </summary>
public int SST09 = 0;
/// <summary>
/// 產假時數
/// </summary>
public int SST10 = 0;
/// <summary>
/// 婚假時數,不影響全勤
/// </summary>
public int SST11 = 0;
/// <summary>
/// 陪產假時數
/// </summary>
public int SST12 = 0;
/// <summary>
/// 公假時數,不影響全勤
/// </summary>
public int SST13 = 0;
/// <summary>
/// 公傷假時數,不影響全勤
/// </summary>
public int SST14 = 0;
/// <summary>
/// 生理假時數,不影響全勤
/// </summary>
public int SST15 = 0;
/// <summary>
/// 家庭照顧假時數,不影響全勤
/// </summary>
public int SST16 = 0;
/// <summary>
/// 育嬰假時數
/// </summary>
public int SST17 = 0;
/// <summary>
/// 原民祭儀假
/// </summary>
public int SST19 = 0;
/// <summary>
/// 產檢假時數
/// </summary>
public int SST20 = 0;
/// <summary>
/// 病假扣款
/// </summary>
public int SSS01 = 0;
/// <summary>
/// 事假扣款
/// </summary>
public int SSS02 = 0;
/// <summary>
/// 其他假別(一)時數,不影響全勤
/// </summary>
public int SST23 = 0;
/// <summary>
/// 無薪扣款
/// </summary>
public int SSS09 = 0;
public void Clear()
{
SST05 = 0;
SST06 = 0;
SST07 = 0;
SST08 = 0;
SST09 = 0;
SST10 = 0;
SST11 = 0;
SST12 = 0;
SST13 = 0;
SST14 = 0;
SST15 = 0;
SST16 = 0;
SST17 = 0;
SST19 = 0;
SST20 = 0;
SST23 = 0;
SSS01 = 0;
SSS02 = 0;
SSS09 = 0;
}
/// <summary>
/// 以假別與總時數計算請假扣款與區分時數
/// </summary>
/// <param name="rptyp">假別</param>
/// <param name="rptct">時數</param>
/// <returns>請假扣款</returns>
public int Add(string rptyp, int rptct)
{
int rpftr = 0;
switch (rptyp)
{
case RPAR_TYPE.T00_補休: //補休時數
SST05 += rptct;
break;
case RPAR_TYPE.T01_特休: //特休時數
SST06 += rptct;
break;
case RPAR_TYPE.T02_事假: //事假時數
SST07 += rptct;
rpftr = Convert.ToInt32(calc.CalcOverTime(bpsrm, bpp02, rptct, 0D, 1D, Formula));
SSS02 += rpftr;
break;
case RPAR_TYPE.T03_病假: //病假時數
SST08 += rptct;
rpftr = Convert.ToInt32(calc.CalcOverTime(bpsrm, bpp02, rptct, 0D, 0.5D, Formula));
SSS01 += rpftr;
break;
case RPAR_TYPE.T04_喪假: //喪假時數
SST09 += rptct;
break;
case RPAR_TYPE.T05_產假: //產假時數
SST10 += rptct;
break;
case RPAR_TYPE.T06_婚假: //婚假時數
SST11 += rptct;
break;
case RPAR_TYPE.T07_陪產假: //陪產假時數
SST12 += rptct;
break;
case RPAR_TYPE.T08_公假: //公假時數
SST13 += rptct;
break;
case RPAR_TYPE.T09_公傷假: //公傷假時數
SST14 += rptct;
break;
case RPAR_TYPE.T0A_生理假: //生理假時數
SST15 += rptct;
rpftr = Convert.ToInt32(calc.CalcOverTime(bpsrm, bpp02, rptct, 0D, 0.5D, Formula));
SSS01 += rpftr;
break;
case RPAR_TYPE.T0B_家庭照顧假: //家庭照顧假時數
SST16 += rptct;
rpftr = Convert.ToInt32(calc.CalcOverTime(bpsrm, bpp02, rptct, 0D, 1D, Formula));
SSS02 += rpftr;
break;
case RPAR_TYPE.T0C_育嬰假: //育嬰假時數
SST17 += rptct;
break;
case RPAR_TYPE.T0D_原民祭儀假: //原民祭儀假
SST19 += rptct;
break;
case RPAR_TYPE.T0E_產檢假: //產檢假時數
SST20 += rptct;
break;
case RPAR_TYPE.T0G_無薪假: //無薪假時數
case RPAR_TYPE.T0F_防疫照顧假:
SST23 += rptct;
rpftr = Convert.ToInt32(calc.CalcOverTime(bpsrm, bpp02, rptct, 0D, 1D, Formula));
SSS09 += rpftr;
break;
case RPAR_TYPE.T0H_防疫隔離假:
SST23 += rptct;
break;
}
return rpftr;
}
public int Add(RPARRecord rparRecord, DateTime calcStartDay, DateTime calcEndDay, bool is進整小時)
{
DateTime 起日 = rparRecord.RPRDT;
DateTime 迄日 = rparRecord.RPEDT;
string 起時 = rparRecord.RPRTM;
string 迄時 = rparRecord.RPETM;
TimeCalc timeCalc = new TimeCalc();
if (起時.Length > 0 && 迄時.Length > 0)
{
return Add(rparRecord.RPNUM, rparRecord.RPTYP, 起日, 迄日, 起時, 迄時, calcStartDay, calcEndDay, is進整小時);
}
else
return Add(rparRecord.RPTYP, rparRecord.RPTCT);
}
public int Add(string RPNUM, string RPTYP, DateTime 起日, DateTime 迄日, string 起時, string 迄時, DateTime calcStartDay, DateTime calcEndDay, bool is進整小時)
{
TimeCalc timeCalc = new TimeCalc();
if (起日 < calcStartDay)
{
起日 = calcStartDay;
}
if (迄日 > calcEndDay)
{
迄日 = calcEndDay;
}
if (string.IsNullOrEmpty(起時))
{
起時 = timeCalc.上班時間;
}
if (string.IsNullOrEmpty(迄時))
{
迄時 = timeCalc.下班時間;
}
if (起日 != 迄日)
{
var rpftr = 0;
var dt = 起日;
while (dt <= 迄日)
{
rpftr += Add(RPTYP, timeCalc.計算請假當日時數(RPNUM, dt, 起日, 迄日, 起時, 迄時, RPTYP, is進整小時));
dt = dt.AddDays(1);
}
return rpftr;
}
else
{
return Add(RPTYP, timeCalc.計算請假總時數(RPNUM, 起日, 迄日, 起時, 迄時, RPTYP, is進整小時));
}
}
/// <summary>
/// 是否全勤
/// </summary>
public bool AllPresent
{
get
{
return (SST07 == 0) && (SST08 == 0) && (SST10 == 0) && (SST12 == 0);
}
}
}
/// <summary>
/// 計算其他費用
/// </summary>
public class OtherFee
{
public OtherFee()
{
}
/// <summary>
/// 短程出差差旅費
/// </summary>
public int ShortTrip = 0;
/// <summary>
/// 長途出差差旅費
/// </summary>
public int LongTrip = 0;
/// <summary>
/// 電話費補助
/// </summary>
public int TelephoneFee = 0;
/// <summary>
/// 油料費補助公里數
/// </summary>
public int FuelKm = 0;
/// <summary>
/// 油料費補助金額
/// </summary>
public int FuelFee = 0;
public void Clear()
{
ShortTrip = 0;
LongTrip = 0;
TelephoneFee = 0;
FuelKm = 0;
FuelFee = 0;
}
public void Add(string rptyp, int rptct, int rpftr)
{
switch (rptyp)
{
case RPAR_TYPE.T21_電話費: // 電話費
TelephoneFee += rpftr;
break;
case RPAR_TYPE.T22_油料費: // 油料費
FuelKm += rptct;
FuelFee += Convert.ToInt32(Math.Round((double)rptct * 2.5d, MidpointRounding.AwayFromZero));
break;
case RPAR_TYPE.T31_短程出差: // 短程差旅
case RPAR_TYPE.T33_公出: // 公出
case RPAR_TYPE.T34_公假: // 公假
ShortTrip += rpftr;
break;
case RPAR_TYPE.T32_長程出差: // 長途差旅
LongTrip += rpftr;
break;
}
}
public void Add(RPARRecord rparRecord)
{
Add(rparRecord.RPTYP, rparRecord.RPTCT, rparRecord.RPFTR);
}
}
/// <summary>
/// 計算公式
/// </summary>
public class Calculate : Wellan.Data.WDAC
{
private DbCommand cmdCalc;
public Calculate()
{
cmdCalc = Query.NewCommand();
cmdCalc.Parameters.Add(Query.NewParameter("月薪", DbType.Double));
cmdCalc.Parameters.Add(Query.NewParameter("本薪", DbType.Double));
cmdCalc.Parameters.Add(Query.NewParameter("伙食費", DbType.Double));
cmdCalc.Parameters.Add(Query.NewParameter("時數", DbType.Double));
cmdCalc.Parameters.Add(Query.NewParameter("加班費比例", DbType.Double));
cmdCalc.Parameters.Add(Query.NewParameter("請假扣款比例", DbType.Double));
}
/// <summary>
/// 計算加班費與請假扣款
/// </summary>
/// <param name="bpsrm">月薪</param>
/// <param name="bpp02">伙食津貼</param>
/// <param name="hours">時數(分鐘)</param>
/// <param name="overtimeRatio">加班費比例</param>
/// <param name="leaveRatio">請假扣款比例</param>
/// <param name="formula">計算公式</param>
/// <returns></returns>
public Double CalcOverTime(int bpsrm, int bpp02, int hours, double overtimeRatio, double leaveRatio, string formula)
{
cmdCalc.CommandText = "SELECT ROUND(" + formula + ", 0)";
cmdCalc.Parameters["月薪"].Value = Convert.ToDouble(bpsrm);
cmdCalc.Parameters["本薪"].Value = Convert.ToDouble(bpsrm - bpp02);
cmdCalc.Parameters["伙食費"].Value = Convert.ToDouble(bpp02);
cmdCalc.Parameters["時數"].Value = Convert.ToDouble(hours) / 60d;
cmdCalc.Parameters["加班費比例"].Value = Convert.ToDouble(overtimeRatio);
cmdCalc.Parameters["請假扣款比例"].Value = Convert.ToDouble(leaveRatio);
int result;
if (ExecuteScalar(cmdCalc, out result))
return result;
else
return 0d;
}
}