chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,329 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
using System.Data;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// BatchService 的摘要描述
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://thinkyu.com/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[ScriptService]
|
||||
public class BatchService : System.Web.Services.WebService
|
||||
{
|
||||
|
||||
public BatchService()
|
||||
{
|
||||
|
||||
//如果使用設計的元件,請取消註解下列一行
|
||||
//InitializeComponent();
|
||||
}
|
||||
|
||||
private WQuery SetupQuery()
|
||||
{
|
||||
var ConnectionConfigName = WConfig.GetConnectionConfigName();
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
var ConnectionString = WConnectionString.GetConnectionString(ConnectionConfigName);
|
||||
var ConnectionType = WConnectionString.GetConnectionType(ConnectionConfigName);
|
||||
var Query = new WQuery(ConnectionType, ConnectionString);
|
||||
WGuard1.SetQuery(ConnectionType, ConnectionString);
|
||||
return Query;
|
||||
}
|
||||
|
||||
private void CheckPunchCard(DateTime date, ref List<打卡異常Item> employeeWarning, ref List<通知督導Item> supervisorWarning)
|
||||
{
|
||||
/*
|
||||
差勤異常通知之定義及需求如下
|
||||
一、差勤異常定義:
|
||||
1.無上下班打卡紀錄,且無"出差" 或 "請假" 申請紀錄
|
||||
2.出勤時數不足8小時(出勤時數指"打卡+出差+請假")
|
||||
註:此處出差或請假申請只要申請人送單即可算
|
||||
二、系統需求
|
||||
1.差勤月報表:有異常者,於備註顯示 "出勤異常"
|
||||
2.寄送異常通知:有出勤異常則於隔日通知個人,專案管理人統一於每月30日收到所有專案人員差勤異常通知
|
||||
3.打卡限定:不能連續七日打卡
|
||||
*/
|
||||
|
||||
TimeCalc timeCalc = new TimeCalc();
|
||||
var Query = SetupQuery();
|
||||
var bhrdDao = new BhrdDAC(Query);
|
||||
var rparDao = new RparDAC(Query);
|
||||
var bsgpDao = new BsgpDAC(Query);
|
||||
|
||||
var cmd1 = Query.NewCommand(
|
||||
@"SELECT A.BPENO, A.BPNME, A.BPEML, A.BPEM2, B.RCC01, B.RCC02, B.RCC07, B.RCC08 ,
|
||||
C.RAPYN, D.BPPYM
|
||||
FROM BPSNView A
|
||||
LEFT JOIN RCRD B ON A.BPENO = B.RCUSR AND B.RCDAT = @DATE
|
||||
LEFT JOIN RASN C ON A.BPENO = C.RANUM AND (C.RAEDT IS NULL OR (C.RASDT <= @DATE AND C.RAEDT >= @DATE))
|
||||
LEFT JOIN BPAA D ON C.RAPYN=D.BPPYN
|
||||
WHERE dbo.EmployeeOnboard(BPENO, @DATE) = 1
|
||||
");
|
||||
Query.AddParam(cmd1, "DATE", date);
|
||||
DataTable tableRcrd = Query.Select(cmd1);
|
||||
foreach (DataRow rowRcrd in tableRcrd.Rows)
|
||||
{
|
||||
var bpeno = WDAC.GetStringValue(rowRcrd["BPENO"]); // 員工編號
|
||||
var bpnme = WDAC.GetStringValue(rowRcrd["BPNME"]); // 員工姓名
|
||||
var bpeml = WDAC.GetStringValue(rowRcrd["BPEML"]); // 郵箱1
|
||||
var bpem2 = WDAC.GetStringValue(rowRcrd["BPEM2"]); // 郵箱2
|
||||
var rcc01 = WDAC.GetStringValue(rowRcrd["RCC01"]); // 上班打卡
|
||||
var rcc02 = WDAC.GetStringValue(rowRcrd["RCC02"]); // 下班打卡
|
||||
var rcc07 = WDAC.GetStringValue(rowRcrd["RCC07"]); // 外出打卡
|
||||
var rcc08 = WDAC.GetStringValue(rowRcrd["RCC08"]); // 返回打卡
|
||||
var isDuty = !bhrdDao.IsHoliday(bpeno, date); // 是否需上班
|
||||
var rapyn = WDAC.GetStringValue(rowRcrd["RAPYN"]); // 派駐專案
|
||||
var rapym = WDAC.GetStringValue(rowRcrd["BPPYM"]); // 派駐專案名稱
|
||||
|
||||
打卡檢查Item checkResult = rparDao.IsPunchcardNormal(date, bpeno, rapyn, isDuty, rcc01, rcc02, rcc07, rcc08);
|
||||
if (!checkResult.正常)
|
||||
{
|
||||
var supervisorItem = supervisorWarning.FirstOrDefault(x => x.專案年度號 == rapyn);
|
||||
if (supervisorItem == null)
|
||||
{
|
||||
supervisorItem = new 通知督導Item()
|
||||
{
|
||||
專案年度號 = rapyn,
|
||||
專案名稱 = rapym
|
||||
};
|
||||
|
||||
// 取得簽核人員第一關與第三關
|
||||
// BSNME 姓名, BSEML 郵箱
|
||||
var tableBsgp = bsgpDao.SelectByLevel(rapyn, "差勤", 1);
|
||||
foreach (DataRow rowBsgp in tableBsgp.Rows)
|
||||
{
|
||||
if (supervisorItem.督導List.Find(p => p.督導郵箱 == WDAC.GetStringValue(rowBsgp["BSEML"])) == null)
|
||||
{
|
||||
supervisorItem.督導List.Add(new 督導Item()
|
||||
{
|
||||
督導姓名 = WDAC.GetStringValue(rowBsgp["BSNME"]),
|
||||
督導郵箱 = WDAC.GetStringValue(rowBsgp["BSEML"])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
tableBsgp = bsgpDao.SelectByLevel(rapyn, "差勤", 3);
|
||||
foreach (DataRow rowBsgp in tableBsgp.Rows)
|
||||
{
|
||||
if (supervisorItem.督導List.Find(p => p.督導郵箱 == WDAC.GetStringValue(rowBsgp["BSEML"])) == null)
|
||||
{
|
||||
supervisorItem.督導List.Add(new 督導Item()
|
||||
{
|
||||
督導姓名 = WDAC.GetStringValue(rowBsgp["BSNME"]),
|
||||
督導郵箱 = WDAC.GetStringValue(rowBsgp["BSEML"])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
supervisorWarning.Add(supervisorItem);
|
||||
}
|
||||
|
||||
var abnormalItem = new 打卡異常Item()
|
||||
{
|
||||
員工編號 = bpeno,
|
||||
姓名 = bpnme,
|
||||
日期 = date,
|
||||
郵箱_1 = bpeml,
|
||||
// 郵箱_2 = bpem2,
|
||||
異常訊息 = checkResult.異常訊息
|
||||
};
|
||||
|
||||
supervisorItem.異常List.Add(abnormalItem);
|
||||
employeeWarning.Add(abnormalItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckPunchCardMonth(DateTime month, ref List<打卡異常Item> employeeWarning, ref List<通知督導Item> supervisorWarning)
|
||||
{
|
||||
DateTime date = new DateTime(month.Year, month.Month, 1);
|
||||
DateTime endDate = date.AddMonths(1);
|
||||
DateTime today = DateTime.UtcNow.AddHours(8).Date;
|
||||
while (date < endDate && date < today)
|
||||
{
|
||||
CheckPunchCard(date, ref employeeWarning, ref supervisorWarning);
|
||||
date = date.AddDays(1);
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
|
||||
public GetDataResponse DoBatchJob(string apiKey, string jobName, string test)
|
||||
{
|
||||
WQuery Query = SetupQuery();
|
||||
if (apiKey != "5D5F88D286A6479889B9DD986419A99C")
|
||||
{
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 400,
|
||||
Message = "Unauthorized"
|
||||
};
|
||||
}
|
||||
|
||||
var today = DateTime.UtcNow.AddHours(8).Date.AddDays(-1);
|
||||
List<打卡異常Item> employeeWarning = new List<打卡異常Item>();
|
||||
List<通知督導Item> supervisorWarning = new List<通知督導Item>();
|
||||
|
||||
switch (jobName.ToUpper())
|
||||
{
|
||||
case "CHECKPUNCHCARD": // 考勤檢查通知個人
|
||||
CheckPunchCard(today, ref employeeWarning, ref supervisorWarning);
|
||||
|
||||
// 發郵件給個人
|
||||
foreach (var w in employeeWarning)
|
||||
{
|
||||
var d = String.Format("{0:yyyy-MM-dd}", w.日期);
|
||||
|
||||
MailMessage mm = new MailMessage();
|
||||
mm.Subject = String.Format("{0} 打卡異常通知", d);
|
||||
if (!string.IsNullOrEmpty(w.郵箱_1))
|
||||
{
|
||||
mm.To.Add(new MailAddress(w.郵箱_1));
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
mm.BodyEncoding = Encoding.UTF8;
|
||||
mm.IsBodyHtml = true;
|
||||
mm.Body = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Template/出勤異常通知.html"))
|
||||
.Replace("{日期}", d)
|
||||
.Replace("{異常狀況}", w.異常訊息)
|
||||
;
|
||||
// 發送郵件
|
||||
try
|
||||
{
|
||||
Wellan.Service.WMailSender.GetInstance().Send(
|
||||
mm
|
||||
, string.Format("打卡異常通知 人員:{0} {1} 日期:{2} 異常:{3}", w.員工編號, w.姓名, d, w.異常訊息));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 0,
|
||||
// Data = Newtonsoft.Json.JsonConvert.SerializeObject(supervisorWarning)
|
||||
Data = "OK"
|
||||
};
|
||||
|
||||
case "CHECKPUNCHCARDMONTH": // 考勤檢查通知督導
|
||||
|
||||
if (today.AddDays(1).Day != 1 && string.Compare(test, "true") != 0)
|
||||
{
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 401,
|
||||
Data = "Not the end of month"
|
||||
};
|
||||
}
|
||||
|
||||
CheckPunchCardMonth(today, ref employeeWarning, ref supervisorWarning);
|
||||
|
||||
byte[] UTF8BOM = new byte[] { 0xEF, 0xBB, 0xBF };
|
||||
|
||||
foreach (var w in supervisorWarning)
|
||||
{
|
||||
if (w.督導List == null || w.督導List.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MailMessage mm = new MailMessage();
|
||||
mm.Subject = String.Format("{0:yyyy-MM} {1} {2} 專案打卡異常通知", today, w.專案年度號, w.專案名稱);
|
||||
foreach (var s in w.督導List)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(s.督導郵箱)) { mm.To.Add(new MailAddress(s.督導郵箱)); }
|
||||
}
|
||||
mm.BodyEncoding = Encoding.UTF8;
|
||||
mm.IsBodyHtml = true;
|
||||
mm.Body = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Template/出勤異常督導通知.html"))
|
||||
.Replace("{年月}", today.ToString("yyyy-MM"))
|
||||
.Replace("{專案編號}", w.專案年度號)
|
||||
.Replace("{專案名稱}", w.專案名稱)
|
||||
;
|
||||
|
||||
MemoryStream 出勤異常明細 = new MemoryStream();
|
||||
出勤異常明細.Write(UTF8BOM, 0, UTF8BOM.Length);
|
||||
byte[] b = Encoding.UTF8.GetBytes("\"日期\",\"員工編號\",\"姓名\",\"異常訊息\"\r\n");
|
||||
出勤異常明細.Write(b, 0, b.Length);
|
||||
foreach (var wp in w.異常List)
|
||||
{
|
||||
b = Encoding.UTF8.GetBytes(string.Format("\"{0:yyyy-MM-dd}\",=T(\"{1}\"),\"{2}\",\"{3}\"\r\n"
|
||||
, wp.日期, wp.員工編號, wp.姓名, wp.異常訊息));
|
||||
出勤異常明細.Write(b, 0, b.Length);
|
||||
}
|
||||
出勤異常明細.Position = 0;
|
||||
mm.Attachments.Add(new Attachment(出勤異常明細, string.Format(
|
||||
"打卡異常_{0:yyyy-MM}_{1}_{2}.csv", today, w.專案年度號, w.專案名稱)));
|
||||
|
||||
// 發送郵件
|
||||
try
|
||||
{
|
||||
Wellan.Service.WMailSender.GetInstance().Send(
|
||||
mm
|
||||
, string.Format("{0:yyyy-MM} {1} {2} 專案打卡異常通知", today, w.專案年度號, w.專案名稱));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
}
|
||||
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 0,
|
||||
// Data = Newtonsoft.Json.JsonConvert.SerializeObject(supervisorWarning)
|
||||
Data = "OK"
|
||||
};
|
||||
|
||||
default:
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 401,
|
||||
Message = "jobName required"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class 打卡異常Item
|
||||
{
|
||||
public string 員工編號 { get; set; }
|
||||
public string 姓名 { get; set; }
|
||||
public DateTime 日期 { get; set; }
|
||||
public string 郵箱_1 { get; set; }
|
||||
public string 郵箱_2 { get; set; }
|
||||
public string 異常訊息 { get; set; }
|
||||
}
|
||||
|
||||
public class 督導Item
|
||||
{
|
||||
public string 督導姓名 { get; set; }
|
||||
public string 督導郵箱 { get; set; }
|
||||
}
|
||||
|
||||
public class 通知督導Item
|
||||
{
|
||||
public string 專案年度號 { get; set; }
|
||||
public string 專案名稱 { get; set; }
|
||||
public List<督導Item> 督導List { get; set; }
|
||||
public List<打卡異常Item> 異常List { get; set; }
|
||||
|
||||
public 通知督導Item()
|
||||
{
|
||||
督導List = new List<督導Item>();
|
||||
異常List = new List<打卡異常Item>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 計算健保費
|
||||
/// </summary>
|
||||
public class Bhif : LaborAndHealthFee
|
||||
{
|
||||
private double _healthInsuranceFeeRate;
|
||||
private double _healthInsuranceAverageFamily;
|
||||
private double _oldHealthInsuranceFeeRate;
|
||||
|
||||
public Bhif(DateTime aDate) : base(aDate)
|
||||
{
|
||||
_bftyp = 2;
|
||||
_tableName = "BHIF";
|
||||
_healthInsuranceFeeRate = 0.0455d;
|
||||
_oldHealthInsuranceFeeRate = 0.0455d;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 健保費率
|
||||
/// </summary>
|
||||
public double HealthInsuranceFeeRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _healthInsuranceFeeRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_healthInsuranceFeeRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 健保平均眷口數
|
||||
/// </summary>
|
||||
public double HealthInsuranceAverageFamily
|
||||
{
|
||||
get
|
||||
{
|
||||
return _healthInsuranceAverageFamily;
|
||||
}
|
||||
set
|
||||
{
|
||||
_healthInsuranceAverageFamily = value;
|
||||
}
|
||||
}
|
||||
|
||||
public HealthInsuranceFee GetFee(int salary, int family, int family25, int family50, string disabled, bool hasHIF, string employeeType)
|
||||
{
|
||||
// 找出投保薪資
|
||||
HealthInsuranceFee fee = new HealthInsuranceFee();
|
||||
fee.Init();
|
||||
|
||||
// 不投健保,直接回傳
|
||||
if (!hasHIF)
|
||||
return fee;
|
||||
|
||||
// 新費率投保薪資
|
||||
double bsamt = GetAmont(salary);
|
||||
// 舊費率投保薪資
|
||||
double oldbsamt = GetAmont(new DateTime(2010, 3, 1) ,salary);
|
||||
|
||||
fee.InsuranceSalary = (Int32)bsamt;
|
||||
|
||||
if (bsamt > 0)
|
||||
{
|
||||
// 計算公司保費
|
||||
// 員工身份是雇主
|
||||
if (employeeType == "1")
|
||||
fee.CompanyFee = 0;
|
||||
// 員工身份是受雇員工
|
||||
else
|
||||
fee.CompanyFee = Convert.ToInt32(Math.Round(bsamt * _healthInsuranceFeeRate * 0.6d * (1d + _healthInsuranceAverageFamily), MidpointRounding.AwayFromZero));
|
||||
|
||||
// 計算個人保費
|
||||
double personalFee = 0;
|
||||
double oldPersonalFee = 0;
|
||||
|
||||
// 員工身份是雇主
|
||||
if (employeeType == "1")
|
||||
{
|
||||
personalFee = bsamt * _healthInsuranceFeeRate;
|
||||
oldPersonalFee = oldbsamt * _oldHealthInsuranceFeeRate;
|
||||
}
|
||||
// 員工身份是受雇員工
|
||||
else
|
||||
{
|
||||
personalFee = bsamt * _healthInsuranceFeeRate * 0.3d;
|
||||
oldPersonalFee = oldbsamt * _oldHealthInsuranceFeeRate * 0.3d;
|
||||
}
|
||||
|
||||
/*
|
||||
99/4/1 到 101/12/31 實施差額補助
|
||||
投保金額等級 所得水準 補助比率
|
||||
40,100元(含)以下 約5萬1千元(含)以下 100%
|
||||
42,000元至50,600元 約5萬3千元至6萬5千元 20%
|
||||
53,000元(含)以上 約6萬8千元(含)以上 0%
|
||||
*/
|
||||
|
||||
if (_baseDate.ToString("yyyyMM", WGuard1.InvariantCulture).CompareTo("201004") >= 0 &&
|
||||
_baseDate.ToString("yyyyMM", WGuard1.InvariantCulture).CompareTo("201301") < 0)
|
||||
{
|
||||
// 以月投保薪資計算補助比率
|
||||
if (bsamt <= 40100)
|
||||
{
|
||||
personalFee = oldPersonalFee;
|
||||
}
|
||||
else if (bsamt > 40100 && bsamt < 53000)
|
||||
{
|
||||
personalFee = personalFee - Convert.ToInt32(Math.Round((personalFee - oldPersonalFee) * 0.2d, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
}
|
||||
|
||||
int noDiscountFee = Convert.ToInt32(Math.Round(personalFee, MidpointRounding.AwayFromZero));
|
||||
int discount25Fee = Convert.ToInt32(Math.Truncate(Math.Round(personalFee, MidpointRounding.AwayFromZero) * 0.75d));
|
||||
int discount50Fee = Convert.ToInt32(Math.Truncate(Math.Round(personalFee, MidpointRounding.AwayFromZero) * 0.5d));
|
||||
int remainFamily = 3;
|
||||
|
||||
switch (disabled)
|
||||
{
|
||||
case "0": // 無
|
||||
fee.PersonalFee = noDiscountFee;
|
||||
break;
|
||||
case "1": // 輕度
|
||||
fee.PersonalFee = discount25Fee;
|
||||
break;
|
||||
case "2": // 中度
|
||||
fee.PersonalFee = discount50Fee;
|
||||
break;
|
||||
case "3": // 重度
|
||||
fee.PersonalFee = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// 加上一般眷口
|
||||
fee.PersonalFee += noDiscountFee * (family > remainFamily ? (remainFamily > 0 ? remainFamily : 0) : family);
|
||||
remainFamily -= family;
|
||||
|
||||
// 加上減免25%眷口
|
||||
fee.PersonalFee += (discount25Fee) * (family25 > remainFamily ? (remainFamily > 0 ? remainFamily : 0) : family25);
|
||||
remainFamily -= family25;
|
||||
|
||||
// 加上減免50%眷口
|
||||
fee.PersonalFee += (discount50Fee) * (family50 > remainFamily ? (remainFamily > 0 ? remainFamily : 0) : family50);
|
||||
}
|
||||
|
||||
return fee;
|
||||
}
|
||||
}
|
||||
|
||||
public struct HealthInsuranceFee
|
||||
{
|
||||
public int InsuranceSalary;
|
||||
public int PersonalFee;
|
||||
public int CompanyFee;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
InsuranceSalary = 0;
|
||||
PersonalFee = 0;
|
||||
CompanyFee = 0;
|
||||
}
|
||||
|
||||
public void Assign(HealthInsuranceFee fee)
|
||||
{
|
||||
InsuranceSalary = fee.InsuranceSalary;
|
||||
PersonalFee = fee.PersonalFee;
|
||||
CompanyFee = fee.CompanyFee;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 計算勞保費
|
||||
/// </summary>
|
||||
public class Blif : LaborAndHealthFee
|
||||
{
|
||||
private int _inWorkDays;
|
||||
private int _insuranceSalary;
|
||||
private int _injurySalary;
|
||||
private decimal _normalPersonalFee;
|
||||
private decimal _normalCompanyFee;
|
||||
private decimal _lostJobPersonalFee;
|
||||
private decimal _lostJobCompanyFee;
|
||||
private decimal _injuryCompanyFee;
|
||||
private decimal _disableNormalSupport;
|
||||
private decimal _disableLostJobSupport;
|
||||
private decimal _salaryReverseFund;
|
||||
|
||||
private double _normalFeeRate;
|
||||
private double _lostJobFeeRate;
|
||||
private double _salaryReverseFundRate;
|
||||
private double _injuryCompanyFeeRate;
|
||||
|
||||
// 職災級距表
|
||||
private Dictionary<DateTime, List<LHFClass>> _bljiAmtData;
|
||||
|
||||
public Blif(DateTime aDate) : base(aDate)
|
||||
{
|
||||
_bftyp = 1;
|
||||
_tableName = "BLIF";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 普通事故費率
|
||||
/// </summary>
|
||||
public double NormalFeeRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _normalFeeRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_normalFeeRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 就業保險費率
|
||||
/// </summary>
|
||||
public double LostJobFeeRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lostJobFeeRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_lostJobFeeRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工資墊償基金費率
|
||||
/// </summary>
|
||||
public double SalaryReverseFundRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _salaryReverseFundRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_salaryReverseFundRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 職災保險費率
|
||||
/// </summary>
|
||||
public double InjuryFeeRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _injuryCompanyFeeRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_injuryCompanyFeeRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LaborInsuranceFee GetFee()
|
||||
{
|
||||
LaborInsuranceFee fee = new LaborInsuranceFee();
|
||||
fee.Init();
|
||||
|
||||
fee.InWorkDays = _inWorkDays;
|
||||
fee.InsuranceSalary = _insuranceSalary;
|
||||
fee.InjurySalary = _injurySalary;
|
||||
fee.NormalPersonalFee = _normalPersonalFee;
|
||||
fee.NormalCompanyFee = _normalCompanyFee;
|
||||
fee.LostJobPersonalFee = _lostJobPersonalFee;
|
||||
fee.LostJobCompanyFee = _lostJobCompanyFee;
|
||||
fee.InjuryCompanyFee = _injuryCompanyFee;
|
||||
fee.DisableNormalSupport = _disableNormalSupport;
|
||||
fee.DisableLostJobSupport = _disableLostJobSupport;
|
||||
fee.SalaryReverseFund = _salaryReverseFund;
|
||||
|
||||
return fee;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_inWorkDays = 0;
|
||||
_insuranceSalary = 0;
|
||||
_injurySalary = 0;
|
||||
_normalPersonalFee = 0;
|
||||
_normalCompanyFee = 0;
|
||||
_lostJobPersonalFee = 0;
|
||||
_lostJobCompanyFee = 0;
|
||||
_injuryCompanyFee = 0;
|
||||
_disableNormalSupport = 0;
|
||||
_disableLostJobSupport = 0;
|
||||
_salaryReverseFund = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得職災級距表
|
||||
/// </summary>
|
||||
/// <param name="aDate">日期</param>
|
||||
private void GetBLJIData(DateTime aDate)
|
||||
{
|
||||
if (this._bljiAmtData == null)
|
||||
_bljiAmtData = new Dictionary<DateTime, List<LHFClass>>();
|
||||
|
||||
if (!_bljiAmtData.ContainsKey(aDate))
|
||||
{
|
||||
List<LHFClass> _newAmtDataItem = new List<LHFClass>();
|
||||
|
||||
// 取得適用級距表版本
|
||||
DataTable _verData = _query.Select("SELECT * FROM BFDT WHERE BFTYP=4 ORDER BY BFVER");
|
||||
int version = 0;
|
||||
|
||||
foreach (System.Data.DataRow row in _verData.Rows)
|
||||
{
|
||||
if (aDate.CompareTo(row["BFSDT"]) >= 0 && (row["BFEDT"] == DBNull.Value || aDate.CompareTo(row["BFEDT"]) <= 0))
|
||||
{
|
||||
version = Convert.ToInt32(row["BFVER"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 取得該版本的級距表
|
||||
DataTable data = _query.Select(String.Format("SELECT * FROM BLJI WHERE BSVER={0} ORDER BY BSLVL", version));
|
||||
|
||||
for (int i = 0; i < data.Rows.Count; i++)
|
||||
{
|
||||
_newAmtDataItem.Add(new LHFClass(Convert.ToInt32(data.Rows[i]["BSLOW"]),
|
||||
Convert.ToInt32(data.Rows[i]["BSHIH"]),
|
||||
Convert.ToInt32(data.Rows[i]["BSAMT"])));
|
||||
}
|
||||
|
||||
_bljiAmtData.Add(aDate, _newAmtDataItem);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得職災保險投保薪資
|
||||
/// </summary>
|
||||
/// <param name="aDate">日期</param>
|
||||
/// <param name="salary">薪資</param>
|
||||
/// <returns></returns>
|
||||
protected double GetBLJIAmt(DateTime aDate, int salary)
|
||||
{
|
||||
GetBLJIData(aDate);
|
||||
|
||||
double bsamt = 0;
|
||||
for (int i = 0; i < _amtData[aDate].Count; i++)
|
||||
{
|
||||
if (salary >= _amtData[aDate][i].Low && salary <= _amtData[aDate][i].High)
|
||||
{
|
||||
bsamt = _amtData[aDate][i].Amt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bsamt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得職災保險投保薪資
|
||||
/// </summary>
|
||||
/// <param name="salary">薪資</param>
|
||||
/// <returns></returns>
|
||||
protected double GetBLJIAmt(int salary)
|
||||
{
|
||||
return GetBLJIAmt(_baseDate, salary);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 計算並加入一段時間段的勞保費
|
||||
/// </summary>
|
||||
/// <param name="salary">投保薪資</param>
|
||||
/// <param name="startDay">時間段起日</param>
|
||||
/// <param name="endDay">時間段迄日</param>
|
||||
/// <param name="goOut">退保</param>
|
||||
/// <param name="disable">身障補助</param>
|
||||
/// <param name="hasLIF">有勞保</param>
|
||||
/// <param name="retired">已領老年給付</param>
|
||||
/// <param name="over65">超過65歲</param>
|
||||
/// <param name="employeeType">員工類型</param>
|
||||
/// <param name="nation">員工國籍 1=本國籍 2=外國籍</param>
|
||||
/// <param name="thisMonthLaborDays">本段時間勞保出席天數</param>
|
||||
public void Add(int salary, DateTime startDay, DateTime endDay, bool goOut, string disable,
|
||||
bool hasLIF, bool retired, bool over65, string employeeType, string nation,
|
||||
ref int thisMonthLaborDays)
|
||||
{
|
||||
// 無勞保,不處理
|
||||
if (!hasLIF)
|
||||
return;
|
||||
|
||||
// 勞保、勞退計算基準
|
||||
double bsamt = GetAmont(salary);
|
||||
|
||||
double daysRatio = 0;
|
||||
int days = 0;
|
||||
int monthEndDay = startDay.AddMonths(1).AddDays(-startDay.Day).Day;
|
||||
_insuranceSalary = Convert.ToInt32(bsamt);
|
||||
|
||||
if (bsamt > 0)
|
||||
{
|
||||
// 整月
|
||||
if (startDay.Day == 1 && endDay.Day == monthEndDay)
|
||||
{
|
||||
days = 30;
|
||||
// 若二月,且退保,要算至月底的實際天數
|
||||
if (goOut && endDay.Month == 2)
|
||||
days = monthEndDay;
|
||||
}
|
||||
// 非整月
|
||||
else
|
||||
{
|
||||
// 結束日是月底日
|
||||
if (endDay.Day == monthEndDay)
|
||||
{
|
||||
if (startDay.Day == 30 || startDay.Day == 31)
|
||||
days = 1;
|
||||
else
|
||||
days = 30 - startDay.Day + 1;
|
||||
|
||||
// 若二月,且退保,要算至月底的實際天數
|
||||
if (goOut && endDay.Month == 2)
|
||||
{
|
||||
days -= (30 - monthEndDay);
|
||||
}
|
||||
}
|
||||
else
|
||||
// 結束日非月底日
|
||||
{
|
||||
days = endDay.Day - startDay.Day + 1;
|
||||
}
|
||||
if (days > 30 - thisMonthLaborDays)
|
||||
days = 30 - thisMonthLaborDays;
|
||||
}
|
||||
|
||||
_inWorkDays += days;
|
||||
thisMonthLaborDays += days;
|
||||
daysRatio = Convert.ToDouble(days) / 30d;
|
||||
|
||||
decimal _thisNormalPersonalFee = 0;
|
||||
decimal _thisNormalCompanyFee = 0;
|
||||
decimal _thisLostJobPersonalFee = 0;
|
||||
decimal _thisLostJobCompanyFee = 0;
|
||||
|
||||
if (!retired)
|
||||
{
|
||||
// 員工身份是雇主:
|
||||
if (employeeType == "1")
|
||||
{
|
||||
// 計算普通事故保費
|
||||
_thisNormalPersonalFee = Convert.ToDecimal(Math.Round(bsamt * _normalFeeRate * daysRatio * 0.2d, 4, MidpointRounding.AwayFromZero));
|
||||
_thisNormalCompanyFee = Convert.ToDecimal(Math.Round(bsamt * _normalFeeRate * daysRatio * 0.7d, 4, MidpointRounding.AwayFromZero));
|
||||
|
||||
// 計算就業保險保費
|
||||
_thisLostJobPersonalFee = 0;
|
||||
_thisLostJobCompanyFee = 0;
|
||||
}
|
||||
// 員工身份是一般勞工:
|
||||
else
|
||||
{
|
||||
// 計算普通事故保費
|
||||
_thisNormalPersonalFee = Convert.ToDecimal(Math.Round(bsamt * _normalFeeRate * daysRatio * 0.2d, 4, MidpointRounding.AwayFromZero));
|
||||
_thisNormalCompanyFee = Convert.ToDecimal(Math.Round(bsamt * _normalFeeRate * daysRatio * 0.7d, 4, MidpointRounding.AwayFromZero));
|
||||
|
||||
// 計算就業保險保費,本國籍員工,未滿65歲才需要
|
||||
if (nation == "1" && !over65)
|
||||
{
|
||||
_thisLostJobPersonalFee = Convert.ToDecimal(Math.Round(bsamt * _lostJobFeeRate * daysRatio * 0.2d, 4, MidpointRounding.AwayFromZero));
|
||||
_thisLostJobCompanyFee = Convert.ToDecimal(Math.Round(bsamt * _lostJobFeeRate * daysRatio * 0.7d, 4, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
}
|
||||
}
|
||||
_normalPersonalFee += _thisNormalPersonalFee;
|
||||
_normalCompanyFee += _thisNormalCompanyFee;
|
||||
_lostJobPersonalFee += _thisLostJobPersonalFee;
|
||||
_lostJobCompanyFee += _thisLostJobCompanyFee;
|
||||
|
||||
// 計算身心障礙補助
|
||||
switch (disable)
|
||||
{
|
||||
case "0": // 無
|
||||
break;
|
||||
case "1": // 輕度
|
||||
_disableNormalSupport = Math.Round((_thisNormalPersonalFee) * 0.25m, MidpointRounding.AwayFromZero);
|
||||
_disableLostJobSupport = Math.Round((_thisLostJobPersonalFee) * 0.25m, MidpointRounding.AwayFromZero);
|
||||
break;
|
||||
case "2": // 中度
|
||||
_disableNormalSupport = Math.Round((_thisNormalPersonalFee) * 0.5m, MidpointRounding.AwayFromZero);
|
||||
_disableLostJobSupport = Math.Round((_thisLostJobPersonalFee) * 0.5m, MidpointRounding.AwayFromZero);
|
||||
break;
|
||||
case "3": // 重度
|
||||
case "4": // 極重度
|
||||
_disableNormalSupport = _thisNormalPersonalFee;
|
||||
_disableLostJobSupport = _thisLostJobPersonalFee;
|
||||
break;
|
||||
}
|
||||
|
||||
// 計算職災保險保費
|
||||
double bljiAmt = GetBLJIAmt(salary);
|
||||
_injurySalary = Convert.ToInt32(bljiAmt);
|
||||
_injuryCompanyFee += Convert.ToDecimal(Math.Round(bljiAmt * _injuryCompanyFeeRate * daysRatio, 4, MidpointRounding.AwayFromZero));
|
||||
|
||||
// 計算工資墊償基金
|
||||
// 員工身份是雇主:
|
||||
if (employeeType == "1")
|
||||
{
|
||||
_salaryReverseFund += 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_salaryReverseFund += Convert.ToDecimal(Math.Round(bsamt * daysRatio * _salaryReverseFundRate, 4, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 勞保費
|
||||
/// </summary>
|
||||
public struct LaborInsuranceFee
|
||||
{
|
||||
/// <summary>
|
||||
/// 到職天數
|
||||
/// </summary>
|
||||
public int InWorkDays;
|
||||
/// <summary>
|
||||
/// 投保薪資
|
||||
/// </summary>
|
||||
public int InsuranceSalary;
|
||||
/// <summary>
|
||||
/// 職災投保薪資
|
||||
/// </summary>
|
||||
public int InjurySalary;
|
||||
/// <summary>
|
||||
/// 普通事故個人保費
|
||||
/// </summary>
|
||||
public decimal NormalPersonalFee;
|
||||
/// <summary>
|
||||
/// 普通事故公司保費
|
||||
/// </summary>
|
||||
public decimal NormalCompanyFee;
|
||||
/// <summary>
|
||||
/// 就業保險個人保費
|
||||
/// </summary>
|
||||
public decimal LostJobPersonalFee;
|
||||
/// <summary>
|
||||
/// 就業保險公司保費
|
||||
/// </summary>
|
||||
public decimal LostJobCompanyFee;
|
||||
/// <summary>
|
||||
/// 職災保費
|
||||
/// </summary>
|
||||
public decimal InjuryCompanyFee;
|
||||
/// <summary>
|
||||
/// 身障補助
|
||||
/// </summary>
|
||||
public decimal DisableNormalSupport;
|
||||
/// <summary>
|
||||
/// 身障補助
|
||||
/// </summary>
|
||||
public decimal DisableLostJobSupport;
|
||||
/// <summary>
|
||||
/// 工資墊償基金
|
||||
/// </summary>
|
||||
public decimal SalaryReverseFund;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
InWorkDays = 0;
|
||||
InsuranceSalary = 0;
|
||||
InjurySalary = 0;
|
||||
NormalCompanyFee = 0;
|
||||
NormalPersonalFee = 0;
|
||||
LostJobCompanyFee = 0;
|
||||
LostJobPersonalFee = 0;
|
||||
InjuryCompanyFee = 0;
|
||||
DisableNormalSupport = 0;
|
||||
DisableLostJobSupport = 0;
|
||||
SalaryReverseFund = 0;
|
||||
}
|
||||
|
||||
public void Add(LaborInsuranceFee fee)
|
||||
{
|
||||
InWorkDays += fee.InWorkDays;
|
||||
InsuranceSalary = fee.InsuranceSalary;
|
||||
InjurySalary = fee.InjurySalary;
|
||||
NormalCompanyFee += fee.NormalCompanyFee;
|
||||
NormalPersonalFee += fee.NormalPersonalFee;
|
||||
LostJobCompanyFee += fee.LostJobCompanyFee;
|
||||
LostJobPersonalFee += fee.LostJobPersonalFee;
|
||||
InjuryCompanyFee += fee.InjuryCompanyFee;
|
||||
DisableNormalSupport += fee.DisableNormalSupport;
|
||||
DisableLostJobSupport += fee.DisableLostJobSupport;
|
||||
SalaryReverseFund += fee.SalaryReverseFund;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 個人總保費
|
||||
/// </summary>
|
||||
public int TotalPersonalFee
|
||||
{
|
||||
// { 四捨五入(普通事故) + 四捨五入(就業保險) }
|
||||
//- { 四捨五入(普通事故減免) + 四捨五入(就業保險減免) }
|
||||
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(Math.Round(NormalPersonalFee, MidpointRounding.AwayFromZero))
|
||||
+ Convert.ToInt32(Math.Round(LostJobPersonalFee, MidpointRounding.AwayFromZero))
|
||||
- Convert.ToInt32(Math.Round(DisableNormalSupport, MidpointRounding.AwayFromZero))
|
||||
- Convert.ToInt32(Math.Round(DisableLostJobSupport, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 計算勞退金
|
||||
/// </summary>
|
||||
public class Blra : LaborAndHealthFee
|
||||
{
|
||||
private int _annuitySalary;
|
||||
private double _companyFee;
|
||||
private double _personalFee;
|
||||
private int _inworkdays;
|
||||
|
||||
public Blra(DateTime aDate)
|
||||
: base(aDate)
|
||||
{
|
||||
_bftyp = 3;
|
||||
_tableName = "BLRA";
|
||||
}
|
||||
|
||||
public LaborRetireAnnuity GetFee()
|
||||
{
|
||||
LaborRetireAnnuity fee = new LaborRetireAnnuity();
|
||||
fee.Init();
|
||||
fee.CompanyFee = Convert.ToInt32(Math.Round(_companyFee, MidpointRounding.AwayFromZero));
|
||||
fee.PersonalFee = Convert.ToInt32(Math.Round(_personalFee, MidpointRounding.AwayFromZero));
|
||||
fee.AnnuitySalary = _annuitySalary;
|
||||
return fee;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_annuitySalary = 0;
|
||||
_companyFee = 0;
|
||||
_personalFee = 0;
|
||||
_inworkdays = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 計算勞退提撥,並加入 Blra 的執行個體中
|
||||
/// </summary>
|
||||
/// <param name="salary">月薪</param>
|
||||
/// <param name="startDay">本月在職起始日</param>
|
||||
/// <param name="endDay">本月在職結束日</param>
|
||||
/// <param name="personalRate">個人提繳率</param>
|
||||
/// <param name="employeeType">員工類別 1=雇主 2=員工</param>
|
||||
/// <param name="thisMonthDays">本月到職天數</param>
|
||||
/// <param name="nation">員工國籍 1=本國籍 2=外國籍</param>
|
||||
public void Add(int salary, DateTime startDay, DateTime endDay, int personalRate, string employeeType, int thisMonthDays, string nation)
|
||||
{
|
||||
// 外國籍員工沒有勞退提撥
|
||||
if (nation == "2")
|
||||
return;
|
||||
|
||||
double bsamt = GetAmont(salary);
|
||||
double daysRatio = 0;
|
||||
int days = 0;
|
||||
int monthEndDay = WGuard1.GetMonthEnd(startDay, 0).Day;
|
||||
_annuitySalary = Convert.ToInt32(bsamt);
|
||||
|
||||
if (bsamt > 0)
|
||||
{
|
||||
// 月初日到月底日
|
||||
if (startDay.Day == 1 && endDay.Day == monthEndDay)
|
||||
{
|
||||
days = 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 結束日是月底日
|
||||
if (endDay.Day == monthEndDay)
|
||||
{
|
||||
if (startDay.Day == 30 || startDay.Day == 31)
|
||||
days = 1;
|
||||
else
|
||||
days = 30 - startDay.Day + 1;
|
||||
}
|
||||
else
|
||||
// 結束日非月底日
|
||||
{
|
||||
days = endDay.Day - startDay.Day + 1;
|
||||
}
|
||||
if (days > 30)
|
||||
days = 30;
|
||||
}
|
||||
|
||||
/*
|
||||
// 月初日到月底日,以 30 天計算
|
||||
if (startDay.Day == 1 && endDay.Day == monthEndDay)
|
||||
{
|
||||
days = 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 結束日是月底日,用 30 去減
|
||||
//if (endDay.Day == monthEndDay)
|
||||
// days = 30 - startDay.Day + 1;
|
||||
// 結束日非月底日,用實際結束日去減
|
||||
//else
|
||||
days = endDay.Day - startDay.Day + 1;
|
||||
// 調整天數,最多 30 天
|
||||
if (days > 30)
|
||||
days = 30;
|
||||
}
|
||||
*/
|
||||
|
||||
// 若本月累計天數 > 30 則減去多出的天數
|
||||
if (_inworkdays + days > 30)
|
||||
days = 30 - _inworkdays;
|
||||
_inworkdays += days;
|
||||
|
||||
daysRatio = Convert.ToDouble(days) / 30d;
|
||||
|
||||
// 計算公司提撥
|
||||
if (employeeType == "1") // 員工身份是雇主
|
||||
_companyFee += 0;
|
||||
else
|
||||
_companyFee += Math.Round(bsamt * 0.06 * daysRatio, 4, MidpointRounding.AwayFromZero);
|
||||
|
||||
// 計算個人提撥
|
||||
_personalFee += Math.Round(bsamt * ((double)personalRate / 100) * daysRatio, 4, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct LaborRetireAnnuity
|
||||
{
|
||||
public int CompanyFee;
|
||||
public int PersonalFee;
|
||||
public int AnnuitySalary;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
AnnuitySalary = 0;
|
||||
CompanyFee = 0;
|
||||
PersonalFee = 0;
|
||||
}
|
||||
|
||||
public void Add(LaborRetireAnnuity fee)
|
||||
{
|
||||
AnnuitySalary = fee.AnnuitySalary;
|
||||
CompanyFee += fee.CompanyFee;
|
||||
PersonalFee += fee.PersonalFee;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,931 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// 計算勞健保費基礎類別
|
||||
/// </summary>
|
||||
public class LaborAndHealthFee
|
||||
{
|
||||
protected WQuery _query;
|
||||
protected DateTime _baseDate;
|
||||
protected Dictionary<DateTime, List<LHFClass>> _amtData;
|
||||
protected int _bftyp;
|
||||
protected string _tableName;
|
||||
|
||||
/// <param name="aDate">計算日期</param>
|
||||
public LaborAndHealthFee(DateTime baseDate)
|
||||
{
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
WConnectionString.ConnectionConfigName = WConfig.GetConnectionConfigName();
|
||||
_query = new WQuery(WConnectionString.GetConnectionType(), WConnectionString.GetConnectionString());
|
||||
_baseDate = baseDate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得特定日期的級距表
|
||||
/// </summary>
|
||||
/// <param name="aDate"></param>
|
||||
protected void GetData(DateTime aDate)
|
||||
{
|
||||
if (_amtData == null)
|
||||
_amtData = new Dictionary<DateTime,List<LHFClass>>();
|
||||
|
||||
if (!_amtData.ContainsKey(aDate))
|
||||
{
|
||||
List<LHFClass> _newAmtDataItem = new List<LHFClass>();
|
||||
|
||||
// 取得適用級距表版本
|
||||
DataTable _verData = _query.Select(String.Format("SELECT * FROM BFDT WHERE BFTYP={0} ORDER BY BFVER", _bftyp));
|
||||
int version = 0;
|
||||
|
||||
foreach (System.Data.DataRow row in _verData.Rows)
|
||||
{
|
||||
if (aDate.CompareTo(row["BFSDT"]) >= 0 && (row["BFEDT"] == DBNull.Value || aDate.CompareTo(row["BFEDT"]) <= 0))
|
||||
{
|
||||
version = Convert.ToInt32(row["BFVER"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 取得該版本的級距表
|
||||
DataTable data = _query.Select(String.Format("SELECT * FROM {1} WHERE BSVER={0} ORDER BY BSLVL", version, _tableName));
|
||||
|
||||
for (int i = 0; i < data.Rows.Count; i++)
|
||||
{
|
||||
_newAmtDataItem.Add(new LHFClass(Convert.ToInt32(data.Rows[i]["BSLOW"]),
|
||||
Convert.ToInt32(data.Rows[i]["BSHIH"]),
|
||||
Convert.ToInt32(data.Rows[i]["BSAMT"])));
|
||||
}
|
||||
|
||||
_amtData.Add(aDate, _newAmtDataItem);
|
||||
}
|
||||
}
|
||||
|
||||
// 取得目前級距表
|
||||
protected void GetData()
|
||||
{
|
||||
GetData(_baseDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以特定日期適用的級距表,取得特定日期適用的投保薪資
|
||||
/// </summary>
|
||||
/// <param name="aDate"></param>
|
||||
/// <param name="salary"></param>
|
||||
/// <returns></returns>
|
||||
protected double GetAmont(DateTime aDate, int salary)
|
||||
{
|
||||
GetData(aDate);
|
||||
|
||||
double bsamt = 0;
|
||||
for (int i = 0; i < _amtData[aDate].Count; i++)
|
||||
{
|
||||
if (salary >= _amtData[aDate][i].Low && salary <= _amtData[aDate][i].High)
|
||||
{
|
||||
bsamt = _amtData[aDate][i].Amt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return bsamt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以目前級距表,取得投保薪資
|
||||
/// </summary>
|
||||
/// <param name="salary"></param>
|
||||
/// <returns></returns>
|
||||
protected double GetAmont(int salary)
|
||||
{
|
||||
return GetAmont(_baseDate, salary);
|
||||
}
|
||||
|
||||
protected struct LHFClass
|
||||
{
|
||||
public int Low;
|
||||
public int High;
|
||||
public int Amt;
|
||||
|
||||
public LHFClass(int aLow, int aHigh, int aAmt)
|
||||
{
|
||||
Low = aLow;
|
||||
High = aHigh;
|
||||
Amt = aAmt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 計算時數的類別
|
||||
/// </summary>
|
||||
public class TimeCalc
|
||||
{
|
||||
public string 上班時間;
|
||||
public string 下班時間;
|
||||
public string 午休開始;
|
||||
public string 午休結束;
|
||||
public int 上班分鐘數;
|
||||
public int 午休分鐘數;
|
||||
public bool 彈性上班時間;
|
||||
private BhrdDAC bhrdDao = new BhrdDAC(WGuard1.Query);
|
||||
private RtmeDAC rtmeDao = new RtmeDAC(WGuard1.Query);
|
||||
private BpsnDAC bpsnDao = new BpsnDAC(WGuard1.Query);
|
||||
private BpaaDAC bpaaDao = new BpaaDAC(WGuard1.Query);
|
||||
private BtmeDAC btmeDao = new BtmeDAC(WGuard1.Query);
|
||||
|
||||
public TimeCalc()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 計算時數之前取得各個時間點
|
||||
/// </summary>
|
||||
/// <param name="員工編號"></param>
|
||||
/// <param name="日期"></param>
|
||||
public void Init(string 員工編號, DateTime 日期)
|
||||
{
|
||||
上班時間 = WGuard1.WSetR("UNRPARTIME", 1);
|
||||
下班時間 = WGuard1.WSetR("UNRPARTIME", 2);
|
||||
午休開始 = WGuard1.WSetR("UNRPARTIME", 3);
|
||||
午休結束 = WGuard1.WSetR("UNRPARTIME", 4);
|
||||
彈性上班時間 = WGuard1.WSetR("彈性上班時間", 1) == "Y";
|
||||
|
||||
// 取員工班表
|
||||
var btmeItem = rtmeDao.SelectBtmeDay(員工編號, 日期);
|
||||
if (btmeItem != null && !String.IsNullOrEmpty(btmeItem.BTSTM) && !String.IsNullOrEmpty(btmeItem.BTETM)
|
||||
&& !String.IsNullOrEmpty(btmeItem.BTRST) && !String.IsNullOrEmpty(btmeItem.BTRED))
|
||||
{
|
||||
上班時間 = btmeItem.BTSTM;
|
||||
下班時間 = btmeItem.BTETM;
|
||||
午休開始 = btmeItem.BTRST;
|
||||
午休結束 = btmeItem.BTRED;
|
||||
}
|
||||
// 若員工班表沒有設定,則取專案預設班表
|
||||
else
|
||||
{
|
||||
// 取員工專案年度接單編號
|
||||
var rapyn = bpsnDao.GetProjectByDate(員工編號, 日期);
|
||||
if (!String.IsNullOrEmpty(rapyn))
|
||||
{
|
||||
// 取專案預設班表編號
|
||||
var bptme = bpaaDao.GetTimeTableNo(rapyn);
|
||||
if (!String.IsNullOrEmpty(bptme))
|
||||
{
|
||||
// 取班表
|
||||
btmeItem = btmeDao.SelectOne(bptme).FirstOrDefault();
|
||||
if (btmeItem != null && !String.IsNullOrEmpty(btmeItem.BTSTM) && !String.IsNullOrEmpty(btmeItem.BTETM)
|
||||
&& !String.IsNullOrEmpty(btmeItem.BTRST) && !String.IsNullOrEmpty(btmeItem.BTRED))
|
||||
{
|
||||
上班時間 = btmeItem.BTSTM;
|
||||
下班時間 = btmeItem.BTETM;
|
||||
午休開始 = btmeItem.BTRST;
|
||||
午休結束 = btmeItem.BTRED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
上班分鐘數 = 計算分鐘數(上班時間, 下班時間) - 計算分鐘數(午休開始, 午休結束);
|
||||
午休分鐘數 = 計算分鐘數(午休開始, 午休結束);
|
||||
}
|
||||
|
||||
public static int 進整小時(int 分鐘)
|
||||
{
|
||||
double 渣渣 = ((double)分鐘 / 30d) % 1d;
|
||||
|
||||
if (渣渣 > 0.5d)
|
||||
return (分鐘 / 60 + 1) * 60;
|
||||
else
|
||||
return (分鐘 / 60) * 60;
|
||||
}
|
||||
|
||||
public static int 進半小時(int 分鐘)
|
||||
{
|
||||
double 渣渣 = ((double)分鐘 / 15d) % 1d;
|
||||
|
||||
if (渣渣 > 0.5d)
|
||||
return (分鐘 / 30 + 1) * 30;
|
||||
else
|
||||
return (分鐘 / 30) * 30;
|
||||
}
|
||||
|
||||
public static int 計算分鐘數(string tm1, string tm2)
|
||||
{
|
||||
DateTime dt1 = new DateTime();
|
||||
DateTime dt2 = new DateTime();
|
||||
dt1 = dt1.AddHours(Convert.ToInt32((tm1 + "00:00").Substring(0, 2))).AddMinutes(Convert.ToInt32((tm1 + "00:00").Substring(3, 2)));
|
||||
dt2 = dt2.AddHours(Convert.ToInt32((tm2 + "00:00").Substring(0, 2))).AddMinutes(Convert.ToInt32((tm2 + "00:00").Substring(3, 2)));
|
||||
|
||||
return Convert.ToInt32((dt2 - dt1).TotalMinutes);
|
||||
}
|
||||
|
||||
public static string 加分鐘數(string tm1, int minutes)
|
||||
{
|
||||
DateTime dt1 = new DateTime();
|
||||
dt1 = dt1.AddHours(Convert.ToInt32((tm1 + "00:00").Substring(0, 2))).AddMinutes(Convert.ToInt32((tm1 + "00:00").Substring(3, 2)));
|
||||
dt1 = dt1.AddMinutes(minutes);
|
||||
|
||||
return dt1.ToString("HH:mm");
|
||||
}
|
||||
|
||||
public int 計算午休分鐘數(string 起時, string 迄時)
|
||||
{
|
||||
if (起時.CompareTo(午休開始) <= 0 && 迄時.CompareTo(午休結束) >= 0)
|
||||
return 午休分鐘數;
|
||||
else if (起時.CompareTo(午休開始) >= 0 && 起時.CompareTo(午休結束) <= 0 && 迄時.CompareTo(午休結束) >= 0)
|
||||
return 計算分鐘數(起時, 午休結束);
|
||||
else if (起時.CompareTo(午休開始) <= 0 && 迄時.CompareTo(午休開始) >= 0 && 迄時.CompareTo(午休結束) <= 0)
|
||||
return 計算分鐘數(午休開始, 迄時);
|
||||
else if (起時.CompareTo(午休開始) >= 0 && 起時.CompareTo(午休結束) <= 0 && 迄時.CompareTo(午休開始) >= 0 && 迄時.CompareTo(午休結束) <= 0)
|
||||
return 計算分鐘數(起時, 迄時);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int 計算請假總時數(string 員工編號, DateTime 起日, DateTime 迄日, string 起時, string 迄時, string 假別, bool is進整小時)
|
||||
{
|
||||
Init(員工編號, 起日);
|
||||
|
||||
if (String.IsNullOrEmpty(起時))
|
||||
起時 = 上班時間;
|
||||
if (String.IsNullOrEmpty(迄時))
|
||||
迄時 = 下班時間;
|
||||
|
||||
int 分鐘數;
|
||||
|
||||
// 起始與結束同一天
|
||||
if (起日 == 迄日)
|
||||
{
|
||||
分鐘數 = 計算分鐘數(起時, 迄時) - 計算午休分鐘數(起時, 迄時);
|
||||
}
|
||||
// 起始與結束不同天
|
||||
else
|
||||
{
|
||||
DateTime std = 起日;
|
||||
分鐘數 = 0;
|
||||
|
||||
while (std <= 迄日)
|
||||
{
|
||||
Init(員工編號, std);
|
||||
|
||||
// 不是假日,或是產假,要列入時數計算
|
||||
if (!bhrdDao.IsHoliday(員工編號, std) || 假別 == RPAR_TYPE.T05_產假)
|
||||
{
|
||||
// 第一天
|
||||
if (std == 起日)
|
||||
{
|
||||
分鐘數 += 計算分鐘數(起時, 下班時間) - 計算午休分鐘數(起時, 下班時間);
|
||||
}
|
||||
// 最後一天
|
||||
else if (std == 迄日)
|
||||
{
|
||||
分鐘數 += 計算分鐘數(上班時間, 迄時) - 計算午休分鐘數(上班時間, 迄時);
|
||||
}
|
||||
// 中間其他天
|
||||
else
|
||||
{
|
||||
分鐘數 += 上班分鐘數;
|
||||
}
|
||||
}
|
||||
|
||||
std = std.AddDays(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (is進整小時)
|
||||
分鐘數 = 進半小時(分鐘數);
|
||||
return 分鐘數;
|
||||
}
|
||||
|
||||
public int 計算請假跨日數(string 員工編號, DateTime 起日, DateTime 迄日, string 假別)
|
||||
{
|
||||
// 起始與結束同一天
|
||||
if (起日 == 迄日)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
// 起始與結束不同天
|
||||
else
|
||||
{
|
||||
DateTime std = 起日;
|
||||
int 天數 = 0;
|
||||
|
||||
while (std <= 迄日)
|
||||
{
|
||||
// 不是假日,或是產假,要列入時數計算
|
||||
if (!bhrdDao.IsHoliday(員工編號, std) || 假別 == RPAR_TYPE.T05_產假)
|
||||
{
|
||||
天數++;
|
||||
}
|
||||
std = std.AddDays(1);
|
||||
}
|
||||
return 天數;
|
||||
}
|
||||
}
|
||||
|
||||
public int 計算請假當日時數(string 員工編號, DateTime 日期, DateTime 起日, DateTime 迄日, string 起時, string 迄時, string 假別, bool is進整小時)
|
||||
{
|
||||
int 當日分鐘數 = 0;
|
||||
|
||||
// 起始與結束同一天
|
||||
if (起日 == 迄日)
|
||||
{
|
||||
Init(員工編號, 起日);
|
||||
|
||||
if (String.IsNullOrEmpty(起時))
|
||||
起時 = 上班時間;
|
||||
if (String.IsNullOrEmpty(迄時))
|
||||
迄時 = 下班時間;
|
||||
|
||||
當日分鐘數 = 計算分鐘數(起時, 迄時) - 計算午休分鐘數(起時, 迄時);
|
||||
|
||||
if (is進整小時)
|
||||
return 進整小時(當日分鐘數);
|
||||
else
|
||||
return 當日分鐘數;
|
||||
}
|
||||
// 起始與結束不同天
|
||||
else
|
||||
{
|
||||
DateTime std = 起日;
|
||||
|
||||
while (std <= 迄日)
|
||||
{
|
||||
Init(員工編號, std);
|
||||
|
||||
// 不是假日,或是產假,要列入時數計算
|
||||
if (!bhrdDao.IsHoliday(員工編號, std) || 假別 == RPAR_TYPE.T05_產假)
|
||||
{
|
||||
// 第一天
|
||||
if (std == 起日)
|
||||
{
|
||||
當日分鐘數 = 計算分鐘數(起時, 下班時間) - 計算午休分鐘數(起時, 下班時間);
|
||||
}
|
||||
// 最後一天
|
||||
else if (std == 迄日)
|
||||
{
|
||||
當日分鐘數 = 計算分鐘數(上班時間, 迄時) - 計算午休分鐘數(上班時間, 迄時);
|
||||
}
|
||||
// 中間其他天
|
||||
else
|
||||
{
|
||||
當日分鐘數 = 上班分鐘數;
|
||||
}
|
||||
// 只計算一天,就返回
|
||||
if (日期 == std)
|
||||
{
|
||||
if (is進整小時)
|
||||
return 進整小時(當日分鐘數);
|
||||
else
|
||||
return 當日分鐘數;
|
||||
}
|
||||
}
|
||||
else
|
||||
當日分鐘數 = 0;
|
||||
|
||||
std = std.AddDays(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int 計算加班時數(string 員工編號, DateTime 日期, string 起時, string 迄時, bool 休息日)
|
||||
{
|
||||
Init(員工編號, 日期);
|
||||
|
||||
int 分鐘數 = 計算分鐘數(起時, 迄時) - 計算午休分鐘數(起時, 迄時);
|
||||
|
||||
// 2018/3/1 之後休息日加班不進整 4 小時
|
||||
if (休息日 && 日期.CompareTo(new DateTime(2018, 3, 1)) < 0)
|
||||
分鐘數 = (int)(Math.Ceiling((decimal)分鐘數 / 240m) * 240m);
|
||||
|
||||
return 分鐘數;
|
||||
}
|
||||
|
||||
//public static void 拆分加班時數(int 分鐘數, bool 是假日, out int 前二, out int 後二, out int 假日)
|
||||
//{
|
||||
// 前二 = 0;
|
||||
// 後二 = 0;
|
||||
// 假日 = 0;
|
||||
|
||||
// if (是假日)
|
||||
// 假日 = 分鐘數;
|
||||
// else
|
||||
// {
|
||||
// if (分鐘數 < 120)
|
||||
// 前二 = 分鐘數;
|
||||
// else
|
||||
// {
|
||||
// 前二 = 120;
|
||||
// 後二 = 分鐘數 - 120;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public int 計算差旅時數(string 員工編號, DateTime 起日, DateTime 迄日, string 起時, string 迄時)
|
||||
{
|
||||
Init(員工編號, 起日);
|
||||
|
||||
if (String.IsNullOrEmpty(起時))
|
||||
起時 = 上班時間;
|
||||
if (String.IsNullOrEmpty(迄時))
|
||||
迄時 = 下班時間;
|
||||
|
||||
int 分鐘數;
|
||||
|
||||
// 起始與結束同一天
|
||||
if (起日 == 迄日)
|
||||
{
|
||||
分鐘數 = 計算分鐘數(起時, 迄時) - 計算午休分鐘數(起時, 迄時);
|
||||
}
|
||||
// 起始與結束不同天
|
||||
else
|
||||
{
|
||||
DateTime std = 起日;
|
||||
分鐘數 = 0;
|
||||
|
||||
while (std <= 迄日)
|
||||
{
|
||||
Init(員工編號, std);
|
||||
|
||||
// 第一天
|
||||
if (std == 起日)
|
||||
{
|
||||
分鐘數 += 計算分鐘數(起時, 下班時間) - 計算午休分鐘數(起時, 下班時間);
|
||||
}
|
||||
// 最後一天
|
||||
else if (std == 迄日)
|
||||
{
|
||||
分鐘數 += 計算分鐘數(上班時間, 迄時) - 計算午休分鐘數(上班時間, 迄時);
|
||||
}
|
||||
// 中間其他天
|
||||
else
|
||||
{
|
||||
分鐘數 += 上班分鐘數;
|
||||
}
|
||||
|
||||
std = std.AddDays(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 分鐘數;
|
||||
}
|
||||
|
||||
public int 計算差旅當日時數(string 員工編號, DateTime 日期, DateTime 起日, DateTime 迄日, string 起時, string 迄時)
|
||||
{
|
||||
Init(員工編號, 起日);
|
||||
|
||||
if (String.IsNullOrEmpty(起時))
|
||||
起時 = 上班時間;
|
||||
if (String.IsNullOrEmpty(迄時))
|
||||
迄時 = 下班時間;
|
||||
|
||||
int 分鐘數;
|
||||
|
||||
// 起始與結束同一天
|
||||
if (起日 == 迄日)
|
||||
{
|
||||
分鐘數 = 計算分鐘數(起時, 迄時) - 計算午休分鐘數(起時, 迄時);
|
||||
if (日期 == 起日)
|
||||
return 分鐘數;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
// 起始與結束不同天
|
||||
else
|
||||
{
|
||||
DateTime std = 起日;
|
||||
|
||||
while (std <= 迄日)
|
||||
{
|
||||
Init(員工編號, std);
|
||||
分鐘數 = 0;
|
||||
|
||||
// 第一天
|
||||
if (std == 起日)
|
||||
{
|
||||
分鐘數 = 計算分鐘數(起時, 下班時間) - 計算午休分鐘數(起時, 下班時間);
|
||||
}
|
||||
// 最後一天
|
||||
else if (std == 迄日)
|
||||
{
|
||||
分鐘數 = 計算分鐘數(上班時間, 迄時) - 計算午休分鐘數(上班時間, 迄時);
|
||||
}
|
||||
// 中間其他天
|
||||
else
|
||||
{
|
||||
分鐘數 = 上班分鐘數;
|
||||
}
|
||||
|
||||
if (日期 == std)
|
||||
return 分鐘數;
|
||||
|
||||
std = std.AddDays(1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static DateTime 轉換時區(string 時區, DateTime 日期, string 時間)
|
||||
{
|
||||
// 解析30小時制(小時可能 >= 24,表示跨入隔日凌晨)
|
||||
var parts = 時間.Split(':');
|
||||
var timeSpan = new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]));
|
||||
var sourceTime = 日期.Date.Add(timeSpan);
|
||||
|
||||
if (string.IsNullOrEmpty(時區) || string.Compare(時區, "Taipei Standard Time") == 0)
|
||||
{
|
||||
return sourceTime;
|
||||
}
|
||||
|
||||
// 重要:將 Kind 設為 Unspecified
|
||||
sourceTime = DateTime.SpecifyKind(sourceTime, DateTimeKind.Unspecified);
|
||||
|
||||
// 轉換到目標時區
|
||||
var sourceZone = TimeZoneInfo.FindSystemTimeZoneById("Taipei Standard Time");
|
||||
var targetZone = TimeZoneInfo.FindSystemTimeZoneById(時區);
|
||||
|
||||
var utcTime = TimeZoneInfo.ConvertTimeToUtc(sourceTime, sourceZone);
|
||||
var targetTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, targetZone);
|
||||
|
||||
return targetTime;
|
||||
}
|
||||
|
||||
public static string 轉換打卡時區(string 時區, DateTime 打卡日期, string 打卡時間)
|
||||
{
|
||||
var targetTime = 轉換時區(時區, 打卡日期, 打卡時間);
|
||||
|
||||
// 輸出 30 小時制時分秒
|
||||
// 06:00 之前算前一天,小時數加 24
|
||||
int outputHours = targetTime.Hour;
|
||||
if (targetTime.TimeOfDay < new TimeSpan(6, 0, 0))
|
||||
outputHours += 24;
|
||||
|
||||
return string.Format("{0:00}:{1:00}:{2:00}", outputHours, targetTime.Minute, targetTime.Second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 30 小時制的日期類別
|
||||
/// </summary>
|
||||
public class DateAndTime
|
||||
{
|
||||
/// <summary>
|
||||
/// 台灣工作日期
|
||||
/// </summary>
|
||||
public DateTime TwWorkDate;
|
||||
|
||||
/// <summary>
|
||||
/// 台灣日曆日期
|
||||
/// </summary>
|
||||
public DateTime TwCalendarDate;
|
||||
|
||||
/// <summary>
|
||||
/// 台灣時間
|
||||
/// </summary>
|
||||
public string TwTime;
|
||||
|
||||
/// <summary>
|
||||
/// 當地日期
|
||||
/// </summary>
|
||||
public DateTime LocalDate;
|
||||
|
||||
/// <summary>
|
||||
/// 當地時間
|
||||
/// </summary>
|
||||
public string LocalTime;
|
||||
|
||||
/// <summary>
|
||||
/// 時區名稱
|
||||
/// </summary>
|
||||
public string TimezoneName;
|
||||
|
||||
/// <summary>
|
||||
/// 時區ID
|
||||
/// </summary>
|
||||
public string TimeZoneID;
|
||||
|
||||
/// <summary>
|
||||
/// 打卡的日期
|
||||
/// </summary>
|
||||
public DateTime CardDate;
|
||||
|
||||
public DateAndTime(DateTime twWorkDate, DateTime twCalendarDate, string twTime, DateTime localDate, string localTime, string timezoneName, string timezoneID) : base()
|
||||
{
|
||||
TwWorkDate = twWorkDate;
|
||||
TwCalendarDate = twCalendarDate;
|
||||
TwTime = twTime;
|
||||
LocalDate = localDate;
|
||||
LocalTime = localTime;
|
||||
TimezoneName = timezoneName;
|
||||
TimeZoneID = timezoneID;
|
||||
CardDate = string.IsNullOrEmpty(TimeZoneID) || string.Compare(TimeZoneID, "Taipei Standard Time") == 0
|
||||
? TwWorkDate
|
||||
: TwCalendarDate;
|
||||
}
|
||||
|
||||
public static DateAndTime GetNow(string bpeno)
|
||||
{
|
||||
var twNow = DateTime.UtcNow.AddHours(8);
|
||||
var rasnDao = new RasnDAC(WGuard1.Query);
|
||||
string timezoneID;
|
||||
string timezoneName;
|
||||
rasnDao.GetTimeZone(bpeno, twNow, out timezoneID, out timezoneName);
|
||||
|
||||
var twCalendarDate = twNow.Date;
|
||||
var twWorkDate = twNow.Date;
|
||||
var localNow = TimeCalc.轉換時區(timezoneID, twNow.Date, twNow.ToString("HH:mm:ss"));
|
||||
var localDate = localNow.Date;
|
||||
var twHourOffset = 0;
|
||||
var localHourOffset = 0;
|
||||
|
||||
// 06:00 之前算前一天
|
||||
if (twNow.TimeOfDay < new TimeSpan(6, 0, 0))
|
||||
{
|
||||
twWorkDate = twWorkDate.AddDays(-1);
|
||||
twHourOffset = 24;
|
||||
}
|
||||
if (localNow.TimeOfDay < new TimeSpan(6, 0, 0))
|
||||
{
|
||||
localDate = localDate.AddDays(-1);
|
||||
localHourOffset = 24;
|
||||
}
|
||||
|
||||
return new DateAndTime(
|
||||
twWorkDate,
|
||||
twCalendarDate,
|
||||
string.Format("{0:00}:{1:00}:{2:00}", twNow.TimeOfDay.Hours + twHourOffset, twNow.TimeOfDay.Minutes, twNow.Second),
|
||||
localDate,
|
||||
string.Format("{0:00}:{1:00}:{2:00}", localNow.TimeOfDay.Hours + localHourOffset, localNow.TimeOfDay.Minutes, localNow.Second),
|
||||
timezoneName,
|
||||
timezoneID
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// 節假日設定檔
|
||||
/// </summary>
|
||||
public class BhrdDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private Hashtable bhrdData = new Hashtable();
|
||||
private string nationalHolidays = "0101,0228,0501,1010";
|
||||
|
||||
public const string 排休 = "排休";
|
||||
public const string 例假日 = "例假日";
|
||||
public const string 休假日 = "休假日";
|
||||
public const string 國定假日 = "國定假日";
|
||||
public static readonly List<string> 休假日班表 = new List<string> { 排休, 例假日, 休假日, 國定假日 };
|
||||
|
||||
public BhrdDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BhrdDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BhrdDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
public DataTable GetAll()
|
||||
{
|
||||
return Query.Select("SELECT BHYER, BHHRD FROM BHRD ORDER BY BHYER");
|
||||
}
|
||||
|
||||
public string[] GetYear(int Year)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT BHYER, BHHRD FROM BHRD WHERE BHYER=@BHYER");
|
||||
cmd.Parameters.Add(Query.NewParameter("BHYER", Year));
|
||||
DataTable bhrd = Query.Select(cmd);
|
||||
string yearData;
|
||||
|
||||
// 有資料,取出該年資料
|
||||
if (bhrd.Rows.Count != 0)
|
||||
{
|
||||
yearData = bhrd.Rows[0]["BHHRD"].ToString();
|
||||
}
|
||||
// 無資料,回傳預設資料
|
||||
else
|
||||
{
|
||||
char[] tmp = new char[366];
|
||||
for (int i = 0; i < tmp.Length; i++)
|
||||
{
|
||||
tmp[i] = ' ';
|
||||
}
|
||||
|
||||
DateTime aDate = new DateTime(Year, 1, 1);
|
||||
for (int i = 0; i < tmp.Length; i++)
|
||||
{
|
||||
if (aDate.DayOfWeek == DayOfWeek.Sunday || aDate.DayOfWeek == DayOfWeek.Saturday)
|
||||
tmp[i] = (char)HolidayType.Holiday;
|
||||
else if (nationalHolidays.Contains(String.Format("{0:00}{1:00}", aDate.Month, aDate.Day)))
|
||||
tmp[i] = (char)HolidayType.NationalHoliday;
|
||||
else
|
||||
tmp[i] = (char)HolidayType.WorkDay;
|
||||
|
||||
aDate = aDate.AddDays(1);
|
||||
if (aDate.Year != Year)
|
||||
break;
|
||||
}
|
||||
|
||||
yearData = new String(tmp);
|
||||
}
|
||||
|
||||
string[] result = new string[12];
|
||||
for (int m = 1; m <= 12; m++)
|
||||
{
|
||||
DateTime aDate = new DateTime(Year, m, 1);
|
||||
result[m - 1] = yearData.Substring(aDate.DayOfYear - 1, WGuard1.GetMonthEnd(aDate, 0).Day);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SetYear(int Year, string[] YearData)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT COUNT(1) FROM BHRD WHERE BHYER=@BHYER");
|
||||
cmd.Parameters.Add(Query.NewParameter("BHYER", Year));
|
||||
int count;
|
||||
ExecuteScalar(cmd, out count);
|
||||
if (count == 0)
|
||||
{
|
||||
cmd.CommandText = "INSERT INTO BHRD (BHYER, BHHRD, TRDAT, TRMOD, TRUSR) VALUES (@BHYER, @BHHRD, GETDATE(), 'INSERT', 'X001')";
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText = "UPDATE BHRD SET BHHRD=@BHHRD, TRDAT=GETDATE(), TRMOD='MODIFY', TRUSR='X001' WHERE BHYER=@BHYER";
|
||||
}
|
||||
cmd.Parameters.Add(Query.NewParameter("BHHRD", String.Concat(YearData)));
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
public string GetMonth(int Year, int Month)
|
||||
{
|
||||
string[] YearData = GetYear(Year);
|
||||
return YearData[Month - 1];
|
||||
}
|
||||
|
||||
public void SetMonth(int Year, int Month, string Value)
|
||||
{
|
||||
string[] YearData = GetYear(Year);
|
||||
YearData[Month - 1] = Value;
|
||||
SetYear(Year, YearData);
|
||||
}
|
||||
|
||||
public HolidayType GetDayHolidayType(DateTime aDateTime)
|
||||
{
|
||||
string bhhrd = "";
|
||||
if (!bhrdData.Contains(aDateTime.Year))
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT BHHRD FROM BHRD WHERE BHYER=@BHYER");
|
||||
cmd.Parameters.Add(Query.NewParameter("BHYER", aDateTime.Year));
|
||||
if (ExecuteScalar(cmd, out bhhrd))
|
||||
bhrdData.Add(aDateTime.Year, bhhrd);
|
||||
}
|
||||
else
|
||||
{
|
||||
bhhrd = bhrdData[aDateTime.Year].ToString();
|
||||
}
|
||||
|
||||
if (bhhrd != "")
|
||||
{
|
||||
// 有節假日資料,找出該日之節假日資料
|
||||
char theDay;
|
||||
try
|
||||
{
|
||||
theDay = bhhrd[aDateTime.DayOfYear - 1];
|
||||
}
|
||||
catch
|
||||
{
|
||||
theDay = ' ';
|
||||
}
|
||||
|
||||
switch ((HolidayType)theDay)
|
||||
{
|
||||
case HolidayType.WorkDay: // 上班日
|
||||
case HolidayType.CompensatoryWorkDay: // 補班
|
||||
case HolidayType.NationalHoliday: // 國定假日或民俗假
|
||||
case HolidayType.Holiday: // 例假日
|
||||
case HolidayType.ElasticRest: // 彈性休假
|
||||
case HolidayType.TyphoonRest: // 颱風假
|
||||
case HolidayType.VoteRest: // 選舉假
|
||||
case HolidayType.CompanyActivity: // 公司活動
|
||||
return (HolidayType)theDay;
|
||||
default:
|
||||
if (nationalHolidays.Contains(aDateTime.ToString("MMdd")))
|
||||
return HolidayType.NationalHoliday;
|
||||
else if (aDateTime.DayOfWeek == DayOfWeek.Sunday || aDateTime.DayOfWeek == DayOfWeek.Saturday)
|
||||
return HolidayType.Holiday;
|
||||
else
|
||||
return HolidayType.WorkDay;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 若無節假日資料,則週六、週日為假日
|
||||
if (nationalHolidays.Contains(aDateTime.ToString("MMdd")))
|
||||
return HolidayType.NationalHoliday;
|
||||
else if (aDateTime.DayOfWeek == DayOfWeek.Sunday || aDateTime.DayOfWeek == DayOfWeek.Saturday)
|
||||
return HolidayType.Holiday;
|
||||
else
|
||||
return HolidayType.WorkDay;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHoliday(string bpeno, DateTime aDateTime)
|
||||
{
|
||||
// 先看班表有沒有資料
|
||||
RtmeDAC rtmeDao = new RtmeDAC();
|
||||
var rtme = rtmeDao.SelectDay(bpeno, aDateTime).FirstOrDefault();
|
||||
if (rtme != null && !string.IsNullOrEmpty(rtme.RTTID.Trim()))
|
||||
{
|
||||
return ItemIsHoliday(rtme.RTTID.Trim());
|
||||
}
|
||||
|
||||
// 若沒有班表資料,用行事曆資料判斷是否需要上班
|
||||
HolidayType theDay = GetDayHolidayType(aDateTime);
|
||||
|
||||
switch (theDay)
|
||||
{
|
||||
case HolidayType.WorkDay: // 上班日
|
||||
case HolidayType.CompensatoryWorkDay: // 補班
|
||||
return false;
|
||||
case HolidayType.NationalHoliday: // 國定假日或民俗假
|
||||
case HolidayType.Holiday: // 例假日
|
||||
case HolidayType.ElasticRest: // 彈性休假
|
||||
case HolidayType.TyphoonRest: // 颱風假
|
||||
case HolidayType.VoteRest: // 選舉假
|
||||
case HolidayType.CompanyActivity: // 公司活動
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ItemIsHoliday(string item)
|
||||
{
|
||||
return 休假日班表.IndexOf(item.Trim()) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
public enum HolidayType
|
||||
{
|
||||
/// <summary>
|
||||
/// 無資料
|
||||
/// </summary>
|
||||
Null = ' ',
|
||||
/// <summary>
|
||||
/// 上班日
|
||||
/// </summary>
|
||||
WorkDay = '-',
|
||||
/// <summary>
|
||||
/// 補班
|
||||
/// </summary>
|
||||
CompensatoryWorkDay = 'B',
|
||||
/// <summary>
|
||||
/// 國定假日或民俗假
|
||||
/// </summary>
|
||||
NationalHoliday = 'N',
|
||||
/// <summary>
|
||||
/// 例假日
|
||||
/// </summary>
|
||||
Holiday = 'H',
|
||||
/// <summary>
|
||||
/// 彈性休假
|
||||
/// </summary>
|
||||
ElasticRest = 'V',
|
||||
/// <summary>
|
||||
/// 颱風假
|
||||
/// </summary>
|
||||
TyphoonRest = 'T',
|
||||
/// <summary>
|
||||
/// 選舉假
|
||||
/// </summary>
|
||||
VoteRest = 'E',
|
||||
/// <summary>
|
||||
/// 公司活動
|
||||
/// </summary>
|
||||
CompanyActivity = 'A'
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 取得專案年度接單資料
|
||||
/// </summary>
|
||||
public class BpaaDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public BpaaDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BpaaDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BpaaDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得所有年度專案計畫代號與名稱,不含總公司
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaa()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPCSD IS NULL) AND (BPPYN <> '000000001') AND (BPPYN <> '103JYB00001') AND (BPPYN <> '103TYB00001')
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度專案計畫代號與名稱,不含總公司
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <param name="year">指定年度</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaa(int year)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPYER=@BPYER) AND (BPCSD IS NULL) AND (BPPYN <> '000000001') AND (BPPYN <> '103JYB00001') AND (BPPYN <> '103TYB00001')
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPYER", year - WGuard1.CY11));
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得所有年度專案計畫代號與名稱,含總公司
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaaWithTY()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT '000000001' BPPYN, '【非專案人員】' BPPYM, 2 CLS
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPCSD IS NULL) AND (BPPYN <> '000000001') AND (BPPYN <> '103JYB00001') AND (BPPYN <> '103TYB00001')
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得所有年度專案計畫代號與名稱,含總公司,並加上一個空項目
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaaWithTYPlusNone()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT '' BPPYN, '【全部】' BPPYM, 1 CLS
|
||||
UNION
|
||||
SELECT '000000001' BPPYN, '【非專案人員】' BPPYM, 2 CLS
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPCSD IS NULL) AND (BPPYN <> '000000001') AND (BPPYN <> '103JYB00001') AND (BPPYN <> '103TYB00001')
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度專案計畫代號與名稱,含總公司
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <param name="yearFrom">指定年度</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaaWithTY(int year)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT '' BPPYN, '【全部】' BPPYM, 1 CLS
|
||||
UNION
|
||||
SELECT '000000001' BPPYN, '【非專案人員】' BPPYM, 2 CLS
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPYER=@BPYER) AND (BPPYN <> '000000001') AND (BPPYN <> '103JYB00001') AND (BPPYN <> '103TYB00001')
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPYER", year - WGuard1.CY11));
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度專案計畫代號與名稱,含總公司,並加上一個空項目
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <param name="year">指定年度</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaaWithTYPlusNone(int year)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT '' BPPYN, '【全部】' BPPYM, 1 CLS
|
||||
UNION
|
||||
SELECT '000000001' BPPYN, '【非專案人員】' BPPYM, 2 CLS
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPYER=@BPYER) AND (BPPYN <> '000000001') AND (BPPYN <> '103JYB00001') AND (BPPYN <> '103TYB00001')
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPYER", year - WGuard1.CY11));
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度專案計畫代號與名稱,含總公司
|
||||
/// </summary>
|
||||
public DataTable GetBpaaWithTYPlusNone(int yearFrom, int yearTo)
|
||||
{
|
||||
return GetBpaa(yearFrom, yearTo, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度專案計畫代號與名稱,含總公司
|
||||
/// </summary>
|
||||
public DataTable GetBpaaWithTYPlusNoneNotCheckYear(int yearFrom, int yearTo)
|
||||
{
|
||||
return GetBpaa(yearFrom, yearTo, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得指定年度專案計畫代號與名稱,含總公司
|
||||
/// 20141230 修改,必定包含 103 年度新譽與展譽
|
||||
/// </summary>
|
||||
/// <param name="yearFrom">指定年度</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetBpaa(int yearFrom, int yearTo, bool checkYearEqual)
|
||||
{
|
||||
if (yearTo <= 0) yearTo = yearFrom;
|
||||
|
||||
DbCommand cmd;
|
||||
if (yearFrom == yearTo || !checkYearEqual)
|
||||
{
|
||||
cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT '' BPPYN, '【全部】' BPPYM, 1 CLS
|
||||
UNION
|
||||
SELECT '000000001' BPPYN, '【非專案人員】' BPPYM, 2 CLS
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- 移除展育的選項
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
FROM BPAA WHERE BPPYN = '103TYB00001'
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPYER = @BPYER1) AND (BPPYN <> '000000001') AND (BPPNM <> 'JYB00001') AND (BPPNM <> 'TYB00001')
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = Query.NewCommand(
|
||||
@"SELECT BPPYN, BPPYM FROM
|
||||
(
|
||||
SELECT '' BPPYN, '【全部】' BPPYM, 1 CLS
|
||||
UNION
|
||||
SELECT '000000001' BPPYN, '【非專案人員】' BPPYM, 2 CLS
|
||||
-- UNION
|
||||
-- SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 3 CLS
|
||||
-- FROM BPAA WHERE BPPYN = '103JYB00001' OR BPPYN = '103TYB00001'
|
||||
UNION
|
||||
SELECT BPPYN, ISNULL('【' + (SELECT TOP 1 BSSCR FROM BCLS WHERE BSPAR='BCUSZON' AND BSCLS=SUBSTRING(BPPYN,LEN(BPPYN)-5,1)) + '】', '') + BPPYM BPPYM, 4 CLS
|
||||
FROM BPAA WHERE (BPYER>=@BPYER1 AND BPYER<=@BPYER2) AND (BPPYN <> '000000001') AND (BPPNM <> 'JYB00001') AND (BPPNM <> 'TYB00001')
|
||||
) AS TMP1
|
||||
ORDER BY CLS, BPPYN");
|
||||
}
|
||||
cmd.Parameters.Add(Query.NewParameter("BPYER1", yearFrom - WGuard1.CY11));
|
||||
cmd.Parameters.Add(Query.NewParameter("BPYER2", yearTo - WGuard1.CY11));
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得加班時數計算方式
|
||||
/// </summary>
|
||||
/// <param name="BPPYN">年度專案計畫編號</param>
|
||||
/// <returns>1=計算至小時,2=計算至分鐘</returns>
|
||||
public string GetOverTimeType(string BPPYN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT BPOTT FROM BPAA WHERE BPPYN=@BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYN", BPPYN));
|
||||
string s = WDAC.GetStringValue(Query.ExecuteScalar(cmd));
|
||||
return s == "1" || s == "2" ? s : "1";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得上下班時間
|
||||
/// </summary>
|
||||
/// <param name="bppyn"></param>
|
||||
/// <returns></returns>
|
||||
//public void GetTime(string bppyn, out string bpstm, out string bpetm)
|
||||
//{
|
||||
// bpstm = WGuard1.WSetR("UNRPARTIME", 1);
|
||||
// bpetm = WGuard1.WSetR("UNRPARTIME", 2);
|
||||
|
||||
// DbCommand cmd1 = Query.NewCommand("SELECT BPPNM FROM BPAA WHERE BPPYN=@BPPYN");
|
||||
// cmd1.Parameters.Add(Query.NewParameter("BPPYN", bppyn));
|
||||
// string bppnm = WDAC.GetStringValue(Query.ExecuteScalar(cmd1));
|
||||
|
||||
// if (string.IsNullOrEmpty(bppnm))
|
||||
// return;
|
||||
|
||||
// DbCommand cmd2 = Query.NewCommand("SELECT BPSTM, BPETM FROM BPRJ WHERE BPPNM=@BPPNM");
|
||||
// cmd1.Parameters.Add(Query.NewParameter("BPPNM", bppnm));
|
||||
// DataTable dt = Query.Select(cmd2);
|
||||
|
||||
// if (dt.Rows.Count == 0)
|
||||
// return;
|
||||
|
||||
// string bpstm1 = WDAC.GetStringValue(dt.Rows[0]["BPSTM"]);
|
||||
// string bpetm1 = WDAC.GetStringValue(dt.Rows[0]["BPETM"]);
|
||||
|
||||
// string[] timepart = bpstm1.Split(':');
|
||||
// if (timepart.Length >= 2)
|
||||
// bpstm = timepart[0].PadRight(2, '0') + timepart[1].PadRight(2, '0');
|
||||
|
||||
// timepart = bpetm1.Split(':');
|
||||
// if (timepart.Length >= 2)
|
||||
// bpetm = timepart[0].PadRight(2, '0') + timepart[1].PadRight(2, '0');
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 取得年初特休計算方式
|
||||
/// </summary>
|
||||
/// <param name="BPPYN">年度專案計畫編號</param>
|
||||
/// <returns>S=加總上年生效(正數) / Z=年初時數為0</returns>
|
||||
public string GetYearBeginAnnualLeaveType(string BPPYN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT BPALT FROM BPAA WHERE BPPYN=@BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYN", BPPYN));
|
||||
string s = WDAC.GetStringValue(Query.ExecuteScalar(cmd));
|
||||
return s == "S" || s == "Z" ? s : "Z";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得年度專案計畫代號對應的班表編號
|
||||
/// </summary>
|
||||
/// <param name="BPPYN">年度專案計畫編號</param>
|
||||
/// <returns>班表編號</returns>
|
||||
public string GetTimeTableNo(string BPPYN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT BPPNM FROM BPAA WHERE BPPYN=@BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYN", BPPYN));
|
||||
var bppnm = WDAC.GetStringValue(Query.ExecuteScalar(cmd));
|
||||
|
||||
cmd.CommandText = "SELECT BPTME FROM BPRJ WHERE BPPNM=@BPPNM";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPNM", bppnm));
|
||||
return WDAC.GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Transactions;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// 外部人員帳號資料檔
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class BpapDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private string _select =
|
||||
@" SELECT BPENO, BPNME, BPPWD, BPEML, BPZON, BPBRH, TRDAT, TRMOD, TRUSR FROM BPAP ";
|
||||
private string _insert =
|
||||
@"INSERT INTO dbo.BPAP
|
||||
(BPENO, BPNME, BPPWD, BPEML, BPZON, BPBRH, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@BPENO, @BPNME, @BPPWD, @BPEML, @BPZON, @BPBRH, GETDATE(), 'INSERT', @TRUSR)";
|
||||
private string _update =
|
||||
@"UPDATE BPAP SET
|
||||
BPNME = @BPNME,
|
||||
BPEML = @BPEML,
|
||||
BPZON = @BPZON,
|
||||
BPBRH = @BPBRH,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE BPENO = @OLD_BPENO";
|
||||
private string _delete =
|
||||
@"DELETE FROM BPAP
|
||||
WHERE BPENO = @OLD_BPENO";
|
||||
|
||||
public BpapDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BpapDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BpapDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectAll()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " ORDER BY BPENO ";
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectOne(string BPENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE BPENO=@BPENO ";
|
||||
AddParam(cmd, "BPENO", BPENO);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(string BPNME, string BPEML, string BPZON, string BPBRH, string TRUSR)
|
||||
{
|
||||
string BPENO = WGuard1.WNextRen(DateTime.UtcNow.AddHours(8).Date, "BPAP", "BPENO", "\"Z\"<999>", "");
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _insert;
|
||||
AddParam(cmd, "BPENO", BPENO);
|
||||
AddParam(cmd, "BPNME", BPNME);
|
||||
AddParam(cmd, "BPPWD", WGuard1.KeyEnc(BPENO));
|
||||
AddParam(cmd, "BPEML", BPEML);
|
||||
AddParam(cmd, "BPZON", BPZON);
|
||||
AddParam(cmd, "BPBRH", BPBRH);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(string OLD_BPENO, string BPENO, string BPNME, string BPEML, string BPZON, string BPBRH, string TRUSR)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _update;
|
||||
AddParam(cmd, "BPNME", BPNME);
|
||||
AddParam(cmd, "BPEML", BPEML);
|
||||
AddParam(cmd, "BPZON", BPZON);
|
||||
AddParam(cmd, "BPBRH", BPBRH);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
AddParam(cmd, "OLD_BPENO", OLD_BPENO);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(string OLD_BPENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _delete;
|
||||
AddParam(cmd, "OLD_BPENO", OLD_BPENO);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員電子郵件
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetEmail(string bpeno)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT BPEML
|
||||
FROM BPAP
|
||||
WHERE BPENO=@BPENO");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
return GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// BprjDAC 的摘要描述
|
||||
/// </summary>
|
||||
public class BprjDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public BprjDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BprjDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BprjDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 用來取得專案處理人員資料的類別
|
||||
/// </summary>
|
||||
public class BprmDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public BprmDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BprmDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BprmDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某使用者是否有處理某專案的權限
|
||||
/// </summary>
|
||||
/// <param name="bppyn">年度專案編號</param>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetRight(string bppyn, string bpeno)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
//@"SELECT COUNT(1) FROM BPRM A
|
||||
// INNER JOIN BPAA B ON A.BPPNM=B.BPPNM
|
||||
// WHERE B.BPPYN=@BPPYN AND BPENO=@BPENO");
|
||||
@"SELECT COUNT(1) FROM BPRM
|
||||
WHERE BPPNM=@BPPYN AND BPENO=@BPENO");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYN", bppyn.Length > 3 ? bppyn.Substring(3) : bppyn));
|
||||
cmd.Parameters.Add(Query.NewParameter("BPENO", bpeno));
|
||||
int i;
|
||||
ExecuteScalar(cmd, out i);
|
||||
return i > 0;
|
||||
}
|
||||
|
||||
public DataTable SelectBy年度接單編號(string BPPYN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT A.BPENO, C.BPNME, C.BPEML
|
||||
FROM BPRM A
|
||||
JOIN BPAA B ON A.BPPNM = B.BPPNM
|
||||
JOIN BPSNView C ON A.BPENO = C.BPENO
|
||||
WHERE B.BPPYN = @BPPYN");
|
||||
cmd.Parameters.Add(Query.NewParameter("BPPYN", BPPYN));
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Transactions;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// BPSE 片語資料表資料處理類別
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class BpseDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public BpseDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BpseDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BpseDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectAll()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT BPTYP, BPCNT
|
||||
FROM BPSE
|
||||
ORDER BY BPTYP, BPCNT";
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectOne(string BPTYP, string BPCNT)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT BPTYP, BPCNT
|
||||
FROM BPSE
|
||||
WHERE BPTYP=@BPTYP
|
||||
AND BPCNT=@BPCNT";
|
||||
Query.AddParam(cmd, "BPTYP", BPTYP);
|
||||
Query.AddParam(cmd, "BPCNT", BPCNT);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable Select片語類別()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT DISTINCT BPTYP
|
||||
FROM BPSE ORDER BY BPTYP";
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable Select片語By類別(string BPTYP)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT BPCNT
|
||||
FROM BPSE
|
||||
WHERE BPTYP=@BPTYP AND BPENB=1
|
||||
ORDER BY BPORD, BPCNT";
|
||||
Query.AddParam(cmd, "BPTYP", BPTYP);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(string BPTYP, string BPCNT, string UserId)
|
||||
{
|
||||
if (SelectOne(BPTYP, BPCNT).Rows.Count == 0)
|
||||
{
|
||||
DbCommand cmdInsert = Query.NewCommand();
|
||||
cmdInsert.CommandText =
|
||||
@"INSERT INTO BPSE (BPTYP, BPCNT, TRDAT, TRMOD, TRUSR)
|
||||
VALUES (@BPTYP, @BPCNT, GETDATE(), 'INSERT', @TRUSR)";
|
||||
Query.AddParam(cmdInsert, "BPTYP", BPTYP);
|
||||
Query.AddParam(cmdInsert, "BPCNT", BPCNT);
|
||||
Query.AddParam(cmdInsert, "TRUSR", UserId);
|
||||
Query.ExecuteNonQuery(cmdInsert);
|
||||
}
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(string OLD_BPTYP, string OLD_BPCNT, string BPTYP, string BPCNT, string UserId)
|
||||
{
|
||||
DbCommand cmdUpdate = Query.NewCommand();
|
||||
cmdUpdate.CommandText =
|
||||
@"UPDATE BPSE SET
|
||||
BPTYP = @BPTYP,
|
||||
BPCNT = @BPCNT,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'MODIFY',
|
||||
TRUSR = @TRUSR
|
||||
WHERE BPTYP=@OLD_BPTYP
|
||||
AND BPCNT=@OLD_BPCNT";
|
||||
Query.AddParam(cmdUpdate, "BPTYP", BPTYP);
|
||||
Query.AddParam(cmdUpdate, "BPCNT", BPCNT);
|
||||
Query.AddParam(cmdUpdate, "TRUSR", UserId);
|
||||
Query.AddParam(cmdUpdate, "OLD_BPTYP", OLD_BPTYP);
|
||||
Query.AddParam(cmdUpdate, "OLD_BPCNT", OLD_BPCNT);
|
||||
Query.ExecuteNonQuery(cmdUpdate);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(string OLD_BPTYP, string OLD_BPCNT)
|
||||
{
|
||||
DbCommand cmdDelete = Query.NewCommand();
|
||||
cmdDelete.CommandText =
|
||||
@"DELETE FROM BPSE
|
||||
WHERE BPTYP=@OLD_BPTYP
|
||||
AND BPCNT=@OLD_BPCNT";
|
||||
Query.AddParam(cmdDelete, "OLD_BPTYP", OLD_BPTYP);
|
||||
Query.AddParam(cmdDelete, "OLD_BPCNT", OLD_BPCNT);
|
||||
Query.ExecuteNonQuery(cmdDelete);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,531 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 薪資資料與薪資異動資料的資料處理類別
|
||||
/// </summary>
|
||||
[DataObject(true)]
|
||||
public class BpslDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private DbCommand cmdSelectBpslBpeno;
|
||||
private DbCommand cmdSelectRpsl;
|
||||
private DbCommand cmdSelectBpslOne;
|
||||
private DbCommand cmdSelectRpslOne;
|
||||
private DbCommand cmdSelectRpslAll;
|
||||
private DbCommand cmdSelectBpsl2;
|
||||
|
||||
public BpslDAC()
|
||||
{
|
||||
// 取出最後一筆異動
|
||||
cmdSelectRpsl = Query.NewCommand(
|
||||
@"SELECT TOP 1 RPENO BPENO, RPITM BPITM, RPBDT BPBDT, RPSRM BPSRM, RPSRD BPSRD,
|
||||
RPP01 BPP01, RPP02 BPP02, RPP03 BPP03, RPP04 BPP04, RPP05 BPP05, APPNO
|
||||
FROM RPSL WHERE RPENO=@BPENO ORDER BY BPITM DESC");
|
||||
cmdSelectRpsl.Parameters.Add(Query.NewParameter("BPENO", DbType.String));
|
||||
|
||||
// 取出員工薪資資料
|
||||
cmdSelectBpslOne = Query.NewCommand(
|
||||
@"SELECT *, 0 BPITM, NULL BPBDT FROM BPSL WHERE BPENO=@BPENO");
|
||||
cmdSelectBpslOne.Parameters.Add(Query.NewParameter("BPENO", DbType.String));
|
||||
|
||||
// 取出某一筆薪資異動資料
|
||||
cmdSelectRpslOne = Query.NewCommand(
|
||||
@"SELECT RPENO BPENO, RPITM BPITM, RPBDT BPBDT, RPSRM BPSRM, RPSRD BPSRD,
|
||||
RPP01 BPP01, RPP02 BPP02, RPP03 BPP03, RPP04 BPP04, RPP05 BPP05, APPNO
|
||||
FROM RPSL WHERE RPENO=@BPENO AND RPITM=@BPITM");
|
||||
cmdSelectRpslOne.Parameters.Add(Query.NewParameter("BPENO", DbType.String));
|
||||
cmdSelectRpslOne.Parameters.Add(Query.NewParameter("BPITM", DbType.Int32));
|
||||
|
||||
// 取出某員工編號全部的紀錄,以異動次數排序
|
||||
cmdSelectRpslAll = Query.NewCommand(
|
||||
@"SELECT BPENO, 0 BPITM, NULL BPBDT, BPSRM, BPSRD,
|
||||
BPP01, BPP02, BPP03, BPP04, BPP05, APPNO
|
||||
FROM BPSL
|
||||
WHERE BPENO=@BPENO
|
||||
UNION
|
||||
SELECT RPENO BPENO, RPITM BPITM, RPBDT BPBDT, RPSRM BPSRM, RPSRD BPSRD,
|
||||
RPP01 BPP01, RPP02 BPP02, RPP03 BPP03, RPP04 BPP04, RPP05 BPP05, APPNO
|
||||
FROM RPSL
|
||||
WHERE RPENO=@BPENO
|
||||
ORDER BY BPITM");
|
||||
cmdSelectRpslAll.Parameters.Add(Query.NewParameter("BPENO", DbType.String));
|
||||
|
||||
// 取出某員工編號全部的紀錄,以生效日期排序
|
||||
cmdSelectBpsl2 = Query.NewCommand(
|
||||
@"SELECT BPENO, 0 BPITM, '1899/12/31' BPBDT, BPSRM, BPSRD,
|
||||
BPP01, BPP02, BPP03, BPP04, BPP05, APPNO
|
||||
FROM BPSL
|
||||
WHERE BPENO=@BPENO
|
||||
UNION
|
||||
SELECT RPENO BPENO, RPITM BPITM, RPBDT BPBDT, RPSRM BPSRM, RPSRD BPSRD,
|
||||
RPP01 BPP01, RPP02 BPP02, RPP03 BPP03, RPP04 BPP04, RPP05 BPP05, APPNO
|
||||
FROM RPSL
|
||||
WHERE RPENO=@BPENO
|
||||
ORDER BY BPBDT");
|
||||
cmdSelectBpsl2.Parameters.Add(Query.NewParameter("BPENO", DbType.String));
|
||||
}
|
||||
|
||||
public BpslDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
base._connectionConfig = connectionConfig;
|
||||
base._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BpslDAC(WQuery query)
|
||||
: this()
|
||||
{
|
||||
base._query = query;
|
||||
}
|
||||
|
||||
private DataTable NewResult()
|
||||
{
|
||||
// 準備輸出資料架構
|
||||
DataTable Result = new DataTable();
|
||||
Result.Columns.Add("BPENO", typeof(String));
|
||||
Result.Columns.Add("BPITM", typeof(Int32));
|
||||
Result.Columns.Add("BPBDT", typeof(DateTime));
|
||||
Result.Columns.Add("BPSRM", typeof(Int32));
|
||||
Result.Columns.Add("BPSRD", typeof(Int32));
|
||||
Result.Columns.Add("BPP01", typeof(Int32));
|
||||
Result.Columns.Add("BPP02", typeof(Int32));
|
||||
Result.Columns.Add("BPP03", typeof(Int32));
|
||||
Result.Columns.Add("BPP04", typeof(Int32));
|
||||
Result.Columns.Add("BPP05", typeof(Int32));
|
||||
Result.Columns.Add("APPNO", typeof(Int32));
|
||||
Result.Columns.Add("BPSRM_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPSRD_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP01_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP02_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP03_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP04_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP05_Changed", typeof(Char));
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
private void FillResult(DataTable Result, DataRow source)
|
||||
{
|
||||
DataRow newRow = Result.NewRow();
|
||||
newRow["BPENO"] = source["BPENO"];
|
||||
newRow["BPITM"] = source["BPITM"];
|
||||
newRow["BPBDT"] = source["BPBDT"];
|
||||
newRow["BPSRM"] = source["BPSRM"];
|
||||
newRow["BPSRD"] = source["BPSRD"];
|
||||
newRow["BPP01"] = source["BPP01"];
|
||||
newRow["BPP02"] = source["BPP02"];
|
||||
newRow["BPP03"] = source["BPP03"];
|
||||
newRow["BPP04"] = source["BPP04"];
|
||||
newRow["BPP05"] = source["BPP05"];
|
||||
newRow["APPNO"] = source["APPNO"];
|
||||
newRow["BPSRM_Changed"] = 'N';
|
||||
newRow["BPSRD_Changed"] = 'N';
|
||||
newRow["BPP01_Changed"] = 'N';
|
||||
newRow["BPP02_Changed"] = 'N';
|
||||
newRow["BPP03_Changed"] = 'N';
|
||||
newRow["BPP04_Changed"] = 'N';
|
||||
newRow["BPP05_Changed"] = 'N';
|
||||
Result.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
private Char FieldDiff(object obj1, object obj2)
|
||||
{
|
||||
string s1 = obj1 != DBNull.Value ? obj1.ToString() : "";
|
||||
string s2 = obj2 != DBNull.Value ? obj2.ToString() : "";
|
||||
if (s1.CompareTo(s2) != 0)
|
||||
return 'Y';
|
||||
else
|
||||
return 'N';
|
||||
}
|
||||
|
||||
private void FillResult(DataTable Result, DataRow current, DataRow prev)
|
||||
{
|
||||
DataRow newRow = Result.NewRow();
|
||||
newRow["BPENO"] = current["BPENO"];
|
||||
newRow["BPITM"] = current["BPITM"];
|
||||
newRow["BPBDT"] = current["BPBDT"];
|
||||
newRow["BPSRM"] = current["BPSRM"];
|
||||
newRow["BPSRD"] = current["BPSRD"];
|
||||
newRow["BPP01"] = current["BPP01"];
|
||||
newRow["BPP02"] = current["BPP02"];
|
||||
newRow["BPP03"] = current["BPP03"];
|
||||
newRow["BPP04"] = current["BPP04"];
|
||||
newRow["BPP05"] = current["BPP05"];
|
||||
newRow["APPNO"] = current["APPNO"];
|
||||
newRow["BPSRM_Changed"] = FieldDiff(current["BPSRM"], prev["BPSRM"]);
|
||||
newRow["BPSRD_Changed"] = FieldDiff(current["BPSRD"], prev["BPSRD"]);
|
||||
newRow["BPP01_Changed"] = FieldDiff(current["BPP01"], prev["BPP01"]);
|
||||
newRow["BPP02_Changed"] = FieldDiff(current["BPP02"], prev["BPP02"]);
|
||||
newRow["BPP03_Changed"] = FieldDiff(current["BPP03"], prev["BPP03"]);
|
||||
newRow["BPP04_Changed"] = FieldDiff(current["BPP04"], prev["BPP04"]);
|
||||
newRow["BPP05_Changed"] = FieldDiff(current["BPP05"], prev["BPP05"]);
|
||||
Result.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 依條件取出資料,給 GridView 的 Select 用的
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable Select(string BPENO, string BPNME)
|
||||
{
|
||||
if (cmdSelectBpslBpeno == null)
|
||||
cmdSelectBpslBpeno = Query.NewCommand();
|
||||
cmdSelectBpslBpeno.Parameters.Clear();
|
||||
|
||||
// 清空輸出資料表
|
||||
DataTable Result = NewResult();
|
||||
|
||||
// 依條件抓出員工編號
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("SELECT A.BPENO FROM BPSL A INNER JOIN BPSNView B ON A.BPENO=B.BPENO WHERE 1=1 ");
|
||||
if (BPENO != null && BPENO.Length > 0)
|
||||
{
|
||||
sb.Append(" AND A.BPENO LIKE @BPENO ");
|
||||
cmdSelectBpslBpeno.Parameters.Add(Query.NewParameter("BPENO", BPENO + "%"));
|
||||
}
|
||||
if (BPNME != null && BPNME.Length > 0)
|
||||
{
|
||||
sb.Append(" AND B.BPNME LIKE @BPNME ");
|
||||
cmdSelectBpslBpeno.Parameters.Add(Query.NewParameter("BPNME", BPNME + "%"));
|
||||
}
|
||||
cmdSelectBpslBpeno.CommandText = sb.ToString();
|
||||
DataTable bpenoTmp = Query.Select(cmdSelectBpslBpeno);
|
||||
|
||||
DataTable bpslTmp;
|
||||
// 一筆一筆的抓出應該顯示的資料
|
||||
foreach (DataRow bpenoRow in bpenoTmp.Rows)
|
||||
{
|
||||
// 依照員工編號,抓出最後一筆異動
|
||||
cmdSelectRpsl.Parameters[0].Value = bpenoRow[0];
|
||||
bpslTmp = Query.Select(cmdSelectRpsl);
|
||||
|
||||
// 有異動資料,填入異動資料
|
||||
if (bpslTmp.Rows.Count != 0)
|
||||
{
|
||||
FillResult(Result, bpslTmp.Rows[0]);
|
||||
}
|
||||
// 沒有異動資料,填入原始資料
|
||||
else
|
||||
{
|
||||
cmdSelectBpslOne.Parameters[0].Value = bpenoRow[0];
|
||||
bpslTmp = Query.Select(cmdSelectBpslOne);
|
||||
FillResult(Result, bpslTmp.Rows[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出最新資料,給 FormView 的 Select 用的
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectOne(string BPENO, int BPITM)
|
||||
{
|
||||
return SelectOne(BPENO, BPITM, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某一筆薪資異動資料
|
||||
/// </summary>
|
||||
public DataTable SelectOne(string BPENO, int BPITM, DbTransaction tran)
|
||||
{
|
||||
DataTable Result = NewResult();
|
||||
|
||||
if (BPENO != null && BPENO.Length > 0)
|
||||
{
|
||||
// 取原始資料
|
||||
if (BPITM == 0)
|
||||
{
|
||||
cmdSelectBpslOne.Parameters[0].Value = BPENO;
|
||||
DataTable tmp;
|
||||
if (tran == null)
|
||||
tmp = Query.Select(cmdSelectBpslOne);
|
||||
else
|
||||
tmp = Query.Select(cmdSelectBpslOne, tran);
|
||||
if (tmp.Rows.Count > 0)
|
||||
FillResult(Result, tmp.Rows[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdSelectRpslOne.Parameters[0].Value = BPENO;
|
||||
cmdSelectRpslOne.Parameters[1].Value = BPITM;
|
||||
DataTable tmp;
|
||||
if (tran == null)
|
||||
tmp = Query.Select(cmdSelectRpslOne);
|
||||
else
|
||||
tmp = Query.Select(cmdSelectRpslOne, tran);
|
||||
if (tmp.Rows.Count > 0)
|
||||
FillResult(Result, tmp.Rows[0]);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出所有薪資異動歷史資料,薪資異動查詢用
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectRPSL(string BPENO)
|
||||
{
|
||||
DataTable Result = NewResult();
|
||||
|
||||
if (BPENO != null && BPENO.Length > 0)
|
||||
{
|
||||
cmdSelectRpslAll.Parameters[0].Value = BPENO;
|
||||
DataTable tmp = Query.Select(cmdSelectRpslAll);
|
||||
for (int i = 0; i < tmp.Rows.Count; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
FillResult(Result, tmp.Rows[i], tmp.Rows[i - 1]);
|
||||
else
|
||||
FillResult(Result, tmp.Rows[i]);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出日期區間內薪資基本資料以及薪資異動資料
|
||||
/// </summary>
|
||||
public DataTable SelectBPSLDateRange(string bpeno, DateTime startDay, DateTime endDay, DbTransaction tran)
|
||||
{
|
||||
DataTable Result = NewResult();
|
||||
|
||||
if (bpeno != null && bpeno.Length > 0)
|
||||
{
|
||||
cmdSelectBpsl2.Parameters[0].Value = bpeno;
|
||||
DataTable tmp = Query.Select(cmdSelectBpsl2, tran);
|
||||
int startIndex = -1;
|
||||
int endIndex = -1;
|
||||
for (int i = 0; i < tmp.Rows.Count; i++)
|
||||
{
|
||||
DateTime bpbdt = Convert.ToDateTime(tmp.Rows[i]["BPBDT"]);
|
||||
if (startDay >= bpbdt)
|
||||
startIndex = i;
|
||||
if (endDay >= bpbdt)
|
||||
endIndex = i;
|
||||
}
|
||||
|
||||
if (startIndex != -1 && endIndex != -1)
|
||||
{
|
||||
for (int i = startIndex; i <= endIndex; i++)
|
||||
{
|
||||
FillResult(Result, tmp.Rows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某一筆薪資異動紀錄
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectRPSLOne(string BPENO, int BPITM)
|
||||
{
|
||||
DataTable Result = NewResult();
|
||||
|
||||
if (BPENO != null && BPENO.Length > 0)
|
||||
{
|
||||
cmdSelectRpslAll.Parameters[0].Value = BPENO;
|
||||
DataTable tmp = Query.Select(cmdSelectRpslAll);
|
||||
for (int i = 0; i < tmp.Rows.Count; i++)
|
||||
{
|
||||
if (Convert.ToInt32(tmp.Rows[i]["BPITM"]) == BPITM)
|
||||
{
|
||||
if (i > 0)
|
||||
FillResult(Result, tmp.Rows[i], tmp.Rows[i - 1]);
|
||||
else
|
||||
FillResult(Result, tmp.Rows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得下一個薪資異動項次
|
||||
/// </summary>
|
||||
private int NextRPITM(string BPENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand("SELECT ISNULL(MAX(RPITM), 0) + 1 FROM RPSL WHERE RPENO=@RPENO");
|
||||
cmd.Parameters.Add(Query.NewParameter("RPENO", BPENO));
|
||||
int Result;
|
||||
ExecuteScalar(cmd, out Result);
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增一筆員工薪資資料,或薪資異動紀錄
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public int Insert(string BPENO, int BPITM, DateTime BPBDT, int BPSRM, int BPSRD, int BPP01, int BPP02,
|
||||
int BPP03, int BPP04, int BPP05, string TRUSR)
|
||||
{
|
||||
DbCommand cmdInsert = Query.NewCommand();
|
||||
|
||||
if (BPITM == 0)
|
||||
{
|
||||
cmdInsert.CommandText =
|
||||
@"INSERT INTO BPSL
|
||||
(BPENO, BPSRM, BPSRD, BPP01, BPP02, BPP03, BPP04, BPP05, APPNO,
|
||||
TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@BPENO, @BPSRM, @BPSRD, @BPP01, @BPP02, @BPP03, @BPP04, @BPP05, 1,
|
||||
GETDATE(), 'INSERT', @TRUSR)";
|
||||
AddParam(cmdInsert, "BPENO", BPENO);
|
||||
AddParam(cmdInsert, "BPSRM", BPSRM);
|
||||
AddParam(cmdInsert, "BPSRD", BPSRD);
|
||||
AddParam(cmdInsert, "BPP01", BPP01);
|
||||
AddParam(cmdInsert, "BPP02", BPP02);
|
||||
AddParam(cmdInsert, "BPP03", BPP03);
|
||||
AddParam(cmdInsert, "BPP04", BPP04);
|
||||
AddParam(cmdInsert, "BPP05", BPP05);
|
||||
AddParam(cmdInsert, "TRUSR", TRUSR);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdInsert.CommandText =
|
||||
@"INSERT INTO RPSL
|
||||
(RPENO, RPITM, RPBDT, RPSRM, RPSRD, RPP01, RPP02, RPP03, RPP04, RPP05, APPNO,
|
||||
TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RPENO, @RPITM, @RPBDT, @RPSRM, @RPSRD, @RPP01, @RPP02, @RPP03, @RPP04, @RPP05, 1,
|
||||
GETDATE(), 'INSERT', @TRUSR)";
|
||||
AddParam(cmdInsert, "RPENO", BPENO);
|
||||
AddParam(cmdInsert, "RPITM", NextRPITM(BPENO));
|
||||
AddParam(cmdInsert, "RPBDT", BPBDT);
|
||||
AddParam(cmdInsert, "RPSRM", BPSRM);
|
||||
AddParam(cmdInsert, "RPSRD", BPSRD);
|
||||
AddParam(cmdInsert, "RPP01", BPP01);
|
||||
AddParam(cmdInsert, "RPP02", BPP02);
|
||||
AddParam(cmdInsert, "RPP03", BPP03);
|
||||
AddParam(cmdInsert, "RPP04", BPP04);
|
||||
AddParam(cmdInsert, "RPP05", BPP05);
|
||||
AddParam(cmdInsert, "TRUSR", TRUSR);
|
||||
}
|
||||
|
||||
return Query.ExecuteNonQuery(cmdInsert);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更正員工薪資資料或薪資異動紀錄
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public int Update(string BPENO, int BPITM, DateTime BPBDT, int BPSRM, int BPSRD, int BPP01, int BPP02,
|
||||
int BPP03, int BPP04, int BPP05, string TRUSR, int APPNO,
|
||||
string OLD_BPENO, int OLD_BPITM, int OLD_APPNO)
|
||||
{
|
||||
DbCommand cmdUpdate = Query.NewCommand();
|
||||
|
||||
if (OLD_BPITM == 0)
|
||||
{
|
||||
cmdUpdate.CommandText =
|
||||
@"UPDATE BPSL SET
|
||||
BPENO = @BPENO,
|
||||
BPSRM = @BPSRM,
|
||||
BPSRD = @BPSRD,
|
||||
BPP01 = @BPP01,
|
||||
BPP02 = @BPP02,
|
||||
BPP03 = @BPP03,
|
||||
BPP04 = @BPP04,
|
||||
BPP05 = @BPP05,
|
||||
APPNO = APPNO + 1,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE BPENO = @OLD_BPENO
|
||||
AND APPNO = @OLD_APPNO";
|
||||
AddParam(cmdUpdate, "BPENO", BPENO);
|
||||
AddParam(cmdUpdate, "BPSRM", BPSRM);
|
||||
AddParam(cmdUpdate, "BPSRD", BPSRD);
|
||||
AddParam(cmdUpdate, "BPP01", BPP01);
|
||||
AddParam(cmdUpdate, "BPP02", BPP02);
|
||||
AddParam(cmdUpdate, "BPP03", BPP03);
|
||||
AddParam(cmdUpdate, "BPP04", BPP04);
|
||||
AddParam(cmdUpdate, "BPP05", BPP05);
|
||||
AddParam(cmdUpdate, "TRUSR", TRUSR);
|
||||
AddParam(cmdUpdate, "OLD_BPENO", OLD_BPENO);
|
||||
AddParam(cmdUpdate, "OLD_APPNO", OLD_APPNO);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdUpdate.CommandText =
|
||||
@"UPDATE RPSL SET
|
||||
RPENO = @RPENO,
|
||||
RPITM = @RPITM,
|
||||
RPBDT = @RPBDT,
|
||||
RPSRM = @RPSRM,
|
||||
RPSRD = @RPSRD,
|
||||
RPP01 = @RPP01,
|
||||
RPP02 = @RPP02,
|
||||
RPP03 = @RPP03,
|
||||
RPP04 = @RPP04,
|
||||
RPP05 = @RPP05,
|
||||
APPNO = APPNO + 1,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE RPENO = @OLD_RPENO
|
||||
AND RPITM = @OLD_RPITM
|
||||
AND APPNO = @OLD_APPNO";
|
||||
AddParam(cmdUpdate, "RPENO", BPENO);
|
||||
AddParam(cmdUpdate, "RPITM", BPITM);
|
||||
AddParam(cmdUpdate, "RPBDT", BPBDT);
|
||||
AddParam(cmdUpdate, "RPSRM", BPSRM);
|
||||
AddParam(cmdUpdate, "RPSRD", BPSRD);
|
||||
AddParam(cmdUpdate, "RPP01", BPP01);
|
||||
AddParam(cmdUpdate, "RPP02", BPP02);
|
||||
AddParam(cmdUpdate, "RPP03", BPP03);
|
||||
AddParam(cmdUpdate, "RPP04", BPP04);
|
||||
AddParam(cmdUpdate, "RPP05", BPP05);
|
||||
AddParam(cmdUpdate, "TRUSR", TRUSR);
|
||||
AddParam(cmdUpdate, "OLD_RPENO", OLD_BPENO);
|
||||
AddParam(cmdUpdate, "OLD_RPITM", OLD_BPITM);
|
||||
AddParam(cmdUpdate, "OLD_APPNO", OLD_APPNO);
|
||||
}
|
||||
|
||||
return Query.ExecuteNonQuery(cmdUpdate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刪除員工薪資資料或薪資異動紀錄
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public int Delete(string OLD_BPENO, int OLD_BPITM, int OLD_APPNO)
|
||||
{
|
||||
OLD_BPENO = OLD_BPENO != null ? OLD_BPENO : "";
|
||||
|
||||
DbCommand cmdDelete = Query.NewCommand();
|
||||
|
||||
if (OLD_BPITM == 0)
|
||||
{
|
||||
cmdDelete.CommandText =
|
||||
@"DELETE FROM BPSL
|
||||
WHERE BPENO = @OLD_BPENO
|
||||
AND APPNO = @OLD_APPNO";
|
||||
AddParam(cmdDelete, "OLD_BPENO", OLD_BPENO);
|
||||
AddParam(cmdDelete, "OLD_APPNO", OLD_APPNO);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdDelete.CommandText =
|
||||
@"DELETE FROM RPSL
|
||||
WHERE RPENO = @OLD_BPENO
|
||||
AND RPITM = @OLD_BPITM
|
||||
AND APPNO = @OLD_APPNO";
|
||||
AddParam(cmdDelete, "OLD_BPENO", OLD_BPENO);
|
||||
AddParam(cmdDelete, "OLD_BPITM", OLD_BPITM);
|
||||
AddParam(cmdDelete, "OLD_APPNO", OLD_APPNO);
|
||||
}
|
||||
|
||||
return Query.ExecuteNonQuery(cmdDelete);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Configuration;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 員工資料的資料處理類別
|
||||
/// </summary>
|
||||
public class BpsnDAC : Wellan.Data.BPSN_DAC
|
||||
{
|
||||
private DbCommand cmdSelect;
|
||||
private DbCommand cmdInsert;
|
||||
private DbCommand cmdUpdate;
|
||||
private DbCommand cmdDelete;
|
||||
private StringBuilder sb = new StringBuilder();
|
||||
private string select = "SELECT * ";
|
||||
private string from = " FROM BPSNView ";
|
||||
private string where = " WHERE 1=1 ";
|
||||
private string order = " ORDER BY BPENO ";
|
||||
|
||||
public BpsnDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BpsnDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BpsnDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
EnsureQuery();
|
||||
EnsureDbObjects();
|
||||
}
|
||||
|
||||
private void EnsureDbObjects()
|
||||
{
|
||||
cmdSelect = Query.NewCommand();
|
||||
cmdInsert = Query.NewCommand();
|
||||
cmdUpdate = Query.NewCommand();
|
||||
cmdDelete = Query.NewCommand();
|
||||
}
|
||||
|
||||
public DataTable SelectAll()
|
||||
{
|
||||
Init();
|
||||
cmdSelect.CommandText = select + from + order;
|
||||
cmdSelect.Parameters.Clear();
|
||||
return Query.Select(cmdSelect);
|
||||
}
|
||||
|
||||
public void ClearWhere()
|
||||
{
|
||||
Init();
|
||||
cmdSelect.Parameters.Clear();
|
||||
sb.Length = 0;
|
||||
sb.Append(select);
|
||||
sb.Append(from);
|
||||
sb.Append(where);
|
||||
}
|
||||
|
||||
public void AddWhere(string fieldName, string value1, string value2, bool like)
|
||||
{
|
||||
Init();
|
||||
|
||||
if (value1 != null && value1.Length > 0 && value2 != null && value2.Length > 0)
|
||||
{
|
||||
sb.Append(String.Format(" AND {0} >= @{0}1 AND {0} <= @{0}2 ", fieldName));
|
||||
cmdSelect.Parameters.Add(Query.NewParameter(fieldName + "1", value1));
|
||||
cmdSelect.Parameters.Add(Query.NewParameter(fieldName + "2", value2));
|
||||
}
|
||||
else if (value1 != null && value1.Length > 0)
|
||||
{
|
||||
if (like)
|
||||
{
|
||||
sb.Append(String.Format(" AND {0} LIKE @{0} ", fieldName));
|
||||
cmdSelect.Parameters.Add(Query.NewParameter(fieldName, value1.ToString() + "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(String.Format(" AND {0} = @{0} ", fieldName));
|
||||
cmdSelect.Parameters.Add(Query.NewParameter(fieldName, value1));
|
||||
}
|
||||
}
|
||||
else if (value2 != null && value2.Length > 0)
|
||||
{
|
||||
if (like)
|
||||
{
|
||||
sb.Append(String.Format(" AND {0} LIKE @{0} ", fieldName));
|
||||
cmdSelect.Parameters.Add(Query.NewParameter(fieldName, value2 + "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(String.Format(" AND {0} = @{0} ", fieldName));
|
||||
cmdSelect.Parameters.Add(Query.NewParameter(fieldName, value2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DataTable SelectByWhere()
|
||||
{
|
||||
Init();
|
||||
sb.Append(order);
|
||||
return Query.Select(cmdSelect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員目前派駐專案
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCurrentProject(string bpeno)
|
||||
{
|
||||
return GetProjectByDate(bpeno, DateTime.UtcNow.AddHours(8).Date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員目前派駐專案
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetProjectByDate(string bpeno, DateTime date)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT TOP 1 RAPYN
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS O, RAPYN
|
||||
FROM RASN
|
||||
WHERE RANUM = @BPENO
|
||||
AND RASDT <= @DATE AND (RAEDT >= @DATE OR RAEDT IS NULL)
|
||||
UNION
|
||||
SELECT TOP 1 2 AS O, RAPYN
|
||||
FROM RASN
|
||||
WHERE RANUM = @BPENO
|
||||
AND DATEPART(YEAR, RASDT) = DATEPART(YEAR, @DATE)
|
||||
AND DATEPART(MONTH, RASDT) = DATEPART(MONTH, @DATE)
|
||||
) AS TMP1
|
||||
WHERE RAPYN <> '' AND RAPYN IS NOT NULL
|
||||
ORDER BY O");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
AddParam(cmd, "DATE", date);
|
||||
return GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員目前派駐地點
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCurrentSite(string bpeno)
|
||||
{
|
||||
return GetSiteByDate(bpeno, DateTime.UtcNow.AddHours(8).Date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員目前派駐地點
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSiteByDate(string bpeno, DateTime date)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT C.BSSCR
|
||||
FROM BPSNView A
|
||||
LEFT OUTER JOIN RASN B ON A.BPENO=B.RANUM AND (B.RASDT <= @DATE AND (B.RAEDT >= @DATE OR B.RAEDT IS NULL))
|
||||
LEFT OUTER JOIN BCLS C ON B.RABRH=C.BSCLS AND C.BSPAR='BPSNBRH'
|
||||
WHERE A.BPENO=@BPENO");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
AddParam(cmd, "DATE", date);
|
||||
return GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員電子郵件
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetEmail(string bpeno)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT BPEML
|
||||
FROM BPSNView
|
||||
WHERE BPENO=@BPENO");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
return GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員電子郵件2
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public string GetEmail2(string bpeno)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT BPEM2
|
||||
FROM BPSNView
|
||||
WHERE BPENO=@BPENO");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
return GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某日期人員所屬公司名稱
|
||||
/// </summary>
|
||||
/// <param name="bpeno">員工編號</param>
|
||||
/// <param name="date">日期</param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetCompanyByDate(string bpeno, DateTime date)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT TOP 1 RPCPY FROM
|
||||
(
|
||||
SELECT RPENO, RPCPY, RPSDT, RPEDT, @YYMM-RPSDT AS SDTDIFF FROM RPIR
|
||||
WHERE RPENO=@BPENO AND
|
||||
(RPSDT <= @YYMM AND RPEDT >= @YYMM
|
||||
OR RPSDT <= @YYMM AND RPEDT IS NULL)
|
||||
UNION
|
||||
SELECT RPENO, RPCPY, RPSDT, RPEDT, @YYMM-RPSDT AS SDTDIFF FROM RPIB
|
||||
WHERE RPENO=@BPENO AND
|
||||
(RPSDT <= @YYMM AND RPEDT >= @YYMM
|
||||
OR RPSDT <= @YYMM AND RPEDT IS NULL)
|
||||
) AS TMP1
|
||||
ORDER BY SDTDIFF");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
AddParam(cmd, "YYMM", date);
|
||||
|
||||
List<string> result = new List<string>();
|
||||
result.Add(GetStringValue(Query.ExecuteScalar(cmd)));
|
||||
result.Add(CompanyDAC.GetCompanyName(result[0]));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員到職日期
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public DateTime GetBPSDY(string bpeno)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT BPSDY
|
||||
FROM BPSNView
|
||||
WHERE BPENO=@BPENO");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
return GetDateTimeValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得人員離職日期
|
||||
/// </summary>
|
||||
/// <param name="bpeno"></param>
|
||||
/// <returns></returns>
|
||||
public DateTime GetBPEDY(string bpeno)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(@"
|
||||
SELECT BPEDY
|
||||
FROM BPSNView
|
||||
WHERE BPENO=@BPENO");
|
||||
AddParam(cmd, "BPENO", bpeno);
|
||||
return GetDateTimeValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
private static List<string> managerIds = new List<string>();
|
||||
|
||||
public static bool IsManager(string bpeno)
|
||||
{
|
||||
if (managerIds.Count == 0)
|
||||
{
|
||||
managerIds.Add("00001");
|
||||
managerIds.Add("00002");
|
||||
managerIds.Add("00003");
|
||||
}
|
||||
|
||||
return managerIds.Contains(bpeno);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某日期在職的員工
|
||||
/// </summary>
|
||||
/// <param name="date">日期</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetOnBoardEmployee(DateTime date)
|
||||
{
|
||||
return Query.Select(Query.NewCommand("SELECT * FROM BPSNView WHERE dbo.EmployeeOnboard(BPENO, @DATE) = 1"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Transactions;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// 簽核關卡人員檔
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class BsgpDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private string _select =
|
||||
@" SELECT BSPYN, BSFLW, BSLVL, BSENO, TRDAT, TRMOD, TRUSR,
|
||||
CASE WHEN SUBSTRING(BSENO, 1, 1) = 'Z'
|
||||
THEN (SELECT TOP 1 BPNME FROM BPAP WHERE BPENO=BSENO)
|
||||
ELSE (SELECT TOP 1 BPNME FROM BPSNView WHERE BPENO=BSENO) END AS BSNME,
|
||||
CASE WHEN SUBSTRING(BSENO, 1, 1) = 'Z'
|
||||
THEN (SELECT TOP 1 BPEML FROM BPAP WHERE BPENO=BSENO)
|
||||
ELSE (SELECT TOP 1 BPEML FROM BPSNView WHERE BPENO=BSENO) END AS BSEML
|
||||
FROM BSGP ";
|
||||
private string _insert =
|
||||
@"INSERT INTO dbo.BSGP
|
||||
(BSPYN, BSFLW, BSLVL, BSENO, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@BSPYN, @BSFLW, @BSLVL, @BSENO, GETDATE(), 'INSERT', @TRUSR)";
|
||||
private string _update =
|
||||
@"UPDATE BSGP SET
|
||||
BSPYN = @BSPYN,
|
||||
BSFLW = @BSFLW,
|
||||
BSLVL = @BSLVL,
|
||||
BSENO = @BSENO,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE BSPYN = @OLD_BSPYN
|
||||
AND BSFLW = @OLD_BSFLW
|
||||
AND BSLVL = @OLD_BSLVL
|
||||
AND BSENO = @OLD_BSENO";
|
||||
private string _delete =
|
||||
@"DELETE FROM BSGP
|
||||
WHERE BSPYN = @OLD_BSPYN
|
||||
AND BSFLW = @OLD_BSFLW
|
||||
AND BSLVL = @OLD_BSLVL
|
||||
AND BSENO = @OLD_BSENO";
|
||||
|
||||
public BsgpDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BsgpDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BsgpDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectAll()
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " ORDER BY BSPYN, BSFLW, BSLVL, BSENO ";
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectOne(string BSPYN, string BSFLW, int BSLVL, string BSENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE BSPYN = @BSPYN AND BSFLW = @BSFLW AND BSLVL = @BSLVL AND BSENO = @BSENO ";
|
||||
AddParam(cmd, "BSPYN", BSPYN);
|
||||
AddParam(cmd, "BSFLW", BSFLW);
|
||||
AddParam(cmd, "BSLVL", BSLVL);
|
||||
AddParam(cmd, "BSENO", BSENO);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectByLevel(string BSPYN, string BSFLW, int BSLVL)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE BSPYN = @BSPYN AND BSFLW = @BSFLW AND BSLVL = @BSLVL ORDER BY BSENO ";
|
||||
AddParam(cmd, "BSPYN", BSPYN);
|
||||
AddParam(cmd, "BSFLW", BSFLW);
|
||||
AddParam(cmd, "BSLVL", BSLVL);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectForDropdown(string BSPYN, string BSFLW, int BSLVL)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE BSPYN = @BSPYN AND BSFLW = @BSFLW AND BSLVL = @BSLVL ORDER BY BSENO ";
|
||||
//@"SELECT NULL AS BSPYN, NULL AS BSFLW, NULL AS BSLVL, NULL AS BSENO, NULL AS TRDAT,
|
||||
// NULL AS TRMOD, NULL AS TRUSR, NULL AS BSNME
|
||||
// UNION ALL "
|
||||
// + _select + " WHERE BSPYN = @BSPYN AND BSFLW = @BSFLW AND BSLVL = @BSLVL ORDER BY BSENO ";
|
||||
AddParam(cmd, "BSPYN", BSPYN);
|
||||
AddParam(cmd, "BSFLW", BSFLW);
|
||||
AddParam(cmd, "BSLVL", BSLVL);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(string BSPYN, string BSFLW, int BSLVL, string BSENO, string TRUSR)
|
||||
{
|
||||
if (SelectOne(BSPYN, BSFLW, BSLVL, BSENO).Rows.Count > 0)
|
||||
return;
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _insert;
|
||||
AddParam(cmd, "BSPYN", BSPYN);
|
||||
AddParam(cmd, "BSFLW", BSFLW);
|
||||
AddParam(cmd, "BSLVL", BSLVL);
|
||||
AddParam(cmd, "BSENO", BSENO);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(string OLD_BSPYN, string OLD_BSFLW, int OLD_BSLVL, string OLD_BSENO,
|
||||
string BSPYN, string BSFLW, int BSLVL, string BSENO, string TRUSR)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _update;
|
||||
AddParam(cmd, "BSPYN", BSPYN);
|
||||
AddParam(cmd, "BSFLW", BSFLW);
|
||||
AddParam(cmd, "BSLVL", BSLVL);
|
||||
AddParam(cmd, "BSENO", BSENO);
|
||||
AddParam(cmd, "OLD_BSPYN", OLD_BSPYN);
|
||||
AddParam(cmd, "OLD_BSFLW", OLD_BSFLW);
|
||||
AddParam(cmd, "OLD_BSLVL", OLD_BSLVL);
|
||||
AddParam(cmd, "OLD_BSENO", OLD_BSENO);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(string OLD_BSPYN, string OLD_BSFLW, int OLD_BSLVL, string OLD_BSENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _delete;
|
||||
AddParam(cmd, "OLD_BSPYN", OLD_BSPYN);
|
||||
AddParam(cmd, "OLD_BSFLW", OLD_BSFLW);
|
||||
AddParam(cmd, "OLD_BSLVL", OLD_BSLVL);
|
||||
AddParam(cmd, "OLD_BSENO", OLD_BSENO);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
public bool 是否是主要簽核(string BSENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT COUNT(1)
|
||||
FROM BSGP
|
||||
WHERE BSLVL IN (1, 3) AND BSENO=@BSENO";
|
||||
AddParam(cmd, "BSENO", BSENO);
|
||||
return GetInt32Value(Query.ExecuteScalar(cmd)) > 0;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable 我督導的專案(string BSENO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT A.BSPYN, B.BPPYM
|
||||
FROM BSGP A
|
||||
INNER JOIN BPAA B ON A.BSPYN=B.BPPYN
|
||||
WHERE BSLVL=3 AND BSENO=@BSENO
|
||||
ORDER BY BSPYN";
|
||||
AddParam(cmd, "BSENO", BSENO);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable 我可簽核的專案(int Year1, int Year2, string BSENO)
|
||||
{
|
||||
string yearWhere = "";
|
||||
if (Year1 > 0 && Year2 > 0)
|
||||
yearWhere = " AND B.BPYER>=@BPYER1 AND B.BPYER<=@BPYER2 ";
|
||||
if (Year1 > 0 && Year2 == 0)
|
||||
yearWhere = " AND B.BPYER=@BPYER1 ";
|
||||
if (Year1 == 0 && Year2 > 0)
|
||||
yearWhere = " AND B.BPYER=@BPYER2 ";
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = String.Format(
|
||||
@"SELECT A.BSPYN, B.BPPYM
|
||||
FROM BSGP A
|
||||
INNER JOIN BPAA B ON A.BSPYN=B.BPPYN {0}
|
||||
WHERE BSLVL IN (1, 3) AND BSENO=@BSENO
|
||||
UNION
|
||||
SELECT A.BSPYN, B.BPPYM
|
||||
FROM BSGP A
|
||||
INNER JOIN BPAA B ON A.BSPYN=B.BPPYN
|
||||
WHERE BSLVL IN (1, 3) AND BSENO=@BSENO AND (BPPYN = '103TYB00001' OR BPPYN = '103JYB00001')
|
||||
ORDER BY BSPYN", yearWhere);
|
||||
AddParam(cmd, "BPYER1", Year1);
|
||||
AddParam(cmd, "BPYER2", Year2);
|
||||
AddParam(cmd, "BSENO", BSENO);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable 我可簽核的專案(int Year, string BSENO)
|
||||
{
|
||||
return 我可簽核的專案(Year, 0, BSENO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// 班表的資料處理類別
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class BtmeDAC : WDAC
|
||||
{
|
||||
public BtmeDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public BtmeDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public BtmeDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<BtmeItem> SelectAll()
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT * FROM BTME ORDER BY BTTID";
|
||||
return Query.Select<BtmeItem>(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<BtmeItem> SelectOne(string BTTID)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT * FROM BTME WHERE BTTID=@BTTID";
|
||||
AddParam(cmd, "BTTID", BTTID);
|
||||
return Query.Select<BtmeItem>(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(BtmeItem value)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO dbo.BTME
|
||||
(BTTID, BTNME, BTSTM, BTETM, BTRST, BTRED, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@BTTID, @BTNME, @BTSTM, @BTETM, @BTRST, @BTRED, GETDATE(), 'INSERT', @TRUSR)";
|
||||
AddParam(cmd, "BTTID", WGuard1.WNextRen(DateTime.UtcNow.AddHours(8).Date, "BTME", "BTTID", "<9999>", "") );
|
||||
AddParam(cmd, "BTNME", value.BTNME);
|
||||
AddParam(cmd, "BTSTM", value.BTSTM);
|
||||
AddParam(cmd, "BTETM", value.BTETM);
|
||||
AddParam(cmd, "BTRST", value.BTRST);
|
||||
AddParam(cmd, "BTRED", value.BTRED);
|
||||
AddParam(cmd, "TRUSR", value.TRUSR);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(BtmeItem value)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"UPDATE dbo.BTME SET
|
||||
BTNME = @BTNME,
|
||||
BTSTM = @BTSTM,
|
||||
BTETM = @BTETM,
|
||||
BTRST = @BTRST,
|
||||
BTRED = @BTRED,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'MODIFY',
|
||||
TRUSR = @TRUSR
|
||||
WHERE
|
||||
BTTID = @OLD_BTTID";
|
||||
AddParam(cmd, "BTNME", value.BTNME);
|
||||
AddParam(cmd, "BTSTM", value.BTSTM);
|
||||
AddParam(cmd, "BTETM", value.BTETM);
|
||||
AddParam(cmd, "BTRST", value.BTRST);
|
||||
AddParam(cmd, "BTRED", value.BTRED);
|
||||
AddParam(cmd, "TRUSR", value.TRUSR);
|
||||
AddParam(cmd, "OLD_BTTID", value.BTTID);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(BtmeItem value)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText = @"DELETE FROM dbo.BTME WHERE BTTID = @OLD_BTTID";
|
||||
AddParam(cmd, "OLD_BTTID", value.BTTID);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出班表選擇下拉選單的資料,包含預設班表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<BtmeItem> SelectForDropdown()
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT NULL BTTID, '預設班表 (08:00-17:00)' BTNME
|
||||
UNION ALL
|
||||
SELECT BTTID, CONCAT(BTNME, ' (', BTSTM, '-', BTETM, ')') BTNME FROM BTME
|
||||
WHERE BTSTM <> '' AND BTSTM IS NOT NULL
|
||||
ORDER BY BTTID";
|
||||
return Query.Select<BtmeItem>(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public class BtmeItem
|
||||
{
|
||||
public string BTTID { get; set; }
|
||||
public string BTNME { get; set; }
|
||||
public string BTSTM { get; set; }
|
||||
public string BTETM { get; set; }
|
||||
public string BTRST { get; set; }
|
||||
public string BTRED { get; set; }
|
||||
public DateTime TRDAT { get; set; }
|
||||
public string TRMOD { get; set; }
|
||||
public string TRUSR { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// CompanyDAC 的摘要描述
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class CompanyDAC
|
||||
{
|
||||
private List<CompanyItem> items;
|
||||
private static CompanyDAC _staticInstance = null;
|
||||
|
||||
public CompanyDAC()
|
||||
{
|
||||
items = new List<CompanyItem>();
|
||||
items.Add(new CompanyItem("", "(請選擇)", "(請選擇)"));
|
||||
items.Add(new CompanyItem("TY", "新譽管理有限公司", "新譽"));
|
||||
items.Add(new CompanyItem("JY", "展譽職涯管理顧問有限公司", "展譽"));
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<CompanyItem> SelectAll()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
private string FindCompanyName(string companyId)
|
||||
{
|
||||
foreach (CompanyItem item in items)
|
||||
{
|
||||
if (item.CompanyId.CompareTo(companyId) == 0)
|
||||
return item.CompanyName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private string FindCompanyShortName(string companyId)
|
||||
{
|
||||
foreach (CompanyItem item in items)
|
||||
{
|
||||
if (item.CompanyId.CompareTo(companyId) == 0)
|
||||
return item.ShortName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string GetCompanyName(string companyId)
|
||||
{
|
||||
if (_staticInstance == null)
|
||||
_staticInstance = new CompanyDAC();
|
||||
return _staticInstance.FindCompanyName(companyId);
|
||||
}
|
||||
|
||||
public static string GetCompanyShortName(string companyId)
|
||||
{
|
||||
if (_staticInstance == null)
|
||||
_staticInstance = new CompanyDAC();
|
||||
return _staticInstance.FindCompanyShortName(companyId);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompanyItem
|
||||
{
|
||||
public CompanyItem(string companyId, string companyName, string shortName)
|
||||
{
|
||||
this.CompanyId = companyId;
|
||||
this.CompanyName = companyName;
|
||||
this.ShortName = shortName;
|
||||
}
|
||||
|
||||
[DataObjectField(true)]
|
||||
public string CompanyId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataObjectField(false)]
|
||||
public string CompanyName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[DataObjectField(false)]
|
||||
public string ShortName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Login
|
||||
/// </summary>
|
||||
public class LoginBPAP
|
||||
{
|
||||
private string _userId = "";
|
||||
private string _password = "";
|
||||
private string _userName = "";
|
||||
private string _errMessage = "";
|
||||
private string _userLang = "";
|
||||
private bool _noPassword = false;
|
||||
|
||||
public LoginBPAP()
|
||||
{
|
||||
}
|
||||
|
||||
public string UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userId;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userName;
|
||||
}
|
||||
}
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _errMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool NoPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
return _noPassword;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserLang
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userLang;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userLang = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得是否登入成功
|
||||
/// </summary>
|
||||
/// <returns>登入成功與否。若回傳 false,錯誤訊息將儲存在 ErrorMessage 屬性中</returns>
|
||||
public bool GetResult()
|
||||
{
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
string ConnName = WConfig.GetConnectionConfigName();
|
||||
string ConnStr = WConnectionString.GetConnectionString(ConnName);
|
||||
string ConnType = WConnectionString.GetConnectionType(ConnName);
|
||||
|
||||
WQuery Query = new WQuery(ConnType);
|
||||
DbConnection conn = Query.NewConnection(ConnStr);
|
||||
DbCommand cmd = Query.NewCommand("SELECT BPENO, BPNME, BPPWD FROM BPAP WHERE BPENO=@BPENO");
|
||||
cmd.Parameters.Add(Query.NewParameter("@BPENO", _userId));
|
||||
DataTable rs = Query.Select(conn, cmd);
|
||||
_noPassword = false;
|
||||
|
||||
if (rs.Rows.Count == 0)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.NOUSERID");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
string pwd1 = rs.Rows[0]["BPPWD"].ToString();
|
||||
string pwd2 = WGuard1.KeyDec(pwd1);
|
||||
|
||||
if (pwd1.CompareTo("\u007f\u007f\u007f\u007f") == 0)
|
||||
{
|
||||
_noPassword = true;
|
||||
pwd2 = "";
|
||||
}
|
||||
|
||||
if (_password.CompareTo(pwd2) != 0)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.WRONGPASSWORD");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (rs.Rows[0]["BPEDY"] != DBNull.Value)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.NORIGHT");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
_errMessage = "";
|
||||
_userName = rs.Rows[0]["BPNME"].ToString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Login
|
||||
/// </summary>
|
||||
public class LoginBPSN
|
||||
{
|
||||
private string _userId = "";
|
||||
private string _password = "";
|
||||
private string _userName = "";
|
||||
private string _errMessage = "";
|
||||
private string _userLang = "";
|
||||
private bool _noPassword = false;
|
||||
|
||||
public LoginBPSN()
|
||||
{
|
||||
}
|
||||
|
||||
public string UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userId;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userName;
|
||||
}
|
||||
}
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _errMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool NoPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
return _noPassword;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserLang
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userLang;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userLang = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得是否登入成功
|
||||
/// </summary>
|
||||
/// <returns>登入成功與否。若回傳 false,錯誤訊息將儲存在 ErrorMessage 屬性中</returns>
|
||||
public bool GetResult()
|
||||
{
|
||||
try
|
||||
{
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
string ConnName = WConfig.GetConnectionConfigName();
|
||||
string ConnStr = WConnectionString.GetConnectionString(ConnName);
|
||||
string ConnType = WConnectionString.GetConnectionType(ConnName);
|
||||
|
||||
WQuery Query = new WQuery(ConnType);
|
||||
DbConnection conn = Query.NewConnection(ConnStr);
|
||||
DbCommand cmd = Query.NewCommand("SELECT BPENO, BPNME, BPEDY, BPAWD FROM BPSNView WHERE BPENO=@BPENO");
|
||||
cmd.Parameters.Add(Query.NewParameter("@BPENO", _userId));
|
||||
DataTable rs = Query.Select(conn, cmd);
|
||||
_noPassword = false;
|
||||
|
||||
if (rs.Rows.Count == 0)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.NOUSERID");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
string pwd1 = rs.Rows[0]["BPAWD"].ToString();
|
||||
string pwd2 = WGuard1.KeyDec(pwd1);
|
||||
|
||||
if (pwd1.CompareTo("\u007f\u007f\u007f\u007f") == 0)
|
||||
{
|
||||
_noPassword = true;
|
||||
pwd2 = "";
|
||||
}
|
||||
|
||||
if (_password.CompareTo(pwd2) != 0)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.WRONGPASSWORD");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rs.Rows[0]["BPEDY"] != DBNull.Value)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.NORIGHT");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_errMessage = "";
|
||||
_userName = rs.Rows[0]["BPNME"].ToString();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errMessage = "系統忙碌中,請稍後再試";
|
||||
_userName = "";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// ProjectBranchGroupDAC 的摘要描述
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class ProjectBranchGroupDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public ProjectBranchGroupDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public ProjectBranchGroupDAC(Wellan.Data.WQuery query): base(query)
|
||||
{
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<ProjectBranchGroupItem> SelectByProject(string projectID)
|
||||
{
|
||||
var cmd = Query.NewCommand(
|
||||
@"SELECT SELECT A.ProjectID, A.BranchID, B.BSSCR BranchName, A.GroupID
|
||||
FROM ProjectBranchGroup A
|
||||
LEFT JOIN BCLS B ON A.BranchID = B.BSCLS AND B.BSPAR='BPSNBRH'
|
||||
WHERE A.ProjectID=@ProjectID ORDER BY A.GroupID, A.BranchID");
|
||||
AddParam(cmd, "ProjectID", projectID);
|
||||
return Query.Select<ProjectBranchGroupItem>(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteByProject(string projectID)
|
||||
{
|
||||
var cmd = Query.NewCommand(@"DELETE FROM ProjectBranchGroup WHERE ProjectID=@ProjectID");
|
||||
AddParam(cmd, "ProjectID", projectID);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void Insert(string projectID, string branchID, string groupID)
|
||||
{
|
||||
var cmd = Query.NewCommand(@"INSERT INTO ProjectBranchGroup (ProjectID, BranchID, GroupID) VALUES (@ProjectID, @BranchID, @GroupID)");
|
||||
AddParam(cmd, "ProjectID", projectID);
|
||||
AddParam(cmd, "BranchID", branchID);
|
||||
AddParam(cmd, "GroupID", groupID);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public class ProjectBranchGroupItem
|
||||
{
|
||||
public string ProjectID { get; set; }
|
||||
public string BranchID { get; set; }
|
||||
public string BranchName { get; set; }
|
||||
public string GroupID { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,595 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 人員派遣資料的資料處理類別
|
||||
/// </summary>
|
||||
public class RasnDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private DbCommand cmdSelectRasnRapyn = null;
|
||||
private DbCommand cmdSelectRasb = null;
|
||||
private DbCommand cmdSelectRasnOne = null;
|
||||
private DbCommand cmdSelectRasbOne = null;
|
||||
private DbCommand cmdSelectRasnAll = null;
|
||||
private DbCommand cmdSelectRasnAll2 = null;
|
||||
|
||||
public RasnDAC()
|
||||
{
|
||||
string selectRasn =
|
||||
@"SELECT A.RANUM, A.RAITM, 0 AS RBITM, NULL AS RBBDT, A.RACNM, A.RAPYN, A.RASDT,
|
||||
A.RAEDT, A.RAJNO, A.RACNO, A.RABRH, A.RAS01, A.RAWTZ, A.APPNO,
|
||||
B.BPSRM, B.BPSRD, B.BPP01, B.BPP02, B.BPP03, B.BPP04, B.BPP05
|
||||
FROM RASN A
|
||||
INNER JOIN BPJB B ON A.RAPYN=B.BPPYN AND A.RAJNO=B.BPJNO AND A.RACNO=B.BPCNO
|
||||
WHERE A.RANUM=@RANUM AND A.RAITM=@RAITM";
|
||||
string selectRasb =
|
||||
@"SELECT A.RANUM, A.RAITM, B.RBITM, B.RBBDT, A.RACNM, A.RAPYN, A.RASDT,
|
||||
A.RAEDT, B.RAJNO, B.RACNO, B.RABRH, A.RAS01, A.RAWTZ, B.APPNO,
|
||||
C.BPSRM, C.BPSRD, C.BPP01, C.BPP02, C.BPP03, C.BPP04, C.BPP05
|
||||
FROM RASN A
|
||||
INNER JOIN RASB B ON A.RANUM=B.RANUM AND A.RAITM=B.RAITM
|
||||
INNER JOIN BPJB C ON A.RAPYN=C.BPPYN AND B.RAJNO=C.BPJNO AND B.RACNO=C.BPCNO
|
||||
WHERE A.RANUM=@RANUM AND A.RAITM=@RAITM";
|
||||
|
||||
// 取出最後一筆異動
|
||||
cmdSelectRasb = Query.NewCommand(
|
||||
"SELECT TOP 1 * FROM ( " + selectRasn + " UNION " + selectRasb + " ) TMP ORDER BY RBITM DESC");
|
||||
cmdSelectRasb.Parameters.Add(Query.NewParameter("RANUM", DbType.String));
|
||||
cmdSelectRasb.Parameters.Add(Query.NewParameter("RAITM", DbType.Int32));
|
||||
|
||||
// 取出某一筆員工派遣資料
|
||||
cmdSelectRasnOne = Query.NewCommand(selectRasn);
|
||||
cmdSelectRasnOne.Parameters.Add(Query.NewParameter("RANUM", DbType.String));
|
||||
cmdSelectRasnOne.Parameters.Add(Query.NewParameter("RAITM", DbType.Int32));
|
||||
|
||||
// 取出某一筆員工派遣異動資料
|
||||
cmdSelectRasbOne = Query.NewCommand(selectRasb + " AND B.RBITM=@RBITM");
|
||||
cmdSelectRasbOne.Parameters.Add(Query.NewParameter("RANUM", DbType.String));
|
||||
cmdSelectRasbOne.Parameters.Add(Query.NewParameter("RAITM", DbType.Int32));
|
||||
cmdSelectRasbOne.Parameters.Add(Query.NewParameter("RBITM", DbType.Int32));
|
||||
|
||||
// 取出某員工編號全部的紀錄,以異動次數排序
|
||||
cmdSelectRasnAll = Query.NewCommand(selectRasn + " UNION " + selectRasb + " ORDER BY RBITM");
|
||||
cmdSelectRasnAll.Parameters.Add(Query.NewParameter("RANUM", DbType.String));
|
||||
cmdSelectRasnAll.Parameters.Add(Query.NewParameter("RAITM", DbType.Int32));
|
||||
|
||||
// 取出某員工編號全部的紀錄,以生效日期排序
|
||||
cmdSelectRasnAll2 = Query.NewCommand(selectRasn + " UNION " + selectRasb + " ORDER BY RBBDT");
|
||||
cmdSelectRasnAll2.Parameters.Add(Query.NewParameter("RANUM", DbType.String));
|
||||
cmdSelectRasnAll2.Parameters.Add(Query.NewParameter("RAITM", DbType.Int32));
|
||||
}
|
||||
|
||||
public RasnDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
base._connectionConfig = connectionConfig;
|
||||
base._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RasnDAC(WQuery query)
|
||||
: this()
|
||||
{
|
||||
base._query = query;
|
||||
}
|
||||
|
||||
// 準備輸出資料架構
|
||||
private DataTable NewResult()
|
||||
{
|
||||
DataTable Result = new DataTable();
|
||||
Result.Columns.Add("RANUM", typeof(String));
|
||||
Result.Columns.Add("RAITM", typeof(Int32));
|
||||
Result.Columns.Add("RBITM", typeof(Int32));
|
||||
Result.Columns.Add("RBBDT", typeof(DateTime));
|
||||
Result.Columns.Add("RACNM", typeof(String));
|
||||
Result.Columns.Add("RAPYN", typeof(String));
|
||||
Result.Columns.Add("RASDT", typeof(DateTime));
|
||||
Result.Columns.Add("RAEDT", typeof(DateTime));
|
||||
Result.Columns.Add("RAJNO", typeof(String));
|
||||
Result.Columns.Add("RACNO", typeof(String));
|
||||
Result.Columns.Add("RABRH", typeof(String));
|
||||
Result.Columns.Add("RAS01", typeof(Double));
|
||||
Result.Columns.Add("RAWTZ", typeof(String));
|
||||
Result.Columns.Add("APPNO", typeof(Int32));
|
||||
Result.Columns.Add("BPSRM", typeof(Int32));
|
||||
Result.Columns.Add("BPSRD", typeof(Int32));
|
||||
Result.Columns.Add("BPP01", typeof(Int32));
|
||||
Result.Columns.Add("BPP02", typeof(Int32));
|
||||
Result.Columns.Add("BPP03", typeof(Int32));
|
||||
Result.Columns.Add("BPP04", typeof(Int32));
|
||||
Result.Columns.Add("BPP05", typeof(Int32));
|
||||
Result.Columns.Add("RAEDT_Changed", typeof(Char));
|
||||
Result.Columns.Add("RAJNO_Changed", typeof(Char));
|
||||
Result.Columns.Add("RACNO_Changed", typeof(Char));
|
||||
Result.Columns.Add("RABRH_Changed", typeof(Char));
|
||||
Result.Columns.Add("RAWTZ_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPSRM_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPSRD_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP01_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP02_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP03_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP04_Changed", typeof(Char));
|
||||
Result.Columns.Add("BPP05_Changed", typeof(Char));
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
private void FillResult(DataTable Result, DataRow source)
|
||||
{
|
||||
DataRow newRow = Result.NewRow();
|
||||
newRow["RANUM"] = source["RANUM"];
|
||||
newRow["RAITM"] = source["RAITM"];
|
||||
newRow["RBITM"] = source["RBITM"];
|
||||
newRow["RBBDT"] = source["RBBDT"];
|
||||
newRow["RACNM"] = source["RACNM"];
|
||||
newRow["RAPYN"] = source["RAPYN"];
|
||||
newRow["RASDT"] = source["RASDT"];
|
||||
newRow["RAEDT"] = source["RAEDT"];
|
||||
newRow["RAJNO"] = source["RAJNO"];
|
||||
newRow["RACNO"] = source["RACNO"];
|
||||
newRow["RABRH"] = source["RABRH"];
|
||||
newRow["RAS01"] = source["RAS01"];
|
||||
newRow["RAWTZ"] = source["RAWTZ"];
|
||||
newRow["APPNO"] = source["APPNO"];
|
||||
newRow["BPSRM"] = source["BPSRM"];
|
||||
newRow["BPSRD"] = source["BPSRD"];
|
||||
newRow["BPP01"] = source["BPP01"];
|
||||
newRow["BPP02"] = source["BPP02"];
|
||||
newRow["BPP03"] = source["BPP03"];
|
||||
newRow["BPP04"] = source["BPP04"];
|
||||
newRow["BPP05"] = source["BPP05"];
|
||||
newRow["RAEDT_Changed"] = 'N';
|
||||
newRow["RAJNO_Changed"] = 'N';
|
||||
newRow["RACNO_Changed"] = 'N';
|
||||
newRow["RABRH_Changed"] = 'N';
|
||||
newRow["RAWTZ_Changed"] = 'N';
|
||||
newRow["BPSRM_Changed"] = 'N';
|
||||
newRow["BPSRD_Changed"] = 'N';
|
||||
newRow["BPP01_Changed"] = 'N';
|
||||
newRow["BPP02_Changed"] = 'N';
|
||||
newRow["BPP03_Changed"] = 'N';
|
||||
newRow["BPP04_Changed"] = 'N';
|
||||
newRow["BPP05_Changed"] = 'N';
|
||||
Result.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
private Char FieldDiff(object obj1, object obj2)
|
||||
{
|
||||
string s1 = obj1 != DBNull.Value ? obj1.ToString() : "";
|
||||
string s2 = obj2 != DBNull.Value ? obj2.ToString() : "";
|
||||
if (s1.CompareTo(s2) != 0)
|
||||
return 'Y';
|
||||
else
|
||||
return 'N';
|
||||
}
|
||||
|
||||
private void FillResult(DataTable Result, DataRow current, DataRow prev)
|
||||
{
|
||||
DataRow newRow = Result.NewRow();
|
||||
newRow["RANUM"] = current["RANUM"];
|
||||
newRow["RAITM"] = current["RAITM"];
|
||||
newRow["RBITM"] = current["RBITM"];
|
||||
newRow["RBBDT"] = current["RBBDT"];
|
||||
newRow["RACNM"] = current["RACNM"];
|
||||
newRow["RAPYN"] = current["RAPYN"];
|
||||
newRow["RASDT"] = current["RASDT"];
|
||||
newRow["RAEDT"] = current["RAEDT"];
|
||||
newRow["RAJNO"] = current["RAJNO"];
|
||||
newRow["RACNO"] = current["RACNO"];
|
||||
newRow["RABRH"] = current["RABRH"];
|
||||
newRow["RAS01"] = current["RAS01"];
|
||||
newRow["APPNO"] = current["APPNO"];
|
||||
newRow["BPSRM"] = current["BPSRM"];
|
||||
newRow["BPSRD"] = current["BPSRD"];
|
||||
newRow["BPP01"] = current["BPP01"];
|
||||
newRow["BPP02"] = current["BPP02"];
|
||||
newRow["BPP03"] = current["BPP03"];
|
||||
newRow["BPP04"] = current["BPP04"];
|
||||
newRow["BPP05"] = current["BPP05"];
|
||||
newRow["RAEDT_Changed"] = FieldDiff(current["RAEDT"], prev["RAEDT"]);
|
||||
newRow["RAJNO_Changed"] = FieldDiff(current["RAJNO"], prev["RAJNO"]);
|
||||
newRow["RACNO_Changed"] = FieldDiff(current["RACNO"], prev["RACNO"]);
|
||||
newRow["RABRH_Changed"] = FieldDiff(current["RABRH"], prev["RABRH"]);
|
||||
newRow["BPSRM_Changed"] = FieldDiff(current["BPSRM"], prev["BPSRM"]);
|
||||
newRow["BPSRD_Changed"] = FieldDiff(current["BPSRD"], prev["BPSRD"]);
|
||||
newRow["BPP01_Changed"] = FieldDiff(current["BPP01"], prev["BPP01"]);
|
||||
newRow["BPP02_Changed"] = FieldDiff(current["BPP02"], prev["BPP02"]);
|
||||
newRow["BPP03_Changed"] = FieldDiff(current["BPP03"], prev["BPP03"]);
|
||||
newRow["BPP04_Changed"] = FieldDiff(current["BPP04"], prev["BPP04"]);
|
||||
newRow["BPP05_Changed"] = FieldDiff(current["BPP05"], prev["BPP05"]);
|
||||
Result.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 依條件取出資料,給 GridView 的 Select 用的
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable Select(string RACNM, string RAPYN)
|
||||
{
|
||||
cmdSelectRasnRapyn.Parameters.Clear();
|
||||
|
||||
DataTable Result = NewResult();
|
||||
|
||||
// 依條件抓出派遣紀錄
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("SELECT * FROM RASN WHERE 1=1");
|
||||
if (RACNM != null && RACNM.Length > 0)
|
||||
{
|
||||
sb.Append(" AND RACNM LIKE @RACNM ");
|
||||
cmdSelectRasnRapyn.Parameters.Add(Query.NewParameter("RACNM", RACNM + "%"));
|
||||
}
|
||||
if (RAPYN != null && RAPYN.Length > 0)
|
||||
{
|
||||
sb.Append(" AND RAPYN LIKE @RAPYN ");
|
||||
cmdSelectRasnRapyn.Parameters.Add(Query.NewParameter("RAPYN", RAPYN + "%"));
|
||||
}
|
||||
sb.Append("ORDER BY RACNM, RAPYN, RANUM, RAITM");
|
||||
|
||||
cmdSelectRasnRapyn.CommandText = sb.ToString();
|
||||
DataTable rasnTmp1 = Query.Select(cmdSelectRasnRapyn);
|
||||
|
||||
// 一筆一筆的抓出應該顯示的資料
|
||||
DataTable rasnTmp2;
|
||||
foreach (DataRow rasnRow in rasnTmp1.Rows)
|
||||
{
|
||||
// 依照員工編號及派遣項次,抓出最後一筆異動
|
||||
cmdSelectRasb.Parameters["RANUM"].Value = rasnRow["RANUM"];
|
||||
cmdSelectRasb.Parameters["RAITM"].Value = rasnRow["RAITM"];
|
||||
rasnTmp2 = Query.Select(cmdSelectRasb);
|
||||
|
||||
// 填入異動資料
|
||||
if (rasnTmp2.Rows.Count != 0)
|
||||
{
|
||||
FillResult(Result, rasnTmp2.Rows[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某一筆派遣異動資料,給 FormView 的 Select 用的
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectOne(string RANUM, int RAITM, int RBITM)
|
||||
{
|
||||
return SelectOne(RANUM, RAITM, RBITM, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某一筆派遣異動資料,可加入交易中執行
|
||||
/// </summary>
|
||||
public DataTable SelectOne(string RANUM, int RAITM, int RBITM, DbTransaction tran)
|
||||
{
|
||||
DataTable Result = NewResult();
|
||||
DataTable tmp;
|
||||
|
||||
if (RANUM != null && RANUM.Length > 0)
|
||||
{
|
||||
// 取原始資料
|
||||
if (RBITM == 0)
|
||||
{
|
||||
cmdSelectRasnOne.Parameters["RANUM"].Value = RANUM;
|
||||
cmdSelectRasnOne.Parameters["RAITM"].Value = RAITM;
|
||||
if (tran == null)
|
||||
tmp = Query.Select(cmdSelectRasnOne);
|
||||
else
|
||||
tmp = Query.Select(cmdSelectRasnOne, tran);
|
||||
if (tmp.Rows.Count > 0)
|
||||
FillResult(Result, tmp.Rows[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdSelectRasbOne.Parameters["RANUM"].Value = RANUM;
|
||||
cmdSelectRasbOne.Parameters["RAITM"].Value = RAITM;
|
||||
cmdSelectRasbOne.Parameters["RBITM"].Value = RBITM;
|
||||
if (tran == null)
|
||||
tmp = Query.Select(cmdSelectRasbOne);
|
||||
else
|
||||
tmp = Query.Select(cmdSelectRasbOne, tran);
|
||||
if (tmp.Rows.Count > 0)
|
||||
FillResult(Result, tmp.Rows[0]);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出所有派遣異動歷史資料,派遣異動查詢用
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectRASB(string RANUM, int RAITM)
|
||||
{
|
||||
DataTable Result = NewResult();
|
||||
|
||||
if (RANUM != null && RANUM.Length > 0)
|
||||
{
|
||||
cmdSelectRasnAll.Parameters["RANUM"].Value = RANUM;
|
||||
cmdSelectRasnAll.Parameters["RAITM"].Value = RAITM;
|
||||
|
||||
DataTable tmp = Query.Select(cmdSelectRasnAll);
|
||||
for (int i = 0; i < tmp.Rows.Count; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
FillResult(Result, tmp.Rows[i], tmp.Rows[i - 1]);
|
||||
else
|
||||
FillResult(Result, tmp.Rows[i]);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某人員最近的專案
|
||||
/// </summary>
|
||||
/// <param name="BPENO"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable SelectRecent(string BPENO)
|
||||
{
|
||||
return SelectRecentByDate(BPENO, DateTime.UtcNow.AddHours(8).Date);
|
||||
|
||||
//var cmd = Query.NewCommand(
|
||||
// @"SELECT TOP 1 A.BPENO, A.BPNME
|
||||
// , B.RANUM, B.RAITM, B.RACNM, B.RAPYN, B.RASDT, B.RAEDT, B.RABRH, B.RAWTZ
|
||||
// , F.BPCNO, F.BPCME, F.BPSRM, F.BPSRD
|
||||
// FROM BPSNView A
|
||||
// LEFT OUTER JOIN RASN B ON A.BPENO=B.RANUM AND (B.RAEDT IS NULL OR (B.RASDT <= @TODAY AND B.RAEDT >= @TODAY))
|
||||
// LEFT OUTER JOIN BPJB F ON B.RAPYN=F.BPPYN AND B.RAJNO=F.BPJNO AND B.RACNO=F.BPCNO
|
||||
// WHERE A.BPENO = @BPENO
|
||||
// ORDER BY B.RASDT DESC");
|
||||
//Query.AddParam(cmd, "TODAY", DateTime.UtcNow.AddHours(8).Date);
|
||||
//Query.AddParam(cmd, "BPENO", BPENO);
|
||||
//return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某人員某日期的專案
|
||||
/// </summary>
|
||||
/// <param name="BPENO"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable SelectRecentByDate(string BPENO, DateTime DATE)
|
||||
{
|
||||
var cmd = Query.NewCommand(
|
||||
@"SELECT TOP 1 A.BPENO, A.BPNME
|
||||
, B.RANUM, B.RAITM, B.RACNM, B.RAPYN, B.RASDT, B.RAEDT, B.RABRH, B.RAWTZ
|
||||
, F.BPCNO, F.BPCME, F.BPSRM, F.BPSRD
|
||||
FROM BPSNView A
|
||||
LEFT OUTER JOIN RASN B ON A.BPENO=B.RANUM AND ((B.RASDT <= @DATE AND B.RAEDT IS NULL) OR (B.RASDT <= @DATE AND B.RAEDT >= @DATE))
|
||||
LEFT OUTER JOIN BPJB F ON B.RAPYN=F.BPPYN AND B.RAJNO=F.BPJNO AND B.RACNO=F.BPCNO
|
||||
WHERE A.BPENO = @BPENO
|
||||
ORDER BY B.RASDT DESC");
|
||||
Query.AddParam(cmd, "DATE", DATE);
|
||||
Query.AddParam(cmd, "BPENO", BPENO);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某專案年度接單的站別清單
|
||||
/// </summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<RASNBRHItem> SelectBranchForForm(string rapyn)
|
||||
{
|
||||
var cmd = Query.NewCommand(
|
||||
@"SELECT DISTINCT A.RAPYN ProjectID, A.RABRH BranchID, B.BSSCR BranchName, B.BSRMK BranchShortName, GroupID
|
||||
FROM RASN A
|
||||
JOIN BCLS B ON A.RABRH=B.BSCLS AND B.BSPAR='BPSNBRH'
|
||||
LEFT JOIN ProjectBranchGroup C ON A.RAPYN=C.ProjectID AND A.RABRH=C.BranchID
|
||||
WHERE A.RAPYN=@RAPYN");
|
||||
Query.AddParam(cmd, "RAPYN", rapyn);
|
||||
return Query.Select<RASNBRHItem>(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某專案年度接單的站別清單,依照分組順序排序
|
||||
/// </summary>
|
||||
public List<RASNBRHItem> SelectBranchForReport(string rapyn)
|
||||
{
|
||||
var cmd = Query.NewCommand(
|
||||
@"SELECT DISTINCT A.RAPYN ProjectID, A.RABRH BranchID, B.BSSCR BranchName, B.BSRMK BranchShortName, GroupID
|
||||
FROM RASN A
|
||||
JOIN BCLS B ON A.RABRH=B.BSCLS AND B.BSPAR='BPSNBRH'
|
||||
JOIN ProjectBranchGroup C ON A.RAPYN=C.ProjectID AND A.RABRH=C.BranchID
|
||||
WHERE A.RAPYN=@RAPYN
|
||||
ORDER BY GroupID");
|
||||
Query.AddParam(cmd, "RAPYN", rapyn);
|
||||
return Query.Select<RASNBRHItem>(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出某人員的專案歷史紀錄
|
||||
/// </summary>
|
||||
/// <param name="ranum"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable SelectHistoryByEmployee(string ranum)
|
||||
{
|
||||
var cmd = Query.NewCommand(
|
||||
@"SELECT B.BPENO, B.BPNME
|
||||
, A.RAITM, A.RAPYN, C.BPPYM
|
||||
, A.RASDT, A.RAEDT, A.RABRH, D.BSSCR
|
||||
, F.BPJNO, F.BPJME
|
||||
FROM RASN A
|
||||
LEFT OUTER JOIN BPSNView B ON B.BPENO=A.RANUM
|
||||
LEFT JOIN BPAA C ON A.RAPYN = C.BPPYN
|
||||
LEFT JOIN BCLS D ON A.RABRH = D.BSCLS AND D.BSPAR = 'BPSNBRH'
|
||||
LEFT JOIN BPJA F ON A.RAPYN = F.BPPYN AND A.RAJNO=F.BPJNO
|
||||
WHERE A.RANUM = @RANUM
|
||||
ORDER BY A.RASDT DESC");
|
||||
Query.AddParam(cmd, "RANUM", ranum);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
public void GetTimeZone(string bpeno, DateTime date, out string timezoneID, out string timezoneName)
|
||||
{
|
||||
var rasnTable = SelectRecentByDate(bpeno, date);
|
||||
timezoneName = string.Empty;
|
||||
timezoneID = string.Empty;
|
||||
|
||||
if (rasnTable.Rows.Count > 0)
|
||||
{
|
||||
timezoneName = WDAC.GetStringValue(rasnTable.Rows[0]["RAWTZ"]);
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT WINDOWS_ID FROM BTMZ WHERE NAME=@NAME";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "NAME", rasnTable.Rows[0]["RAWTZ"]);
|
||||
timezoneID = WDAC.GetStringValue(Query.ExecuteScalar(cmd)).Trim();
|
||||
|
||||
// 如果表格內沒取到,這裡做個保險
|
||||
if (string.IsNullOrEmpty(timezoneID))
|
||||
{
|
||||
switch (timezoneName)
|
||||
{
|
||||
case "台北":
|
||||
case "":
|
||||
case null:
|
||||
break;
|
||||
case "美西":
|
||||
timezoneID = "Pacific Standard Time";
|
||||
break;
|
||||
case "美東":
|
||||
timezoneID = "Eastern Standard Time";
|
||||
break;
|
||||
case "東京":
|
||||
timezoneID = "Tokyo Standard Time";
|
||||
break;
|
||||
case "倫敦":
|
||||
timezoneID = "GMT Standard Time";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出日期區間內派遣資料以及派遣異動資料
|
||||
/// </summary>
|
||||
/*
|
||||
public DataTable SelectRASNDateRange(string RANUM, int RAITM, DateTime startDay, DateTime endDay, DbTransaction tran)
|
||||
{
|
||||
// 1. 取出區間內派遣資料,依照開始日期排序
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT RANUM, RAITM, RASDT
|
||||
FROM RASN
|
||||
WHERE RANUM=@RANUM AND RAITM=@RAITM
|
||||
AND ((RASDT <= @YYMM1 AND RAEDT >= @YYMM2)
|
||||
OR (RASDT <= @YYMM1 AND RAEDT IS NULL)
|
||||
OR (RASDT <= @YYMM1 AND RAEDT >= @YYMM1 AND RAEDT <= @YYMM2)
|
||||
OR (RASDT >= @YYMM1 AND RASDT <= @YYMM2 AND RAEDT >= @YYMM2)
|
||||
OR (RASDT >= @YYMM1 AND RASDT <= @YYMM2 AND RAEDT IS NULL)
|
||||
OR (RASDT >= @YYMM1 AND RASDT <= @YYMM2 AND RAEDT >= @YYMM1 AND RAEDT <= @YYMM2))
|
||||
ORDER BY RASDT");
|
||||
cmd.Parameters.Add(Query.NewParameter("RANUM", RANUM));
|
||||
cmd.Parameters.Add(Query.NewParameter("RAITM", RAITM));
|
||||
cmd.Parameters.Add(Query.NewParameter("YYMM1", startDay));
|
||||
cmd.Parameters.Add(Query.NewParameter("YYMM2", endDay));
|
||||
cmd.Connection = tran.Connection;
|
||||
cmd.Transaction = tran;
|
||||
DbDataAdapter da = Query.NewDataAdapter(cmd);
|
||||
DataTable rasnTmp1 = new DataTable();
|
||||
da.Fill(rasnTmp1);
|
||||
|
||||
if (rasnTmp1.Rows.Count == 0)
|
||||
return rasnTmp1;
|
||||
|
||||
DataTable rasn;
|
||||
|
||||
foreach (DataRow rasnRow in rasnTmp1.Rows)
|
||||
{
|
||||
string ranum = rasnRow["RANUM"].ToString();
|
||||
int raitm = Convert.ToInt32(rasnRow["RAITM"]);
|
||||
|
||||
// 取得主檔與異動紀錄
|
||||
rasn = SelectRASB(ranum, raitm);
|
||||
// 取得異動紀錄
|
||||
//rpir.Merge(rpirDao.SelectRPIBMonth(ranum, startDay, endDay, tran), true, MissingSchemaAction.Add);
|
||||
}
|
||||
|
||||
// 整理每一筆紀錄,將退保日期填入
|
||||
for (int i = 0; i < rasn.Rows.Count; i++)
|
||||
{
|
||||
int rpitm = Convert.ToInt32(rasn.Rows[i]["RPITM"]);
|
||||
|
||||
rasn.Rows[i].BeginEdit();
|
||||
|
||||
// 若項次不是 0,把加保日填入生效日 //的次月一號
|
||||
if (rpitm != 0)
|
||||
{
|
||||
DateTime rpbdt = Convert.ToDateTime(rasn.Rows[i]["RPBDT"]);
|
||||
//rpir.Rows[i]["RPSDT"] = WGuard1.GetMonthBegin(rpbdt, 1);
|
||||
rasn.Rows[i]["RPSDT"] = rpbdt;
|
||||
}
|
||||
|
||||
// 沒有退保日
|
||||
if (rasn.Rows[i]["RPEDT"] == DBNull.Value)
|
||||
{
|
||||
// 若不是最後一筆,且下一筆項次不是 0
|
||||
if (i < rasn.Rows.Count - 1 && Convert.ToInt32(rasn.Rows[i + 1]["RPITM"]) != 0)
|
||||
{
|
||||
// 下一筆沒有退保日,把下一筆的生效日期前一天 // 的當月月底,放入退保日期
|
||||
if (rasn.Rows[i + 1]["RPEDT"] == DBNull.Value)
|
||||
{
|
||||
DateTime rpbdt = Convert.ToDateTime(rasn.Rows[i + 1]["RPBDT"]);
|
||||
//rpir.Rows[i]["RPEDT"] = WGuard1.GetMonthEnd(rpbdt, 0);
|
||||
rasn.Rows[i]["RPEDT"] = rpbdt.AddDays(-1);
|
||||
}
|
||||
// 下一筆有退保日,把下一筆的退保日,放入這一筆的退保日期
|
||||
else
|
||||
{
|
||||
rasn.Rows[i]["RPEDT"] = rasn.Rows[i + 1]["RPEDT"];
|
||||
}
|
||||
}
|
||||
// 最後一筆
|
||||
else if (i == rasn.Rows.Count - 1)
|
||||
{
|
||||
DateTime rpsdt = Convert.ToDateTime(rasn.Rows[i]["RPSDT"]);
|
||||
// 加保日大於月底日,退保日放入加保日的當月月底
|
||||
if (rpsdt > endDay)
|
||||
rasn.Rows[i]["RPEDT"] = WGuard1.GetMonthEnd(rpsdt, 0);
|
||||
// 否則放入月底日
|
||||
else
|
||||
rasn.Rows[i]["RPEDT"] = endDay;
|
||||
}
|
||||
}
|
||||
|
||||
rasn.Rows[i].EndEdit();
|
||||
}
|
||||
|
||||
// 再一次整理,剔除:
|
||||
// 1. 加保日與退保日均在日期區間外的紀錄
|
||||
// 2. 退保日小於加保日的紀錄
|
||||
// 3. 加保日等於退保日且是最後一筆,但項次不是 0 的紀錄
|
||||
int count = rasn.Rows.Count - 1;
|
||||
for (int i = rasn.Rows.Count - 1; i >= 0; i--)
|
||||
{
|
||||
DateTime rpsdt = Convert.ToDateTime(rasn.Rows[i]["RPSDT"]);
|
||||
DateTime rpedt = Convert.ToDateTime(rasn.Rows[i]["RPEDT"]);
|
||||
int rpitm = Convert.ToInt32(rasn.Rows[i]["RPITM"]);
|
||||
|
||||
if ((rpsdt < startDay && rpedt < startDay)
|
||||
|| (rpsdt > endDay && rpedt > endDay)
|
||||
|| (rpsdt > rpedt)
|
||||
|| (rpsdt == rpedt && i == count && rpitm != 0))
|
||||
rasn.Rows.RemoveAt(i);
|
||||
}
|
||||
return rasn;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class RASNBRHItem
|
||||
{
|
||||
public string ProjectID { get; set; }
|
||||
public string BranchID { get; set; }
|
||||
public string BranchName { get; set; }
|
||||
public string BranchShortName { get; set; }
|
||||
public string GroupID { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 補休補登以及沖補登
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class RbsaDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public RbsaDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RbsaDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RbsaDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable Select(string RBPYN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"SELECT RBREN, RBENO, RBPYN, RBDAT, RBTCT / 60 AS RBTCT, RBUST FROM RBSA
|
||||
WHERE RBPYN=@RBPYN
|
||||
ORDER BY RBENO, RBDAT";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RBPYN", RBPYN);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(string RBENO, string RBPYN, DateTime RBDAT, int RBTCT, string TRUSR)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO RBSA
|
||||
(RBREN, RBENO, RBPYN, RBDAT, RBTCT, RBUST, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RBREN, @RBENO, @RBPYN, @RBDAT, @RBTCT, 0, GETDATE(), 'INSERT', @TRUSR)";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RBREN", NextRBREN(RBDAT));
|
||||
Query.AddParam(cmd, "RBENO", RBENO);
|
||||
Query.AddParam(cmd, "RBPYN", RBPYN);
|
||||
Query.AddParam(cmd, "RBDAT", RBDAT);
|
||||
Query.AddParam(cmd, "RBTCT", RBTCT * 60);
|
||||
Query.AddParam(cmd, "TRUSR", TRUSR);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(string OLD_RBREN, string RBENO, string RBPYN, DateTime RBDAT, int RBTCT, string TRUSR)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"UPDATE RBSA
|
||||
SET TRDAT = GETDATE() ,
|
||||
TRMOD = 'UPDATE' ,
|
||||
TRUSR = @TRUSR ,
|
||||
RBENO = @RBENO ,
|
||||
RBPYN = @RBPYN ,
|
||||
RBDAT = @RBDAT ,
|
||||
RBTCT = @RBTCT
|
||||
WHERE RBREN = @RBREN";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", TRUSR);
|
||||
Query.AddParam(cmd, "RBENO", RBENO);
|
||||
Query.AddParam(cmd, "RBPYN", RBPYN);
|
||||
Query.AddParam(cmd, "RBDAT", RBDAT);
|
||||
Query.AddParam(cmd, "RBTCT", RBTCT * 60);
|
||||
Query.AddParam(cmd, "RBREN", OLD_RBREN);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(string OLD_RBREN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"DELETE FROM RBSA
|
||||
WHERE RBREN = @RBREN";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RBREN", OLD_RBREN);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
public string NextRBREN(DateTime RBDAT)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"DECLARE @MAXRBREN NVARCHAR(10)
|
||||
DECLARE @YYMM NVARCHAR(6)
|
||||
DECLARE @SERIAL NVARCHAR(4)
|
||||
SELECT @MAXRBREN = ISNULL(MAX(RBREN), @RBREN1) FROM RBSA WHERE RBREN > @RBREN1 AND RBREN <= @RBREN2
|
||||
SET @YYMM = SUBSTRING(@MAXRBREN, 1, 6)
|
||||
SET @SERIAL = SUBSTRING(@MAXRBREN, 7, 4)
|
||||
SELECT @YYMM + RIGHT('0000' + CAST(CAST(@SERIAL AS INT) + 1 AS NVARCHAR(4)), 4)";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RBREN1", RBDAT.ToString("yyyyMM", WGuard1.InvariantCulture) + "0000");
|
||||
Query.AddParam(cmd, "RBREN2", RBDAT.ToString("yyyyMM", WGuard1.InvariantCulture) + "9999");
|
||||
return Query.ExecuteScalar(cmd).ToString();
|
||||
}
|
||||
|
||||
/// <param name="rbeno">員工編號</param>
|
||||
/// <param name="rpdat">請假日期</param>
|
||||
/// <returns></returns>
|
||||
public int Get可用補休(string rbeno, DateTime rpdat)
|
||||
{
|
||||
// 取得員工在請假日期所在專案的補休期限設定
|
||||
int otd = new GetData(Query).GetBPOTD_DATE_BPENO(rpdat, rbeno);
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = @"
|
||||
SELECT SUM(RBTCT - ISNULL(RBUST, 0))
|
||||
FROM RBSA
|
||||
WHERE RBENO = @RBENO
|
||||
AND RBDAT >= @RBDAT
|
||||
AND (RBUST IS NULL OR RBUST<RBTCT)
|
||||
AND RBDAT < @TODAY -- 20160429 增加加班日期需小於今天的條件
|
||||
AND RBDAT >= dbo.BPSDY(@RBENO) -- 加班日期大於到職日的條件
|
||||
";
|
||||
|
||||
AddParam(cmd, "RBENO", rbeno);
|
||||
AddParam(cmd, "RBDAT", rpdat.AddMonths(-otd));
|
||||
AddParam(cmd, "TODAY", DateTime.UtcNow.AddHours(8).Date);
|
||||
return WDAC.GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 沖補休補登
|
||||
/// </summary>
|
||||
/// <param name="tran">要參加的交易</param>
|
||||
/// <param name="rbren">請假單號</param>
|
||||
/// <param name="rbeno">員工編號</param>
|
||||
/// <param name="rbdat">請假日期</param>
|
||||
/// <param name="rbtct">請假時數</param>
|
||||
/// <param name="備註">補休備註</param>
|
||||
/// <returns>剩餘時數</returns>
|
||||
public int 沖補休(DbTransaction tran, string rbren, string rbeno, DateTime rbdat, int rbtct, out string 備註)
|
||||
{
|
||||
備註 = "";
|
||||
|
||||
// 取得員工在請假日期所在專案的補休期限設定
|
||||
int otd = new GetData(Query).GetBPOTD_DATE_BPENO(rbdat, rbeno);
|
||||
|
||||
// 取出可沖補休補登單
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT RBREN, RBENO, RBPYN, RBDAT, RBTCT, RBUST
|
||||
FROM RBSA
|
||||
WHERE RBENO = @RBENO
|
||||
AND RBDAT >= @RBDAT -- 補休6個月之內有效
|
||||
AND RBDAT >= dbo.BPSDY(@RBENO) -- 到職日之後
|
||||
AND RBDAT < @TODAY -- 今天之前
|
||||
AND (RBUST IS NULL OR RBUST<RBTCT)
|
||||
ORDER BY RBDAT, RBREN";
|
||||
AddParam(cmd, "RBENO", rbeno);
|
||||
AddParam(cmd, "RBDAT", rbdat.AddMonths(-otd));
|
||||
AddParam(cmd, "TODAY", DateTime.UtcNow.AddHours(8).Date);
|
||||
DataTable data = Query.Select(cmd, tran);
|
||||
|
||||
// 準備新增補休補登沖帳檔 SQL
|
||||
DbCommand cmdInsertRbsb = Query.NewCommand();
|
||||
cmdInsertRbsb.CommandText =
|
||||
@"INSERT INTO RBSB
|
||||
(RBREN, RBREX, RBTCT, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RBREN, @RBREX, @RBTCT, GETDATE(), 'INSERT', @TRUSR)";
|
||||
|
||||
// 準備回填已沖時數 SQL
|
||||
DbCommand cmdUpdateRbsa = Query.NewCommand();
|
||||
cmdUpdateRbsa.CommandText =
|
||||
@"UPDATE RBSA
|
||||
SET RBUST = (SELECT SUM(RBTCT) FROM RBSB WHERE RBREX=RBSA.RBREN)
|
||||
WHERE RBREN = @RBREN";
|
||||
|
||||
// 用來儲存要重新加總的 RBSA 的 RBREN,以免 RBSA 重複 UPDATE 被 LOCK
|
||||
List<string> RbsaRbren = new List<string>();
|
||||
|
||||
foreach (DataRow row in data.Rows)
|
||||
{
|
||||
// 一筆一筆的寫沖銷紀錄
|
||||
string rbren1 = WDAC.GetStringValue(row["RBREN"]);
|
||||
int rbtct1 = WDAC.GetInt32Value(row["RBTCT"]);
|
||||
int rbust1 = WDAC.GetInt32Value(row["RBUST"]);
|
||||
DateTime rbdat1 = WDAC.GetDateTimeValue(row["RBDAT"]);
|
||||
|
||||
int tct = rbtct > rbtct1 - rbust1 ? rbtct1 - rbust1 : rbtct;
|
||||
rbtct -= tct;
|
||||
|
||||
// 新增補休補登沖帳檔
|
||||
AddParam(cmdInsertRbsb, "RBREN", rbren);
|
||||
AddParam(cmdInsertRbsb, "RBREX", rbren1);
|
||||
AddParam(cmdInsertRbsb, "RBTCT", tct);
|
||||
AddParam(cmdInsertRbsb, "TRUSR", rbeno);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmdInsertRbsb);
|
||||
|
||||
備註 += String.Format("{0:MM/dd}-{1}、", rbdat1, tct / 60);
|
||||
|
||||
if (!RbsaRbren.Contains(rbren1))
|
||||
RbsaRbren.Add(rbren1);
|
||||
|
||||
if (rbtct <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
// 重新加總 RBSA 的已用時數
|
||||
foreach (string rbren1 in RbsaRbren)
|
||||
{
|
||||
AddParam(cmdUpdateRbsa, "RBREN", rbren1);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmdUpdateRbsa);
|
||||
}
|
||||
|
||||
// 回傳未沖完的時數
|
||||
return rbtct;
|
||||
}
|
||||
|
||||
public void 取消沖補休(DbTransaction tran, string rbren)
|
||||
{
|
||||
// 取出本張單據沖銷的紀錄
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = @"SELECT RBREN, RBREX, RBTCT FROM RBSB WHERE RBREN=@RBREN";
|
||||
AddParam(cmd, "RBREN", rbren);
|
||||
DataTable data = Query.Select(cmd, tran);
|
||||
|
||||
DbCommand cmdDeleteRbsb = Query.NewCommand();
|
||||
cmdDeleteRbsb.CommandText =
|
||||
@"DELETE FROM RBSB
|
||||
WHERE RBREN = @RBREN AND RBREX = @RBREX";
|
||||
|
||||
DbCommand cmdUpdateRbsa = Query.NewCommand();
|
||||
cmdUpdateRbsa.CommandText =
|
||||
@"UPDATE RBSA
|
||||
SET RBUST = (SELECT SUM(RBTCT) FROM RBSB WHERE RBREX=RBSA.RBREN)
|
||||
WHERE RBREN = @RBREN";
|
||||
|
||||
// 用來儲存要重新加總的 RBSA 的 RBREN,以免 RBSA 重複 UPDATE 被 LOCK
|
||||
List<string> RbsaRbren = new List<string>();
|
||||
|
||||
// 還原被沖銷單據的被沖銷時數
|
||||
foreach (DataRow row in data.Rows)
|
||||
{
|
||||
string rprex1 = WDAC.GetStringValue(row["RBREX"]);
|
||||
int rptct1 = WDAC.GetInt32Value(row["RBTCT"]);
|
||||
|
||||
AddParam(cmdDeleteRbsb, "RBREN", rbren);
|
||||
AddParam(cmdDeleteRbsb, "RBREX", rprex1);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmdDeleteRbsb);
|
||||
|
||||
if (!RbsaRbren.Contains(rprex1))
|
||||
RbsaRbren.Add(rprex1);
|
||||
}
|
||||
|
||||
// 重新加總 RBSA 的已用時數
|
||||
foreach (string rbren1 in RbsaRbren)
|
||||
{
|
||||
AddParam(cmdUpdateRbsa, "RBREN", rbren1);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmdUpdateRbsa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 打卡資料檔
|
||||
/// </summary>
|
||||
public class RcrdDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public const string T01_上班 = "01";
|
||||
public const string T02_下班 = "02";
|
||||
public const string T03_中午休息 = "03";
|
||||
public const string T04_下午上班 = "04";
|
||||
public const string T05_加班上班 = "05";
|
||||
public const string T06_加班下班 = "06";
|
||||
public const string T07_出差離開 = "07";
|
||||
public const string T08_出差返回 = "08";
|
||||
|
||||
|
||||
public RcrdDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RcrdDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RcrdDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 讀取今天某人員的打卡資料
|
||||
/// </summary>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public DataTable ReadToday(string rcusr, DateTime date)
|
||||
{
|
||||
return ReadByDate(rcusr, date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 讀取某天某人員的打卡資料
|
||||
/// </summary>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public DataTable ReadByDate(string rcusr, DateTime date)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT RCDAT, RCUSR, RCC01, RCC02, RCC03, RCC04, RCC05, RCC06, RCC07, RCC08,
|
||||
RCP01, RCP02, RCP03, RCP04, RCP05, RCP06, RCP07, RCP08
|
||||
FROM RCRD WHERE RCDAT = @RCDAT AND RCUSR = @RCUSR ";
|
||||
Query.AddParam(cmd, "RCDAT", date);
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 讀取日期區間某人員的打卡資料
|
||||
/// </summary>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public DataTable SelectPeriod(string rcusr, DateTime rcdat1, DateTime rcdat2)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT RCDAT, RCUSR, RCC01, RCC02, RCC03, RCC04, RCC05, RCC06, RCC07, RCC08,
|
||||
RCP01, RCP02, RCP03, RCP04, RCP05, RCP06, RCP07, RCP08
|
||||
FROM RCRD WHERE RCUSR = @RCUSR AND RCDAT >= @RCDAT1 AND RCDAT < @RCDAT2";
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
Query.AddParam(cmd, "RCDAT1", rcdat1.Date);
|
||||
Query.AddParam(cmd, "RCDAT2", rcdat2.Date.AddDays(1));
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 檢查某一天某人員是否有打卡資料
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <returns></returns>
|
||||
public bool CheckExists(DateTime rcdat, string rcusr)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT COUNT(1) FROM RCRD WHERE RCDAT = @RCDAT AND RCUSR = @RCUSR ";
|
||||
Query.AddParam(cmd, "RCDAT", rcdat.Date);
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
int c = WQuery.GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <param name="time">時間</param>
|
||||
/// <param name="fieldName">打卡欄位</param>
|
||||
/// <param name="補打">是否為補打卡</param>
|
||||
private void Punch(DateAndTime rcdat, string rcusr, string ip, string fieldName, bool 補打)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
var d = ReadByDate(rcusr, rcdat.CardDate);
|
||||
|
||||
if (d.Rows.Count == 0)
|
||||
{
|
||||
cmd.CommandText =
|
||||
String.Format(@"INSERT INTO RCRD
|
||||
(TRDAT, TRMOD, TRUSR, RCDAT, RCUSR, RCC{0}, RCP{0}, RCZ{0})
|
||||
VALUES
|
||||
(GETDATE(), 'INSERT', @TRUSR, @RCDAT, @RCUSR, @TIME, @IP, @TIMEZONE)", fieldName);
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", rcusr);
|
||||
Query.AddParam(cmd, "RCDAT", rcdat.CardDate);
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
Query.AddParam(cmd, "TIME", rcdat.LocalTime);
|
||||
Query.AddParam(cmd, "IP", ip);
|
||||
Query.AddParam(cmd, "TIMEZONE", rcdat.TimezoneName);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (String.IsNullOrEmpty(WDAC.GetStringValue(d.Rows[0]["RCC" + fieldName])))
|
||||
{
|
||||
cmd.CommandText =
|
||||
String.Format(@"UPDATE RCRD
|
||||
SET TRDAT = GETDATE() ,
|
||||
TRMOD = 'UPDATE' ,
|
||||
TRUSR = @TRUSR ,
|
||||
RCC{0} = @TIME ,
|
||||
RCP{0} = @IP ,
|
||||
RCZ{0} = @TIMEZONE
|
||||
WHERE RCDAT = @RCDAT
|
||||
AND RCUSR = @RCUSR", fieldName);
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", rcusr);
|
||||
Query.AddParam(cmd, "TIME", rcdat.LocalTime);
|
||||
Query.AddParam(cmd, "IP", ip);
|
||||
Query.AddParam(cmd, "TIMEZONE", rcdat.TimezoneName);
|
||||
Query.AddParam(cmd, "RCDAT", rcdat.CardDate);
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除打卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <param name="fieldName">打卡欄位</param>
|
||||
private void Clear(DateTime rcdat, string rcusr, string fieldName)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
String.Format(@"UPDATE RCRD
|
||||
SET TRDAT = GETDATE() ,
|
||||
TRMOD = 'UPDATE' ,
|
||||
TRUSR = @TRUSR ,
|
||||
RCC{0} = NULL ,
|
||||
RCP{0} = NULL
|
||||
WHERE RCDAT = @RCDAT
|
||||
AND RCUSR = @RCUSR", fieldName);
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", rcusr);
|
||||
Query.AddParam(cmd, "RCDAT", rcdat);
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打上班卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <param name="time">時間</param>
|
||||
/// <param name="補打"></param>
|
||||
public void PunchRCC01(DateAndTime rcdat, string rcusr, string ip, bool 補打)
|
||||
{
|
||||
Punch(rcdat, rcusr, ip, T01_上班, 補打);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除上班卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public void ClearRCC01(DateTime rcdat, string rcusr)
|
||||
{
|
||||
Clear(rcdat, rcusr, T01_上班);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打下班卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <param name="time">時間</param>
|
||||
public void PunchRCC02(DateAndTime rcdat, string rcusr, string ip, bool 補打)
|
||||
{
|
||||
Punch(rcdat, rcusr, ip, T02_下班, 補打);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除下班卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public void ClearRCC02(DateTime rcdat, string rcusr)
|
||||
{
|
||||
Clear(rcdat, rcusr, T02_下班);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打出差外出打卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <param name="time">時間</param>
|
||||
public void PunchRCC07(DateAndTime rcdat, string rcusr, string ip, bool 補打)
|
||||
{
|
||||
Punch(rcdat, rcusr, ip, T07_出差離開, 補打);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除出差外出打卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public void ClearRCC07(DateTime rcdat, string rcusr)
|
||||
{
|
||||
Clear(rcdat, rcusr, T07_出差離開);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打出差返回打卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
/// <param name="time">時間</param>
|
||||
public void PunchRCC08(DateAndTime rcdat, string rcusr, string ip, bool 補打)
|
||||
{
|
||||
Punch(rcdat, rcusr, ip, T08_出差返回, 補打);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除出差返回打卡
|
||||
/// </summary>
|
||||
/// <param name="rcdat">日期</param>
|
||||
/// <param name="rcusr">人員編號</param>
|
||||
public void ClearRCC08(DateTime rcdat, string rcusr)
|
||||
{
|
||||
Clear(rcdat, rcusr, T08_出差返回);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某員工某日期往前6天之內的打卡天數
|
||||
/// </summary>
|
||||
/// <param name="rcdat"></param>
|
||||
/// <param name="rcusr"></param>
|
||||
/// <returns></returns>
|
||||
public int PunchDaysIn7Days(DateTime rcdat, string rcusr, bool includeLastDay)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = string.Format(@"SELECT COUNT(1) FROM RCRD
|
||||
WHERE RCUSR = @RCUSR
|
||||
AND RCDAT >= @RCDAT1
|
||||
AND RCDAT {0} @RCDAT2
|
||||
AND (RCC01 IS NOT NULL AND RCC01 <> ''
|
||||
OR RCC02 IS NOT NULL AND RCC02 <> ''
|
||||
OR RCC07 IS NOT NULL AND RCC07 <> ''
|
||||
OR RCC08 IS NOT NULL AND RCC08 <> '')", (includeLastDay ? "<=": "<"));
|
||||
Query.AddParam(cmd, "RCUSR", rcusr);
|
||||
Query.AddParam(cmd, "RCDAT1", rcdat.Date.AddDays(-6));
|
||||
Query.AddParam(cmd, "RCDAT2", rcdat.Date);
|
||||
int c = WQuery.GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Transactions;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// RlogDAC 的摘要描述
|
||||
/// </summary>
|
||||
public class RlogDAC : Wellan.Data.WDAC
|
||||
{
|
||||
//private string _select =
|
||||
// @" SELECT RLDAT, RLTIM, RLUSR, RLPRG, RLCIP, RLCNT, TRDAT, TRMOD, TRUSR FROM RLOG ";
|
||||
|
||||
private string _insert =
|
||||
@"INSERT INTO RLOG
|
||||
(RLDAT, RLTIM, RLUSR, RLPRG, RLCIP, RLCNT, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RLDAT, @RLTIM, @RLUSR, @RLPRG, @RLCIP, @RLCNT, GETDATE(), 'INSERT', @TRUSR)";
|
||||
|
||||
public RlogDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RlogDAC(WQuery query)
|
||||
: this()
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
public RlogDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public void InsertOne(string RLUSR, string RLPRG, string RLCIP, string RLCNT)
|
||||
{
|
||||
DbCommand cmdInsert = Query.NewCommand(_insert);
|
||||
Query.AddParam(cmdInsert, "RLDAT", DateTime.UtcNow.AddHours(8).Date);
|
||||
Query.AddParam(cmdInsert, "RLTIM", DateTime.UtcNow.AddHours(8).ToString("HH:mm:ss"));
|
||||
Query.AddParam(cmdInsert, "RLUSR", RLUSR);
|
||||
Query.AddParam(cmdInsert, "RLPRG", RLPRG);
|
||||
Query.AddParam(cmdInsert, "RLCIP", RLCIP);
|
||||
Query.AddParam(cmdInsert, "RLCNT", RLCNT);
|
||||
Query.AddParam(cmdInsert, "TRUSR", RLUSR);
|
||||
Query.ExecuteNonQuery(cmdInsert);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Transactions;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// 人員差勤簽核檔
|
||||
/// </summary>
|
||||
public class RpabDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private string _select =
|
||||
@" SELECT RPREN, RPANO, RPAPN, RPENO, RPDAT, RPAPP, RPDOC, TRDAT, TRMOD, TRUSR FROM RPAB ";
|
||||
private string _insert =
|
||||
@"INSERT INTO dbo.RPAB
|
||||
(RPREN, RPANO, RPAPN, RPENO, RPDAT, RPAPP, RPDOC, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RPREN, @RPANO, @RPAPN, @RPENO, NULL, NULL, NULL, GETDATE(), 'INSERT', @TRUSR)";
|
||||
private string _update1 =
|
||||
@"UPDATE dbo.RPAB SET
|
||||
RPDAT = @RPDAT,
|
||||
RPAPP = @RPAPP,
|
||||
RPDOC = @RPDOC,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE RPREN = @OLD_RPREN
|
||||
AND RPANO = @OLD_RPANO";
|
||||
private string _update2 =
|
||||
@"UPDATE dbo.RPAB SET
|
||||
RPENO = @RPENO,
|
||||
RPDAT = NULL,
|
||||
RPAPP = NULL,
|
||||
RPDOC = NULL,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE RPREN = @OLD_RPREN
|
||||
AND RPANO = @OLD_RPANO";
|
||||
private string _delete =
|
||||
@"DELETE FROM dbo.RPAB
|
||||
WHERE RPREN = @OLD_RPREN
|
||||
AND RPANO = @OLD_RPANO";
|
||||
|
||||
public RpabDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RpabDAC(WQuery query)
|
||||
: this()
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
public RpabDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public DataTable SelectRpren(string RPREN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE RPREN=@RPREN ";
|
||||
AddParam(cmd, "RPREN", RPREN);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
public DataTable SelectOne(string RPREN, string RPANO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE RPREN=@RPREN AND RPANO=@RPANO ";
|
||||
AddParam(cmd, "RPREN", RPREN);
|
||||
AddParam(cmd, "RPANO", RPANO);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
public DataTable SelectOne(DbTransaction tran, string RPREN, string RPANO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE RPREN=@RPREN AND RPANO=@RPANO ";
|
||||
AddParam(cmd, "RPREN", RPREN);
|
||||
AddParam(cmd, "RPANO", RPANO);
|
||||
return Query.Select(cmd, tran);
|
||||
}
|
||||
|
||||
private string NextRPANO(string RPREN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT ISNULL(MAX(RPANO), '0') + 1 FROM RPAB WHERE RPREN=@RPREN AND RPANO <> 'D' ";
|
||||
AddParam(cmd, "RPREN", RPREN);
|
||||
string s;
|
||||
ExecuteScalar(cmd, out s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private void InsertOne(DbTransaction tran, string RPREN, string RPAPN, string RPANO, string RPENO, object TRUSR)
|
||||
{
|
||||
if (string.IsNullOrEmpty(RPREN) || string.IsNullOrEmpty(RPAPN) || string.IsNullOrEmpty(RPANO) || string.IsNullOrEmpty(RPENO))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectOne(RPREN, RPANO).Rows.Count > 0)
|
||||
{
|
||||
UpdateOne(tran, RPREN, RPANO, RPENO, TRUSR);
|
||||
}
|
||||
else
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _insert;
|
||||
AddParam(cmd, "RPREN", RPREN);
|
||||
AddParam(cmd, "RPANO", RPANO);
|
||||
AddParam(cmd, "RPAPN", RPAPN);
|
||||
AddParam(cmd, "RPENO", RPENO);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOne(DbTransaction tran, string RPREN, string RPANO,
|
||||
object RPENO, object TRUSR)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _update2;
|
||||
AddParam(cmd, "RPENO", RPENO);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
AddParam(cmd, "OLD_RPREN", RPREN);
|
||||
AddParam(cmd, "OLD_RPANO", RPANO);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmd);
|
||||
}
|
||||
|
||||
private void UpdateOne(DbTransaction tran, string RPREN, string RPANO,
|
||||
object RPDAT, object RPAPP, object RPDOC, object TRUSR)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _update1;
|
||||
AddParam(cmd, "RPDAT", RPDAT);
|
||||
AddParam(cmd, "RPAPP", RPAPP);
|
||||
AddParam(cmd, "RPDOC", RPDOC);
|
||||
AddParam(cmd, "TRUSR", TRUSR);
|
||||
AddParam(cmd, "OLD_RPREN", RPREN);
|
||||
AddParam(cmd, "OLD_RPANO", RPANO);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmd);
|
||||
}
|
||||
|
||||
private void DeleteOne(DbTransaction tran, string RPREN, string RPANO)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _delete;
|
||||
AddParam(cmd, "OLD_RPREN", RPREN);
|
||||
AddParam(cmd, "OLD_RPANO", RPANO);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmd);
|
||||
}
|
||||
|
||||
public DataTable SelectLastOne(DbTransaction tran, string RPREN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT TOP 1 * FROM RPAB WHERE RPREN=@RPREN AND RPANO <> 'D' ORDER BY RPANO DESC";
|
||||
AddParam(cmd, "RPREN", RPREN);
|
||||
return Query.Select(cmd, tran);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 送簽
|
||||
/// </summary>
|
||||
/// <param name="RPREN">單號</param>
|
||||
/// <param name="RPENO">簽核人員</param>
|
||||
public void 送簽(DbTransaction tran, string RPREN, string RPAPN, string RPANO, string RPENO, string TRUSR)
|
||||
{
|
||||
InsertOne(tran, RPREN, RPAPN, RPANO, RPENO, TRUSR);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 抽單
|
||||
/// </summary>
|
||||
/// <param name="RPREN">單號</param>
|
||||
/// <param name="RPENO">簽核人員</param>
|
||||
public void 抽單(DbTransaction tran, string RPREN, string RPENO, string TRUSR)
|
||||
{
|
||||
InsertOne(tran, RPREN, "D", "D", RPENO, TRUSR);
|
||||
}
|
||||
|
||||
public string 取消抽單(DbTransaction tran, string RPREN, out string 前關關號,
|
||||
out DateTime 前關日期, out string 前關結果, out string 前關應簽)
|
||||
{
|
||||
DeleteOne(tran, RPREN, "D");
|
||||
DataTable t = SelectLastOne(tran, RPREN);
|
||||
if (t.Rows.Count > 0)
|
||||
{
|
||||
前關關號 = WDAC.GetStringValue(t.Rows[0]["RPANO"]);
|
||||
前關日期 = WDAC.GetDateTimeValue(t.Rows[0]["RPDAT"]);
|
||||
前關結果 = WDAC.GetStringValue(t.Rows[0]["RPAPP"]);
|
||||
前關應簽 = WDAC.GetStringValue(t.Rows[0]["RPAPN"]);
|
||||
return WDAC.GetStringValue(t.Rows[0]["RPENO"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
前關關號 = "";
|
||||
前關日期 = new DateTime();
|
||||
前關結果 = "";
|
||||
前關應簽 = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 核准
|
||||
/// </summary>
|
||||
/// <param name="RPREN">單號</param>
|
||||
/// <param name="RPANO">關卡</param>
|
||||
/// <param name="RPDAT">簽核日期</param>
|
||||
/// <param name="RPDOC">簽核備註</param>
|
||||
public void 核准(DbTransaction tran, string RPREN, string RPANO,
|
||||
DateTime RPDAT, string RPDOC, string TRUSR)
|
||||
{
|
||||
UpdateOne(tran, RPREN, RPANO, RPDAT, "Y", RPDOC, TRUSR);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 駁回
|
||||
/// </summary>
|
||||
/// <param name="RPREN">單號</param>
|
||||
/// <param name="RPENO">簽核人員</param>
|
||||
/// <param name="RPDAT">簽核日期</param>
|
||||
/// <param name="RPDOC">簽核備註</param>
|
||||
public void 不核准(DbTransaction tran, string RPREN, string RPANO,
|
||||
DateTime RPDAT, string RPDOC, string TRUSR)
|
||||
{
|
||||
UpdateOne(tran, RPREN, RPANO, RPDAT, "N", RPDOC, TRUSR);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消本關簽核
|
||||
/// </summary>
|
||||
public void 取消本關(DbTransaction tran, string RPREN, string 本關, string TRUSR)
|
||||
{
|
||||
UpdateOne(tran, RPREN, 本關, DBNull.Value, DBNull.Value, DBNull.Value, TRUSR);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消本關簽核,並退回上一關
|
||||
/// </summary>
|
||||
public string 退回上一關(DbTransaction tran, string RPREN, string 本關, string TRUSR)
|
||||
{
|
||||
// 抽單
|
||||
if (本關.CompareTo("D") == 0)
|
||||
{
|
||||
UpdateOne(tran, RPREN, "D", DBNull.Value, DBNull.Value, DBNull.Value, TRUSR);
|
||||
return "";
|
||||
}
|
||||
// 非抽單
|
||||
else
|
||||
{
|
||||
int i本關 = Convert.ToInt32(本關);
|
||||
if (i本關 > 1)
|
||||
{
|
||||
DeleteOne(tran, RPREN, 本關);
|
||||
UpdateOne(tran, RPREN, Convert.ToString(i本關 - 1), DBNull.Value, DBNull.Value, DBNull.Value, TRUSR);
|
||||
|
||||
DataTable t = SelectLastOne(tran, RPREN);
|
||||
if (t.Rows.Count > 0)
|
||||
return WDAC.GetStringValue(t.Rows[0]["RPENO"]);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刪除某張單據的簽核資料
|
||||
/// </summary>
|
||||
/// <param name="RPREN"></param>
|
||||
public void Delete(DbTransaction tran, string RPREN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"DELETE FROM dbo.RPAB
|
||||
WHERE RPREN = @OLD_RPREN";
|
||||
AddParam(cmd, "OLD_RPREN", RPREN);
|
||||
Query.ExecuteNonQuery(tran.Connection, tran, cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.Transactions;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// 出差費用檔
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class RpadDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private string _select =
|
||||
@"SELECT RPREN, RPITM, RPSTP, RPEDP, RPF01, RPF02, RPF03, RPF04, RPF05, RPF06, RPF07, RPF08,
|
||||
RPF09, RPF10, RPSUM, RPDAT, RPJOB, RPVCH, RPDOC, TRDAT, TRMOD, TRUSR
|
||||
FROM RPAD ";
|
||||
|
||||
public RpadDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RpadDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RpadDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectRpar(string rpren)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = _select + " WHERE RPREN=@RPREN ORDER BY RPITM";
|
||||
AddParam(cmd, "RPREN", rpren);
|
||||
return Query.Select(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(string userId, string rpren, string rpstp, string rpedp, int rpf01, int rpf02, int rpf03, int rpf04,
|
||||
int rpf05, int rpf06, int rpf07, int rpf08, int rpf09, int rpf10, DateTime rpdat, string rpvch, string rpdoc)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO RPAD
|
||||
(RPREN, RPITM, RPSTP, RPEDP, RPF01, RPF02, RPF03, RPF04, RPF05, RPF06, RPF07, RPF08, RPF09, RPF10, RPSUM, RPDAT, RPVCH, RPDOC, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RPREN, @RPITM, @RPSTP, @RPEDP, @RPF01, @RPF02, @RPF03, @RPF04, @RPF05, @RPF06, @RPF07, @RPF08, @RPF09, @RPF10, @RPSUM, @RPDAT, @RPVCH, @RPDOC, GETDATE(), 'INSERT', @TRUSR)";
|
||||
AddParam(cmd, "RPREN", rpren);
|
||||
AddParam(cmd, "RPITM", GetNextRpitm(rpren));
|
||||
AddParam(cmd, "RPSTP", rpstp);
|
||||
AddParam(cmd, "RPEDP", rpedp);
|
||||
AddParam(cmd, "RPF01", rpf01);
|
||||
AddParam(cmd, "RPF02", rpf02);
|
||||
AddParam(cmd, "RPF03", rpf03);
|
||||
AddParam(cmd, "RPF04", rpf04);
|
||||
AddParam(cmd, "RPF05", rpf05);
|
||||
AddParam(cmd, "RPF06", rpf06);
|
||||
AddParam(cmd, "RPF07", rpf07);
|
||||
AddParam(cmd, "RPF08", rpf08);
|
||||
AddParam(cmd, "RPF09", rpf09);
|
||||
AddParam(cmd, "RPF10", rpf10);
|
||||
AddParam(cmd, "RPSUM", rpf01 + rpf02 + rpf03 + rpf04 + rpf05 + rpf06 + rpf07 + rpf08 + rpf09 + rpf10);
|
||||
AddParam(cmd, "RPDAT", rpdat);
|
||||
AddParam(cmd, "RPVCH", rpvch);
|
||||
AddParam(cmd, "RPDOC", rpdoc);
|
||||
AddParam(cmd, "TRUSR", userId);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
|
||||
UpdateRpar(rpren);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(string userId, string rpren, int rpitm, string rpstp, string rpedp, int rpf01, int rpf02, int rpf03, int rpf04,
|
||||
int rpf05, int rpf06, int rpf07, int rpf08, int rpf09, int rpf10, DateTime rpdat, string rpvch, string rpdoc)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"UPDATE RPAD SET
|
||||
RPSTP = @RPSTP,
|
||||
RPEDP = @RPEDP,
|
||||
RPF01 = @RPF01,
|
||||
RPF02 = @RPF02,
|
||||
RPF03 = @RPF03,
|
||||
RPF04 = @RPF04,
|
||||
RPF05 = @RPF05,
|
||||
RPF06 = @RPF06,
|
||||
RPF07 = @RPF07,
|
||||
RPF08 = @RPF08,
|
||||
RPF09 = @RPF09,
|
||||
RPF10 = @RPF10,
|
||||
RPSUM = @RPSUM,
|
||||
RPDAT = @RPDAT,
|
||||
RPVCH = @RPVCH,
|
||||
RPDOC = @RPDOC,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'UPDATE',
|
||||
TRUSR = @TRUSR
|
||||
WHERE RPREN = @RPREN
|
||||
AND RPITM = @RPITM";
|
||||
AddParam(cmd, "RPSTP", rpstp);
|
||||
AddParam(cmd, "RPEDP", rpedp);
|
||||
AddParam(cmd, "RPF01", rpf01);
|
||||
AddParam(cmd, "RPF02", rpf02);
|
||||
AddParam(cmd, "RPF03", rpf03);
|
||||
AddParam(cmd, "RPF04", rpf04);
|
||||
AddParam(cmd, "RPF05", rpf05);
|
||||
AddParam(cmd, "RPF06", rpf06);
|
||||
AddParam(cmd, "RPF07", rpf07);
|
||||
AddParam(cmd, "RPF08", rpf08);
|
||||
AddParam(cmd, "RPF09", rpf09);
|
||||
AddParam(cmd, "RPF10", rpf10);
|
||||
AddParam(cmd, "RPSUM", rpf01 + rpf02 + rpf03 + rpf04 + rpf05 + rpf06 + rpf07 + rpf08 + rpf09 + rpf10);
|
||||
AddParam(cmd, "RPDAT", rpdat);
|
||||
AddParam(cmd, "RPVCH", rpvch);
|
||||
AddParam(cmd, "RPDOC", rpdoc);
|
||||
AddParam(cmd, "TRUSR", userId);
|
||||
AddParam(cmd, "RPREN", rpren);
|
||||
AddParam(cmd, "RPITM", rpitm);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
|
||||
UpdateRpar(rpren);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(string rpren, int rpitm)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"DELETE FROM RPAD
|
||||
WHERE RPREN = @RPREN
|
||||
AND RPITM = @RPITM";
|
||||
AddParam(cmd, "RPREN", rpren);
|
||||
AddParam(cmd, "RPITM", rpitm);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
|
||||
UpdateRpar(rpren);
|
||||
}
|
||||
|
||||
public void DeleteByRpren(string rpren)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"DELETE FROM RPAD
|
||||
WHERE RPREN = @RPREN";
|
||||
AddParam(cmd, "RPREN", rpren);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
|
||||
UpdateRpar(rpren);
|
||||
}
|
||||
|
||||
private int GetNextRpitm(string rpren)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = @"SELECT ISNULL(MAX(RPITM), 0) + 1 FROM RPAD WHERE RPREN=@RPREN";
|
||||
AddParam(cmd, "RPREN", rpren);
|
||||
return WDAC.GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
private void UpdateRpar(string rpren)
|
||||
{
|
||||
DbCommand cmd1 = Query.NewCommand();
|
||||
cmd1.CommandText =
|
||||
@"UPDATE RPAR
|
||||
SET RPFTR = (SELECT ISNULL(SUM(RPSUM), 0) FROM RPAD WHERE RPREN=@RPREN)
|
||||
WHERE RPREN=@RPREN";
|
||||
AddParam(cmd1, "RPREN", rpren);
|
||||
Query.ExecuteNonQuery(cmd1);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,439 @@
|
||||
//
|
||||
// 這個檔案是 RPSB 資料表的資料存取類別 檔案一
|
||||
// 請不要修改這個檔案,重新產生資料存取類別時,這個檔案會被覆蓋掉
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Wellan.Data;
|
||||
using System.Data.Common;
|
||||
using Wellan.Common;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
///<summary>
|
||||
/// RPSB 人員異動資料 資料存取類別
|
||||
///</summary>
|
||||
[DataObject]
|
||||
public class RpsbDAC : Wellan.Data.WDAC
|
||||
{
|
||||
private const string _tableName = "[RPSB]";
|
||||
private const string _allFields = "[RPENO], [RPITM], [RPDAT], [RPCLS], [RPODT], [RPDPT], [RPDOC], [DB_CRDAT], [DB_CRUSR], [DB_TRDAT], [DB_TRUSR]";
|
||||
//private string _select = "select " + _allFields;
|
||||
private string _insert = "[RPENO], [RPITM], [RPDAT], [RPCLS], [RPODT], [RPDPT], [RPDOC], [DB_CRDAT], [DB_CRUSR], [DB_TRDAT], [DB_TRUSR]";
|
||||
private string _insertValue = "@RPENO, @RPITM, @RPDAT, @RPCLS, @RPODT, @RPDPT, @RPDOC, @DB_CRDAT, @DB_CRUSR, @DB_TRDAT, @DB_TRUSR";
|
||||
//private string _from = " from " + _tableName + " WITH (NOLOCK) ";
|
||||
//private string _where = " where 1=1 ";
|
||||
//private string _order = " order by [RPENO], [RPITM] ";
|
||||
|
||||
public RpsbDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RpsbDAC(string connectionConfig, string connectionConfigName) : this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RpsbDAC(WQuery query) : this()
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 查詢
|
||||
///</summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public RPSBList Select(string RPENO)
|
||||
{
|
||||
RPSBList result = new RPSBList();
|
||||
IDataList list = result as IDataList;
|
||||
DbCommand cmdSelect = Query.NewCommand();
|
||||
cmdSelect.CommandText = @"
|
||||
SELECT A.*, B.BDNAM AS RPODT_NAME, C.BDNAM AS RPDPT_NAME
|
||||
FROM RPSB A
|
||||
LEFT JOIN BDPT B ON A.RPODT = B.BDNUM
|
||||
LEFT JOIN BDPT C ON A.RPDPT = C.BDNUM
|
||||
WHERE A.RPENO = @RPENO
|
||||
ORDER BY A.RPITM";
|
||||
AddParam(cmdSelect, "RPENO", RPENO);
|
||||
Query.Select(cmdSelect, ref list);
|
||||
return result;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 查詢
|
||||
///</summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public RPSBList SelectOne(string RPENO, int RPITM)
|
||||
{
|
||||
RPSBList result = new RPSBList();
|
||||
IDataList list = result as IDataList;
|
||||
DbCommand cmdSelect = Query.NewCommand();
|
||||
cmdSelect.CommandText = @"
|
||||
SELECT A.*, B.BDNAM AS RPODT_NAME, C.BDNAM AS RPDPT_NAME
|
||||
FROM RPSB A
|
||||
LEFT JOIN BDPT B ON A.RPODT = B.BDNUM
|
||||
LEFT JOIN BDPT C ON A.RPDPT = C.BDNUM
|
||||
WHERE A.RPENO = @RPENO
|
||||
AND A.RPITM = @RPITM";
|
||||
AddParam(cmdSelect, "RPENO", RPENO);
|
||||
AddParam(cmdSelect, "RPITM", RPITM);
|
||||
Query.Select(cmdSelect, ref list);
|
||||
return result;
|
||||
}
|
||||
|
||||
public RPSBItem SelectLast(string RPENO, int prevRBITM)
|
||||
{
|
||||
RPSBList result = new RPSBList();
|
||||
IDataList list = result as IDataList;
|
||||
DbCommand cmdSelect = Query.NewCommand();
|
||||
cmdSelect.CommandText = @"
|
||||
SELECT TOP 1 A.*, B.BDNAM AS RPODT_NAME, C.BDNAM AS RPDPT_NAME
|
||||
FROM RPSB A
|
||||
LEFT JOIN BDPT B ON A.RPODT = B.BDNUM
|
||||
LEFT JOIN BDPT C ON A.RPDPT = C.BDNUM
|
||||
WHERE A.RPENO = @RPENO
|
||||
AND A.RPITM < @RPITM
|
||||
ORDER BY RPITM DESC";
|
||||
AddParam(cmdSelect, "RPENO", RPENO);
|
||||
AddParam(cmdSelect, "RPITM", prevRBITM == 0 ? Int32.MaxValue : prevRBITM);
|
||||
Query.Select(cmdSelect, ref list);
|
||||
if (result.Count == 0)
|
||||
return null;
|
||||
else
|
||||
return result[0];
|
||||
}
|
||||
|
||||
public string PrevRPDPT(string RPENO, int RPITM)
|
||||
{
|
||||
DbCommand cmdSelect = Query.NewCommand();
|
||||
cmdSelect.CommandText = @"
|
||||
SELECT TOP 1 RPDPT
|
||||
FROM RPSB
|
||||
WHERE RPENO = @RPENO
|
||||
AND RPITM < @RPITM
|
||||
AND RPCLS = '部門調動'
|
||||
ORDER BY RPITM DESC";
|
||||
AddParam(cmdSelect, "RPENO", RPENO);
|
||||
AddParam(cmdSelect, "RPITM", RPITM);
|
||||
return WDAC.GetStringValue(Query.ExecuteScalar(cmdSelect));
|
||||
}
|
||||
|
||||
public int NextRPITM(string RPENO)
|
||||
{
|
||||
DbCommand cmdSelect = Query.NewCommand();
|
||||
cmdSelect.CommandText = @"
|
||||
SELECT ISNULL(MAX(RPITM), 0) + 1
|
||||
FROM RPSB
|
||||
WHERE RPENO = @RPENO";
|
||||
AddParam(cmdSelect, "RPENO", RPENO);
|
||||
return WDAC.GetInt32Value(Query.ExecuteScalar(cmdSelect));
|
||||
}
|
||||
|
||||
private bool BeforeInsertOne(RPSBItem value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 新增一筆資料
|
||||
///</summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public bool InsertOne(RPSBItem value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!BeforeInsertOne(value))
|
||||
return false;
|
||||
value.DB_CRDAT = DateTime.UtcNow.AddHours(8);
|
||||
value.DB_CRUSR = UserId;
|
||||
value.DB_TRDAT = DateTime.UtcNow.AddHours(8);
|
||||
value.DB_TRUSR = UserId;
|
||||
DbCommand cmdInsert = Query.NewCommand();
|
||||
cmdInsert.CommandText =
|
||||
"insert into [RPSB]"
|
||||
+ " (" + _insert + ") "
|
||||
+ " values "
|
||||
+ " (" + _insertValue + ") "
|
||||
;
|
||||
AddParam(cmdInsert, "RPENO", value.RPENO);
|
||||
AddParam(cmdInsert, "RPITM", value.RPITM);
|
||||
AddParam(cmdInsert, "RPDAT", value.RPDAT);
|
||||
AddParam(cmdInsert, "RPCLS", value.RPCLS);
|
||||
AddParam(cmdInsert, "RPODT", value.RPODT);
|
||||
AddParam(cmdInsert, "RPDPT", value.RPDPT);
|
||||
AddParam(cmdInsert, "RPDOC", value.RPDOC);
|
||||
AddParam(cmdInsert, "DB_CRDAT", value.DB_CRDAT);
|
||||
AddParam(cmdInsert, "DB_CRUSR", value.DB_CRUSR);
|
||||
AddParam(cmdInsert, "DB_TRDAT", value.DB_TRDAT);
|
||||
AddParam(cmdInsert, "DB_TRUSR", value.DB_TRUSR);
|
||||
Query.ExecuteNonQuery(cmdInsert);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool BeforeUpdateOne(RPSBItem value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 修改一筆資料
|
||||
///</summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public bool UpdateOne(RPSBItem value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!BeforeUpdateOne(value))
|
||||
return false;
|
||||
value.DB_TRDAT = DateTime.UtcNow.AddHours(8);
|
||||
value.DB_TRUSR = UserId;
|
||||
DbCommand cmdUpdate = Query.NewCommand();
|
||||
cmdUpdate.CommandText = @"
|
||||
update [RPSB]
|
||||
set
|
||||
[RPDAT] = @RPDAT ,
|
||||
[RPCLS] = @RPCLS ,
|
||||
[RPODT] = @RPODT ,
|
||||
[RPDPT] = @RPDPT ,
|
||||
[RPDOC] = @RPDOC ,
|
||||
DB_TRDAT = @DB_TRDAT ,
|
||||
DB_TRUSR = @DB_TRUSR
|
||||
where 1=1
|
||||
and [RPENO] = @original_RPENO
|
||||
and [RPITM] = @original_RPITM
|
||||
";
|
||||
AddParam(cmdUpdate, "RPDAT", value.RPDAT);
|
||||
AddParam(cmdUpdate, "RPCLS", value.RPCLS);
|
||||
AddParam(cmdUpdate, "RPODT", value.RPODT);
|
||||
AddParam(cmdUpdate, "RPDPT", value.RPDPT);
|
||||
AddParam(cmdUpdate, "RPDOC", value.RPDOC);
|
||||
AddParam(cmdUpdate, "DB_TRDAT", value.DB_TRDAT);
|
||||
AddParam(cmdUpdate, "DB_TRUSR", value.DB_TRUSR);
|
||||
AddParam(cmdUpdate, "original_RPENO", value.RPENO);
|
||||
AddParam(cmdUpdate, "original_RPITM", value.RPITM);
|
||||
Query.ExecuteNonQuery(cmdUpdate);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool BeforeDeleteOne(string RPENO, int RPITM)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 刪除一筆資料
|
||||
///</summary>
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public bool DeleteOne(string RPENO, int RPITM)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!BeforeDeleteOne(RPENO, RPITM))
|
||||
return false;
|
||||
DbCommand cmdDelete = Query.NewCommand();
|
||||
cmdDelete.CommandText = @"
|
||||
delete from [RPSB]
|
||||
where 1=1
|
||||
and RPENO = @RPENO
|
||||
and RPITM = @RPITM
|
||||
";
|
||||
AddParam(cmdDelete, "RPENO", RPENO);
|
||||
AddParam(cmdDelete, "RPITM", RPITM);
|
||||
Query.ExecuteNonQuery(cmdDelete);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///<summary>
|
||||
/// RPSB 資料集合類別
|
||||
///</summary>
|
||||
[Serializable]
|
||||
public partial class RPSBList : List<RPSBItem>, IDataList
|
||||
{
|
||||
///<summary>
|
||||
/// 從 DataReader 填入資料
|
||||
///</summary>
|
||||
public void Fill(DbDataReader reader)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
RPSBItem newItem = new RPSBItem
|
||||
{
|
||||
RPENO = WDAC.GetStringValue(reader["RPENO"]),
|
||||
RPITM = WDAC.GetInt32Value(reader["RPITM"]),
|
||||
RPCLS = WDAC.GetStringValue(reader["RPCLS"]),
|
||||
RPDAT = WDAC.GetDateTimeValue(reader["RPDAT"]),
|
||||
RPDPT = WDAC.GetStringValue(reader["RPDPT"]),
|
||||
RPODT = WDAC.GetStringValue(reader["RPODT"]),
|
||||
RPDOC = WDAC.GetStringValue(reader["RPDOC"]),
|
||||
RPDPT_NAME = WDAC.GetStringValue(reader["RPDPT_NAME"]),
|
||||
RPODT_NAME = WDAC.GetStringValue(reader["RPODT_NAME"]),
|
||||
DB_CRDAT = WDAC.GetDateTimeValue(reader["DB_CRDAT"]),
|
||||
DB_CRUSR = WDAC.GetStringValue(reader["DB_CRUSR"]),
|
||||
DB_TRDAT = WDAC.GetDateTimeValue(reader["DB_TRDAT"]),
|
||||
DB_TRUSR = WDAC.GetStringValue(reader["DB_TRUSR"]),
|
||||
};
|
||||
Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///<summary>
|
||||
/// RPSB 資料紀錄類別
|
||||
///</summary>
|
||||
[Serializable]
|
||||
[Description("人員異動資料")]
|
||||
public class RPSBItem
|
||||
{
|
||||
public static string 到職 = "到職";
|
||||
public static string 離職回任 = "離職回任";
|
||||
public static string 離職 = "離職";
|
||||
public static string 留職停薪 = "留職停薪";
|
||||
public static string 留停復職 = "留停復職";
|
||||
public static string 部門調動 = "部門調動";
|
||||
|
||||
///<summary>
|
||||
/// 人員編號
|
||||
///</summary>
|
||||
public string RPENO { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// 異動項次
|
||||
///</summary>
|
||||
public int RPITM { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// 異動日期
|
||||
///</summary>
|
||||
[JsonIgnore]
|
||||
public DateTime? RPDAT { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "RPDAT")]
|
||||
public string RPDAT_STR { get { return string.Format("{0:yyyyMMdd}", RPDAT); } }
|
||||
///<summary>
|
||||
/// 異動類別
|
||||
/// 到職/離職/留職停薪/留停復職/部門調動
|
||||
///</summary>
|
||||
public string RPCLS { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// 原部門
|
||||
///</summary>
|
||||
public string RPODT { get; set; }
|
||||
public string RPODT_NAME { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// 新部門
|
||||
///</summary>
|
||||
public string RPDPT { get; set; }
|
||||
public string RPDPT_NAME { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// 備註
|
||||
///</summary>
|
||||
public string RPDOC { get; set; }
|
||||
|
||||
public DateTime? DB_CRDAT { get; set; }
|
||||
public string DB_CRUSR { get; set; }
|
||||
public DateTime? DB_TRDAT { get; set; }
|
||||
public string DB_TRUSR { get; set; }
|
||||
public bool OnBoard { get { return Array.IndexOf(RPSBSaveItem.OnBoardRPCLS, RPCLS) >= 0; } }
|
||||
public bool OffBoard { get { return Array.IndexOf(RPSBSaveItem.OffBoardRPCLS, RPCLS) >= 0; } }
|
||||
public bool Quit { get { return Array.IndexOf(RPSBSaveItem.QuitRPCLS, RPCLS) >= 0; } }
|
||||
public bool DeptChange { get { return RPCLS == RPSBItem.部門調動; } }
|
||||
}
|
||||
|
||||
|
||||
public class RPSBSaveItem
|
||||
{
|
||||
public static string[] RPCLSOptions = { RPSBItem.到職, RPSBItem.離職回任, RPSBItem.離職, RPSBItem.留職停薪, RPSBItem.留停復職 };
|
||||
public static string[] OnBoardRPCLS = { RPSBItem.到職, RPSBItem.離職回任, RPSBItem.留停復職 };
|
||||
public static string[] OffBoardRPCLS = { RPSBItem.離職, RPSBItem.留職停薪 };
|
||||
public static string[] QuitRPCLS = { RPSBItem.離職 };
|
||||
|
||||
private DateTime _RPDAT_DATE;
|
||||
public string RPENO { get; set; }
|
||||
public int RPITM { get; set; }
|
||||
public string RPDAT { get; set; }
|
||||
public string RPCLS { get; set; }
|
||||
public string RPDPT { get; set; }
|
||||
public string RPDOC { get; set; }
|
||||
public DateTime RPDAT_DATE { get { return _RPDAT_DATE; } }
|
||||
public string Message;
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
var valid = true;
|
||||
var messages = new List<string>();
|
||||
|
||||
if (string.IsNullOrEmpty(RPCLS))
|
||||
{
|
||||
messages.Add("異動類別未輸入");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
else if (Array.IndexOf(RPCLSOptions, RPCLS) < 0)
|
||||
{
|
||||
messages.Add("異動類別不正確");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(RPENO))
|
||||
{
|
||||
messages.Add("人員編號未輸入");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(RPDAT))
|
||||
{
|
||||
messages.Add("異動日期未輸入");
|
||||
valid = false;
|
||||
}
|
||||
else if (!WGuard1.CheckDate(RPDAT, out _RPDAT_DATE) || _RPDAT_DATE.Year > 2112)
|
||||
{
|
||||
messages.Add("異動日期不正確");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
//if (RPCLS == RPSBItem.部門調動 && string.IsNullOrEmpty(RPDPT))
|
||||
//{
|
||||
// messages.Add("新部門未輸入");
|
||||
// valid = false;
|
||||
//}
|
||||
|
||||
Message = string.Join(" / ", messages.ToArray());
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
|
||||
public bool OnBoard { get { return Array.IndexOf(OnBoardRPCLS, RPCLS) >= 0; } }
|
||||
public bool OffBoard { get { return Array.IndexOf(OffBoardRPCLS, RPCLS) >= 0; } }
|
||||
public bool Quit { get { return Array.IndexOf(QuitRPCLS, RPCLS) >= 0; } }
|
||||
public bool DeptChange { get { return RPCLS == RPSBItem.部門調動; } }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 薪資加減項資料處理類別
|
||||
/// </summary>
|
||||
public class RsajDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public RsajDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RsajDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RsajDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某年月、某人員薪資加減項紀錄
|
||||
/// </summary>
|
||||
/// <param name="yymm">年月</param>
|
||||
/// <param name="rseno">人員編號</param>
|
||||
/// <param name="rspyn">專案年度編號</param>
|
||||
/// <param name="tran">要加入的交易</param>
|
||||
public DataTable GetRSAJ(DateTime yymm, string rseno, string rspyn, DbTransaction tran)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT RSAMT, RSDOC
|
||||
FROM RSAJ WHERE RSENO=@RSENO AND RSPYN=@RSPYN
|
||||
AND RSYMM = @YYMM");
|
||||
cmd.Parameters.Add(Query.NewParameter("RSENO", rseno));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSPYN", rspyn));
|
||||
cmd.Parameters.Add(Query.NewParameter("YYMM", yymm));
|
||||
cmd.Connection = tran.Connection;
|
||||
cmd.Transaction = tran;
|
||||
DbDataAdapter da = Query.NewDataAdapter(cmd);
|
||||
DataTable result = new DataTable();
|
||||
da.Fill(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 寫特休結算薪資加減項
|
||||
/// </summary>
|
||||
/// <param name="yymm"></param>
|
||||
/// <param name="rseno"></param>
|
||||
/// <param name="rspyn"></param>
|
||||
/// <param name="rsamt"></param>
|
||||
/// <param name="rsdoc"></param>
|
||||
public string WriteAnnualLeaveSalary(DateTime yymm, string rseno, string rspyn, int rsamt, string rsdoc)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
var rsren = GetAnnualLeaveSalaryREN(yymm, rseno, rspyn);
|
||||
if (string.IsNullOrEmpty(rsren) && rsamt > 0)
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO RSAJ
|
||||
(TRDAT, TRMOD, TRUSR, RSREN, RSENO, RSPYN, RSYMM, RSAMT, RSDOC, APPNO)
|
||||
VALUES
|
||||
(@TRDAT, 'INSERT', @TRUSR, @RSREN, @RSENO, @RSPYN, @RSYMM, @RSAMT, @RSDOC, 1)";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add(Query.NewParameter("TRDAT", DateTime.UtcNow.AddHours(8)));
|
||||
cmd.Parameters.Add(Query.NewParameter("TRUSR", UserId));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSREN", WGuard1.WNextRen(yymm, "RSAJ", "RSREN", "YYYYMM\"F\"<9999>", "", null)));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSENO", rseno));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSPYN", rspyn));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSYMM", yymm));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSAMT", rsamt));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSDOC", rsdoc));
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
else if (rsamt == 0)
|
||||
{
|
||||
cmd.CommandText = @"DELETE FROM RSAJ WHERE RSREN = @RSREN";
|
||||
cmd.Parameters.Add(Query.NewParameter("RSREN", rsren));
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"UPDATE RSAJ
|
||||
SET TRDAT = @TRDAT
|
||||
, TRMOD = 'UPDATE'
|
||||
, TRUSR = @TRUSR
|
||||
, RSENO = @RSENO
|
||||
, RSPYN = @RSPYN
|
||||
, RSYMM = @RSYMM
|
||||
, RSAMT = @RSAMT
|
||||
, RSDOC = @RSDOC
|
||||
, APPNO = APPNO + 1
|
||||
WHERE RSREN = @RSREN";
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Parameters.Add(Query.NewParameter("TRDAT", DateTime.UtcNow.AddHours(8)));
|
||||
cmd.Parameters.Add(Query.NewParameter("TRUSR", UserId));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSENO", rseno));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSPYN", rspyn));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSYMM", yymm));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSAMT", rsamt));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSDOC", rsdoc));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSREN", rsren));
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
return rsren;
|
||||
}
|
||||
|
||||
public string GetAnnualLeaveSalaryREN(DateTime yymm, string rseno, string rspyn)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand(
|
||||
@"SELECT RSREN
|
||||
FROM RSAJ
|
||||
WHERE RSENO=@RSENO
|
||||
AND RSPYN=@RSPYN
|
||||
AND RSYMM=@RSYMM
|
||||
AND RSREN LIKE '______F____'");
|
||||
cmd.Parameters.Add(Query.NewParameter("RSENO", rseno));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSPYN", rspyn));
|
||||
cmd.Parameters.Add(Query.NewParameter("RSYMM", yymm));
|
||||
return GetStringValue(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// 人員班表的資料處理類別
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class RtmeDAC : WDAC
|
||||
{
|
||||
public RtmeDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RtmeDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RtmeDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<RtmeItem> SelectDay(string RTENO, DateTime? RTDAT)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT * FROM RTME WHERE 1=1";
|
||||
|
||||
if (!string.IsNullOrEmpty(RTENO))
|
||||
cmd.CommandText += " AND RTENO = @RTENO ";
|
||||
if (RTDAT.HasValue)
|
||||
cmd.CommandText += " AND RTDAT = @RTDAT ";
|
||||
|
||||
AddParam(cmd, "RTENO", RTENO);
|
||||
AddParam(cmd, "RTDAT", RTDAT);
|
||||
return Query.Select<RtmeItem>(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public List<RtmeItem> SelectMonth(string RTENO, DateTime? RTDAT)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText = "SELECT * FROM RTME WHERE 1=1";
|
||||
|
||||
// if (!string.IsNullOrEmpty(RTENO))
|
||||
cmd.CommandText += " AND RTENO = @RTENO ";
|
||||
|
||||
if (RTDAT.HasValue)
|
||||
{
|
||||
cmd.CommandText += " AND RTDAT >= @RTDAT_1 AND RTDAT < @RTDAT_2 ";
|
||||
var d = RTDAT.Value.AddDays(-(RTDAT.Value.Day - 1));
|
||||
AddParam(cmd, "RTDAT_1", d);
|
||||
AddParam(cmd, "RTDAT_2", d.AddMonths(1));
|
||||
}
|
||||
|
||||
AddParam(cmd, "RTENO", RTENO);
|
||||
return Query.Select<RtmeItem>(cmd);
|
||||
}
|
||||
|
||||
public void SetDay(string RTENO, DateTime RTDAT, string RTTID, string TRUSR)
|
||||
{
|
||||
var item = SelectDay(RTENO, RTDAT).FirstOrDefault();
|
||||
if (item == null)
|
||||
{
|
||||
InsertOne(new RtmeItem()
|
||||
{
|
||||
RTENO = RTENO,
|
||||
RTDAT = RTDAT,
|
||||
RTTID = RTTID,
|
||||
TRUSR = TRUSR
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
item.RTTID = RTTID;
|
||||
UpdateOne(item);
|
||||
}
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Insert)]
|
||||
public void InsertOne(RtmeItem value)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO dbo.RTME
|
||||
(RTENO, RTDAT, RTTID, TRDAT, TRMOD, TRUSR)
|
||||
VALUES
|
||||
(@RTENO, @RTDAT, @RTTID, GETDATE(), 'INSERT', @TRUSR)";
|
||||
AddParam(cmd, "RTENO", value.RTENO);
|
||||
AddParam(cmd, "RTDAT", value.RTDAT);
|
||||
AddParam(cmd, "RTTID", value.RTTID);
|
||||
AddParam(cmd, "TRUSR", value.TRUSR);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(RtmeItem value)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"UPDATE dbo.RTME SET
|
||||
RTTID = @RTTID,
|
||||
TRDAT = GETDATE(),
|
||||
TRMOD = 'MODIFY',
|
||||
TRUSR = @TRUSR
|
||||
WHERE RTENO = @OLD_RTENO
|
||||
AND RTDAT = @OLD_RTDAT";
|
||||
AddParam(cmd, "RTTID", value.RTTID);
|
||||
AddParam(cmd, "TRUSR", value.TRUSR);
|
||||
AddParam(cmd, "OLD_RTENO", value.RTENO);
|
||||
AddParam(cmd, "OLD_RTDAT", value.RTDAT);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(RtmeItem value)
|
||||
{
|
||||
var cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"DELETE FROM dbo.RTME
|
||||
WHERE RTENO = @OLD_RTENO
|
||||
AND RTDAT = @OLD_RTDAT";
|
||||
AddParam(cmd, "OLD_RTENO", value.RTENO);
|
||||
AddParam(cmd, "OLD_RTDAT", value.RTDAT);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由員工與日期取班表資料
|
||||
/// </summary>
|
||||
/// <param name="RTENO"></param>
|
||||
/// <param name="RTDAT"></param>
|
||||
/// <returns></returns>
|
||||
public BtmeItem SelectBtmeDay(string RTENO, DateTime RTDAT)
|
||||
{
|
||||
var rtmeItem = SelectDay(RTENO, RTDAT).FirstOrDefault();
|
||||
if (rtmeItem != null && !string.IsNullOrEmpty(rtmeItem.RTTID.Trim()) && !BhrdDAC.ItemIsHoliday(rtmeItem.RTTID))
|
||||
{
|
||||
return new BtmeDAC(Query).SelectOne(rtmeItem.RTTID).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class RtmeItem
|
||||
{
|
||||
public string RTENO { get; set; }
|
||||
public DateTime RTDAT { get; set; }
|
||||
public string RTTID { get; set; }
|
||||
public DateTime TRDAT { get; set; }
|
||||
public string TRMOD { get; set; }
|
||||
public string TRUSR { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,788 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System.IdentityModel.Claims;
|
||||
using Microsoft.Win32;
|
||||
|
||||
/// <summary>
|
||||
/// 年度特休
|
||||
/// </summary>
|
||||
[DataObject]
|
||||
public class RyerDAC : Wellan.Data.WDAC
|
||||
{
|
||||
public RyerDAC()
|
||||
{
|
||||
}
|
||||
|
||||
public RyerDAC(string connectionConfig, string connectionConfigName)
|
||||
: this()
|
||||
{
|
||||
this._connectionConfig = connectionConfig;
|
||||
this._connectionConfigName = connectionConfigName;
|
||||
}
|
||||
|
||||
public RyerDAC(WQuery query)
|
||||
{
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||
public DataTable SelectProject(int RYYERFrom, int RYYERTo, string RAPYN, string RANUM)
|
||||
{
|
||||
string select = @"SELECT A.RANUM AS RYENO
|
||||
, A.BPYER AS RYYER
|
||||
, B.BPNME
|
||||
, B.BPSDY
|
||||
, B.BPEDY
|
||||
, C.RYYST
|
||||
, '' AS RYYST_H
|
||||
, '' AS RYYST_M
|
||||
, ISNULL(C.RYYXT, 0) AS RYYXT
|
||||
, '' AS RYYXT_D
|
||||
, ISNULL(C.RYTOT, 0) / 60 AS RYTOT
|
||||
, ISNULL(C.RYH01, 0) / 60 AS RYH01
|
||||
, ISNULL(C.RYH02, 0) / 60 AS RYH02
|
||||
, ISNULL(C.RYH03, 0) / 60 AS RYH03
|
||||
, ISNULL(C.RYH04, 0) / 60 AS RYH04
|
||||
, ISNULL(C.RYH05, 0) / 60 AS RYH05
|
||||
, ISNULL(C.RYH06, 0) / 60 AS RYH06
|
||||
, ISNULL(C.RYH07, 0) / 60 AS RYH07
|
||||
, ISNULL(C.RYH08, 0) / 60 AS RYH08
|
||||
, ISNULL(C.RYH09, 0) / 60 AS RYH09
|
||||
, ISNULL(C.RYH10, 0) / 60 AS RYH10
|
||||
, ISNULL(C.RYH11, 0) / 60 AS RYH11
|
||||
, ISNULL(C.RYH12, 0) / 60 AS RYH12
|
||||
, ISNULL(C.RYD01, 1) AS RYD01
|
||||
, ISNULL(C.RYD02, 1) AS RYD02
|
||||
, ISNULL(C.RYD03, 1) AS RYD03
|
||||
, ISNULL(C.RYD04, 1) AS RYD04
|
||||
, ISNULL(C.RYD05, 1) AS RYD05
|
||||
, ISNULL(C.RYD06, 1) AS RYD06
|
||||
, ISNULL(C.RYD07, 1) AS RYD07
|
||||
, ISNULL(C.RYD08, 1) AS RYD08
|
||||
, ISNULL(C.RYD09, 1) AS RYD09
|
||||
, ISNULL(C.RYD10, 1) AS RYD10
|
||||
, ISNULL(C.RYD11, 1) AS RYD11
|
||||
, ISNULL(C.RYD12, 1) AS RYD12
|
||||
, '' AS RYVLD
|
||||
, '' AS RYUST
|
||||
, '' AS RYLFT
|
||||
, '' AS RYPLF
|
||||
, ISNULL(C.RYSLY, 0) AS RYSLY
|
||||
, ISNULL(C.RYNXT, 0) AS RYNXT
|
||||
, '' AS RYSLY_H
|
||||
, '' AS RYSLY_M
|
||||
, '' AS RYNXT_H
|
||||
, '' AS RYNXT_M
|
||||
, C.RYRMK";
|
||||
|
||||
if (RAPYN == "103JYB00001" || RAPYN == "103TYB00001")
|
||||
{
|
||||
RYYERTo = RYYERFrom;
|
||||
}
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
if (RYYERFrom != RYYERTo)
|
||||
{
|
||||
cmd.CommandText = string.Format(
|
||||
@"{0}
|
||||
FROM (SELECT DISTINCT RASN.RANUM, BPAA.BPYER + @CY11 BPYER
|
||||
FROM RASN
|
||||
JOIN BPAA on RASN.RAPYN = BPAA.BPPYN
|
||||
WHERE (BPYER + @CY11 >= @RYYER_FROM AND BPYER + @CY11 <= @RYYER_TO)
|
||||
AND (RASN.RAPYN = @RAPYN OR @RAPYN = '') -- 跨年度查詢忽略專案條件
|
||||
AND (RASN.RANUM = @RANUM OR @RANUM = '')
|
||||
) A
|
||||
JOIN BPSNView B ON A.RANUM=B.BPENO -- AND (B.BPEDY IS NULL OR YEAR(B.BPEDY) = BPYER)
|
||||
LEFT JOIN RYER C ON A.RANUM=C.RYENO AND A.BPYER = C.RYYER
|
||||
ORDER BY (CASE WHEN BPEDY IS NULL THEN 0 ELSE 1 END), RYENO, BPYER"
|
||||
, select);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText = string.Format(
|
||||
@"{0}
|
||||
FROM (SELECT DISTINCT RASN.RANUM, @RYYER_FROM BPYER
|
||||
FROM RASN
|
||||
WHERE (RASN.RAPYN = @RAPYN OR @RAPYN = '')
|
||||
AND (RASN.RANUM = @RANUM OR @RANUM = '')
|
||||
-- AND (RASN.RAEDT IS NULL OR YEAR(RASN.RAEDT) = @RYYER_FROM) -- 加上專案結束日為空或年度=查詢年度
|
||||
) A
|
||||
JOIN BPSNView B ON A.RANUM=B.BPENO -- AND (B.BPEDY IS NULL OR YEAR(B.BPEDY) = BPYER)
|
||||
LEFT JOIN RYER C ON A.RANUM=C.RYENO AND A.BPYER = C.RYYER
|
||||
ORDER BY (CASE WHEN BPEDY IS NULL THEN 0 ELSE 1 END), RYENO, BPYER"
|
||||
, select);
|
||||
}
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "CY11", WGuard1.CY11);
|
||||
Query.AddParam(cmd, "RANUM", RANUM);
|
||||
Query.AddParam(cmd, "RAPYN", RAPYN);
|
||||
Query.AddParam(cmd, "RYYER_FROM", RYYERFrom);
|
||||
Query.AddParam(cmd, "RYYER_TO", RYYERTo);
|
||||
DataTable result = Query.Select(cmd);
|
||||
|
||||
var nowtime = DateTime.UtcNow.AddHours(8);
|
||||
int month = nowtime.Month;
|
||||
int day = nowtime.Day;
|
||||
foreach (DataRow r in result.Rows)
|
||||
{
|
||||
var ryyer = WDAC.GetInt32Value(r["RYYER"]);
|
||||
var ryeno = WDAC.GetStringValue(r["RYENO"]);
|
||||
if (ryyer < nowtime.Year)
|
||||
{
|
||||
month = 12;
|
||||
day = 31;
|
||||
}
|
||||
|
||||
r.BeginEdit();
|
||||
int 年初特休 = Get年初特休(ryeno, ryyer);
|
||||
int 可用特休 = Get可用特休(ryeno, ryyer, month, day);
|
||||
int 至今生效特休 = Get至今生效特休(ryeno, ryyer, month, day);
|
||||
int 已休時數 = 年初特休 + 至今生效特休 - 可用特休;
|
||||
int 上年未休 = Get可用特休(ryeno, ryyer - 1, 12, 31);
|
||||
|
||||
r["RYYST_H"] = String.Format("{0}", GetInt32Value(GetInt32Value(r["RYYST"]) / 60));
|
||||
r["RYYST_M"] = String.Format("{0:00}", GetInt32Value(GetInt32Value(r["RYYST"]) % 60));
|
||||
r["RYYXT_D"] = String.Format("{0}:{1:00}", GetInt32Value(GetInt32Value(r["RYYXT"]) / 60), GetInt32Value(r["RYYXT"]) % 60);
|
||||
r["RYVLD"] = String.Format("{0}:{1:00}", GetInt32Value(至今生效特休 / 60), 至今生效特休 % 60);
|
||||
r["RYUST"] = String.Format("{0}:{1:00}", GetInt32Value(已休時數 / 60), 已休時數 % 60);
|
||||
r["RYLFT"] = String.Format("{0}:{1:00}", GetInt32Value(可用特休 / 60), 可用特休 % 60);
|
||||
r["RYPLF"] = String.Format("{0}:{1:00}", GetInt32Value(上年未休 / 60), 上年未休 % 60);
|
||||
r["RYSLY_H"] = String.Format("{0}", GetInt32Value(GetInt32Value(r["RYSLY"]) / 60));
|
||||
r["RYSLY_M"] = String.Format("{0:00}", GetInt32Value(r["RYSLY"]) % 60);
|
||||
r["RYNXT_H"] = String.Format("{0}", GetInt32Value(GetInt32Value(r["RYNXT"]) / 60));
|
||||
r["RYNXT_M"] = String.Format("{0:00}", GetInt32Value(r["RYNXT"]) % 60);
|
||||
r.EndEdit();
|
||||
r.AcceptChanges();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某人某年還有多少特休
|
||||
/// </summary>
|
||||
/// <param name="RYENO">員工編號</param>
|
||||
/// <param name="year">年</param>
|
||||
/// <param name="month">月</param>
|
||||
/// <param name="day">日</param>
|
||||
/// <param name="addYearBegin">加入年初已生效時數</param>
|
||||
/// <param name="substrateOffHours">減去本年已休時數</param>
|
||||
public int DoGet可用特休(string RYENO, int year, int month, int day, bool addYearBegin, bool substrateOffHours)
|
||||
{
|
||||
// 取得總時數
|
||||
if (month < 1) month = 1;
|
||||
if (month > 12) month = 12;
|
||||
List<string> monthsql = new List<string>();
|
||||
if (addYearBegin)
|
||||
{
|
||||
monthsql.Add("ISNULL(RYYST, 0)"); // 年初生效時數
|
||||
monthsql.Add("ISNULL(RYYXT, 0)"); // 上年遞延時數
|
||||
}
|
||||
for (int i = 1; i < month; i++)
|
||||
{
|
||||
monthsql.Add(string.Format("ISNULL(RYH{0:00}, 0)", i));
|
||||
}
|
||||
monthsql.Add(string.Format("ISNULL(CASE WHEN @RYDAY >= ISNULL(RYD{0:00}, 1) THEN RYH{0:00} ELSE 0 END, 0)", month));
|
||||
|
||||
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
string.Format(@"SELECT {0}
|
||||
FROM RYER
|
||||
WHERE RYYER=@RYYER
|
||||
AND RYENO=@RYENO", string.Join("+", monthsql.ToArray()));
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYYER", year);
|
||||
Query.AddParam(cmd, "RYENO", RYENO);
|
||||
Query.AddParam(cmd, "RYDAY", day);
|
||||
int 總時數 = GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
|
||||
// 取得已休時數
|
||||
int 已休時數 = 0;
|
||||
if (substrateOffHours)
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"SELECT ISNULL(SUM(RPTCT), 0)
|
||||
FROM RPAR
|
||||
WHERE RPNUM = @RYENO
|
||||
AND RPTYP = '01'
|
||||
AND YEAR(RPRDT) = @RYYER
|
||||
AND YEAR(RPEDT) = @RYYER
|
||||
AND (MONTH(RPRDT) < @RYMON or MONTH(RPRDT) = @RYMON AND DAY(RPRDT) <= @RYDAY)
|
||||
AND (RPAPN IS NULL OR RPAPN <> 'D' AND (RPAPP IS NULL OR RPAPP <> 'N'))";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYENO", RYENO);
|
||||
Query.AddParam(cmd, "RYYER", year);
|
||||
Query.AddParam(cmd, "RYMON", month);
|
||||
Query.AddParam(cmd, "RYDAY", day);
|
||||
已休時數 += GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
return 總時數 - 已休時數;
|
||||
}
|
||||
|
||||
public int Get可用特休(string RYENO, int year, int month, int day)
|
||||
{
|
||||
return DoGet可用特休(RYENO, year, month, day, true, true);
|
||||
}
|
||||
public int Get至今生效特休(string RYENO, int year, int month, int day)
|
||||
{
|
||||
return DoGet可用特休(RYENO, year, month, day, false, false);
|
||||
}
|
||||
public int Get年初特休(string RYENO, int year)
|
||||
{
|
||||
return DoGet可用特休(RYENO, year, 1, 0, true, false);
|
||||
}
|
||||
|
||||
public int Get上年結轉(string RYENO, int year)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"SELECT RYNXT
|
||||
FROM RYER
|
||||
WHERE RYYER=@RYYER
|
||||
AND RYENO=@RYENO";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYYER", year - 1);
|
||||
Query.AddParam(cmd, "RYENO", RYENO);
|
||||
return GetInt32Value(Query.ExecuteScalar(cmd));
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Update)]
|
||||
public void UpdateOne(
|
||||
string old_ryeno
|
||||
, int old_ryyer
|
||||
, int rytot
|
||||
, string trusr
|
||||
, int ryyst
|
||||
, int ryh01
|
||||
, int ryh02
|
||||
, int ryh03
|
||||
, int ryh04
|
||||
, int ryh05
|
||||
, int ryh06
|
||||
, int ryh07
|
||||
, int ryh08
|
||||
, int ryh09
|
||||
, int ryh10
|
||||
, int ryh11
|
||||
, int ryh12
|
||||
, int ryd01
|
||||
, int ryd02
|
||||
, int ryd03
|
||||
, int ryd04
|
||||
, int ryd05
|
||||
, int ryd06
|
||||
, int ryd07
|
||||
, int ryd08
|
||||
, int ryd09
|
||||
, int ryd10
|
||||
, int ryd11
|
||||
, int ryd12
|
||||
, int rysly
|
||||
, int rynxt
|
||||
, string ryrmk
|
||||
)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
if (!CheckExists(old_ryeno, old_ryyer))
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO RYER
|
||||
(TRDAT, TRMOD, TRUSR, RYENO, RYYER, RYTOT, RYUST, RYYST,
|
||||
RYH01, RYH02, RYH03, RYH04, RYH05, RYH06, RYH07, RYH08, RYH09, RYH10, RYH11, RYH12,
|
||||
RYD01, RYD02, RYD03, RYD04, RYD05, RYD06, RYD07, RYD08, RYD09, RYD10, RYD11, RYD12,
|
||||
RYSLY, RYNXT, RYRMK
|
||||
)
|
||||
VALUES
|
||||
(GETDATE(), 'INSERT', @TRUSR, @RYENO, @RYYER, @RYTOT, 0, @RYYST,
|
||||
@RYH01, @RYH02, @RYH03, @RYH04, @RYH05, @RYH06, @RYH07, @RYH08, @RYH09, @RYH10, @RYH11, @RYH12,
|
||||
@RYD01, @RYD02, @RYD03, @RYD04, @RYD05, @RYD06, @RYD07, @RYD08, @RYD09, @RYD10, @RYD11, @RYD12,
|
||||
@RYSLY, @RYNXT, @RYRMK
|
||||
)";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", trusr);
|
||||
Query.AddParam(cmd, "RYENO", old_ryeno);
|
||||
Query.AddParam(cmd, "RYYER", old_ryyer);
|
||||
Query.AddParam(cmd, "RYTOT", rytot);
|
||||
Query.AddParam(cmd, "RYYST", ryyst);
|
||||
Query.AddParam(cmd, "RYH01", ryh01);
|
||||
Query.AddParam(cmd, "RYH02", ryh02);
|
||||
Query.AddParam(cmd, "RYH03", ryh03);
|
||||
Query.AddParam(cmd, "RYH04", ryh04);
|
||||
Query.AddParam(cmd, "RYH05", ryh05);
|
||||
Query.AddParam(cmd, "RYH06", ryh06);
|
||||
Query.AddParam(cmd, "RYH07", ryh07);
|
||||
Query.AddParam(cmd, "RYH08", ryh08);
|
||||
Query.AddParam(cmd, "RYH09", ryh09);
|
||||
Query.AddParam(cmd, "RYH10", ryh10);
|
||||
Query.AddParam(cmd, "RYH11", ryh11);
|
||||
Query.AddParam(cmd, "RYH12", ryh12);
|
||||
Query.AddParam(cmd, "RYD01", ryd01);
|
||||
Query.AddParam(cmd, "RYD02", ryd02);
|
||||
Query.AddParam(cmd, "RYD03", ryd03);
|
||||
Query.AddParam(cmd, "RYD04", ryd04);
|
||||
Query.AddParam(cmd, "RYD05", ryd05);
|
||||
Query.AddParam(cmd, "RYD06", ryd06);
|
||||
Query.AddParam(cmd, "RYD07", ryd07);
|
||||
Query.AddParam(cmd, "RYD08", ryd08);
|
||||
Query.AddParam(cmd, "RYD09", ryd09);
|
||||
Query.AddParam(cmd, "RYD10", ryd10);
|
||||
Query.AddParam(cmd, "RYD11", ryd11);
|
||||
Query.AddParam(cmd, "RYD12", ryd12);
|
||||
Query.AddParam(cmd, "RYSLY", rysly);
|
||||
Query.AddParam(cmd, "RYNXT", rynxt);
|
||||
Query.AddParam(cmd, "RYRMK", ryrmk);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"UPDATE RYER
|
||||
SET TRDAT = GETDATE() ,
|
||||
TRMOD = 'UPDATE' ,
|
||||
TRUSR = @TRUSR ,
|
||||
RYTOT = @RYTOT ,
|
||||
RYYST = @RYYST ,
|
||||
RYH01 = @RYH01 ,
|
||||
RYH02 = @RYH02 ,
|
||||
RYH03 = @RYH03 ,
|
||||
RYH04 = @RYH04 ,
|
||||
RYH05 = @RYH05 ,
|
||||
RYH06 = @RYH06 ,
|
||||
RYH07 = @RYH07 ,
|
||||
RYH08 = @RYH08 ,
|
||||
RYH09 = @RYH09 ,
|
||||
RYH10 = @RYH10 ,
|
||||
RYH11 = @RYH11 ,
|
||||
RYH12 = @RYH12 ,
|
||||
RYD01 = @RYD01 ,
|
||||
RYD02 = @RYD02 ,
|
||||
RYD03 = @RYD03 ,
|
||||
RYD04 = @RYD04 ,
|
||||
RYD05 = @RYD05 ,
|
||||
RYD06 = @RYD06 ,
|
||||
RYD07 = @RYD07 ,
|
||||
RYD08 = @RYD08 ,
|
||||
RYD09 = @RYD09 ,
|
||||
RYD10 = @RYD10 ,
|
||||
RYD11 = @RYD11 ,
|
||||
RYD12 = @RYD12 ,
|
||||
RYSLY = @RYSLY ,
|
||||
RYNXT = @RYNXT ,
|
||||
RYRMK = @RYRMK
|
||||
WHERE RYENO = @OLD_RYENO
|
||||
AND RYYER = @OLD_RYYER";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", trusr);
|
||||
Query.AddParam(cmd, "RYTOT", rytot);
|
||||
Query.AddParam(cmd, "RYYST", ryyst);
|
||||
Query.AddParam(cmd, "RYH01", ryh01);
|
||||
Query.AddParam(cmd, "RYH02", ryh02);
|
||||
Query.AddParam(cmd, "RYH03", ryh03);
|
||||
Query.AddParam(cmd, "RYH04", ryh04);
|
||||
Query.AddParam(cmd, "RYH05", ryh05);
|
||||
Query.AddParam(cmd, "RYH06", ryh06);
|
||||
Query.AddParam(cmd, "RYH07", ryh07);
|
||||
Query.AddParam(cmd, "RYH08", ryh08);
|
||||
Query.AddParam(cmd, "RYH09", ryh09);
|
||||
Query.AddParam(cmd, "RYH10", ryh10);
|
||||
Query.AddParam(cmd, "RYH11", ryh11);
|
||||
Query.AddParam(cmd, "RYH12", ryh12);
|
||||
Query.AddParam(cmd, "RYD01", ryd01);
|
||||
Query.AddParam(cmd, "RYD02", ryd02);
|
||||
Query.AddParam(cmd, "RYD03", ryd03);
|
||||
Query.AddParam(cmd, "RYD04", ryd04);
|
||||
Query.AddParam(cmd, "RYD05", ryd05);
|
||||
Query.AddParam(cmd, "RYD06", ryd06);
|
||||
Query.AddParam(cmd, "RYD07", ryd07);
|
||||
Query.AddParam(cmd, "RYD08", ryd08);
|
||||
Query.AddParam(cmd, "RYD09", ryd09);
|
||||
Query.AddParam(cmd, "RYD10", ryd10);
|
||||
Query.AddParam(cmd, "RYD11", ryd11);
|
||||
Query.AddParam(cmd, "RYD12", ryd12);
|
||||
Query.AddParam(cmd, "RYSLY", rysly);
|
||||
Query.AddParam(cmd, "RYNXT", rynxt);
|
||||
Query.AddParam(cmd, "RYRMK", ryrmk);
|
||||
Query.AddParam(cmd, "OLD_RYENO", old_ryeno);
|
||||
Query.AddParam(cmd, "OLD_RYYER", old_ryyer);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
[DataObjectMethod(DataObjectMethodType.Delete)]
|
||||
public void DeleteOne(string OLD_RYENO, int OLD_RYYER)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"UPDATE FROM RYER
|
||||
WHERE RYENO = @RYENO
|
||||
AND RYYER = @RYYER";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYENO", OLD_RYENO);
|
||||
Query.AddParam(cmd, "RYYER", OLD_RYYER);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
public bool CheckExists(string RYENO, int RYYER)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
cmd.CommandText =
|
||||
@"SELECT COUNT(1) FROM RYER
|
||||
WHERE RYENO = @RYENO
|
||||
AND RYYER = @RYYER";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYENO", RYENO);
|
||||
Query.AddParam(cmd, "RYYER", RYYER);
|
||||
return GetInt32Value(Query.ExecuteScalar(cmd)) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 沖特休
|
||||
/// </summary>
|
||||
/// <param name="RYENO">員工編號</param>
|
||||
/// <param name="RYYER">年</param>
|
||||
/// <param name="特休">特休分鐘數</param>
|
||||
/// <param name="tran"></param>
|
||||
public void 沖特休(string RYENO, int RYYER, int 特休, DbTransaction tran)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText =
|
||||
@"UPDATE RYER
|
||||
SET RYUST = ISNULL(RYUST, 0) + @RYUST
|
||||
WHERE RYENO=@RYENO AND RYYER=@RYYER";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYENO", RYENO);
|
||||
Query.AddParam(cmd, "RYYER", RYYER);
|
||||
Query.AddParam(cmd, "RYUST", 特休);
|
||||
|
||||
if (tran != null)
|
||||
{
|
||||
cmd.Connection = tran.Connection;
|
||||
cmd.Transaction = tran;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public void 取消沖特休(DbTransaction tran, string _RPREN)
|
||||
{
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
cmd.CommandText = @"SELECT RPNUM, RPRDT, RPTCT FROM RPAR WHERE RPREN=@RPREN";
|
||||
Query.AddParam(cmd, "RPREN", _RPREN);
|
||||
DataTable t = Query.Select(cmd, tran);
|
||||
|
||||
if (t.Rows.Count > 0)
|
||||
{
|
||||
string 舊User = WDAC.GetStringValue(t.Rows[0]["RPNUM"]);
|
||||
DateTime 舊日期 = WDAC.GetDateTimeValue(t.Rows[0]["RPRDT"]);
|
||||
int 舊時數 = WDAC.GetInt32Value(t.Rows[0]["RPTCT"]);
|
||||
|
||||
沖特休(舊User, 舊日期.Year, -舊時數, tran);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 結算特休
|
||||
/// </summary>
|
||||
/// <param name="ryeno">員工編號</param>
|
||||
/// <param name="ryyer">年度</param>
|
||||
/// <param name="trusr">操作人員</param>
|
||||
public string Final(
|
||||
string ryeno
|
||||
, int ryyer
|
||||
, string trusr
|
||||
)
|
||||
{
|
||||
var rasnDao = new RasnDAC(Query);
|
||||
var rsajDao = new RsajDAC(Query);
|
||||
var bpaaDao = new BpaaDAC(Query);
|
||||
MWEB unmweb = new MWEB();
|
||||
DbCommand cmd = Query.NewCommand();
|
||||
|
||||
// 取出今年
|
||||
cmd.CommandText = @"select * from RYER where RYENO=@RYENO AND RYYER=@RYYER";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "RYENO", ryeno);
|
||||
Query.AddParam(cmd, "RYYER", ryyer);
|
||||
var thisYear = Query.Select(cmd);
|
||||
|
||||
if (thisYear.Rows.Count <= 0)
|
||||
{
|
||||
throw new Exception("找不到可結算的資料");
|
||||
}
|
||||
|
||||
var thisRecord = thisYear.Rows[0];
|
||||
if (GetInt32Value(thisRecord["RYNXT"]) + GetInt32Value(thisRecord["RYSLY"]) != Get可用特休(ryeno, ryyer, 12, 31))
|
||||
{
|
||||
throw new Exception("折算薪資時數 + 遞延下年時數 應等於 本年未休時數");
|
||||
}
|
||||
|
||||
// 計算下年時數
|
||||
|
||||
// 取得派駐專案
|
||||
var project = rasnDao.SelectRecentByDate(ryeno, new DateTime(ryyer, 12, 01));
|
||||
var rapyn = GetStringValue(project.Rows[0]["RAPYN"]);
|
||||
// 取得派駐專案的年初特休計算方式
|
||||
var alt = bpaaDao.GetYearBeginAnnualLeaveType(rapyn);
|
||||
|
||||
// 年初時數
|
||||
var ryyst = 0;
|
||||
if (alt == "S")
|
||||
{
|
||||
ryyst = GetInt32Value(thisRecord["RYYST"]);
|
||||
for (int m = 1; m <= 12; m++)
|
||||
{
|
||||
var ryhmm = GetInt32Value(thisRecord[string.Format("RYH{0:D2}", m)]);
|
||||
ryyst += ryhmm > 0 ? ryhmm : 0;
|
||||
}
|
||||
}
|
||||
|
||||
var ryyxt = GetInt32Value(thisRecord["RYNXT"]); // 遞延下年時數
|
||||
var rysly = GetInt32Value(thisRecord["RYSLY"]); // 結算薪資時數
|
||||
|
||||
// 若未輸入離職日期
|
||||
var bpsnDao = new BpsnDAC(Query);
|
||||
var bpedy = bpsnDao.GetBPEDY(ryeno);
|
||||
if (bpedy.Ticks == 0)
|
||||
{
|
||||
if (!CheckExists(ryeno, ryyer + 1))
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"INSERT INTO RYER
|
||||
(TRDAT, TRMOD, TRUSR, RYENO, RYYER, RYTOT, RYUST, RYYST,
|
||||
RYH01, RYH02, RYH03, RYH04, RYH05, RYH06, RYH07, RYH08, RYH09, RYH10, RYH11, RYH12,
|
||||
RYD01, RYD02, RYD03, RYD04, RYD05, RYD06, RYD07, RYD08, RYD09, RYD10, RYD11, RYD12,
|
||||
RYSLY, RYNXT, RYRMK, RYYXT
|
||||
)
|
||||
VALUES
|
||||
(GETDATE(), 'INSERT', @TRUSR, @RYENO, @RYYER, @RYTOT, 0, @RYYST,
|
||||
@RYH01, @RYH02, @RYH03, @RYH04, @RYH05, @RYH06, @RYH07, @RYH08, @RYH09, @RYH10, @RYH11, @RYH12,
|
||||
@RYD01, @RYD02, @RYD03, @RYD04, @RYD05, @RYD06, @RYD07, @RYD08, @RYD09, @RYD10, @RYD11, @RYD12,
|
||||
@RYSLY, @RYNXT, @RYRMK, @RYYXT
|
||||
)";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", trusr);
|
||||
Query.AddParam(cmd, "RYENO", ryeno);
|
||||
Query.AddParam(cmd, "RYYER", ryyer + 1);
|
||||
Query.AddParam(cmd, "RYTOT", ryyst);
|
||||
Query.AddParam(cmd, "RYYST", ryyst);
|
||||
Query.AddParam(cmd, "RYH01", 0);
|
||||
Query.AddParam(cmd, "RYH02", 0);
|
||||
Query.AddParam(cmd, "RYH03", 0);
|
||||
Query.AddParam(cmd, "RYH04", 0);
|
||||
Query.AddParam(cmd, "RYH05", 0);
|
||||
Query.AddParam(cmd, "RYH06", 0);
|
||||
Query.AddParam(cmd, "RYH07", 0);
|
||||
Query.AddParam(cmd, "RYH08", 0);
|
||||
Query.AddParam(cmd, "RYH09", 0);
|
||||
Query.AddParam(cmd, "RYH10", 0);
|
||||
Query.AddParam(cmd, "RYH11", 0);
|
||||
Query.AddParam(cmd, "RYH12", 0);
|
||||
Query.AddParam(cmd, "RYD01", 1);
|
||||
Query.AddParam(cmd, "RYD02", 1);
|
||||
Query.AddParam(cmd, "RYD03", 1);
|
||||
Query.AddParam(cmd, "RYD04", 1);
|
||||
Query.AddParam(cmd, "RYD05", 1);
|
||||
Query.AddParam(cmd, "RYD06", 1);
|
||||
Query.AddParam(cmd, "RYD07", 1);
|
||||
Query.AddParam(cmd, "RYD08", 1);
|
||||
Query.AddParam(cmd, "RYD09", 1);
|
||||
Query.AddParam(cmd, "RYD10", 1);
|
||||
Query.AddParam(cmd, "RYD11", 1);
|
||||
Query.AddParam(cmd, "RYD12", 1);
|
||||
Query.AddParam(cmd, "RYSLY", 0);
|
||||
Query.AddParam(cmd, "RYNXT", 0);
|
||||
Query.AddParam(cmd, "RYRMK", "");
|
||||
Query.AddParam(cmd, "RYYXT", ryyxt);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText =
|
||||
@"UPDATE RYER
|
||||
SET TRDAT = GETDATE() ,
|
||||
TRMOD = 'UPDATE' ,
|
||||
TRUSR = @TRUSR ,
|
||||
RYTOT = @RYTOT ,
|
||||
RYYST = @RYYST ,
|
||||
RYSLY = @RYSLY ,
|
||||
RYNXT = @RYNXT ,
|
||||
RYYXT = @RYYXT
|
||||
WHERE RYENO = @OLD_RYENO
|
||||
AND RYYER = @OLD_RYYER";
|
||||
cmd.Parameters.Clear();
|
||||
Query.AddParam(cmd, "TRUSR", trusr);
|
||||
Query.AddParam(cmd, "RYTOT", ryyst);
|
||||
Query.AddParam(cmd, "RYYST", ryyst);
|
||||
Query.AddParam(cmd, "RYSLY", 0);
|
||||
Query.AddParam(cmd, "RYNXT", 0);
|
||||
Query.AddParam(cmd, "RYYXT", ryyxt);
|
||||
Query.AddParam(cmd, "OLD_RYENO", ryeno);
|
||||
Query.AddParam(cmd, "OLD_RYYER", ryyer + 1);
|
||||
Query.ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
var finalDate = new DateTime(ryyer, 12, 01);
|
||||
|
||||
// 取得派駐專案
|
||||
project = rasnDao.SelectRecentByDate(ryeno, finalDate);
|
||||
if (project.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception("人員無派遣紀錄,無法結算");
|
||||
}
|
||||
rapyn = GetStringValue(project.Rows[0]["RAPYN"]);
|
||||
// 取得結算單號
|
||||
var finalREN = rsajDao.GetAnnualLeaveSalaryREN(finalDate, ryeno, rapyn);
|
||||
// 若結算單號已存在,需要有權限的人員才可以執行
|
||||
if (!string.IsNullOrEmpty(finalREN) && !unmweb.CheckRight("RYER_FINAL", WRightName.Execute, UserId))
|
||||
{
|
||||
throw new Exception("已經結算過,你沒有權限再次結算");
|
||||
}
|
||||
|
||||
WriteAnnualLeaveSalary(ryeno, finalDate, rysly, false);
|
||||
return "年度結算";
|
||||
}
|
||||
// 離職日期是今年才要結算
|
||||
else if (bpedy.Year == ryyer)
|
||||
{
|
||||
var finalDate = new DateTime(bpedy.Year, bpedy.Month, 01);
|
||||
|
||||
// 取得派駐專案
|
||||
project = rasnDao.SelectRecentByDate(ryeno, finalDate);
|
||||
if (project.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception("人員無派遣紀錄,無法結算");
|
||||
}
|
||||
rapyn = GetStringValue(project.Rows[0]["RAPYN"]);
|
||||
// 取得結算單號
|
||||
var finalREN = rsajDao.GetAnnualLeaveSalaryREN(finalDate, ryeno, rapyn);
|
||||
// 若結算單號已存在,需要有權限的人員才可以執行
|
||||
if (!string.IsNullOrEmpty(finalREN) && !unmweb.CheckRight("RYER_FINAL", WRightName.Execute, UserId))
|
||||
{
|
||||
throw new Exception("已經結算過,你沒有權限再次結算");
|
||||
}
|
||||
|
||||
WriteAnnualLeaveSalary(ryeno, finalDate, rysly, true);
|
||||
return "離職結算";
|
||||
}
|
||||
//
|
||||
throw new Exception("離職日期年度不是本年,不予結算");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 寫入特休薪資結算
|
||||
/// </summary>
|
||||
/// <param name="ryeno">人員編號</param>
|
||||
/// <param name="date">結算日期</param>
|
||||
/// <param name="rysly">結算時數</param>
|
||||
/// <param name="isQuit">是否離職</param>
|
||||
internal void WriteAnnualLeaveSalary(string ryeno, DateTime date, int rysly, bool isQuit)
|
||||
{
|
||||
var rasnDao = new RasnDAC(Query);
|
||||
var rsajDao = new RsajDAC(Query);
|
||||
GetData getData = new GetData();
|
||||
Calculate calc = new Calculate();
|
||||
getData.Query = Query;
|
||||
|
||||
// 取得派駐專案
|
||||
var project = rasnDao.SelectRecentByDate(ryeno, date);
|
||||
if (project.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception("人員無派遣紀錄,無法結算");
|
||||
}
|
||||
var rapyn = GetStringValue(project.Rows[0]["RAPYN"]);
|
||||
|
||||
// 取得月薪
|
||||
// 取得計算公式
|
||||
int bpsrm; // 月薪
|
||||
int bpp02; // 伙食津貼
|
||||
double dumm1; // 前二加班比率
|
||||
double dumm2; // 後二加班比率
|
||||
double dumm3; // 假日加班比率
|
||||
string bpovr; // 加班費公式
|
||||
string dumm4; // 請假扣款公式
|
||||
string dumm5; // 加班費計算方式
|
||||
// 取得月薪、伙食津貼、前二加班比率、後二加班比率、假日加班比率、加班費公式、請假扣款公式
|
||||
getData.GetRASN_Date_Bppyn_Bpeno_Overwork_Rate(
|
||||
date, rapyn, ryeno, out bpsrm, out bpp02, out dumm1, out dumm2, out dumm3, out bpovr, out dumm4, out dumm5);
|
||||
|
||||
// 計算特休薪資
|
||||
var rsamt = GetInt32Value(Math.Truncate(calc.CalcOverTime(bpsrm, bpp02, rysly, 1.0, 1.0, bpovr)));
|
||||
|
||||
// 寫入離職當月薪資加減項
|
||||
var rsdoc = isQuit
|
||||
? string.Format("{0}離職特休結算{1}小時", date.ToString("yyyyMMdd", WGuard1.TaiwanCulture), (int)(rysly / 60))
|
||||
: string.Format("{0}年度特休結算{1}小時", date.ToString("yyyy", WGuard1.TaiwanCulture), (int)(rysly / 60));
|
||||
var rsajRen = rsajDao.WriteAnnualLeaveSalary(date, ryeno, rapyn, rsamt, rsdoc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RyerSaveItem
|
||||
{
|
||||
public int result;
|
||||
public string message;
|
||||
public string userid;
|
||||
public string ryeno;
|
||||
public int ryyer;
|
||||
public int? ryyst;
|
||||
public int? ryyst_h;
|
||||
public int? ryyst_m;
|
||||
public int ryyxt;
|
||||
public string ryyxt_d;
|
||||
public int ryh01;
|
||||
public int ryh02;
|
||||
public int ryh03;
|
||||
public int ryh04;
|
||||
public int ryh05;
|
||||
public int ryh06;
|
||||
public int ryh07;
|
||||
public int ryh08;
|
||||
public int ryh09;
|
||||
public int ryh10;
|
||||
public int ryh11;
|
||||
public int ryh12;
|
||||
public int ryd01;
|
||||
public int ryd02;
|
||||
public int ryd03;
|
||||
public int ryd04;
|
||||
public int ryd05;
|
||||
public int ryd06;
|
||||
public int ryd07;
|
||||
public int ryd08;
|
||||
public int ryd09;
|
||||
public int ryd10;
|
||||
public int ryd11;
|
||||
public int ryd12;
|
||||
public int? rysly;
|
||||
public int? rysly_h;
|
||||
public int? rysly_m;
|
||||
public int? rynxt;
|
||||
public int? rynxt_h;
|
||||
public int? rynxt_m;
|
||||
public string ryrmk;
|
||||
public string ryvld;
|
||||
public string ryust;
|
||||
public string rylft;
|
||||
public string ryeny;
|
||||
public int rymmy;
|
||||
public int ryslq;
|
||||
public string ryenq;
|
||||
public int rymmq;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.Script.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
using System.Data;
|
||||
|
||||
/// <summary>
|
||||
/// GetData 的摘要描述
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://tempuri.org/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[ScriptService]
|
||||
public class GetDataService : System.Web.Services.WebService
|
||||
{
|
||||
|
||||
public GetDataService()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public GetDataResponse GetOverTimeBegin(string date, string userid)
|
||||
{
|
||||
DateTime aDate;
|
||||
int result = -1;
|
||||
string beginHour = string.Empty;
|
||||
string beginMinute = string.Empty;
|
||||
TimeCalc timeCalc = new TimeCalc();
|
||||
|
||||
if (WGuard1.CheckDate(date, out aDate))
|
||||
{
|
||||
aDate = aDate.AddYears(WGuard1.CY11);
|
||||
RcrdDAC rcrdDAC = new RcrdDAC(WGuard1.Query);
|
||||
DataTable dt = rcrdDAC.ReadByDate(userid, aDate);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
string begintime = WDAC.GetStringValue(dt.Rows[0]["RCC01"]);
|
||||
|
||||
if (!string.IsNullOrEmpty(begintime))
|
||||
{
|
||||
begintime = TimeCalc.加分鐘數(begintime, 540);
|
||||
beginHour = begintime.Substring(0, 2);
|
||||
beginMinute = begintime.Substring(3, 2);
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//JObject data = new JObject();
|
||||
//data.Add("beginhour", new JValue(beginHour));
|
||||
//data.Add("beginminute", new JValue(beginMinute));
|
||||
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = result,
|
||||
Data = new { beginhour = beginHour , beginminute = beginMinute }
|
||||
};
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public GetDataResponse CheckAvailHours(string USERID, string RPPYN, string RPREN, string RPTYP, string RPRDT, string RPRTM, string RPEDT, string RPETM)
|
||||
{
|
||||
// 從設定檔中取得連線字串
|
||||
var ConnectionConfigName = WConfig.GetConnectionConfigName();
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
var ConnectionString = WConnectionString.GetConnectionString(ConnectionConfigName);
|
||||
var ConnectionType = WConnectionString.GetConnectionType(ConnectionConfigName);
|
||||
var Query = new WQuery(ConnectionType, ConnectionString);
|
||||
WGuard1.SetQuery(ConnectionType, ConnectionString);
|
||||
|
||||
DateTime rprdt, rpedt;
|
||||
//if (WGuard1.CheckDate(RPRDT, out rprdt))
|
||||
//{
|
||||
// rprdt = rprdt.AddYears(WGuard1.CY11);
|
||||
//}
|
||||
//if (WGuard1.CheckDate(RPEDT, out rpedt))
|
||||
//{
|
||||
// rpedt = rpedt.AddYears(WGuard1.CY11);
|
||||
//}
|
||||
WGuard1.CheckDate(RPRDT, out rprdt);
|
||||
WGuard1.CheckDate(RPEDT, out rpedt);
|
||||
|
||||
#region 取剩餘時數
|
||||
var rparDao = new RparDAC(Query);
|
||||
int 年度事假;
|
||||
int 年度病假;
|
||||
int availHours = 0;
|
||||
if (int.TryParse(WGuard1.WSetR("UNRPARTIME", 5), out 年度事假))
|
||||
年度事假 = 年度事假 * 60;
|
||||
else
|
||||
年度事假 = 112 * 60;
|
||||
if (int.TryParse(WGuard1.WSetR("UNRPARTIME", 6), out 年度病假))
|
||||
年度病假 = 年度病假 * 60;
|
||||
else
|
||||
年度病假 = 240 * 60;
|
||||
|
||||
if (rprdt.Ticks == 0 || rpedt.Ticks == 0 || string.IsNullOrEmpty(RPRTM) || string.IsNullOrEmpty(RPETM))
|
||||
{
|
||||
availHours = - 1;
|
||||
}
|
||||
if (RPTYP == RPAR_TYPE.T02_事假 || RPTYP == RPAR_TYPE.T0B_家庭照顧假)
|
||||
{
|
||||
availHours = 年度事假 - rparDao.Get已請事假(USERID, rprdt, RPREN) - new TimeCalc().計算請假總時數(USERID, rprdt, rpedt, RPRTM, RPETM, RPTYP, true);
|
||||
}
|
||||
if (RPTYP == RPAR_TYPE.T03_病假)
|
||||
{
|
||||
availHours = 年度病假 - rparDao.Get已請病假(USERID, rprdt, RPREN) - new TimeCalc().計算請假總時數(USERID, rprdt, rpedt, RPRTM, RPETM, RPTYP, true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region
|
||||
var bpsnDao = new BpsnDAC(Query);
|
||||
var rdt_rppyn = string.Empty;
|
||||
var edt_rppyn = string.Empty;
|
||||
var dateMessage = new List<string>();
|
||||
if (rprdt.Ticks > 0)
|
||||
{
|
||||
rdt_rppyn = bpsnDao.GetProjectByDate(USERID, rprdt);
|
||||
if (RPPYN.CompareTo(rdt_rppyn) != 0)
|
||||
{
|
||||
dateMessage.Add(string.Format("{0}日期不在目前專案的範圍", rprdt.Ticks > 0 && rpedt.Ticks > 0 ? "開始" : ""));
|
||||
}
|
||||
}
|
||||
if (rpedt.Ticks > 0)
|
||||
{
|
||||
edt_rppyn = bpsnDao.GetProjectByDate(USERID, rpedt);
|
||||
if (RPPYN.CompareTo(edt_rppyn) != 0)
|
||||
{
|
||||
dateMessage.Add("結束日期不在目前專案的範圍");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 0,
|
||||
Data = new {
|
||||
availHours = availHours,
|
||||
dateMessage = dateMessage
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class GetDataResponse
|
||||
{
|
||||
public int Result;
|
||||
public object Data;
|
||||
public string Message;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.ComponentModel;
|
||||
|
||||
/// <summary>
|
||||
/// RPAR 的摘要描述
|
||||
/// </summary>
|
||||
public partial class RPAR
|
||||
{
|
||||
public string RPREN { get; set; }
|
||||
public string RPNUM { get; set; }
|
||||
public int RAITM { get; set; }
|
||||
public string RPCNM { get; set; }
|
||||
public string RPPYN { get; set; }
|
||||
public DateTime RPRDT { get; set; }
|
||||
public DateTime RPEDT { get; set; }
|
||||
public string RPTYP { get; set; }
|
||||
public double RPFTR { get; set; }
|
||||
public string RPDOC { get; set; }
|
||||
public int APPNO { get; set; }
|
||||
public DateTime RPADT { get; set; }
|
||||
public string RPAPN { get; set; }
|
||||
public string RPANO { get; set; }
|
||||
public string RPAPP { get; set; }
|
||||
public DateTime RPAPD { get; set; }
|
||||
public string RPAPU { get; set; }
|
||||
public string RPAGT { get; set; }
|
||||
public string RPAGM { get; set; }
|
||||
public string RPRTM { get; set; }
|
||||
public string RPETM { get; set; }
|
||||
public int RPUST { get; set; }
|
||||
public string RPRSN { get; set; }
|
||||
public string RPPLC { get; set; }
|
||||
public string RPFPC { get; set; }
|
||||
public string RPFAD { get; set; }
|
||||
public decimal RPKMS { get; set; }
|
||||
public DateTime TRDAT { get; set; }
|
||||
public string TRMOD { get; set; }
|
||||
public string TRUSR { get; set; }
|
||||
public int RPTCT { get; set; }
|
||||
public int RPTMT { get; set; }
|
||||
public int RPTC1 { get; set; }
|
||||
public int RPTM1 { get; set; }
|
||||
public int RPTC2 { get; set; }
|
||||
public int RPTM2 { get; set; }
|
||||
public int RPTC3 { get; set; }
|
||||
public int RPTM3 { get; set; }
|
||||
public int RPTC4 { get; set; }
|
||||
public int RPTM4 { get; set; }
|
||||
public int RPTC5 { get; set; }
|
||||
public int RPTM5 { get; set; }
|
||||
public int RPTA1 { get; set; }
|
||||
public int RPTA2 { get; set; }
|
||||
public int RPTA3 { get; set; }
|
||||
public int RPTA4 { get; set; }
|
||||
public int RPTA5 { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class RPAR_TYPE
|
||||
{
|
||||
public const string T0_請假 = "0";
|
||||
public const string T00_補休 = "00";
|
||||
public const string T01_特休 = "01";
|
||||
public const string T02_事假 = "02";
|
||||
public const string T03_病假 = "03";
|
||||
public const string T04_喪假 = "04";
|
||||
public const string T05_產假 = "05";
|
||||
public const string T06_婚假 = "06";
|
||||
public const string T07_陪產假 = "07";
|
||||
public const string T08_公假 = "08";
|
||||
public const string T09_公傷假 = "09";
|
||||
public const string T0A_生理假 = "0A";
|
||||
public const string T0B_家庭照顧假 = "0B";
|
||||
public const string T0C_育嬰假 = "0C";
|
||||
public const string T0D_原民祭儀假 = "0D";
|
||||
public const string T0E_產檢假 = "0E";
|
||||
public const string T0F_防疫照顧假 = "0F";
|
||||
public const string T0G_無薪假 = "0G";
|
||||
public const string T0H_防疫隔離假 = "0H";
|
||||
|
||||
public const string T1_加班 = "1";
|
||||
public const string T11_非休息日累積補休時數 = "11";
|
||||
public const string T12_非休息日請領加班費 = "12";
|
||||
public const string T13_休息日累積補休時數 = "13";
|
||||
public const string T14_休息日請領加班費 = "14";
|
||||
public const string T15_國定假日累積補休時數 = "15";
|
||||
public const string T16_國定假日請領加班費 = "16";
|
||||
public const string T17_例假日累積補休時數 = "17";
|
||||
public const string T18_例假日請領加班費 = "18";
|
||||
|
||||
public const string T2_電話油料 = "2";
|
||||
public const string T21_電話費 = "21";
|
||||
public const string T22_油料費 = "22";
|
||||
|
||||
public const string T3_出差 = "3";
|
||||
public const string T31_短程出差 = "31";
|
||||
public const string T32_長程出差 = "32";
|
||||
public const string T33_公出 = "33";
|
||||
public const string T34_公假 = "34";
|
||||
|
||||
public static bool 休息日加班(string rparType)
|
||||
{
|
||||
return rparType == T13_休息日累積補休時數 || rparType == T14_休息日請領加班費;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Wellan.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
/// <summary>
|
||||
/// RPARList 的摘要描述
|
||||
/// </summary>
|
||||
public partial class RPARList : List<RPAR>, IDataList
|
||||
{
|
||||
public void Fill(DbDataReader reader)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
RPAR newItem = new RPAR
|
||||
{
|
||||
RPREN = WDAC.GetStringValue(reader["RPREN"]),
|
||||
RPNUM = WDAC.GetStringValue(reader["RPNUM"]),
|
||||
RAITM = WDAC.GetInt32Value(reader["RAITM"]),
|
||||
RPCNM = WDAC.GetStringValue(reader["RPCNM"]),
|
||||
RPPYN = WDAC.GetStringValue(reader["RPPYN"]),
|
||||
RPRDT = WDAC.GetDateTimeValue(reader["RPRDT"]),
|
||||
RPEDT = WDAC.GetDateTimeValue(reader["RPEDT"]),
|
||||
RPTYP = WDAC.GetStringValue(reader["RPTYP"]),
|
||||
RPFTR = WDAC.GetDoubleValue(reader["RPFTR"]),
|
||||
RPDOC = WDAC.GetStringValue(reader["RPDOC"]),
|
||||
APPNO = WDAC.GetInt32Value(reader["APPNO"]),
|
||||
RPADT = WDAC.GetDateTimeValue(reader["RPADT"]),
|
||||
RPAPN = WDAC.GetStringValue(reader["RPAPN"]),
|
||||
RPANO = WDAC.GetStringValue(reader["RPANO"]),
|
||||
RPAPP = WDAC.GetStringValue(reader["RPAPP"]),
|
||||
RPAPD = WDAC.GetDateTimeValue(reader["RPAPD"]),
|
||||
RPAPU = WDAC.GetStringValue(reader["RPAPU"]),
|
||||
RPAGT = WDAC.GetStringValue(reader["RPAGT"]),
|
||||
RPAGM = WDAC.GetStringValue(reader["RPAGM"]),
|
||||
RPRTM = WDAC.GetStringValue(reader["RPRTM"]),
|
||||
RPETM = WDAC.GetStringValue(reader["RPETM"]),
|
||||
RPUST = WDAC.GetInt32Value(reader["RPUST"]),
|
||||
RPRSN = WDAC.GetStringValue(reader["RPRSN"]),
|
||||
RPPLC = WDAC.GetStringValue(reader["RPPLC"]),
|
||||
RPFPC = WDAC.GetStringValue(reader["RPFPC"]),
|
||||
RPFAD = WDAC.GetStringValue(reader["RPFAD"]),
|
||||
RPKMS = WDAC.GetDecimalValue(reader["RPKMS"]),
|
||||
TRDAT = WDAC.GetDateTimeValue(reader["TRDAT"]),
|
||||
TRMOD = WDAC.GetStringValue(reader["TRMOD"]),
|
||||
TRUSR = WDAC.GetStringValue(reader["TRUSR"]),
|
||||
RPTCT = WDAC.GetInt32Value(reader["RPTCT"]),
|
||||
RPTMT = WDAC.GetInt32Value(reader["RPTMT"]),
|
||||
RPTC1 = WDAC.GetInt32Value(reader["RPTC1"]),
|
||||
RPTM1 = WDAC.GetInt32Value(reader["RPTM1"]),
|
||||
RPTC2 = WDAC.GetInt32Value(reader["RPTC2"]),
|
||||
RPTM2 = WDAC.GetInt32Value(reader["RPTM2"]),
|
||||
RPTC3 = WDAC.GetInt32Value(reader["RPTC3"]),
|
||||
RPTM3 = WDAC.GetInt32Value(reader["RPTM3"]),
|
||||
RPTC4 = WDAC.GetInt32Value(reader["RPTC4"]),
|
||||
RPTM4 = WDAC.GetInt32Value(reader["RPTM4"]),
|
||||
RPTC5 = WDAC.GetInt32Value(reader["RPTC5"]),
|
||||
RPTM5 = WDAC.GetInt32Value(reader["RPTM5"]),
|
||||
};
|
||||
Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
/// <summary>
|
||||
/// 專案內的公用變數
|
||||
/// </summary>
|
||||
public class PublicVariable
|
||||
{
|
||||
public PublicVariable()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 內部人員部門
|
||||
/// </summary>
|
||||
public static string InnerDepartment = " ('A01','B01','B01-1','B01-2','C01','C01-1','C01-2','D01','E01','E01-1','E01-2','E02','E02-1','E02-2','E03','E03-1','E03-2') ";
|
||||
|
||||
public static string RPARAttachPath = "";
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 SSL 登入發郵件
|
||||
/// </summary>
|
||||
public static bool SendMailBySSL = false;
|
||||
|
||||
/// <summary>
|
||||
/// 郵件發送主機
|
||||
/// </summary>
|
||||
public static string SendMailHost = "";
|
||||
|
||||
/// <summary>
|
||||
/// 郵件發送通訊埠,不使用 SSL 的通常是 25,使用 SSL 的通常是 465
|
||||
/// </summary>
|
||||
public static int SendMailPort = 25;
|
||||
|
||||
/// <summary>
|
||||
/// 郵件發送帳號
|
||||
/// </summary>
|
||||
public static string SendMailUserName = "";
|
||||
|
||||
/// <summary>
|
||||
/// 郵件發送密碼
|
||||
/// </summary>
|
||||
public static string SendMailPassword = "";
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO.Compression;
|
||||
|
||||
[WebService(Namespace = "http://www.maolaoda.com/CRAXFileTransfer")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
public class CRAXFileTransfer : System.Web.Services.WebService
|
||||
{
|
||||
public CRAXFileTransfer()
|
||||
{
|
||||
//Uncomment the following line if using designed components
|
||||
//InitializeComponent();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public GetFileResponse GetFile(string filename, bool compress)
|
||||
{
|
||||
GetFileResponse response = new GetFileResponse();
|
||||
try
|
||||
{
|
||||
response.FileName = filename;
|
||||
|
||||
if (compress)
|
||||
{
|
||||
FileStream readStream = File.Open(Server.MapPath(filename), FileMode.Open, FileAccess.Read);
|
||||
byte[] buffer = new byte[readStream.Length];
|
||||
int count = readStream.Read(buffer, 0, buffer.Length);
|
||||
readStream.Close();
|
||||
if (count != buffer.Length)
|
||||
{
|
||||
response.Message = "Unable to read data from " + filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
GZipStream compressStream = new GZipStream(outputStream, CompressionMode.Compress, true);
|
||||
compressStream.Write(buffer, 0, buffer.Length);
|
||||
compressStream.Flush();
|
||||
compressStream.Close();
|
||||
response.FileContents = outputStream.GetBuffer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.FileContents = File.ReadAllBytes(Server.MapPath(filename));
|
||||
}
|
||||
|
||||
response.Message = "OK";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Message = "ERROR:" + ex.Message;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
[XmlRoot("getFileResponse", Namespace = "http://www.maolaoda.com/CRAXFileTransfer")]
|
||||
public class GetFileResponse
|
||||
{
|
||||
[XmlElement("fileName", IsNullable = false)]
|
||||
public string FileName;
|
||||
|
||||
[XmlElement("message", IsNullable = false)]
|
||||
public string Message;
|
||||
|
||||
[XmlElement("fileData", IsNullable = true)]
|
||||
public byte[] FileContents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
using System;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.SS.Util;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
|
||||
public class Excel
|
||||
{
|
||||
public HSSFWorkbook WorkBook
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public HSSFSheet Sheet
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立或取得指定行列的儲存格
|
||||
/// </summary>
|
||||
/// <param name="row">列</param>
|
||||
/// <param name="col">行</param>
|
||||
/// <returns></returns>
|
||||
public ICell Cell(int row, int col)
|
||||
{
|
||||
if (Sheet.GetRow(row) == null)
|
||||
Sheet.CreateRow(row);
|
||||
if (Sheet.GetRow(row).GetCell(col) == null)
|
||||
Sheet.GetRow(row).CreateCell(col);
|
||||
return Sheet.GetRow(row).GetCell(col);
|
||||
}
|
||||
|
||||
public string RCtoA1(int row, int col)
|
||||
{
|
||||
string colX;
|
||||
|
||||
if (col <= 25)
|
||||
colX = Char.ConvertFromUtf32(65 + col);
|
||||
else
|
||||
{
|
||||
col = col - 26;
|
||||
colX = Char.ConvertFromUtf32(65 + (int)(col / 26)) + Char.ConvertFromUtf32(65 + (col % 26));
|
||||
}
|
||||
|
||||
return String.Format("{0}{1}", colX, row + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName)
|
||||
{
|
||||
return NewFont(fontName, 9, FontBoldWeight.Normal, HSSFColor.COLOR_NORMAL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName, short fontSize)
|
||||
{
|
||||
return NewFont(fontName, fontSize, FontBoldWeight.Normal, HSSFColor.COLOR_NORMAL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName, short fontSize, FontBoldWeight fontWeight)
|
||||
{
|
||||
return NewFont(fontName, fontSize, fontWeight, HSSFColor.COLOR_NORMAL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新字體
|
||||
/// </summary>
|
||||
public IFont NewFont(string fontName, short fontSize, FontBoldWeight fontWeight, short color)
|
||||
{
|
||||
IFont result = WorkBook.CreateFont(); // 抬頭字體
|
||||
result.FontName = fontName;
|
||||
result.FontHeightInPoints = fontSize;
|
||||
result.Boldweight = (short)fontWeight;
|
||||
result.Color = color;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立新樣式
|
||||
/// </summary>
|
||||
public ICellStyle NewCellStyle(IFont font, HorizontalAlignment align, VerticalAlignment valign, bool warpText)
|
||||
{
|
||||
ICellStyle style = WorkBook.CreateCellStyle();
|
||||
style.SetFont(font);
|
||||
style.Alignment = align;
|
||||
style.VerticalAlignment = valign;
|
||||
style.WrapText = warpText;
|
||||
return style;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合併儲存格
|
||||
/// </summary>
|
||||
public void MergeCell(int row1, int col1, int row2, int col2)
|
||||
{
|
||||
// 建立範圍內所有儲存格
|
||||
for (int row = row1; row <= row2; row++)
|
||||
for (int col = col1; col <= col2; col++)
|
||||
Cell(row, col);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2); // Region.ConvertToCellRangeAddress(new Region(row1, col1, row2, col2));
|
||||
Sheet.AddMergedRegion(region);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合併儲存格,並設定合併後的邊框樣式
|
||||
/// </summary>
|
||||
public void MergeCell(int row1, int col1, int row2, int col2, BorderStyle bordertype)
|
||||
{
|
||||
// 建立範圍內所有儲存格
|
||||
for (int row = row1; row <= row2; row++)
|
||||
for (int col = col1; col <= col2; col++)
|
||||
Cell(row, col);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2); //Region.ConvertToCellRangeAddress(new Region(row1, col1, row2, col2));
|
||||
Sheet.AddMergedRegion(region);
|
||||
SetRangeOuterBorder(region, bordertype);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定單一儲存格的邊框樣式
|
||||
/// </summary>
|
||||
public void SetCellBorder(int row, int col, BorderStyle bordertype)
|
||||
{
|
||||
CellRangeAddress region = new CellRangeAddress(row, row, col, col);
|
||||
HSSFRegionUtil.SetBorderTop(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(int row1, int col1, int row2, int col2, BorderStyle bordertype)
|
||||
{
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2);
|
||||
HSSFRegionUtil.SetBorderTop(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(int row1, int col1, int row2, int col2, BorderStyle bordertypeTop, BorderStyle bordertypeLeft, BorderStyle bordertypeBottom, BorderStyle bordertypeRight)
|
||||
{
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2);
|
||||
HSSFRegionUtil.SetBorderTop(bordertypeTop, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertypeLeft, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertypeBottom, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertypeRight, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(CellRangeAddress region, BorderStyle bordertype)
|
||||
{
|
||||
HSSFRegionUtil.SetBorderTop(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertype, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的外圍邊框樣式
|
||||
/// </summary>
|
||||
public void SetRangeOuterBorder(CellRangeAddress region, BorderStyle bordertypeTop, BorderStyle bordertypeLeft, BorderStyle bordertypeBottom, BorderStyle bordertypeRight)
|
||||
{
|
||||
HSSFRegionUtil.SetBorderTop(bordertypeTop, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderLeft(bordertypeLeft, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderBottom(bordertypeBottom, region, Sheet as HSSFSheet, WorkBook);
|
||||
HSSFRegionUtil.SetBorderRight(bordertypeRight, region, Sheet as HSSFSheet, WorkBook);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設定一個儲存格範圍的內部格線樣式 (慢,建議僅使用於小範圍!)
|
||||
/// </summary>
|
||||
public void SetRangeInnerGrid(int row1, int col1, int row2, int col2, BorderStyle bordertype)
|
||||
{
|
||||
/*
|
||||
CellRangeAddress region = new CellRangeAddress(row1, row2, col1, col2);
|
||||
Sheet.SetEnclosedBorderOfRegion(region, bordertype, HSSFColor.COLOR_NORMAL);
|
||||
*/
|
||||
|
||||
for (int col = col1; col <= col2; col++)
|
||||
{
|
||||
SetRangeOuterBorder(row1, col, row2, col, bordertype);
|
||||
}
|
||||
for (int row = row1; row <= row2; row++)
|
||||
{
|
||||
SetRangeOuterBorder(row, col1, row, col2, bordertype);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCellStyle(int row, int col, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, bool value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, DateTime value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, double value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, IRichTextString value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, string value, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, bool value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, DateTime value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, double value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, IRichTextString value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellValue(int row, int col, string value)
|
||||
{
|
||||
Cell(row, col).SetCellValue(value);
|
||||
}
|
||||
|
||||
public void SetCellFormula(int row, int col, string formula)
|
||||
{
|
||||
Cell(row, col).CellFormula = formula;
|
||||
}
|
||||
|
||||
public void SetCellFormula(int row, int col, string formula, ICellStyle style)
|
||||
{
|
||||
Cell(row, col).CellFormula = formula;
|
||||
Cell(row, col).CellStyle = style;
|
||||
}
|
||||
|
||||
private HSSFPatriarch patriarch = null;
|
||||
public void DrawLine(int col1, int row1, int dx1, int dy1, int col2, int row2, int dx2, int dy2, LineStyle lineStyle, int lineWidth)
|
||||
{
|
||||
if (patriarch == null)
|
||||
patriarch = Sheet.CreateDrawingPatriarch() as HSSFPatriarch;
|
||||
|
||||
HSSFClientAnchor a = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
|
||||
HSSFSimpleShape s = patriarch.CreateSimpleShape(a);
|
||||
s.ShapeType = HSSFSimpleShape.OBJECT_TYPE_LINE; // 設定線條類型為線條
|
||||
s.LineStyle = lineStyle; // 設定為實線
|
||||
s.LineWidth = lineWidth;
|
||||
}
|
||||
|
||||
public void DrawPicture(int col1, int row1, int dx1, int dy1, int col2, int row2, int dx2, int dy2, string pictureFileName)
|
||||
{
|
||||
if (patriarch == null)
|
||||
patriarch = Sheet.CreateDrawingPatriarch() as HSSFPatriarch;
|
||||
|
||||
byte[] picture = File.ReadAllBytes(pictureFileName);
|
||||
int pictureIdx = WorkBook.AddPicture(picture, PictureType.JPEG);
|
||||
|
||||
HSSFClientAnchor a = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
|
||||
HSSFPicture p = patriarch.CreatePicture(a, pictureIdx) as HSSFPicture;
|
||||
//p.Resize();
|
||||
}
|
||||
|
||||
public void SetColumnWidth(int column, int width)
|
||||
{
|
||||
Sheet.SetColumnWidth(column, width * 256 + 182);
|
||||
}
|
||||
|
||||
public void SetRowHeight(int row, int height)
|
||||
{
|
||||
Sheet.GetRow(row).HeightInPoints = height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
|
||||
/// <summary>
|
||||
/// 報表基礎類別
|
||||
/// </summary>
|
||||
public abstract class ExcelReportBase
|
||||
{
|
||||
protected HSSFWorkbook workbook;
|
||||
protected HSSFSheet sheet;
|
||||
protected Excel excel;
|
||||
protected IFont headerFont;
|
||||
protected IFont footerFont;
|
||||
protected IFont titleFont;
|
||||
protected IFont titleFontBoldUnderLine;
|
||||
protected IFont bodyFont;
|
||||
protected IFont bodyFontS;
|
||||
protected IFont bodyFont6PT;
|
||||
protected IFont bodyFont8PT;
|
||||
protected ICellStyle headerStyle;
|
||||
protected ICellStyle footerStyle;
|
||||
protected ICellStyle titleStyleLeft;
|
||||
protected ICellStyle titleStyleRight;
|
||||
protected ICellStyle titleStyleCenter;
|
||||
protected ICellStyle titleStyleCenterYellowBGC;
|
||||
protected ICellStyle titleStyleCenterBottom;
|
||||
protected ICellStyle titleStyleLeftNoBorder;
|
||||
protected ICellStyle titleStyleRightNoBorder;
|
||||
protected ICellStyle titleStyleCenterNoBorder;
|
||||
protected ICellStyle titleStyleCenterBottomNoBorder;
|
||||
protected ICellStyle titleStyleCenterUDBorder;
|
||||
protected ICellStyle bodyStyleLeft;
|
||||
protected ICellStyle bodyStyleRight;
|
||||
protected ICellStyle bodyStyleCenter;
|
||||
protected ICellStyle bodyStyleLeftNoBorder;
|
||||
protected ICellStyle bodyStyleRightNoBorder;
|
||||
protected ICellStyle bodyStyleCenterNoBorder;
|
||||
|
||||
protected ICellStyle bodyNumberStyle;
|
||||
protected ICellStyle bodyNumberStyleNoBorder;
|
||||
protected ICellStyle bodyNumberStyleUDBorder;
|
||||
protected ICellStyle bodyNumberStyle2;
|
||||
protected ICellStyle bodyStyleCenterS;
|
||||
protected ICellStyle bodyStyleCenterXS;
|
||||
protected int HeaderRowHeight = 27;
|
||||
protected int BodyRowHeight = 24;
|
||||
protected int thisYy;
|
||||
protected int thisMm;
|
||||
protected int prevYy;
|
||||
protected int prevMm;
|
||||
|
||||
public ExcelReportBase()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public DataSet 資料來源
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 公司名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 客戶名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 專案名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 報表名稱
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DateTime 報表時間
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 客戶編號
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 專案編號
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 年度
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string 月份
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Dictionary<string, string> 報表參數
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool 以時分顯示時數 { get; set; }
|
||||
|
||||
protected virtual void Init()
|
||||
{
|
||||
workbook = new HSSFWorkbook();
|
||||
sheet = workbook.CreateSheet("報表") as HSSFSheet;
|
||||
sheet.ForceFormulaRecalculation = true;
|
||||
excel = new Excel();
|
||||
excel.WorkBook = workbook;
|
||||
excel.Sheet = sheet;
|
||||
numberFormat = workbook.CreateDataFormat();
|
||||
|
||||
SetPaperAndMargin(sheet);
|
||||
|
||||
headerFont = excel.NewFont("標楷體", 16, FontBoldWeight.Bold);
|
||||
footerFont = excel.NewFont("標楷體", 16);
|
||||
titleFont = excel.NewFont("標楷體", 12);
|
||||
titleFontBoldUnderLine = excel.NewFont("標楷體", 12, FontBoldWeight.Bold);
|
||||
titleFontBoldUnderLine.Underline = FontUnderlineType.Single;
|
||||
bodyFont = excel.NewFont("標楷體", 12);
|
||||
bodyFontS = excel.NewFont("標楷體", 10);
|
||||
bodyFont6PT = excel.NewFont("標楷體", 6);
|
||||
bodyFont8PT = excel.NewFont("標楷體", 8);
|
||||
|
||||
headerStyle = excel.NewCellStyle(headerFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
footerStyle = excel.NewCellStyle(footerFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
|
||||
titleStyleLeft = excel.NewCellStyle(titleFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
titleStyleLeft.BorderTop = BorderStyle.Thin;
|
||||
titleStyleLeft.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleLeft.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleLeft.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleRight = excel.NewCellStyle(titleFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
titleStyleRight.BorderTop = BorderStyle.Thin;
|
||||
titleStyleRight.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleRight.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleRight.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleCenter = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenter.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenter.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleCenter.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleCenter.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleCenterYellowBGC = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenterYellowBGC.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.BorderRight = BorderStyle.Thin;
|
||||
titleStyleCenterYellowBGC.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
|
||||
titleStyleCenterYellowBGC.FillPattern = FillPattern.SolidForeground;
|
||||
titleStyleCenterYellowBGC.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
|
||||
|
||||
titleStyleCenterBottom = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Bottom, true);
|
||||
titleStyleCenterBottom.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenterBottom.BorderBottom = BorderStyle.Thin;
|
||||
titleStyleCenterBottom.BorderLeft = BorderStyle.Thin;
|
||||
titleStyleCenterBottom.BorderRight = BorderStyle.Thin;
|
||||
|
||||
titleStyleLeftNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
titleStyleRightNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
titleStyleCenterNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenterBottomNoBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Bottom, true);
|
||||
|
||||
titleStyleCenterUDBorder = excel.NewCellStyle(titleFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
titleStyleCenterUDBorder.BorderTop = BorderStyle.Thin;
|
||||
titleStyleCenterUDBorder.BorderBottom = BorderStyle.Thin;
|
||||
|
||||
bodyStyleLeft = excel.NewCellStyle(bodyFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
bodyStyleLeft.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleLeft.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleLeft.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleLeft.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleLeft.WrapText = true;
|
||||
|
||||
bodyStyleRight = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyStyleRight.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleRight.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleRight.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleRight.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleRight.WrapText = true;
|
||||
|
||||
bodyStyleCenter = excel.NewCellStyle(bodyFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenter.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleCenter.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleCenter.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleCenter.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleCenter.WrapText = true;
|
||||
|
||||
bodyStyleLeftNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Left, VerticalAlignment.Top, true);
|
||||
bodyStyleLeftNoBorder.WrapText = true;
|
||||
|
||||
bodyStyleRightNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyStyleRightNoBorder.WrapText = true;
|
||||
|
||||
bodyStyleCenterNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenterNoBorder.WrapText = true;
|
||||
|
||||
bodyStyleCenterS = excel.NewCellStyle(bodyFontS, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenterS.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleCenterS.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleCenterS.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleCenterS.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleCenterS.WrapText = true;
|
||||
|
||||
bodyStyleCenterXS = excel.NewCellStyle(bodyFont6PT, HorizontalAlignment.Center, VerticalAlignment.Top, true);
|
||||
bodyStyleCenterXS.BorderTop = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.BorderBottom = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.BorderLeft = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.BorderRight = BorderStyle.Thin;
|
||||
bodyStyleCenterXS.WrapText = true;
|
||||
|
||||
bodyNumberStyle = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyle.DataFormat = numberFormat.GetFormat("###,###,##0");
|
||||
bodyNumberStyle.BorderTop = BorderStyle.Thin;
|
||||
bodyNumberStyle.BorderBottom = BorderStyle.Thin;
|
||||
bodyNumberStyle.BorderLeft = BorderStyle.Thin;
|
||||
bodyNumberStyle.BorderRight = BorderStyle.Thin;
|
||||
bodyNumberStyle.WrapText = true;
|
||||
|
||||
bodyNumberStyle2 = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyle2.DataFormat = numberFormat.GetFormat("###,###,##0.00");
|
||||
bodyNumberStyle2.BorderTop = BorderStyle.Thin;
|
||||
bodyNumberStyle2.BorderBottom = BorderStyle.Thin;
|
||||
bodyNumberStyle2.BorderLeft = BorderStyle.Thin;
|
||||
bodyNumberStyle2.BorderRight = BorderStyle.Thin;
|
||||
bodyNumberStyle2.WrapText = true;
|
||||
|
||||
bodyNumberStyleNoBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyleNoBorder.DataFormat = numberFormat.GetFormat("###,###,##0");
|
||||
bodyNumberStyleNoBorder.WrapText = true;
|
||||
|
||||
bodyNumberStyleUDBorder = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyleUDBorder.DataFormat = numberFormat.GetFormat("###,###,##0");
|
||||
bodyNumberStyleUDBorder.BorderTop = BorderStyle.Thin;
|
||||
bodyNumberStyleUDBorder.BorderBottom = BorderStyle.Thin;
|
||||
bodyNumberStyleUDBorder.WrapText = true;
|
||||
|
||||
資料來源 = new DataSet();
|
||||
}
|
||||
|
||||
private IDataFormat numberFormat;
|
||||
protected IDataFormat NumberFormat { get { return numberFormat; } }
|
||||
|
||||
protected void SetPaperAndMargin(HSSFSheet Asheet)
|
||||
{
|
||||
// 設定紙張
|
||||
Asheet.PrintSetup.PaperSize = 9; // A4
|
||||
Asheet.PrintSetup.Landscape = false; // 橫向
|
||||
|
||||
// 列印格式
|
||||
Asheet.PrintSetup.UsePage = true;
|
||||
Asheet.PrintSetup.FitWidth = 1; // 將所有欄擠進 1 頁寬
|
||||
Asheet.PrintSetup.FitHeight = 0; // 0 表示不指定幾頁
|
||||
|
||||
// 頁首頁尾
|
||||
Asheet.Footer.Left = "列印日期:&D";
|
||||
Asheet.Footer.Right = "頁數:&P";
|
||||
|
||||
// 紙張邊界
|
||||
Asheet.PrintSetup.HeaderMargin = 0d;
|
||||
Asheet.PrintSetup.FooterMargin = 0.3d;
|
||||
Asheet.SetMargin(MarginType.TopMargin, 0.5d);
|
||||
Asheet.SetMargin(MarginType.BottomMargin, 0.5d);
|
||||
Asheet.SetMargin(MarginType.LeftMargin, 0.3d);
|
||||
Asheet.SetMargin(MarginType.RightMargin, 0.3d);
|
||||
}
|
||||
|
||||
protected string MinuteToTime(int minute)
|
||||
{
|
||||
int hh = minute / 60;
|
||||
int mm = minute % 60;
|
||||
|
||||
if (以時分顯示時數)
|
||||
return String.Format("{0:##0}:{1:00}", hh, mm);
|
||||
else
|
||||
return hh.ToString();
|
||||
}
|
||||
|
||||
public abstract MemoryStream 產生報表();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ReportParameter
|
||||
/// </summary>
|
||||
public class ReportParameter
|
||||
{
|
||||
private SortedList<string, string> _paramList = new SortedList<string, string>();
|
||||
|
||||
public ReportParameter()
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(string name, string value)
|
||||
{
|
||||
if (!_paramList.ContainsKey(name))
|
||||
_paramList.Add(name, value);
|
||||
else
|
||||
_paramList[name] = value;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_paramList.Clear();
|
||||
}
|
||||
|
||||
public string Save(string fileName, bool random)
|
||||
{
|
||||
string realFileName = GetRealFileName(fileName, random);
|
||||
if (File.Exists(realFileName))
|
||||
File.Delete(realFileName);
|
||||
using (StreamWriter sw = File.CreateText(realFileName))
|
||||
{
|
||||
for (int i = 0; i < _paramList.Count; i++)
|
||||
{
|
||||
sw.WriteLine(String.Format("{0}={1}", _paramList.Keys[i], _paramList.Values[i]));
|
||||
}
|
||||
sw.Close();
|
||||
}
|
||||
return realFileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 為檔案名稱加上隨機字尾
|
||||
/// </summary>
|
||||
private string GetRealFileName(string fileName, bool random)
|
||||
{
|
||||
if (!random)
|
||||
return fileName;
|
||||
|
||||
string ext = Path.GetExtension(fileName);
|
||||
string s = Path.ChangeExtension(fileName, null);
|
||||
do
|
||||
{
|
||||
Random r = new Random();
|
||||
int suffix = r.Next(int.MaxValue);
|
||||
fileName = String.Format("{0}_{1:x8}{2}", s, suffix, ext);
|
||||
}
|
||||
while (File.Exists(fileName));
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// 畫薪資條
|
||||
/// </summary>
|
||||
public class SalaryStrip
|
||||
{
|
||||
public string 公司名稱 = "";
|
||||
public string 薪資別 = "";
|
||||
public string 發薪年月 = "";
|
||||
public string 部門 = "";
|
||||
public string 員工代號 = "";
|
||||
public string 姓名 = "";
|
||||
public string 職務 = "";
|
||||
|
||||
public int 公司提繳 = 0;
|
||||
public int 津貼合計 = 0;
|
||||
public int 課稅金額 = 0;
|
||||
public int 應發金額 = 0;
|
||||
public int 員工累計 = 0;
|
||||
public int 扣款合計 = 0;
|
||||
public int 所得稅 = 0;
|
||||
public int 實發金額 = 0;
|
||||
public int 公司累計 = 0;
|
||||
public string 帳號 = "";
|
||||
public int 薪資條樣板 = 0;
|
||||
|
||||
public bool 列印公司提繳 = true;
|
||||
public bool 列印津貼合計 = true;
|
||||
public bool 列印課稅金額 = true;
|
||||
public bool 列印應發金額 = true;
|
||||
public bool 列印員工累計 = true;
|
||||
public bool 列印扣款合計 = true;
|
||||
public bool 列印所得稅 = true;
|
||||
public bool 列印實發金額 = true;
|
||||
public bool 列印公司累計 = true;
|
||||
public bool 列印帳號 = true;
|
||||
|
||||
#region 私用變數
|
||||
|
||||
private Font companyFont = new Font("細明體", 18, FontStyle.Bold);
|
||||
private Font titleFont = new Font("細明體", 11, FontStyle.Regular);
|
||||
private Font detailFont = new Font("細明體", 10, FontStyle.Regular);
|
||||
|
||||
// 定義各點位置
|
||||
private PointF pt公司名稱 = new PointF(379, 35);
|
||||
private PointF pt薪資別 = new PointF(100, 76);
|
||||
private PointF pt發薪年月 = new PointF(633, 76);
|
||||
private PointF pt部門 = new PointF(100, 98);
|
||||
private PointF pt員工代號 = new PointF(290, 98);
|
||||
private PointF pt姓名 = new PointF(442, 98);
|
||||
private PointF pt職務 = new PointF(633, 98);
|
||||
|
||||
private PointF pt加項1 = new PointF(40, 180);
|
||||
private PointF pt減項1 = new PointF(267, 180);
|
||||
private PointF pt出勤1 = new PointF(494, 180);
|
||||
private PointF pt加項2 = new PointF(126, 180);
|
||||
private PointF pt減項2 = new PointF(352, 180);
|
||||
private PointF pt出勤2 = new PointF(668, 180);
|
||||
|
||||
private PointF pt公司提繳 = new PointF(192, 404);
|
||||
private PointF pt津貼合計 = new PointF(343, 404);
|
||||
private PointF pt課稅金額 = new PointF(494, 404);
|
||||
private PointF pt應發金額 = new PointF(645, 404);
|
||||
private PointF pt員工累計 = new PointF(192, 424);
|
||||
private PointF pt扣款合計 = new PointF(343, 424);
|
||||
private PointF pt所得稅 = new PointF(494, 424);
|
||||
private PointF pt實發金額 = new PointF(645, 424);
|
||||
private PointF pt公司累計 = new PointF(192, 443);
|
||||
private PointF pt帳號 = new PointF(343, 443);
|
||||
|
||||
// 定義加項名稱
|
||||
private List<string> PlusNames = new List<string>();
|
||||
private List<int> PlusAmounts = new List<int>();
|
||||
|
||||
// 定義減項名稱
|
||||
private List<string> MinusNames = new List<string>();
|
||||
private List<int> MinusAmounts = new List<int>();
|
||||
|
||||
// 定義出勤名稱
|
||||
private List<string> PresentNames = new List<string>();
|
||||
private List<string> PresentAmounts = new List<string>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 私用方法
|
||||
|
||||
private string[] 薪資條樣板檔案 = { @"picture\SalaryStrip.dib", @"picture\SalaryStrip_Bonus.dib" };
|
||||
|
||||
private void DrawTitle(Graphics g)
|
||||
{
|
||||
DrawString(g, 公司名稱, companyFont, pt公司名稱, "C");
|
||||
DrawString(g, 薪資別, titleFont, pt薪資別, "L");
|
||||
DrawString(g, 發薪年月, titleFont, pt發薪年月, "L");
|
||||
DrawString(g, 部門, titleFont, pt部門, "L");
|
||||
DrawString(g, 員工代號, titleFont, pt員工代號, "L");
|
||||
DrawString(g, 姓名, titleFont, pt姓名, "L");
|
||||
DrawString(g, 職務, titleFont, pt職務, "L");
|
||||
|
||||
if (列印公司提繳)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 公司提繳), titleFont, pt公司提繳, "L");
|
||||
if (列印津貼合計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 津貼合計), titleFont, pt津貼合計, "L");
|
||||
if (列印課稅金額)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 課稅金額), titleFont, pt課稅金額, "L");
|
||||
if (列印應發金額)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 應發金額), titleFont, pt應發金額, "L");
|
||||
if (列印員工累計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 員工累計), titleFont, pt員工累計, "L");
|
||||
if (列印扣款合計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 扣款合計), titleFont, pt扣款合計, "L");
|
||||
if (列印所得稅)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 所得稅), titleFont, pt所得稅, "L");
|
||||
if (列印實發金額)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 實發金額), titleFont, pt實發金額, "L");
|
||||
if (列印公司累計)
|
||||
DrawString(g, String.Format("{0,9:#,###,##0}", 公司累計), titleFont, pt公司累計, "L");
|
||||
if (列印帳號)
|
||||
DrawString(g, 帳號, titleFont, pt帳號, "L");
|
||||
}
|
||||
|
||||
private void DrawItems(Graphics g)
|
||||
{
|
||||
for (int i = 0; i < PlusNames.Count; i++)
|
||||
g.DrawString(PlusNames[i], detailFont, Brushes.Black, pt加項1.X, pt加項1.Y + (i * 18));
|
||||
for (int i = 0; i < PlusAmounts.Count; i++)
|
||||
g.DrawString(String.Format("{0,9:#,###,##0}", PlusAmounts[i]), detailFont, Brushes.Black, pt加項2.X, pt加項2.Y + (i * 18));
|
||||
|
||||
for (int i = 0; i < MinusNames.Count; i++)
|
||||
g.DrawString(MinusNames[i], detailFont, Brushes.Black, pt減項1.X, pt減項1.Y + (i * 18));
|
||||
for (int i = 0; i < MinusAmounts.Count; i++)
|
||||
g.DrawString(String.Format("{0,9:#,###,##0}", MinusAmounts[i]), detailFont, Brushes.Black, pt減項2.X, pt減項2.Y + (i * 18));
|
||||
|
||||
for (int i = 0; i < PresentNames.Count; i++)
|
||||
g.DrawString(PresentNames[i], detailFont, Brushes.Black, pt出勤1.X, pt出勤1.Y + (i * 18));
|
||||
for (int i = 0; i < PresentAmounts.Count; i++)
|
||||
g.DrawString(String.Format("{0,6:c}", PresentAmounts[i]), detailFont, Brushes.Black, pt出勤2.X, pt出勤2.Y + (i * 18));
|
||||
}
|
||||
|
||||
private void DrawString(Graphics g, string s, Font f, PointF pt, string align)
|
||||
{
|
||||
PointF pt1 = new PointF() { X = pt.X, Y = pt.Y };
|
||||
SizeF size = g.MeasureString(s, f);
|
||||
|
||||
if (align == "R")
|
||||
pt1.X -= size.Width;
|
||||
else if (align == "C")
|
||||
pt1.X -= size.Width / 2;
|
||||
|
||||
g.DrawString(s, f, Brushes.Black, pt1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddPlus(string name, int amount)
|
||||
{
|
||||
PlusNames.Add(name);
|
||||
PlusAmounts.Add(amount);
|
||||
}
|
||||
|
||||
public void AddMinus(string name, int amount)
|
||||
{
|
||||
MinusNames.Add(name);
|
||||
MinusAmounts.Add(amount);
|
||||
}
|
||||
|
||||
public void AddPresent(string name, string amount)
|
||||
{
|
||||
PresentNames.Add(name);
|
||||
PresentAmounts.Add(amount);
|
||||
}
|
||||
|
||||
public MemoryStream Draw(string rootpath)
|
||||
{
|
||||
Image img = Image.FromFile(rootpath + 薪資條樣板檔案[薪資條樣板]);
|
||||
Graphics g = Graphics.FromImage(img);
|
||||
DrawTitle(g);
|
||||
DrawItems(g);
|
||||
MemoryStream result = new MemoryStream();
|
||||
img.Save(result, System.Drawing.Imaging.ImageFormat.Gif);
|
||||
img.Dispose();
|
||||
g.Dispose();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
PlusNames.Clear();
|
||||
PlusAmounts.Clear();
|
||||
MinusNames.Clear();
|
||||
MinusAmounts.Clear();
|
||||
PresentNames.Clear();
|
||||
PresentAmounts.Clear();
|
||||
|
||||
公司名稱 = "";
|
||||
薪資別 = "";
|
||||
發薪年月 = "";
|
||||
部門 = "";
|
||||
員工代號 = "";
|
||||
姓名 = "";
|
||||
職務 = "";
|
||||
|
||||
公司提繳 = 0;
|
||||
津貼合計 = 0;
|
||||
課稅金額 = 0;
|
||||
應發金額 = 0;
|
||||
員工累計 = 0;
|
||||
扣款合計 = 0;
|
||||
所得稅 = 0;
|
||||
實發金額 = 0;
|
||||
公司累計 = 0;
|
||||
帳號 = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 出差申請單
|
||||
/// </summary>
|
||||
public class 出差申請單 : ExcelReportBase
|
||||
{
|
||||
public 出差申請單()
|
||||
{
|
||||
報表名稱 = "出差申請單";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 9);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.MergeCell(1, 1, 1, 2);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 3, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 4, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 5, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 6, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 7, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 8, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 2);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 2, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 0, "公差日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "類別", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "開始時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "結束時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 6, "時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 7, "公差地點", titleStyleCenter);
|
||||
excel.SetCellValue(2, 8, "公差事由", titleStyleCenter);
|
||||
excel.SetCellValue(2, 9, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
int rowId = 3;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetDateTimeValue(r["RPRDT"]).ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, "~", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 2, WDAC.GetDateTimeValue(r["RPEDT"]).ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 3, WDAC.GetStringValue(r["類別"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, WDAC.GetStringValue(r["RPRTM"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, WDAC.GetStringValue(r["RPETM"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 6, MinuteToTime(WDAC.GetInt32Value(r["RPTCT"])), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 7, WDAC.GetStringValue(r["RPPLC"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetStringValue(r["RPRSN"]), bodyStyleCenterS);
|
||||
excel.SetCellValue(rowId, 9, WDAC.GetStringValue(r["RPDOC"]), bodyStyleCenterS);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 2, 0, rowId + 2, 9);
|
||||
//excel.SetCellValue(rowId + 2, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 1, rowId + 1, 3);
|
||||
//excel.MergeCell(rowId + 2, 1, rowId + 2, 3);
|
||||
//excel.SetCellValue(rowId + 1, 1, "申請人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 1, rowId + 1, 3, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 1, rowId + 2, 3, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 4, rowId + 1, 6);
|
||||
//excel.MergeCell(rowId + 2, 4, rowId + 2, 6);
|
||||
//excel.SetCellValue(rowId + 1, 4, "公司計畫督導", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 4, rowId + 1, 6, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 4, rowId + 2, 6, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 7, rowId + 1, 8);
|
||||
//excel.MergeCell(rowId + 2, 7, rowId + 2, 8);
|
||||
//excel.SetCellValue(rowId + 1, 7, "公司計畫主持人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 7, rowId + 1, 8, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 7, rowId + 2, 8, BorderStyle.Thin);
|
||||
|
||||
//excel.SetRowHeight(rowId + 1, BodyRowHeight);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 11);
|
||||
excel.SetColumnWidth(1, 4);
|
||||
excel.SetColumnWidth(2, 11);
|
||||
excel.SetColumnWidth(3, 11);
|
||||
excel.SetColumnWidth(4, 11);
|
||||
excel.SetColumnWidth(5, 11);
|
||||
excel.SetColumnWidth(6, 12);
|
||||
excel.SetColumnWidth(7, 12);
|
||||
excel.SetColumnWidth(8, 30);
|
||||
excel.SetColumnWidth(9, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 出缺勤情形統計表 的摘要描述
|
||||
/// </summary>
|
||||
public class 出缺勤情形統計表 : ExcelReportBase
|
||||
{
|
||||
public 出缺勤情形統計表()
|
||||
{
|
||||
}
|
||||
|
||||
private ICellStyle bodyNumberStyleNoBorderD2;
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
|
||||
bodyNumberStyleNoBorderD2 = excel.NewCellStyle(bodyFont, HorizontalAlignment.Right, VerticalAlignment.Top, true);
|
||||
bodyNumberStyleNoBorderD2.DataFormat = NumberFormat.GetFormat("###,###,##0.00");
|
||||
bodyNumberStyleNoBorderD2.WrapText = true;
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, string.Format("{0}{1}出缺勤情形(單位:時)", 年度, 月份), titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, "站別", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, "人員姓名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, "補休", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, "特休", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "產假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, "公假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "事假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, "喪假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, "病假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, "加班一", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, "加班二", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, "婚假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, "工傷假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, "生理假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, "家庭照顧假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, "陪產假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, "原民祭儀假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 18, "產檢假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, "其他假別(一)", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
int SST05_SUM = 0;
|
||||
int SST06_SUM = 0;
|
||||
int SST10_SUM = 0;
|
||||
int SST13_SUM = 0;
|
||||
int SST07_SUM = 0;
|
||||
int SST09_SUM = 0;
|
||||
int SST08_SUM = 0;
|
||||
int 加班_SUM = 0;
|
||||
int SST04_SUM = 0;
|
||||
int SST11_SUM = 0;
|
||||
int SST14_SUM = 0;
|
||||
int SST15_SUM = 0;
|
||||
int SST16_SUM = 0;
|
||||
int SST12_SUM = 0;
|
||||
int SST19_SUM = 0;
|
||||
int SST20_SUM = 0;
|
||||
int SST23_SUM = 0;
|
||||
int 全勤人數 = 0;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 加班 = WDAC.GetInt32Value(r["SST01"]) * 60 + WDAC.GetInt32Value(r["SST01M"])
|
||||
+ WDAC.GetInt32Value(r["SST02"]) * 60 + WDAC.GetInt32Value(r["SST02M"])
|
||||
+ WDAC.GetInt32Value(r["SST03"]) * 60 + WDAC.GetInt32Value(r["SST03M"])
|
||||
+ WDAC.GetInt32Value(r["SST21"]) * 60 + WDAC.GetInt32Value(r["SST21M"])
|
||||
+ WDAC.GetInt32Value(r["SST22"]) * 60 + WDAC.GetInt32Value(r["SST22M"]);
|
||||
|
||||
SST05_SUM += WDAC.GetInt32Value(r["SST05"]) * 60 + WDAC.GetInt32Value(r["SST05M"]);
|
||||
SST06_SUM += WDAC.GetInt32Value(r["SST06"]) * 60 + WDAC.GetInt32Value(r["SST06M"]);
|
||||
SST10_SUM += WDAC.GetInt32Value(r["SST10"]) * 60 + WDAC.GetInt32Value(r["SST10M"]);
|
||||
SST13_SUM += WDAC.GetInt32Value(r["SST13"]) * 60 + WDAC.GetInt32Value(r["SST13M"]);
|
||||
SST07_SUM += WDAC.GetInt32Value(r["SST07"]) * 60 + WDAC.GetInt32Value(r["SST07M"]);
|
||||
SST09_SUM += WDAC.GetInt32Value(r["SST09"]) * 60 + WDAC.GetInt32Value(r["SST09M"]);
|
||||
SST08_SUM += WDAC.GetInt32Value(r["SST08"]) * 60 + WDAC.GetInt32Value(r["SST08M"]);
|
||||
加班_SUM += 加班;
|
||||
SST04_SUM += WDAC.GetInt32Value(r["SST04"]) * 60 + WDAC.GetInt32Value(r["SST04M"]);
|
||||
SST11_SUM += WDAC.GetInt32Value(r["SST11"]) * 60 + WDAC.GetInt32Value(r["SST11M"]);
|
||||
SST14_SUM += WDAC.GetInt32Value(r["SST14"]) * 60 + WDAC.GetInt32Value(r["SST14M"]);
|
||||
SST15_SUM += WDAC.GetInt32Value(r["SST15"]) * 60 + WDAC.GetInt32Value(r["SST15M"]);
|
||||
SST16_SUM += WDAC.GetInt32Value(r["SST16"]) * 60 + WDAC.GetInt32Value(r["SST16M"]);
|
||||
SST12_SUM += WDAC.GetInt32Value(r["SST12"]) * 60 + WDAC.GetInt32Value(r["SST12M"]);
|
||||
SST19_SUM += WDAC.GetInt32Value(r["SST19"]) * 60 + WDAC.GetInt32Value(r["SST19M"]);
|
||||
SST20_SUM += WDAC.GetInt32Value(r["SST20"]) * 60 + WDAC.GetInt32Value(r["SST20M"]);
|
||||
SST23_SUM += WDAC.GetInt32Value(r["SST23"]) * 60 + WDAC.GetInt32Value(r["SST23M"]);
|
||||
全勤人數 += WDAC.GetInt32Value(r["SST07"]) == 0 &&
|
||||
WDAC.GetInt32Value(r["SST08"]) == 0 &&
|
||||
WDAC.GetInt32Value(r["SST10"]) == 0 &&
|
||||
WDAC.GetInt32Value(r["SST12"]) == 0 ? 1 : 0;
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 3, string.Format("{0:#00}:{1:00}", r["SST05"], r["SST05M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", r["SST06"], r["SST06M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, string.Format("{0:#00}:{1:00}", r["SST10"], r["SST10M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", r["SST13"], r["SST13M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, string.Format("{0:#00}:{1:00}", r["SST07"], r["SST07M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", r["SST09"], r["SST09M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, string.Format("{0:#00}:{1:00}", r["SST08"], r["SST08M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", (int)Math.Floor(加班 / 60.0), 加班 % 60), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, string.Format("{0:#00}:{1:00}", r["SST04"], r["SST04M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", r["SST11"], r["SST11M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, string.Format("{0:#00}:{1:00}", r["SST14"], r["SST14M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, string.Format("{0:#00}:{1:00}", r["SST15"], r["SST15M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, string.Format("{0:#00}:{1:00}", r["SST16"], r["SST16M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, string.Format("{0:#00}:{1:00}", r["SST12"], r["SST12M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, string.Format("{0:#00}:{1:00}", r["SST19"], r["SST19M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 18, string.Format("{0:#00}:{1:00}", r["SST20"], r["SST20M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, string.Format("{0:#00}:{1:00}", r["SST23"], r["SST23M"]), bodyStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(row, 3, WDAC.GetInt32Value(r["SST05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SST06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SST10"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SST13"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SST07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SST09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SST08"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, (int)Math.Floor(加班 / 60.0), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SST04"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SST11"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SST14"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, WDAC.GetInt32Value(r["SST15"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetInt32Value(r["SST16"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 16, WDAC.GetInt32Value(r["SST12"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 17, WDAC.GetInt32Value(r["SST19"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, WDAC.GetInt32Value(r["SST20"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 19, WDAC.GetInt32Value(r["SST23"]), bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
var 人數 = (float)資料來源.Tables[0].Rows.Count;
|
||||
|
||||
// 表尾合計
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0} 位合計", 人數), titleStyleLeftNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 3, MinuteToTime(SST05_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, MinuteToTime(SST06_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, MinuteToTime(SST10_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, MinuteToTime(SST13_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, MinuteToTime(SST07_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, MinuteToTime(SST09_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, MinuteToTime(SST08_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, MinuteToTime(加班_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, MinuteToTime(SST04_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, MinuteToTime(SST11_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, MinuteToTime(SST14_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, MinuteToTime(SST15_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, MinuteToTime(SST16_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, MinuteToTime(SST12_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, MinuteToTime(SST19_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 18, MinuteToTime(SST20_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, MinuteToTime(SST23_SUM), bodyStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellFormula(row, 3, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 3), excel.RCtoA1(row - 1, 3)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 4, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 1, 4)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 5, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 1, 5)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 1, 13)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 14, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 1, 14)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 15, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(row - 1, 15)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 16, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 16), excel.RCtoA1(row - 1, 16)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 17, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 1, 17)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 18, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 18), excel.RCtoA1(row - 1, 18)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 19, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 19), excel.RCtoA1(row - 1, 19)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
|
||||
// 表尾平均、備註
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0} 位平均", 人數), titleStyleLeftNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
var SST05_AVG = SST05_SUM / 人數;
|
||||
var SST06_AVG = SST06_SUM / 人數;
|
||||
var SST10_AVG = SST10_SUM / 人數;
|
||||
var SST13_AVG = SST13_SUM / 人數;
|
||||
var SST07_AVG = SST07_SUM / 人數;
|
||||
var SST09_AVG = SST09_SUM / 人數;
|
||||
var SST08_AVG = SST08_SUM / 人數;
|
||||
var 加班_AVG = 加班_SUM / 人數;
|
||||
var SST04_AVG = SST04_SUM / 人數;
|
||||
var SST11_AVG = SST11_SUM / 人數;
|
||||
var SST14_AVG = SST14_SUM / 人數;
|
||||
var SST15_AVG = SST15_SUM / 人數;
|
||||
var SST16_AVG = SST16_SUM / 人數;
|
||||
var SST12_AVG = SST12_SUM / 人數;
|
||||
var SST19_AVG = SST19_SUM / 人數;
|
||||
var SST20_AVG = SST20_SUM / 人數;
|
||||
var SST23_AVG = SST23_SUM / 人數;
|
||||
|
||||
excel.SetCellValue(row, 3, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST05_AVG / 60.0), (int)Math.Floor(SST05_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST06_AVG / 60.0), (int)Math.Floor(SST06_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST10_AVG / 60.0), (int)Math.Floor(SST10_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST13_AVG / 60.0), (int)Math.Floor(SST13_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST07_AVG / 60.0), (int)Math.Floor(SST07_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST09_AVG / 60.0), (int)Math.Floor(SST09_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST08_AVG / 60.0), (int)Math.Floor(SST08_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", (int)Math.Floor(加班_AVG / 60.0), (int)Math.Floor(加班_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST04_AVG / 60.0), (int)Math.Floor(SST04_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST11_AVG / 60.0), (int)Math.Floor(SST11_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST14_AVG / 60.0), (int)Math.Floor(SST14_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST15_AVG / 60.0), (int)Math.Floor(SST15_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST16_AVG / 60.0), (int)Math.Floor(SST16_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST12_AVG / 60.0), (int)Math.Floor(SST12_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST19_AVG / 60.0), (int)Math.Floor(SST19_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 18, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST20_AVG / 60.0), (int)Math.Floor(SST20_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, string.Format("{0:#00}:{1:00}", (int)Math.Floor(SST23_AVG / 60.0), (int)Math.Floor(SST23_AVG % 60)), bodyStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "備註:1.", titleStyleRightNoBorder);
|
||||
excel.MergeCell(row, 3, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, "加班1為加班採申請加班費方式;加班2為加班採補休方式申請。", titleStyleLeftNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 3, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, string.Format("本月平均加班時數為 {0:#00}:{1:00} 小時。", (int)Math.Floor(加班_AVG / 60.0), (int)Math.Floor(加班_AVG % 60)), titleStyleLeftNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "2.", titleStyleRightNoBorder);
|
||||
excel.MergeCell(row, 3, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, string.Format("{0}全勤(不含補休、特休及公假)共 {1} 位,全勤占 {2:##0.0}%。", 月份, 全勤人數, ((double)全勤人數 / (double)人數 * 100.0)), titleStyleLeftNoBorder);
|
||||
row++;
|
||||
}
|
||||
else
|
||||
{
|
||||
var 加班_AVG = (double)加班_SUM / (double)人數;
|
||||
|
||||
excel.SetCellFormula(row, 3, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 3), excel.RCtoA1(row - 2, 3)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 4, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 2, 4)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 5, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 2, 5)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 6, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 2, 6)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 7, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 2, 7)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 8, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 2, 8)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 9, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 2, 9)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 10, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 2, 10)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 11, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 2, 11)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 12, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 2, 12)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 13, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 2, 13)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 14, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 2, 14)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 15, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(row - 2, 15)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 16, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 16), excel.RCtoA1(row - 2, 16)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 17, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 2, 17)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 18, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 18), excel.RCtoA1(row - 2, 18)), bodyNumberStyleNoBorderD2);
|
||||
excel.SetCellFormula(row, 19, String.Format("AVERAGE({0}:{1})", excel.RCtoA1(beginRow, 19), excel.RCtoA1(row - 2, 19)), bodyNumberStyleNoBorderD2);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "備註:1.", titleStyleRightNoBorder);
|
||||
excel.MergeCell(row, 3, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, "加班1為加班採申請加班費方式;加班2為加班採補休方式申請。", titleStyleLeftNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 3, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, string.Format("本月平均加班時數為 {0:#00.00} 小時。", 加班_AVG), titleStyleLeftNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "2.", titleStyleRightNoBorder);
|
||||
excel.MergeCell(row, 3, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, string.Format("{0}全勤(不含補休、特休及公假)共 {1} 位,全勤占 {2:##0.0}%。", 月份, 全勤人數, ((double)全勤人數 / (double)人數 * 100.0)), titleStyleLeftNoBorder);
|
||||
row++;
|
||||
}
|
||||
|
||||
excel.MergeCell(row, 0, row, 6, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 7, row, 13, BorderStyle.None);
|
||||
excel.SetCellValue(row, 7, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 14, row, 19, BorderStyle.None);
|
||||
excel.SetCellValue(row, 14, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 10);
|
||||
excel.SetColumnWidth(5, 10);
|
||||
excel.SetColumnWidth(6, 10);
|
||||
excel.SetColumnWidth(7, 10);
|
||||
excel.SetColumnWidth(8, 10);
|
||||
excel.SetColumnWidth(9, 10);
|
||||
excel.SetColumnWidth(10, 10);
|
||||
excel.SetColumnWidth(11, 10);
|
||||
excel.SetColumnWidth(12, 10);
|
||||
excel.SetColumnWidth(13, 10);
|
||||
excel.SetColumnWidth(14, 10);
|
||||
excel.SetColumnWidth(15, 10);
|
||||
excel.SetColumnWidth(16, 10);
|
||||
excel.SetColumnWidth(17, 10);
|
||||
excel.SetColumnWidth(18, 10);
|
||||
excel.SetColumnWidth(19, 10);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 加班申請單
|
||||
/// </summary>
|
||||
public class 加班申請單 : ExcelReportBase
|
||||
{
|
||||
public 加班申請單()
|
||||
{
|
||||
報表名稱 = "加班申請單";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 8);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 2, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 3, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 4, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 5, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 6, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 7, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.SetCellValue(2, 0, "加班日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 1, "開始時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 2, "結束時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "核定加班時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "核定加班費時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "核定補休時數", titleStyleCenter);
|
||||
excel.MergeCell(2, 6, 2, 7);
|
||||
excel.SetCellValue(2, 6, "加班事由", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(2, 6, 2, 7, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 8, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight * 2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int RPTC1_SUM = 0;
|
||||
int RPTC2_SUM = 0;
|
||||
int RPTC3_SUM = 0;
|
||||
int RPTC4_SUM = 0;
|
||||
int RPTC5_SUM = 0;
|
||||
int RPTCT_SUM = 0;
|
||||
int FEE_THIS = 0;
|
||||
int RST_THIS = 0;
|
||||
int RST_SUM = 0;
|
||||
int FEE_SUM = 0;
|
||||
|
||||
int rowId = 3;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
int RPTCT = WDAC.GetInt32Value(r["RPTCT"]);
|
||||
RPTCT_SUM += RPTCT;
|
||||
|
||||
#region 區分假別統計
|
||||
switch (WDAC.GetStringValue(r["RPTYP"]))
|
||||
{
|
||||
case RPAR_TYPE.T11_非休息日累積補休時數:
|
||||
case RPAR_TYPE.T13_休息日累積補休時數:
|
||||
case RPAR_TYPE.T15_國定假日累積補休時數:
|
||||
case RPAR_TYPE.T17_例假日累積補休時數:
|
||||
RST_SUM += RPTCT;
|
||||
RST_THIS = RPTCT;
|
||||
FEE_THIS = 0;
|
||||
break;
|
||||
default:
|
||||
RPTC1_SUM += WDAC.GetInt32Value(r["RPTC1"]);
|
||||
RPTC2_SUM += WDAC.GetInt32Value(r["RPTC2"]);
|
||||
RPTC3_SUM += WDAC.GetInt32Value(r["RPTC3"]);
|
||||
RPTC4_SUM += WDAC.GetInt32Value(r["RPTC4"]);
|
||||
RPTC5_SUM += WDAC.GetInt32Value(r["RPTC5"]);
|
||||
FEE_SUM += RPTCT;
|
||||
RST_THIS = 0;
|
||||
FEE_THIS = RPTCT;
|
||||
break;
|
||||
}
|
||||
#endregion
|
||||
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetDateTimeValue(r["RPRDT"]).ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, WDAC.GetStringValue(r["RPRTM"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 2, WDAC.GetStringValue(r["RPETM"]), titleStyleCenter);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(rowId, 3, String.Format("{0:00}:{1:00}", RPTCT / 60, RPTCT % 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, String.Format("{0:00}:{1:00}", FEE_THIS / 60, FEE_THIS % 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, String.Format("{0:00}:{1:00}", RST_THIS / 60, RST_THIS % 60), titleStyleCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId, 3, String.Format("{0:00}", RPTCT / 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, String.Format("{0:00}", FEE_THIS / 60), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, String.Format("{0:00}", RST_THIS / 60), titleStyleCenter);
|
||||
}
|
||||
|
||||
excel.MergeCell(rowId, 6, rowId, 7);
|
||||
excel.SetCellValue(rowId, 6, WDAC.GetStringValue(r["RPRSN"]), bodyStyleCenterS);
|
||||
excel.SetRangeOuterBorder(rowId, 6, rowId, 7, BorderStyle.Thin);
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetStringValue(r["RPDOC"]), bodyStyleCenterS);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#region 底下的統計
|
||||
// 左
|
||||
excel.MergeCell(rowId + 2, 0, rowId + 7, 0);
|
||||
excel.MergeCell(rowId + 2, 1, rowId + 7, 1);
|
||||
excel.MergeCell(rowId + 2, 2, rowId + 7, 2);
|
||||
excel.SetCellValue(rowId + 2, 0, "總加班時數:", titleStyleRightNoBorder);
|
||||
if (以時分顯示時數)
|
||||
excel.SetCellValue(rowId + 2, 1, String.Format("{0:00}:{1:00}", RPTCT_SUM / 60, RPTCT_SUM % 60), titleStyleCenterNoBorder);
|
||||
else
|
||||
excel.SetCellValue(rowId + 2, 1, String.Format("{0:00}", RPTCT_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 2, 2, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + 2, 0, rowId + 7, 2, BorderStyle.Thin);
|
||||
|
||||
// 中
|
||||
excel.SetCellValue(rowId + 2, 3, "申請加班費:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 3, "申請補休:", titleStyleLeftNoBorder);
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 4, String.Format("{0:00}:{1:00}", FEE_SUM / 60, FEE_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 4, String.Format("{0:00}:{1:00}", RST_SUM / 60, RST_SUM % 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 4, String.Format("{0:00}", FEE_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 4, String.Format("{0:00}", RST_SUM / 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
excel.SetCellValue(rowId + 2, 5, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 7, 5, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + 2, 3, rowId + 6, 5, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 7, 3, rowId + 7, 5, BorderStyle.Thin);
|
||||
|
||||
// 右
|
||||
excel.SetCellValue(rowId + 2, 6, "一又三分之一:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 6, "一又三分之二:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 6, "國定假日:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 6, "休息日再延長:", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 6, "例假日再延長:", titleStyleLeftNoBorder);
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 7, String.Format("{0:00}:{1:00}", RPTC1_SUM / 60, RPTC1_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 7, String.Format("{0:00}:{1:00}", RPTC2_SUM / 60, RPTC2_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 7, String.Format("{0:00}:{1:00}", RPTC3_SUM / 60, RPTC3_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 7, String.Format("{0:00}:{1:00}", RPTC4_SUM / 60, RPTC4_SUM % 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 7, String.Format("{0:00}:{1:00}", RPTC5_SUM / 60, RPTC5_SUM % 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId + 2, 7, String.Format("{0:00}", RPTC1_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 7, String.Format("{0:00}", RPTC2_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 7, String.Format("{0:00}", RPTC3_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 7, String.Format("{0:00}", RPTC4_SUM / 60), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 7, String.Format("{0:00}", RPTC5_SUM / 60), titleStyleCenterNoBorder);
|
||||
}
|
||||
excel.SetCellValue(rowId + 2, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 3, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 4, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 5, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + 6, 8, "hrs", titleStyleLeftNoBorder);
|
||||
|
||||
excel.SetRangeOuterBorder(rowId + 2, 6, rowId + 2, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 3, 6, rowId + 3, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 4, 6, rowId + 4, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 5, 6, rowId + 5, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 6, 6, rowId + 6, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId + 7, 6, rowId + 7, 8, BorderStyle.Thin);
|
||||
|
||||
excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 3, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 4, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 5, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 6, BodyRowHeight);
|
||||
excel.SetRowHeight(rowId + 7, BodyRowHeight);
|
||||
|
||||
rowId += 7;
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 7, 0, rowId + 7, 8);
|
||||
//excel.SetCellValue(rowId + 7, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 7, BodyRowHeight);
|
||||
|
||||
//excel.MergeCell(rowId + 2, 0, rowId + 2, 2);
|
||||
//excel.MergeCell(rowId + 3, 0, rowId + 3, 2);
|
||||
//excel.SetCellValue(rowId + 2, 0, "申請人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 0, rowId + 2, 2, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 3, 0, rowId + 3, 2, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 2, 3, rowId + 2, 5);
|
||||
//excel.MergeCell(rowId + 3, 3, rowId + 3, 5);
|
||||
//excel.SetCellValue(rowId + 2, 3, "公司計畫督導", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 3, rowId + 2, 5, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 3, 3, rowId + 3, 5, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 2, 6, rowId + 2, 8);
|
||||
//excel.MergeCell(rowId + 3, 6, rowId + 3, 8);
|
||||
//excel.SetCellValue(rowId + 2, 6, "公司計畫主持人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 6, rowId + 2, 8, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 3, 6, rowId + 3, 8, BorderStyle.Thin);
|
||||
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
//excel.SetRowHeight(rowId + 3, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 15);
|
||||
excel.SetColumnWidth(1, 12);
|
||||
excel.SetColumnWidth(2, 12);
|
||||
excel.SetColumnWidth(3, 15);
|
||||
excel.SetColumnWidth(4, 15);
|
||||
excel.SetColumnWidth(5, 15);
|
||||
excel.SetColumnWidth(6, 15);
|
||||
excel.SetColumnWidth(7, 15);
|
||||
excel.SetColumnWidth(8, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,491 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
using System.Linq;
|
||||
using Microsoft.Win32;
|
||||
|
||||
/// <summary>
|
||||
/// 加班費印領清冊 的摘要描述
|
||||
/// </summary>
|
||||
public class 加班費印領清冊 : ExcelReportBase
|
||||
{
|
||||
public 加班費印領清冊()
|
||||
{
|
||||
報表名稱 = "加班費明細表";
|
||||
}
|
||||
|
||||
private int r = 2;
|
||||
private DataRow[] data;
|
||||
private int 加班費加總 = 0;
|
||||
private int bodyBeginRow, dataBeginRow;
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
// 只要領加班費的紀錄
|
||||
data = 資料來源.Tables[0].Select(
|
||||
string.Format("RPTYP = '{0}' OR RPTYP = '{1}' OR RPTYP = '{2}' OR RPTYP = '{3}'",
|
||||
RPAR_TYPE.T12_非休息日請領加班費,
|
||||
RPAR_TYPE.T14_休息日請領加班費,
|
||||
RPAR_TYPE.T16_國定假日請領加班費,
|
||||
RPAR_TYPE.T18_例假日請領加班費) ,
|
||||
"RPRDT");
|
||||
|
||||
foreach (DataRow r in data)
|
||||
{
|
||||
加班費加總 += WDAC.GetInt32Value(r["RPAC1"])
|
||||
+ WDAC.GetInt32Value(r["RPAC2"])
|
||||
+ WDAC.GetInt32Value(r["RPAC3"])
|
||||
+ WDAC.GetInt32Value(r["RPAC4"])
|
||||
+ WDAC.GetInt32Value(r["RPAC5"]);
|
||||
}
|
||||
|
||||
產生抬頭();
|
||||
產生表身();
|
||||
產生結尾();
|
||||
設定欄寬及列印範圍();
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
private void 產生抬頭()
|
||||
{
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, 專案名稱, headerStyle);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, 報表名稱, headerStyle);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 13);
|
||||
excel.SetCellValue(r, 0, "金額(此欄填寫數字)", bodyStyleCenter);
|
||||
excel.SetRowHeight(r, 20);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 3);
|
||||
excel.SetCellValue(r, 0, "萬", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 3, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 4, r, 6);
|
||||
excel.SetCellValue(r, 4, "仟", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 4, r, 6, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 7, r, 7);
|
||||
excel.SetCellValue(r, 7, "佰", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 7, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 8, r, 10);
|
||||
excel.SetCellValue(r, 8, "拾", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 8, r, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 11, r, 13);
|
||||
excel.SetCellValue(r, 11, "元", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 11, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
string s加班費加總 = String.Format("{0:00000}", 加班費加總) + "00000";
|
||||
excel.MergeCell(r, 0, r, 3);
|
||||
excel.SetCellValue(r, 0, s加班費加總[0].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 3, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 4, r, 6);
|
||||
excel.SetCellValue(r, 4, s加班費加總[1].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 4, r, 6, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 7, r, 7);
|
||||
excel.SetCellValue(r, 7, s加班費加總[2].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 7, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 8, r, 10);
|
||||
excel.SetCellValue(r, 8, s加班費加總[3].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 8, r, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 11, r, 13);
|
||||
excel.SetCellValue(r, 11, s加班費加總[4].ToString(), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 11, r, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(r - 2, 0, r, 13, BorderStyle.Thick);
|
||||
excel.SetRowHeight(r, 25);
|
||||
r++;
|
||||
|
||||
excel.SetCellValue(r, 11, String.Format("{0:yyyy}年度", 報表時間, WGuard1.TaiwanCulture), bodyStyleRightNoBorder);
|
||||
excel.SetCellValue(r, 12, String.Format("{0:MM}", 報表時間), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(r, 13, "月", bodyStyleLeftNoBorder);
|
||||
excel.SetRowHeight(r, 25);
|
||||
r++;
|
||||
|
||||
bodyBeginRow = r;
|
||||
excel.MergeCell(r, 0, r, 1);
|
||||
excel.SetCellValue(r, 0, "姓名", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 1, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 2, r, 5);
|
||||
excel.SetCellValue(r, 2, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 2, r, 5, BorderStyle.Thin);
|
||||
excel.SetCellValue(r, 6, "單位", bodyStyleCenter);
|
||||
excel.MergeCell(r, 7, r, 10);
|
||||
excel.SetCellValue(r, 7, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 10, BorderStyle.Thin);
|
||||
excel.SetCellValue(r, 11, "職稱", bodyStyleCenter);
|
||||
excel.MergeCell(r, 12, r, 13);
|
||||
excel.SetCellValue(r, 12, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 12, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 35);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 6);
|
||||
excel.SetCellValue(r, 0, "加班日及起迄時間", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 6, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 7, r + 1, 8);
|
||||
excel.SetCellValue(r, 7, "加班時數", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r + 1, 8, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 9, r + 1, 10);
|
||||
excel.SetCellValue(r, 9, "加班費\n金額", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 9, r + 1, 10, BorderStyle.Thin);
|
||||
//excel.MergeCell(r, 11, r + 1, 11);
|
||||
//excel.SetCellValue(r, 11, "蓋章", bodyStyleCenter);
|
||||
//excel.SetRangeOuterBorder(r, 11, r + 1, 11, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 11, r + 1, 13);
|
||||
excel.SetCellValue(r, 11, "備註", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 11, r + 1, 13, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(r + 1, 0, "月", bodyStyleCenter);
|
||||
excel.SetCellValue(r + 1, 1, "日", bodyStyleCenter);
|
||||
excel.MergeCell(r + 1, 2, r + 1, 3);
|
||||
excel.SetCellValue(r + 1, 2, "起", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + 1, 2, r + 1, 3, BorderStyle.Thin);
|
||||
excel.MergeCell(r + 1, 4, r + 1, 5);
|
||||
excel.SetCellValue(r + 1, 4, "至", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + 1, 4, r + 1, 5, BorderStyle.Thin);
|
||||
excel.SetCellValue(r + 1, 6, "迄", bodyStyleCenter);
|
||||
|
||||
// 畫雙線
|
||||
excel.SetRangeOuterBorder(r - 1, 0, r - 1, 13, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Double, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 25);
|
||||
excel.SetRowHeight(r + 1, 25);
|
||||
r += 2;
|
||||
dataBeginRow = r;
|
||||
}
|
||||
|
||||
private void 產生表身()
|
||||
{
|
||||
List<OverTimeItem> oneDayItems = new List<OverTimeItem>();
|
||||
|
||||
TimeCalc timeCalc = new TimeCalc();
|
||||
|
||||
foreach (DataRow row in data)
|
||||
{
|
||||
timeCalc.Init(WDAC.GetStringValue(row["RPNUM"]), WDAC.GetDateTimeValue(row["RPRDT"]));
|
||||
|
||||
int rptc1, rptc2, rptc3, rptc4, rptc5, rpac1, rpac2, rpac3, rpac4, rpac5;
|
||||
string rptyp;
|
||||
rptc1 = WDAC.GetInt32Value(row["RPTC1"]);
|
||||
rptc2 = WDAC.GetInt32Value(row["RPTC2"]);
|
||||
rptc3 = WDAC.GetInt32Value(row["RPTC3"]);
|
||||
rptc4 = WDAC.GetInt32Value(row["RPTC4"]);
|
||||
rptc5 = WDAC.GetInt32Value(row["RPTC5"]);
|
||||
rpac1 = WDAC.GetInt32Value(row["RPAC1"]);
|
||||
rpac2 = WDAC.GetInt32Value(row["RPAC2"]);
|
||||
rpac3 = WDAC.GetInt32Value(row["RPAC3"]);
|
||||
rpac4 = WDAC.GetInt32Value(row["RPAC4"]);
|
||||
rpac5 = WDAC.GetInt32Value(row["RPAC5"]);
|
||||
rptyp = WDAC.GetStringValue(row["RPTYP"]);
|
||||
|
||||
oneDayItems.Clear();
|
||||
string beginTime = WDAC.GetStringValue(row["RPRTM"]);
|
||||
|
||||
switch (rptyp)
|
||||
{
|
||||
case RPAR_TYPE.T12_非休息日請領加班費:
|
||||
case RPAR_TYPE.T14_休息日請領加班費:
|
||||
case RPAR_TYPE.T18_例假日請領加班費:
|
||||
var skiprest = rptyp != RPAR_TYPE.T12_非休息日請領加班費;
|
||||
if (rptc1 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc1, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "一又三分之一",
|
||||
Hours = (double)rptc1 / 60D,
|
||||
Amount = rpac1
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc2 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc2, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "一又三分之二",
|
||||
Hours = (double)rptc2 / 60D,
|
||||
Amount = rpac2
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc3 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc3, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日",
|
||||
Hours = (double)rptc3 / 60D,
|
||||
Amount = rpac3
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc4 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc4, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "休息日再延長",
|
||||
Hours = (double)rptc4 / 60D,
|
||||
Amount = rpac4
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc5 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc5, timeCalc.午休開始, timeCalc.午休結束, skiprest);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "例假日再延長",
|
||||
Hours = (double)rptc5 / 60D,
|
||||
Amount = rpac5
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
break;
|
||||
case RPAR_TYPE.T16_國定假日請領加班費:
|
||||
if (rptc3 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc3, timeCalc.午休開始, timeCalc.午休結束, false);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日",
|
||||
Hours = (double)rptc3 / 60D,
|
||||
Amount = rpac3
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc1 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc1, timeCalc.午休開始, timeCalc.午休結束, false);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日延長(9-10)",
|
||||
Hours = (double)rptc1 / 60D,
|
||||
Amount = rpac1
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
if (rptc2 > 0)
|
||||
{
|
||||
var endtime = TimeAddMinutes(beginTime, rptc2, timeCalc.午休開始, timeCalc.午休結束, false);
|
||||
oneDayItems.Add(new OverTimeItem()
|
||||
{
|
||||
BeginTime = beginTime,
|
||||
EndTime = endtime,
|
||||
TimeName = "國定假日延長(11-12)",
|
||||
Hours = (double)rptc2 / 60D,
|
||||
Amount = rpac2
|
||||
});
|
||||
beginTime = endtime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < oneDayItems.Count; i++)
|
||||
{
|
||||
OverTimeItem item = oneDayItems[i];
|
||||
|
||||
excel.SetCellValue(r + i, 0, String.Format("{0:MM}", row["RPRDT"]), bodyStyleCenter);
|
||||
excel.SetCellValue(r + i, 1, String.Format("{0:dd}", row["RPRDT"]), bodyStyleCenter);
|
||||
|
||||
excel.MergeCell(r + i, 11, r + i, 13);
|
||||
excel.SetCellValue(r + i, 11, String.Format("{0}", row["RPDOC"]), bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 11, r + i, 13, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(r + i, 2, r + i, 3);
|
||||
excel.SetCellValue(r + i, 2, item.BeginTime, bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 2, r + i, 3, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(r + i, 4, r + i, 5);
|
||||
excel.SetCellValue(r + i, 4, "~", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 4, r + i, 5, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(r + i, 6, item.EndTime, bodyStyleCenter);
|
||||
|
||||
excel.SetCellValue(r + i, 7, item.TimeName, bodyStyleCenter);
|
||||
|
||||
excel.SetCellValue(r + i, 8, item.Hours, bodyStyleCenter);
|
||||
|
||||
excel.MergeCell(r + i, 9, r + i, 10);
|
||||
excel.SetCellValue(r + i, 9, item.Amount, bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r + i, 9, r + i, 10, BorderStyle.Thin);
|
||||
|
||||
excel.SetRowHeight(r + i, 35);
|
||||
}
|
||||
|
||||
r += oneDayItems.Count;
|
||||
|
||||
}
|
||||
|
||||
// 蓋章
|
||||
//excel.MergeCell(dataBeginRow, 11, r - 1, 11);
|
||||
//excel.SetCellValue(dataBeginRow, 11, "", bodyStyleCenter);
|
||||
//excel.SetRangeOuterBorder(dataBeginRow, 11, r - 1, 11, BorderStyle.Thin);
|
||||
|
||||
// 合計
|
||||
excel.SetCellValue(r, 6, "合計", bodyStyleCenter);
|
||||
excel.SetCellFormula(r, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(dataBeginRow, 8), excel.RCtoA1(r - 1, 8)), bodyStyleCenter);
|
||||
excel.SetCellValue(r, 8, "小時", bodyStyleCenter);
|
||||
excel.SetCellFormula(r, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(dataBeginRow, 9), excel.RCtoA1(r - 1, 9)), bodyStyleCenter);
|
||||
excel.SetCellValue(r, 10, "元", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 7, r, 7, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 8, r, 8, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(r, 9, r, 9, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 10, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 25);
|
||||
r++;
|
||||
}
|
||||
|
||||
private void 產生結尾()
|
||||
{
|
||||
excel.MergeCell(r, 0, r, 3);
|
||||
excel.SetCellValue(r, 0, "茲收到加班費新台幣", bodyStyleCenter);
|
||||
excel.MergeCell(r, 4, r, 9);
|
||||
excel.SetCellValue(r, 4, WGuard1.WNTSA(加班費加總, "", true), bodyStyleRight);
|
||||
excel.MergeCell(r, 10, r, 13);
|
||||
excel.SetCellValue(r, 10, "此 據 (金額請大寫)", bodyStyleCenter);
|
||||
excel.SetRowHeight(r, 30);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 3, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 4, r, 9, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.None);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 13, BorderStyle.Thin, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 5);
|
||||
excel.SetCellValue(r, 0, "申請人", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 5, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 6, r, 9);
|
||||
excel.SetCellValue(r, 6, "計劃督導", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 6, r, 9, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 10, r, 13);
|
||||
excel.SetCellValue(r, 10, "計劃主持人", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 30);
|
||||
r++;
|
||||
|
||||
excel.MergeCell(r, 0, r, 5);
|
||||
excel.SetCellValue(r, 0, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 0, r, 5, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 6, r, 9);
|
||||
excel.SetCellValue(r, 6, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 6, r, 9, BorderStyle.Thin);
|
||||
excel.MergeCell(r, 10, r, 13);
|
||||
excel.SetCellValue(r, 10, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(r, 10, r, 13, BorderStyle.Thin);
|
||||
excel.SetRowHeight(r, 50);
|
||||
|
||||
excel.SetRangeOuterBorder(bodyBeginRow, 0, r, 13, BorderStyle.Thick);
|
||||
}
|
||||
|
||||
private void 設定欄寬及列印範圍()
|
||||
{
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 6);
|
||||
excel.SetColumnWidth(2, 2);
|
||||
excel.SetColumnWidth(3, 7);
|
||||
excel.SetColumnWidth(4, 3);
|
||||
excel.SetColumnWidth(5, 5);
|
||||
excel.SetColumnWidth(6, 11);
|
||||
excel.SetColumnWidth(7, 18);
|
||||
excel.SetColumnWidth(8, 7);
|
||||
excel.SetColumnWidth(9, 8);
|
||||
excel.SetColumnWidth(10, 3);
|
||||
excel.SetColumnWidth(11, 11);
|
||||
excel.SetColumnWidth(12, 7);
|
||||
excel.SetColumnWidth(13, 8);
|
||||
}
|
||||
|
||||
private string TimeAddMinutes(string time, int addMinutes, string restBegin, string restEnd, bool skipRest)
|
||||
{
|
||||
int restBeginHour = 0;
|
||||
int restBeginMin = 0;
|
||||
int restEndHour = 0;
|
||||
int restEndMin = 0;
|
||||
int restBeginTime = 0;
|
||||
int restEndTime = 0;
|
||||
if (!string.IsNullOrEmpty(restBegin))
|
||||
{
|
||||
string[] tp1 = restBegin.Split(':');
|
||||
if (int.TryParse(tp1[0], out restBeginHour) && int.TryParse(tp1[1], out restBeginMin))
|
||||
restBeginTime = restBeginHour * 60 + restBeginMin;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(restEnd))
|
||||
{
|
||||
string[] tp1 = restEnd.Split(':');
|
||||
if (int.TryParse(tp1[0], out restEndHour) && int.TryParse(tp1[1], out restEndMin))
|
||||
restEndTime = restEndHour * 60 + restEndMin;
|
||||
}
|
||||
|
||||
string[] timepart = time.Split(':');
|
||||
int hour, min;
|
||||
if (int.TryParse(timepart[0], out hour) && int.TryParse(timepart[1], out min))
|
||||
{
|
||||
int beginTime = hour * 60 + min;
|
||||
int extraAddMinutes = 0;
|
||||
|
||||
if (beginTime <= restBeginTime && beginTime + addMinutes >= restBeginTime)
|
||||
{
|
||||
int tempEndTime = beginTime + addMinutes;
|
||||
// 跨越中午休息時間,要摳掉
|
||||
if (tempEndTime >= restEndTime && skipRest)
|
||||
extraAddMinutes = restEndTime - restBeginTime;
|
||||
// 跨進,但未跨越,不要摳掉
|
||||
if (tempEndTime < restEndTime)
|
||||
// extraAddMinutes = (int)Math.Truncate((restEndTime - tempEndTime).TotalMinutes);
|
||||
extraAddMinutes = 0;
|
||||
}
|
||||
|
||||
var result = beginTime + addMinutes + extraAddMinutes;
|
||||
return string.Format("{0:00}:{1:00}", (int)Math.Truncate((double)result / (double)60), result % 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OverTimeItem
|
||||
{
|
||||
public string BeginTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public string TimeName { get; set; }
|
||||
public double Hours { get; set; }
|
||||
public double Amount { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 加班費明細 的摘要描述
|
||||
/// </summary>
|
||||
public class 加班費明細 : ExcelReportBase
|
||||
{
|
||||
public 加班費明細()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleLeftNoBorder.SetFont(bodyFont8PT);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, "加班時數 / 金額", titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, "站別", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, "人員姓名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, "薪資", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, string.Format("前段*{0}", 報表參數["前段"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("後段*{0}", 報表參數["後段"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("休息日再延長*{0}", 報表參數["休息日延長"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("假日*{0}", 報表參數["假日"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("例假日再延長*{0}", 報表參數["例假日延長"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, "請領金額", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, "備註", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 24);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
int SST01_SUM = 0;
|
||||
int SST02_SUM = 0;
|
||||
int SST03_SUM = 0;
|
||||
int SST21_SUM = 0;
|
||||
int SST22_SUM = 0;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 加班費合計 = WDAC.GetInt32Value(r["SSP06"])
|
||||
+ WDAC.GetInt32Value(r["SSP07"])
|
||||
+ WDAC.GetInt32Value(r["SSP08"])
|
||||
+ WDAC.GetInt32Value(r["SSP13"])
|
||||
+ WDAC.GetInt32Value(r["SSP14"]);
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, 月薪, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SSP06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SSP07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SSP13"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SSP08"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SSP14"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, 加班費合計, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetStringValue(r["SSC02"]), bodyStyleLeftNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", r["SST01"], r["SST01M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", r["SST02"], r["SST02M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", r["SST21"], r["SST21M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", r["SST03"], r["SST03M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", r["SST22"], r["SST22M"]), bodyStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SST01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SST02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SST21"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SST03"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SST22"]), bodyNumberStyleNoBorder);
|
||||
}
|
||||
|
||||
SST01_SUM += WDAC.GetInt32Value(r["SST01"]) * 60 + WDAC.GetInt32Value(r["SST01M"]);
|
||||
SST02_SUM += WDAC.GetInt32Value(r["SST02"]) * 60 + WDAC.GetInt32Value(r["SST02M"]);
|
||||
SST03_SUM += WDAC.GetInt32Value(r["SST03"]) * 60 + WDAC.GetInt32Value(r["SST03M"]);
|
||||
SST21_SUM += WDAC.GetInt32Value(r["SST21"]) * 60 + WDAC.GetInt32Value(r["SST21M"]);
|
||||
SST22_SUM += WDAC.GetInt32Value(r["SST22"]) * 60 + WDAC.GetInt32Value(r["SST22M"]);
|
||||
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
excel.SetCellFormula(row, 5, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 1, 5)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 1, 13)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 14, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 1, 14)), bodyNumberStyleNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, MinuteToTime(SST01_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, MinuteToTime(SST02_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, MinuteToTime(SST21_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, MinuteToTime(SST03_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, MinuteToTime(SST22_SUM), bodyStyleCenterNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellFormula(row, 4, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 1, 4)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 5, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 6, row, 10, BorderStyle.None);
|
||||
excel.SetCellValue(row, 6, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 11, row, 15, BorderStyle.None);
|
||||
excel.SetCellValue(row, 11, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 10);
|
||||
excel.SetColumnWidth(5, 10);
|
||||
excel.SetColumnWidth(6, 10);
|
||||
excel.SetColumnWidth(7, 10);
|
||||
excel.SetColumnWidth(8, 10);
|
||||
excel.SetColumnWidth(9, 10);
|
||||
excel.SetColumnWidth(10, 10);
|
||||
excel.SetColumnWidth(11, 10);
|
||||
excel.SetColumnWidth(12, 10);
|
||||
excel.SetColumnWidth(13, 10);
|
||||
excel.SetColumnWidth(14, 10);
|
||||
excel.SetColumnWidth(15, 50);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 各項法定提撥費用明細表 的摘要描述
|
||||
/// </summary>
|
||||
public class 各項法定提撥費用明細表 : ExcelReportBase
|
||||
{
|
||||
public 各項法定提撥費用明細表()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 5, row, 8, BorderStyle.None);
|
||||
excel.SetCellValue(row, 5, "員工自負額", titleStyleCenterNoBorder);
|
||||
excel.MergeCell(row, 9, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 9, "雇主負擔部分", titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, "派遣者", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, "薪資", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, "投保等級", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, "到職天數", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "勞保", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, "健保", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "福利金", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, "勞退自提", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, "勞保", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, "職災保險", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, "就業保險", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, "工資墊償", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, "健保", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, "勞退提撥", titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 3, WDAC.GetInt32Value(r["SSL01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SSD02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SSS04"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SSS05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SSS07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SSS06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SSH01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SSH02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SSH03"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SSH04"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SSH05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, WDAC.GetInt32Value(r["SSH06"]), bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
excel.SetCellFormula(row, 5, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 1, 5)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 1, 13)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 14, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 1, 14)), bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 9, "雇主勞保", titleStyleRightNoBorder);
|
||||
excel.MergeCell(row, 10, row, 11, BorderStyle.None);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 2, 11)), bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 4, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 5, row, 9, BorderStyle.None);
|
||||
excel.SetCellValue(row, 5, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 10, row, 14, BorderStyle.None);
|
||||
excel.SetCellValue(row, 10, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 10);
|
||||
excel.SetColumnWidth(5, 10);
|
||||
excel.SetColumnWidth(6, 10);
|
||||
excel.SetColumnWidth(7, 10);
|
||||
excel.SetColumnWidth(8, 10);
|
||||
excel.SetColumnWidth(9, 10);
|
||||
excel.SetColumnWidth(10, 10);
|
||||
excel.SetColumnWidth(11, 10);
|
||||
excel.SetColumnWidth(12, 10);
|
||||
excel.SetColumnWidth(13, 10);
|
||||
excel.SetColumnWidth(14, 10);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 外勤工作明細表 的摘要描述
|
||||
/// </summary>
|
||||
public class 外勤工作明細表 : ExcelReportBase
|
||||
{
|
||||
public 外勤工作明細表()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
bodyStyleLeftNoBorder.SetFont(bodyFont8PT);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 5, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, "差旅費", titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, "站別", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, "人員姓名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, "薪資", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, "長差", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "短差", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, "差旅費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "備註", titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 差旅費 = WDAC.GetInt32Value(r["SSP09"])
|
||||
+ WDAC.GetInt32Value(r["SSP10"]);
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, 月薪, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SSP10"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SSP09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, 差旅費, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetStringValue(r["SSC07"]), bodyStyleLeftNoBorder);
|
||||
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
excel.SetCellFormula(row, 4, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 1, 4)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 5, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 1, 5)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 2, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 3, row, 5, BorderStyle.None);
|
||||
excel.SetCellValue(row, 3, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 6, row, 7, BorderStyle.None);
|
||||
excel.SetCellValue(row, 6, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 10);
|
||||
excel.SetColumnWidth(5, 10);
|
||||
excel.SetColumnWidth(6, 10);
|
||||
excel.SetColumnWidth(7, 80);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
using System.Linq;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
|
||||
/// <summary>
|
||||
/// 差勤日報表
|
||||
/// </summary>
|
||||
public class 差勤日報表 : ExcelReportBase
|
||||
{
|
||||
|
||||
public 差勤日報表()
|
||||
{
|
||||
報表名稱 = "差勤日報表";
|
||||
}
|
||||
|
||||
public DateTime 開始日期 { get; set; }
|
||||
public DateTime 結束日期 { get; set; }
|
||||
|
||||
public List<ProjectEmployeeItem> 人員Data { get; set; }
|
||||
public List<差勤日報表Item> 請假Data { get; set; }
|
||||
public List<差勤日報表Item> 加班Data { get; set; }
|
||||
public List<差勤日報表Item> 出差Data { get; set; }
|
||||
public List<RASNBRHItem> 站別分組 { get; set; }
|
||||
|
||||
private RparDAC rparDao = new RparDAC();
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
var groupIdList = new List<string>();
|
||||
foreach (var 站別 in 站別分組)
|
||||
{
|
||||
if (!groupIdList.Contains(站別.GroupID))
|
||||
groupIdList.Add(站別.GroupID);
|
||||
}
|
||||
|
||||
var row = 0;
|
||||
foreach (var groupId in groupIdList)
|
||||
{
|
||||
var 本組站別 = 站別分組.FindAll(p => p.GroupID.CompareTo(groupId) == 0);
|
||||
var branchID = String.Join(",", (from 站別 in 本組站別 select 站別.BranchID).ToArray());
|
||||
var branchName = String.Join("+", (from 站別 in 本組站別 select 站別.BranchName).ToArray());
|
||||
|
||||
row += 產生單位報表(row, branchName, branchID) + 2;
|
||||
}
|
||||
|
||||
excel.SetColumnWidth(0, 8);
|
||||
excel.SetColumnWidth(1, 20);
|
||||
excel.SetColumnWidth(2, 40);
|
||||
excel.SetColumnWidth(3, 20);
|
||||
excel.SetColumnWidth(4, 40);
|
||||
excel.SetColumnWidth(5, 20);
|
||||
excel.SetColumnWidth(6, 40);
|
||||
excel.SetColumnWidth(7, 60);
|
||||
excel.SetColumnWidth(8, 20);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
|
||||
public int 產生單位報表(int startRow, string branchName, string branchID)
|
||||
{
|
||||
var rows = 報表抬頭(startRow, branchName);
|
||||
rows += 報表明細與結尾(startRow + rows, branchID);
|
||||
return rows;
|
||||
}
|
||||
|
||||
public int 報表抬頭(int startRow, string branchName)
|
||||
{
|
||||
excel.MergeCell(startRow + 0, 0, startRow + 1, 0);
|
||||
excel.SetCellValue(startRow + 0, 0, "單位", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 0, startRow + 1, 0, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 1, startRow + 1, 1);
|
||||
excel.SetCellValue(startRow + 0, 1, branchName, titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 1, startRow + 1, 1, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 2, startRow + 0, 3);
|
||||
excel.SetCellValue(startRow + 0, 2, String.Format("日期-{0:MM月dd日}", 開始日期), titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 2, startRow + 0, 3, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 1, 2, startRow + 1, 3);
|
||||
excel.SetCellValue(startRow + 1, 2, "加班申請", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 1, 2, startRow + 1, 3, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 4, startRow + 0, 7);
|
||||
excel.SetCellValue(startRow + 0, 4, String.Format("日期-{0:MM月dd日}", 結束日期), titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 4, startRow + 0, 7, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 1, 4, startRow + 1, 5);
|
||||
excel.SetCellValue(startRow + 1, 4, "請假申請", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 1, 4, startRow + 1, 5, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 1, 6, startRow + 1, 7);
|
||||
excel.SetCellValue(startRow + 1, 6, "出差申請", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 1, 6, startRow + 1, 7, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(startRow + 0, 8, startRow + 1, 8);
|
||||
excel.SetCellValue(startRow + 0, 8, "備註說明", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(startRow + 0, 8, startRow + 1, 8, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(startRow + 2, 0, "序號", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 1, "姓名", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 2, "起迄時間", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 3, "時數", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 4, "起迄時間", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 5, "假別/事由", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 6, "起迄時間", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 7, "地點", titleStyleCenter);
|
||||
excel.SetCellValue(startRow + 2, 8, "剩餘補休時數", titleStyleCenter);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int 報表明細與結尾(int startRow, string branchID)
|
||||
{
|
||||
int rows = 0;
|
||||
|
||||
var 人員Data1 = 人員Data.FindAll(p => branchID.Contains(p.BPBRH)).OrderBy(p => p.BPENO);
|
||||
|
||||
foreach (var 人員Item in 人員Data1)
|
||||
{
|
||||
excel.SetCellValue(startRow + rows, 0, rows + 1, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 1, 人員Item.BPNME, bodyStyleCenter);
|
||||
|
||||
var 加班 = "";
|
||||
var 加班時數 = 0D;
|
||||
foreach (var 加班Item in 加班Data.FindAll(p => p.員工編號 == 人員Item.BPENO).OrderBy(p => p.起日))
|
||||
{
|
||||
加班 += (加班.Length > 0 ? "\n" : "") + String.Format("{0:yyyy/MM/dd} {1}~{2}", 加班Item.起日, 加班Item.起時, 加班Item.迄時);
|
||||
加班時數 += 加班Item.時數;
|
||||
}
|
||||
excel.SetCellValue(startRow + rows, 2, 加班, bodyStyleCenter);
|
||||
if (加班時數 > 0)
|
||||
excel.SetCellValue(startRow + rows, 3, (int)加班時數, bodyStyleCenter);
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 3, "", bodyStyleCenter);
|
||||
|
||||
|
||||
var 請假 = "";
|
||||
var 請假假別 = "";
|
||||
foreach (var 請假Item in 請假Data.FindAll(p => p.員工編號 == 人員Item.BPENO).OrderBy(p => p.起日))
|
||||
{
|
||||
請假 += (請假.Length > 0 ? "\n" : "")
|
||||
+ (請假Item.起日 == 請假Item.迄日
|
||||
? String.Format("{0:yyyy/MM/dd} {1}~{2}", 請假Item.起日, 請假Item.起時, 請假Item.迄時)
|
||||
: String.Format("{0:yyyy/MM/dd} {1}~{2:yyyy/MM/dd} {3}", 請假Item.起日, 請假Item.起時, 請假Item.迄日, 請假Item.迄時));
|
||||
請假假別 += (請假假別.Length > 0 ? "\n" : "") + 請假Item.類別名稱;
|
||||
}
|
||||
|
||||
excel.SetCellValue(startRow + rows, 4, 請假, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 5, 請假假別, bodyStyleCenter);
|
||||
|
||||
var 出差 = "";
|
||||
var 出差地點 = "";
|
||||
foreach (var 出差Item in 出差Data.FindAll(p => p.員工編號 == 人員Item.BPENO).OrderBy(p => p.起日))
|
||||
{
|
||||
出差 += (出差.Length > 0 ? "\n" : "")
|
||||
+ (出差Item.起日 == 出差Item.迄日
|
||||
? String.Format("{0:yyyy/MM/dd} {1}~{2}", 出差Item.起日, 出差Item.起時, 出差Item.迄時)
|
||||
: String.Format("{0:yyyy/MM/dd} {1}~{2:yyyy/MM/dd} {3}", 出差Item.起日, 出差Item.起時, 出差Item.迄日, 出差Item.迄時));
|
||||
出差地點 += (出差地點.Length > 0 ? "\n" : "") + 出差Item.出差地點;
|
||||
}
|
||||
|
||||
excel.SetCellValue(startRow + rows, 6, 出差, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 7, 出差地點, bodyStyleCenter);
|
||||
|
||||
|
||||
var 補休分數 = 0D;
|
||||
var 補休明細 = "";
|
||||
foreach (var 補休Item in rparDao.取得補休明細資料(人員Item.BPENO))
|
||||
{
|
||||
補休分數 += 補休Item.可用時數 * 60 + 補休Item.可用分數;
|
||||
if (以時分顯示時數)
|
||||
補休明細 += (補休明細.Length > 0 ? "\n" : "")
|
||||
+ String.Format("{0}:{1:00} {2:yyyy/MM/dd}", 補休Item.可用時數, 補休Item.可用分數, 補休Item.有效期限);
|
||||
else
|
||||
補休明細 += (補休明細.Length > 0 ? "\n" : "")
|
||||
+ String.Format("{0}H {1:yyyy/MM/dd}", 補休Item.可用時數, 補休Item.有效期限);
|
||||
}
|
||||
|
||||
if (補休分數 > 0) {
|
||||
if (以時分顯示時數)
|
||||
excel.SetCellValue(startRow + rows, 8, String.Format("{0}:{1:00}\n{2}", (int)補休分數 / 60, (int)補休分數 % 60, 補休明細), bodyStyleCenter);
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 8, String.Format("{0}H\n{1}", (int)補休分數 / 60, 補休明細), bodyStyleCenter);
|
||||
}
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 8, "", bodyStyleCenter);
|
||||
|
||||
excel.SetRowHeight(startRow + rows, 35);
|
||||
|
||||
rows++;
|
||||
}
|
||||
|
||||
excel.SetCellValue(startRow + rows, 0, "小計", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 1, String.Format("共 {0} 位", 人員Data1.ToList().Count), bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 2, "總申請時數", bodyStyleCenter);
|
||||
if (人員Data1.ToList().Count > 0)
|
||||
excel.SetCellFormula(startRow + rows, 3, String.Format("SUM({0}:{1})", excel.RCtoA1(startRow, 3), excel.RCtoA1(startRow + rows - 1, 3)) , bodyStyleCenter);
|
||||
else
|
||||
excel.SetCellValue(startRow + rows, 3, 0, bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 4, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 5, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 6, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 7, "", bodyStyleCenter);
|
||||
excel.SetCellValue(startRow + rows, 8, "", bodyStyleCenter);
|
||||
|
||||
rows++;
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 差勤月報表
|
||||
/// </summary>
|
||||
public class 差勤月報表 : ExcelReportBase
|
||||
{
|
||||
public 差勤月報表()
|
||||
{
|
||||
報表名稱 = "差勤月報表";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 10);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 2, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 3, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["單位"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 4, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 5, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 6, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 7, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["姓名"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 1);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 1, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 0, "日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 2, "出勤別", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "實際上班", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "出差外出", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "出差返回", titleStyleCenter);
|
||||
excel.SetCellValue(2, 6, "實際下班", titleStyleCenter);
|
||||
excel.SetCellValue(2, 7, "請假", titleStyleCenter);
|
||||
excel.SetCellValue(2, 8, "加班", titleStyleCenter);
|
||||
excel.SetCellValue(2, 9, "公差", titleStyleCenter);
|
||||
excel.SetCellValue(2, 10, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int rowId = 3;
|
||||
ICellStyle rowStyle;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
string 請假 = WDAC.GetStringValue(r["請假"]);
|
||||
string 加班 = WDAC.GetStringValue(r["加班"]);
|
||||
string 公差 = WDAC.GetStringValue(r["公差"]);
|
||||
string 出勤別 = WDAC.GetStringValue(r["出勤別"]);
|
||||
|
||||
if (出勤別 == "上班")
|
||||
rowStyle = titleStyleCenter;
|
||||
else
|
||||
rowStyle = titleStyleCenterYellowBGC;
|
||||
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetDateTimeValue(r["日期"]).ToString("MM月dd日"), rowStyle);
|
||||
excel.SetCellValue(rowId, 1, WDAC.GetDateTimeValue(r["日期"]).ToString("dddd"), rowStyle);
|
||||
excel.SetCellValue(rowId, 2, 出勤別, rowStyle);
|
||||
excel.SetCellValue(rowId, 3, WDAC.GetStringValue(r["上班"]), rowStyle);
|
||||
excel.SetCellValue(rowId, 4, WDAC.GetStringValue(r["出差外出"]), rowStyle);
|
||||
excel.SetCellValue(rowId, 5, WDAC.GetStringValue(r["出差返回"]), rowStyle);
|
||||
excel.SetCellValue(rowId, 6, WDAC.GetStringValue(r["下班"]), rowStyle);
|
||||
|
||||
if (請假 != "0:00")
|
||||
excel.SetCellValue(rowId, 7, 請假, rowStyle);
|
||||
else
|
||||
excel.SetCellValue(rowId, 7, "", rowStyle);
|
||||
|
||||
if (加班 != "0:00")
|
||||
excel.SetCellValue(rowId, 8, 加班, rowStyle);
|
||||
else
|
||||
excel.SetCellValue(rowId, 8, "", rowStyle);
|
||||
|
||||
if (公差 != "0:00")
|
||||
excel.SetCellValue(rowId, 9, 公差, rowStyle);
|
||||
else
|
||||
excel.SetCellValue(rowId, 9, "", rowStyle);
|
||||
|
||||
excel.SetCellValue(rowId, 10, string.Format("{0} {1} {2}", r["班別名稱"], r["班別時間"], r["出勤異常"]), rowStyle);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 2, 0, rowId + 2, 8);
|
||||
//excel.SetCellValue(rowId + 2, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 11);
|
||||
excel.SetColumnWidth(1, 11);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 15);
|
||||
excel.SetColumnWidth(4, 15);
|
||||
excel.SetColumnWidth(5, 15);
|
||||
excel.SetColumnWidth(6, 15);
|
||||
excel.SetColumnWidth(7, 15);
|
||||
excel.SetColumnWidth(8, 15);
|
||||
excel.SetColumnWidth(9, 15);
|
||||
excel.SetColumnWidth(10, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 支出憑證黏存單
|
||||
/// </summary>
|
||||
public class 支出憑證黏存單 : ExcelReportBase
|
||||
{
|
||||
public 支出憑證黏存單()
|
||||
{
|
||||
報表名稱 = "支出憑證黏存單";
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
bodyStyleCenterXS.SetFont(bodyFont8PT);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
int 總金額 = 0;
|
||||
int 總天數 = 0;
|
||||
List<string> 出差事由List = new List<string>();
|
||||
string 出差事由 = "";
|
||||
|
||||
#region 先加總所有金額以及產生摘要
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
總天數 += (WDAC.GetDateTimeValue(r["RPEDT"]) - WDAC.GetDateTimeValue(r["RPRDT"])).Days + 1;
|
||||
出差事由List.Add(WDAC.GetStringValue(r["RPRSN"]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 出差事由List.Count; i++)
|
||||
{
|
||||
出差事由 += String.Format("{0}.{1}\n", i + 1, 出差事由List[i]);
|
||||
}
|
||||
if (出差事由.Length > 0)
|
||||
出差事由 = 出差事由.Substring(0, 出差事由.Length - 1);
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[1].Rows)
|
||||
{
|
||||
總金額 += WDAC.GetInt32Value(r["總計"]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 16);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\n承辦{1}\n『{2}』\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
|
||||
excel.MergeCell(1, 0, 1, 16);
|
||||
excel.SetCellValue(1, 0, String.Format("所屬年度:{0}年度", WGuard1.WNTSA(報表時間.Year - WGuard1.CY11, "", false)), titleStyleLeftNoBorder);
|
||||
excel.MergeCell(1, 0, 1, 16);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 4);
|
||||
excel.SetCellValue(2, 0, "傳票(付款憑單)編號:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(2, 15, 2, 16);
|
||||
excel.SetCellValue(2, 15, "黏貼單據___張", titleStyleRightNoBorder);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(3, 0, 5, 1);
|
||||
excel.SetCellValue(3, 0, "第 號", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 0, 5, 1, BorderStyle.Thin);
|
||||
excel.MergeCell(3, 2, 3, 7);
|
||||
excel.SetCellValue(3, 2, "金 額", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 2, 3, 7, BorderStyle.Thin);
|
||||
excel.SetCellValue(4, 2, "拾", titleStyleCenter);
|
||||
excel.SetCellValue(4, 3, "萬", titleStyleCenter);
|
||||
excel.SetCellValue(4, 4, "仟", titleStyleCenter);
|
||||
excel.SetCellValue(4, 5, "佰", titleStyleCenter);
|
||||
excel.SetCellValue(4, 6, "拾", titleStyleCenter);
|
||||
excel.SetCellValue(4, 7, "元", titleStyleCenter);
|
||||
|
||||
string s總金額 = String.Format("{0:000000}", 總金額);
|
||||
excel.SetCellValue(5, 2, Convert.ToString(s總金額[0]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 3, Convert.ToString(s總金額[1]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 4, Convert.ToString(s總金額[2]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 5, Convert.ToString(s總金額[3]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 6, Convert.ToString(s總金額[4]), titleStyleCenter);
|
||||
excel.SetCellValue(5, 7, Convert.ToString(s總金額[5]), titleStyleCenter);
|
||||
|
||||
excel.MergeCell(3, 8, 4, 10);
|
||||
excel.SetCellValue(3, 8, "用途別", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 8, 4, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(5, 8, 5, 10);
|
||||
excel.SetCellValue(5, 8, "用途摘要", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(5, 8, 5, 10, BorderStyle.Thin);
|
||||
excel.MergeCell(3, 11, 4, 16);
|
||||
excel.SetCellValue(3, 11, "國內旅費", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(3, 11, 4, 16, BorderStyle.Thin);
|
||||
excel.MergeCell(5, 11, 5, 16);
|
||||
excel.SetCellValue(5, 11, String.Format("{0:MM}月出差", 報表時間), titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(5, 11, 5, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(6, 8, 6, 12);
|
||||
excel.SetCellValue(6, 8, "國內出差旅費報告單", headerStyle);
|
||||
excel.MergeCell(6, 13, 6, 16);
|
||||
excel.SetCellValue(6, 13, String.Format("{0:填表日期:yyyy年MM月dd日}", DateTime.UtcNow.AddHours(8).Date), titleStyleRightNoBorder);
|
||||
excel.SetRangeOuterBorder(6, 0, 6, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(7, 0, 7, 2);
|
||||
excel.MergeCell(7, 3, 7, 6);
|
||||
excel.MergeCell(7, 7, 7, 8);
|
||||
excel.MergeCell(7, 9, 7, 11);
|
||||
excel.MergeCell(7, 12, 7, 13);
|
||||
excel.MergeCell(7, 14, 7, 16);
|
||||
excel.SetCellValue(7, 0, "姓 名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 3, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 7, "單 位", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 9, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 12, "職 稱", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(7, 14, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(7, 0, 7, 2, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 3, 7, 6, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 7, 7, 8, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 9, 7, 11, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 12, 7, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(7, 14, 7, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(8, 0, 8, 2);
|
||||
excel.MergeCell(8, 3, 8, 16);
|
||||
excel.SetCellValue(8, 0, "出差事由", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(8, 3, 出差事由, titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(8, 0, 8, 2, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(8, 3, 8, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(9, 0, 9, 16);
|
||||
excel.SetCellValue(9, 0, String.Format("中華民國 {0:yyyy} 年 {0:MM} 月 {0:dd} 日 至 {1:yyyy} 年 {1:MM} 月 {1:dd} 日止 共計 {2} 天 附單據___張",
|
||||
報表時間, 報表時間.AddMonths(1).AddDays(-1), 總天數), titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(9, 0, 9, 16, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(10, 0, 10, 1);
|
||||
excel.MergeCell(10, 2, 11, 4);
|
||||
excel.MergeCell(10, 5, 11, 7);
|
||||
excel.MergeCell(10, 8, 10, 11);
|
||||
excel.MergeCell(10, 12, 11, 12);
|
||||
excel.MergeCell(10, 13, 11, 13);
|
||||
excel.MergeCell(10, 14, 11, 14);
|
||||
excel.MergeCell(10, 15, 11, 15);
|
||||
excel.MergeCell(10, 16, 11, 16);
|
||||
excel.SetCellValue(10, 0, String.Format("{0:yyyy}年", 報表時間), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(11, 0, "月", titleStyleCenter);
|
||||
excel.SetCellValue(11, 1, "日", titleStyleCenter);
|
||||
excel.SetCellValue(10, 2, "起訖地點", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 5, "工作摘要", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 8, "交通費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(11, 8, "捷運\n及\n汽車", titleStyleCenter);
|
||||
excel.SetCellValue(11, 9, "火\n車", titleStyleCenter);
|
||||
excel.SetCellValue(11, 10, "高\n鐵", titleStyleCenter);
|
||||
excel.SetCellValue(11, 11, "飛\n機", titleStyleCenter);
|
||||
excel.SetCellValue(10, 12, "住宿費\n+\n過路費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 13, "雜費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 14, "單據\n號數", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 15, "總計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(10, 16, "備註", titleStyleCenterNoBorder);
|
||||
excel.SetRangeOuterBorder(10, 0, 10, 1, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 2, 11, 4, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 5, 11, 7, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 8, 10, 11, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 12, 11, 12, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 13, 11, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 14, 11, 14, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 15, 11, 15, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(10, 16, 11, 16, BorderStyle.Thin);
|
||||
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
excel.SetRowHeight(3, BodyRowHeight);
|
||||
excel.SetRowHeight(4, BodyRowHeight);
|
||||
excel.SetRowHeight(5, BodyRowHeight * 2);
|
||||
excel.SetRowHeight(6, BodyRowHeight * 2);
|
||||
excel.SetRowHeight(7, BodyRowHeight);
|
||||
excel.SetRowHeight(8, BodyRowHeight * (資料來源.Tables[0].Rows.Count > 4 ? 資料來源.Tables[0].Rows.Count : 4));
|
||||
excel.SetRowHeight(9, BodyRowHeight);
|
||||
excel.SetRowHeight(10, BodyRowHeight);
|
||||
excel.SetRowHeight(11, BodyRowHeight * 2);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int rowId = 12;
|
||||
int beginRow = 12;
|
||||
foreach (DataRow r in 資料來源.Tables[1].Rows)
|
||||
{
|
||||
DataRow[] master = 資料來源.Tables[0].Select("RPREN='" + WDAC.GetStringValue(r["單號"]) + "'");
|
||||
|
||||
excel.SetCellValue(rowId, 0, String.Format("{0:MM}", r["日期"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, String.Format("{0:dd}", r["日期"]), bodyStyleCenter);
|
||||
excel.MergeCell(rowId, 2, rowId, 4);
|
||||
excel.SetCellValue(rowId, 2, WDAC.GetStringValue(r["起地點"]) + "~" + WDAC.GetStringValue(r["迄地點"]), bodyStyleCenterS);
|
||||
excel.SetRangeOuterBorder(rowId, 2, rowId, 4, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(rowId, 5, rowId, 7);
|
||||
出差事由 = WDAC.GetStringValue(master[0]["RPRSN"]);
|
||||
if (master.Length > 0 && 出差事由List.Contains(出差事由))
|
||||
excel.SetCellValue(rowId, 5, String.Format("同出差事由 {0}", 出差事由List.IndexOf(出差事由) + 1), bodyStyleCenterS);
|
||||
else
|
||||
excel.SetCellValue(rowId, 5, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 7, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetDoubleValue(r["捷運"]) + WDAC.GetDoubleValue(r["汽車"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 9, WDAC.GetDoubleValue(r["火車"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, WDAC.GetDoubleValue(r["高鐵"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 11, WDAC.GetDoubleValue(r["飛機"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 12, WDAC.GetDoubleValue(r["住宿費"]) + WDAC.GetDoubleValue(r["過路費"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 13, WDAC.GetDoubleValue(r["雜費"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, WDAC.GetStringValue(r["單據號數"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 15, WDAC.GetDoubleValue(r["總計"]), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 16, WDAC.GetStringValue(r["備註"]), bodyStyleCenterXS);
|
||||
|
||||
excel.SetRowHeight(rowId, (int)(BodyRowHeight * 1.5));
|
||||
rowId++;
|
||||
}
|
||||
|
||||
// 補空行
|
||||
if (資料來源.Tables[1].Rows.Count < 10)
|
||||
{
|
||||
for (int n = 資料來源.Tables[1].Rows.Count; n < 10; n++)
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, "", bodyStyleCenter);
|
||||
excel.MergeCell(rowId, 2, rowId, 4);
|
||||
excel.SetCellValue(rowId, 2, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 2, rowId, 4, BorderStyle.Thin);
|
||||
|
||||
excel.MergeCell(rowId, 5, rowId, 7);
|
||||
excel.SetCellValue(rowId, 5, "", bodyStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 7, BorderStyle.Thin);
|
||||
|
||||
excel.SetCellValue(rowId, 8, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 9, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 11, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 12, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 13, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 15, "", bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 16, "", bodyStyleCenter);
|
||||
|
||||
excel.SetRowHeight(rowId, (int)(BodyRowHeight * 0.8));
|
||||
|
||||
rowId++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(rowId, 0, rowId, 4);
|
||||
excel.SetCellValue(rowId, 0, "合 計", titleStyleCenter);
|
||||
excel.SetRangeOuterBorder(rowId, 0, rowId, 4, BorderStyle.Thin);
|
||||
excel.MergeCell(rowId, 5, rowId, 7);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 7, BorderStyle.Thin);
|
||||
excel.SetCellFormula(rowId, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(rowId - 1, 8)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(rowId - 1, 9)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(rowId - 1, 10)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(rowId - 1, 11)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(rowId - 1, 12)), bodyStyleCenter);
|
||||
excel.SetCellFormula(rowId, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(rowId - 1, 13)), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "", titleStyleCenter);
|
||||
excel.SetCellFormula(rowId, 15, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(rowId - 1, 15)), bodyStyleCenter);
|
||||
excel.SetCellValue(rowId, 16, "", titleStyleCenter);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
|
||||
rowId++;
|
||||
excel.MergeCell(rowId, 0, rowId, 4);
|
||||
excel.MergeCell(rowId, 5, rowId, 9);
|
||||
excel.MergeCell(rowId, 10, rowId, 13);
|
||||
excel.MergeCell(rowId, 14, rowId, 16);
|
||||
|
||||
if (專案編號.Length >= 6 && 專案編號.Substring(專案編號.Length - 6, 6) == "B00001")
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, "申 請 人", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, "單 位 主 管", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, "財 會 經 辦", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "人 資 單 位", titleStyleCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(rowId, 0, "申 請 人", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, "計 畫 督 導", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 10, "人 事 單 位", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 14, "財 務 主 管", titleStyleCenter);
|
||||
}
|
||||
excel.SetRangeOuterBorder(rowId, 0, rowId, 4, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 9, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 10, rowId, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 14, rowId, 16, BorderStyle.Thin);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
|
||||
rowId++;
|
||||
excel.MergeCell(rowId, 0, rowId, 4);
|
||||
excel.SetCellValue(rowId, 0, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), bodyStyleCenter);
|
||||
excel.MergeCell(rowId, 5, rowId, 9);
|
||||
excel.MergeCell(rowId, 10, rowId, 13);
|
||||
excel.MergeCell(rowId, 14, rowId, 16);
|
||||
excel.SetRangeOuterBorder(rowId, 0, rowId, 4, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 5, rowId, 9, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 10, rowId, 13, BorderStyle.Thin);
|
||||
excel.SetRangeOuterBorder(rowId, 14, rowId, 16, BorderStyle.Thin);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight * 3);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 4);
|
||||
excel.SetColumnWidth(1, 4);
|
||||
excel.SetColumnWidth(2, 4);
|
||||
excel.SetColumnWidth(3, 4);
|
||||
excel.SetColumnWidth(4, 4);
|
||||
excel.SetColumnWidth(5, 4);
|
||||
excel.SetColumnWidth(6, 4);
|
||||
excel.SetColumnWidth(7, 4);
|
||||
excel.SetColumnWidth(8, 7);
|
||||
excel.SetColumnWidth(9, 7);
|
||||
excel.SetColumnWidth(10, 7);
|
||||
excel.SetColumnWidth(11, 7);
|
||||
excel.SetColumnWidth(12, 7);
|
||||
excel.SetColumnWidth(13, 7);
|
||||
excel.SetColumnWidth(14, 7);
|
||||
excel.SetColumnWidth(15, 9);
|
||||
excel.SetColumnWidth(16, 20);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 薪資清冊 的摘要描述
|
||||
/// </summary>
|
||||
public class 薪資清冊 : ExcelReportBase
|
||||
{
|
||||
public 薪資清冊()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱.Trim()), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, "站別", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, "職務", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, "姓名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, "到職日", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "派遣開始日", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, "核定薪資", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "本薪", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, "其他津貼", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, "事假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, "病假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, "其他假別(一)", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, "應領薪資", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, "加班費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, "外勤工作費", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, "勞保", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, "健保", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, "福利金", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 18, "個人提繳勞退金", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, "其他加扣款", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 20, "實領薪資", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 26);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 應領薪資 = 月薪
|
||||
+ WDAC.GetInt32Value(r["SSP01"])
|
||||
+ WDAC.GetInt32Value(r["SSP03"])
|
||||
+ WDAC.GetInt32Value(r["SSP04"])
|
||||
+ WDAC.GetInt32Value(r["SSP05"])
|
||||
- WDAC.GetInt32Value(r["SSS01"])
|
||||
- WDAC.GetInt32Value(r["SSS02"])
|
||||
- WDAC.GetInt32Value(r["SSS09"]);
|
||||
var 加班費 = WDAC.GetInt32Value(r["SSP06"])
|
||||
+ WDAC.GetInt32Value(r["SSP07"])
|
||||
+ WDAC.GetInt32Value(r["SSP08"])
|
||||
+ WDAC.GetInt32Value(r["SSP13"])
|
||||
+ WDAC.GetInt32Value(r["SSP14"]);
|
||||
var 外勤工作費 = WDAC.GetInt32Value(r["SSP09"])
|
||||
+ WDAC.GetInt32Value(r["SSP10"])
|
||||
+ WDAC.GetInt32Value(r["SSP12"]);
|
||||
var 其他加扣 = WDAC.GetInt32Value(r["SSP99"]) - WDAC.GetInt32Value(r["SSS99"]);
|
||||
var 實領薪資 = 應領薪資
|
||||
+ 外勤工作費
|
||||
+ 加班費
|
||||
+ WDAC.GetInt32Value(r["SSP11"])
|
||||
- WDAC.GetInt32Value(r["SSS04"])
|
||||
- WDAC.GetInt32Value(r["SSS05"])
|
||||
- WDAC.GetInt32Value(r["SSS06"])
|
||||
- WDAC.GetInt32Value(r["SSS07"])
|
||||
+ 其他加扣;
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPJME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, string.Format("{0:yyyy/MM/dd}", r["BPSDY"], WGuard1.TaiwanCulture), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, string.Format("{0:yyyy/MM/dd}", r["RASDT"], WGuard1.TaiwanCulture), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["BPSRM"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, 月薪, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SSP05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SSS02"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SSS01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SSS09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, 應領薪資, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, 加班費, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, 外勤工作費, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetInt32Value(r["SSS04"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 16, WDAC.GetInt32Value(r["SSS05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 17, WDAC.GetInt32Value(r["SSS07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, WDAC.GetInt32Value(r["SSS06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 19, 其他加扣, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 20, 實領薪資, bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
excel.SetCellFormula(row, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 1, 13)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 14, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 1, 14)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 15, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(row - 1, 15)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 16, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 16), excel.RCtoA1(row - 1, 16)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 17, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 1, 17)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 18, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 18), excel.RCtoA1(row - 1, 18)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 19, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 19), excel.RCtoA1(row - 1, 19)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 20, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 20), excel.RCtoA1(row - 1, 20)), bodyNumberStyleNoBorder);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 6, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 7, row, 13, BorderStyle.None);
|
||||
excel.SetCellValue(row, 7, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 14, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 14, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 14);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 12);
|
||||
excel.SetColumnWidth(5, 12);
|
||||
excel.SetColumnWidth(6, 10);
|
||||
excel.SetColumnWidth(7, 10);
|
||||
excel.SetColumnWidth(8, 10);
|
||||
excel.SetColumnWidth(9, 10);
|
||||
excel.SetColumnWidth(10, 10);
|
||||
excel.SetColumnWidth(11, 10);
|
||||
excel.SetColumnWidth(12, 10);
|
||||
excel.SetColumnWidth(13, 10);
|
||||
excel.SetColumnWidth(14, 10);
|
||||
excel.SetColumnWidth(15, 10);
|
||||
excel.SetColumnWidth(16, 10);
|
||||
excel.SetColumnWidth(17, 10);
|
||||
excel.SetColumnWidth(18, 10);
|
||||
excel.SetColumnWidth(19, 10);
|
||||
excel.SetColumnWidth(20, 10);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.IO;
|
||||
using Wellan.Data;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 請假明細 的摘要描述
|
||||
/// </summary>
|
||||
public class 請假明細 : ExcelReportBase
|
||||
{
|
||||
public 請假明細()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
titleStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyStyleCenterNoBorder.SetFont(bodyFont);
|
||||
bodyNumberStyleNoBorder.SetFont(bodyFont);
|
||||
titleStyleRightNoBorder.SetFont(bodyFont);
|
||||
titleStyleLeftNoBorder.SetFont(bodyFont);
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
#region 報表抬頭
|
||||
|
||||
var row = 0;
|
||||
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, 公司名稱, headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("承辦{0}", 客戶名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("『{0}』", 專案名稱), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
excel.MergeCell(row, 0, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, string.Format("{0}【{1}{2}】", 報表名稱, 年度, 月份), headerStyle);
|
||||
excel.SetRowHeight(row, 20);
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 4, row, 20, BorderStyle.None);
|
||||
excel.SetCellValue(row, 4, "請假時數 / 金額", titleStyleCenterNoBorder);
|
||||
row++;
|
||||
|
||||
excel.SetCellValue(row, 0, "序號", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, "站別", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, "人員姓名", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, "薪資", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 4, "補休", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, "特休", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, "產假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, "陪產假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, "產檢假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, "婚假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, "公假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, "工傷假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, "喪假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, "事假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, "家庭照顧假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, "原民祭儀假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, "其他(一)", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 18, "病假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, "生理假", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 20, "小計", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 21, "合計金額", titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 22, "備註", titleStyleCenterNoBorder);
|
||||
excel.SetRowHeight(row, 18);
|
||||
row++;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
int beginRow = row;
|
||||
int serial = 1;
|
||||
var SST05_SUM = 0;
|
||||
var SST06_SUM = 0;
|
||||
var SST10_SUM = 0;
|
||||
var SST12_SUM = 0;
|
||||
var SST20_SUM = 0;
|
||||
var SST11_SUM = 0;
|
||||
var SST13_SUM = 0;
|
||||
var SST14_SUM = 0;
|
||||
var SST09_SUM = 0;
|
||||
var SST07_SUM = 0;
|
||||
var SST16_SUM = 0;
|
||||
var SST19_SUM = 0;
|
||||
var SST23_SUM = 0;
|
||||
var SST08_SUM = 0;
|
||||
var SST15_SUM = 0;
|
||||
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
var 月薪 = WDAC.GetInt32Value(r["SSP00"]) + WDAC.GetInt32Value(r["SSP02"]);
|
||||
var 無薪小計 = WDAC.GetInt32Value(r["SSS02"]) + WDAC.GetInt32Value(r["SSS09"]);
|
||||
var 扣款合計 = WDAC.GetInt32Value(r["SSS01"]) + WDAC.GetInt32Value(r["SSS02"]) + WDAC.GetInt32Value(r["SSS09"]);
|
||||
|
||||
excel.SetCellValue(row, 0, serial, bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 1, WDAC.GetStringValue(r["SSBRHX"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 2, WDAC.GetStringValue(r["BPNME"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 3, 月薪, bodyNumberStyleNoBorder);
|
||||
|
||||
SST05_SUM += WDAC.GetInt32Value(r["SST05"]) * 60 + WDAC.GetInt32Value(r["SST05M"]);
|
||||
SST06_SUM += WDAC.GetInt32Value(r["SST06"]) * 60 + WDAC.GetInt32Value(r["SST06M"]);
|
||||
SST10_SUM += WDAC.GetInt32Value(r["SST10"]) * 60 + WDAC.GetInt32Value(r["SST10M"]);
|
||||
SST12_SUM += WDAC.GetInt32Value(r["SST12"]) * 60 + WDAC.GetInt32Value(r["SST12M"]);
|
||||
SST20_SUM += WDAC.GetInt32Value(r["SST20"]) * 60 + WDAC.GetInt32Value(r["SST20M"]);
|
||||
SST11_SUM += WDAC.GetInt32Value(r["SST11"]) * 60 + WDAC.GetInt32Value(r["SST11M"]);
|
||||
SST13_SUM += WDAC.GetInt32Value(r["SST13"]) * 60 + WDAC.GetInt32Value(r["SST13M"]);
|
||||
SST14_SUM += WDAC.GetInt32Value(r["SST14"]) * 60 + WDAC.GetInt32Value(r["SST14M"]);
|
||||
SST09_SUM += WDAC.GetInt32Value(r["SST09"]) * 60 + WDAC.GetInt32Value(r["SST09M"]);
|
||||
SST07_SUM += WDAC.GetInt32Value(r["SST07"]) * 60 + WDAC.GetInt32Value(r["SST07M"]);
|
||||
SST16_SUM += WDAC.GetInt32Value(r["SST16"]) * 60 + WDAC.GetInt32Value(r["SST16M"]);
|
||||
SST19_SUM += WDAC.GetInt32Value(r["SST19"]) * 60 + WDAC.GetInt32Value(r["SST19M"]);
|
||||
SST23_SUM += WDAC.GetInt32Value(r["SST23"]) * 60 + WDAC.GetInt32Value(r["SST23M"]);
|
||||
SST08_SUM += WDAC.GetInt32Value(r["SST08"]) * 60 + WDAC.GetInt32Value(r["SST08M"]);
|
||||
SST15_SUM += WDAC.GetInt32Value(r["SST15"]) * 60 + WDAC.GetInt32Value(r["SST15M"]);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, string.Format("{0:#00}:{1:00}", r["SST05"], r["SST05M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, string.Format("{0:#00}:{1:00}", r["SST06"], r["SST06M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, string.Format("{0:#00}:{1:00}", r["SST10"], r["SST10M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, string.Format("{0:#00}:{1:00}", r["SST12"], r["SST12M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, string.Format("{0:#00}:{1:00}", r["SST20"], r["SST20M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, string.Format("{0:#00}:{1:00}", r["SST11"], r["SST11M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, string.Format("{0:#00}:{1:00}", r["SST13"], r["SST13M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, string.Format("{0:#00}:{1:00}", r["SST14"], r["SST14M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, string.Format("{0:#00}:{1:00}", r["SST09"], r["SST09M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, string.Format("{0:#00}:{1:00}", r["SST07"], r["SST07M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, string.Format("{0:#00}:{1:00}", r["SST16"], r["SST16M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, string.Format("{0:#00}:{1:00}", r["SST19"], r["SST19M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, string.Format("{0:#00}:{1:00}", r["SST23"], r["SST23M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 17, 無薪小計, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, string.Format("{0:#00}:{1:00}", r["SST08"], r["SST08M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, string.Format("{0:#00}:{1:00}", r["SST15"], r["SST15M"]), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 20, WDAC.GetInt32Value(r["SSS01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 21, 扣款合計, bodyNumberStyleNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellValue(row, 4, WDAC.GetInt32Value(r["SST05"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 5, WDAC.GetInt32Value(r["SST06"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 6, WDAC.GetInt32Value(r["SST10"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 7, WDAC.GetInt32Value(r["SST12"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 8, WDAC.GetInt32Value(r["SST20"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 9, WDAC.GetInt32Value(r["SST11"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 10, WDAC.GetInt32Value(r["SST13"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 11, WDAC.GetInt32Value(r["SST14"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 12, WDAC.GetInt32Value(r["SST09"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 13, WDAC.GetInt32Value(r["SST07"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 14, WDAC.GetInt32Value(r["SST16"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 15, WDAC.GetInt32Value(r["SST19"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 16, WDAC.GetInt32Value(r["SST23"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 17, 無薪小計, bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, WDAC.GetInt32Value(r["SST08"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 19, WDAC.GetInt32Value(r["SST15"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 20, WDAC.GetInt32Value(r["SSS01"]), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 21, 扣款合計, bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
serial++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 合計及表尾批示
|
||||
excel.MergeCell(row, 0, row, 1, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "合計", titleStyleLeftNoBorder);
|
||||
|
||||
if (以時分顯示時數)
|
||||
{
|
||||
excel.SetCellValue(row, 4, MinuteToTime(SST05_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 5, MinuteToTime(SST06_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 6, MinuteToTime(SST10_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 7, MinuteToTime(SST12_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 8, MinuteToTime(SST20_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 9, MinuteToTime(SST11_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 10, MinuteToTime(SST13_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 11, MinuteToTime(SST14_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 12, MinuteToTime(SST09_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 13, MinuteToTime(SST07_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 14, MinuteToTime(SST16_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 15, MinuteToTime(SST19_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 16, MinuteToTime(SST23_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellFormula(row, 17, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 1, 17)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellValue(row, 18, MinuteToTime(SST08_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellValue(row, 19, MinuteToTime(SST15_SUM), bodyStyleCenterNoBorder);
|
||||
excel.SetCellFormula(row, 20, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 20), excel.RCtoA1(row - 1, 20)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 21, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 21), excel.RCtoA1(row - 1, 21)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
else
|
||||
{
|
||||
excel.SetCellFormula(row, 4, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 4), excel.RCtoA1(row - 1, 4)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 5, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 5), excel.RCtoA1(row - 1, 5)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 6, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 6), excel.RCtoA1(row - 1, 6)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 7, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 7), excel.RCtoA1(row - 1, 7)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 8, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 8), excel.RCtoA1(row - 1, 8)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 9, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 9), excel.RCtoA1(row - 1, 9)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 10, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 10), excel.RCtoA1(row - 1, 10)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 11, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 11), excel.RCtoA1(row - 1, 11)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 12, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 12), excel.RCtoA1(row - 1, 12)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 13, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 13), excel.RCtoA1(row - 1, 13)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 14, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 14), excel.RCtoA1(row - 1, 14)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 15, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 15), excel.RCtoA1(row - 1, 15)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 16, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 16), excel.RCtoA1(row - 1, 16)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 17, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 17), excel.RCtoA1(row - 1, 17)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 18, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 18), excel.RCtoA1(row - 1, 18)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 19, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 19), excel.RCtoA1(row - 1, 19)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 20, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 20), excel.RCtoA1(row - 1, 20)), bodyNumberStyleNoBorder);
|
||||
excel.SetCellFormula(row, 21, String.Format("SUM({0}:{1})", excel.RCtoA1(beginRow, 21), excel.RCtoA1(row - 1, 21)), bodyNumberStyleNoBorder);
|
||||
}
|
||||
row++;
|
||||
|
||||
excel.MergeCell(row, 0, row, 6, BorderStyle.None);
|
||||
excel.SetCellValue(row, 0, "承辦人:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 7, row, 13, BorderStyle.None);
|
||||
excel.SetCellValue(row, 7, "業務主管:", titleStyleLeftNoBorder);
|
||||
excel.MergeCell(row, 14, row, 22, BorderStyle.None);
|
||||
excel.SetCellValue(row, 14, "公司章:", titleStyleLeftNoBorder);
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 6);
|
||||
excel.SetColumnWidth(1, 10);
|
||||
excel.SetColumnWidth(2, 10);
|
||||
excel.SetColumnWidth(3, 10);
|
||||
excel.SetColumnWidth(4, 10);
|
||||
excel.SetColumnWidth(5, 10);
|
||||
excel.SetColumnWidth(6, 10);
|
||||
excel.SetColumnWidth(7, 10);
|
||||
excel.SetColumnWidth(8, 10);
|
||||
excel.SetColumnWidth(9, 10);
|
||||
excel.SetColumnWidth(10, 10);
|
||||
excel.SetColumnWidth(11, 10);
|
||||
excel.SetColumnWidth(12, 10);
|
||||
excel.SetColumnWidth(13, 10);
|
||||
excel.SetColumnWidth(14, 10);
|
||||
excel.SetColumnWidth(15, 10);
|
||||
excel.SetColumnWidth(16, 10);
|
||||
excel.SetColumnWidth(17, 10);
|
||||
excel.SetColumnWidth(18, 10);
|
||||
excel.SetColumnWidth(19, 10);
|
||||
excel.SetColumnWidth(20, 10);
|
||||
excel.SetColumnWidth(21, 10);
|
||||
excel.SetColumnWidth(22, 10);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.HSSF.Util;
|
||||
using System.IO;
|
||||
using NPOI.SS.Util;
|
||||
using Wellan.Data;
|
||||
using System.Linq;
|
||||
|
||||
/// <summary>
|
||||
/// 請假申請單
|
||||
/// </summary>
|
||||
public class 請假申請單 : ExcelReportBase
|
||||
{
|
||||
public 請假申請單()
|
||||
{
|
||||
報表名稱 = "請假申請單";
|
||||
}
|
||||
|
||||
public override MemoryStream 產生報表()
|
||||
{
|
||||
BodyRowHeight = 35;
|
||||
TimeCalc timeCalc = new TimeCalc();
|
||||
|
||||
#region 報表抬頭
|
||||
|
||||
excel.MergeCell(0, 0, 0, 9);
|
||||
excel.SetCellValue(0, 0, String.Format("{0}\r\n承辦{1}\r\n『{2}』\r\n{3}", 公司名稱, 客戶名稱, 專案名稱, 報表名稱), headerStyle);
|
||||
excel.SetCellValue(1, 0, "月份:", titleStyleRightNoBorder);
|
||||
excel.MergeCell(1, 1, 1, 2);
|
||||
excel.SetCellValue(1, 1, 報表時間.ToString("MM月"), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 3, "單位:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 4, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["站別"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 5, "職稱:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 6, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["職稱"]), titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(1, 7, "姓名:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(1, 8, WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["BPNME"]), titleStyleLeftNoBorder);
|
||||
excel.SetRowHeight(0, HeaderRowHeight * 4);
|
||||
excel.SetRowHeight(1, BodyRowHeight);
|
||||
|
||||
excel.MergeCell(2, 0, 2, 2);
|
||||
excel.SetRangeOuterBorder(2, 0, 2, 2, BorderStyle.Thin);
|
||||
excel.SetCellValue(2, 0, "請假日期", titleStyleCenter);
|
||||
excel.SetCellValue(2, 3, "開始時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 4, "結束時間", titleStyleCenter);
|
||||
excel.SetCellValue(2, 5, "請假類別", titleStyleCenter);
|
||||
excel.SetCellValue(2, 6, "請假時數", titleStyleCenter);
|
||||
excel.SetCellValue(2, 7, "代理人", titleStyleCenter);
|
||||
excel.SetCellValue(2, 8, "請假事由", titleStyleCenter);
|
||||
excel.SetCellValue(2, 9, "備註", titleStyleCenter);
|
||||
excel.SetRowHeight(2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 報表資料
|
||||
|
||||
DateTime 月初 = 報表時間;
|
||||
DateTime 月底 = 報表時間.AddMonths(1).AddDays(-1);
|
||||
|
||||
var summarys = new List<Summary>()
|
||||
{
|
||||
new Summary() { Title = "補休" , RparTyps = new List<string>() { RPAR_TYPE.T00_補休 } },
|
||||
new Summary() { Title = "特休" , RparTyps = new List<string>() { RPAR_TYPE.T01_特休 } } ,
|
||||
new Summary() { Title = "事假" , RparTyps = new List<string>() { RPAR_TYPE.T02_事假 } },
|
||||
new Summary() { Title = "病假" , RparTyps = new List<string>() { RPAR_TYPE.T03_病假 } },
|
||||
new Summary() { Title = "喪假" , RparTyps = new List<string>() { RPAR_TYPE.T04_喪假 } },
|
||||
new Summary() { Title = "產假" , RparTyps = new List<string>() { RPAR_TYPE.T05_產假 } },
|
||||
new Summary() { Title = "婚假" , RparTyps = new List<string>() { RPAR_TYPE.T06_婚假 } },
|
||||
new Summary() { Title = "陪產假" , RparTyps = new List<string>() { RPAR_TYPE.T07_陪產假 } },
|
||||
new Summary() { Title = "公假(出)" , RparTyps = new List<string>() { RPAR_TYPE.T08_公假 } },
|
||||
new Summary() { Title = "公傷假" , RparTyps = new List<string>() { RPAR_TYPE.T09_公傷假 } },
|
||||
new Summary() { Title = "生理假" , RparTyps = new List<string>() { RPAR_TYPE.T0A_生理假 } },
|
||||
new Summary() { Title = "家庭照顧假" , RparTyps = new List<string>() { RPAR_TYPE.T0B_家庭照顧假 } },
|
||||
new Summary() { Title = "育嬰假" , RparTyps = new List<string>() { RPAR_TYPE.T0C_育嬰假 } },
|
||||
new Summary() { Title = "原民祭儀假" , RparTyps = new List<string>() { RPAR_TYPE.T0D_原民祭儀假 } },
|
||||
new Summary() { Title = "產檢假" , RparTyps = new List<string>() { RPAR_TYPE.T0E_產檢假 } },
|
||||
new Summary() { Title = "其他假別(一)", RparTyps = new List<string>() { RPAR_TYPE.T0F_防疫照顧假,
|
||||
RPAR_TYPE.T0G_無薪假,
|
||||
RPAR_TYPE.T0H_防疫隔離假 } }
|
||||
};
|
||||
|
||||
int 總時數 = 0;
|
||||
|
||||
int rowId = 3;
|
||||
foreach (DataRow r in 資料來源.Tables[0].Rows)
|
||||
{
|
||||
DateTime 起日 = WDAC.GetDateTimeValue(r["RPRDT"]);
|
||||
DateTime 迄日 = WDAC.GetDateTimeValue(r["RPEDT"]);
|
||||
string 起時 = WDAC.GetStringValue(r["RPRTM"]);
|
||||
string 迄時 = WDAC.GetStringValue(r["RPETM"]);
|
||||
string 類別 = WDAC.GetStringValue(r["RPTYP"]);
|
||||
|
||||
if (起日 < 月初)
|
||||
{
|
||||
起日 = 月初;
|
||||
起時 = timeCalc.上班時間;
|
||||
}
|
||||
if (迄日 > 月底)
|
||||
{
|
||||
迄日 = 月底;
|
||||
迄時 = timeCalc.下班時間;
|
||||
}
|
||||
|
||||
//Double 時數 = WDAC.GetDoubleValue(r["RPTCT"]) / 60;
|
||||
int 時數 = timeCalc.計算請假總時數(WDAC.GetStringValue(資料來源.Tables[0].Rows[0]["RPNUM"]), 起日, 迄日, 起時, 迄時, 類別, !以時分顯示時數);
|
||||
總時數 += 時數;
|
||||
|
||||
#region 區分假別統計
|
||||
var summary = summarys.FirstOrDefault(p => p.RparTyps.Contains(類別));
|
||||
if (summary != null) {
|
||||
summary.Minutes += 時數;
|
||||
}
|
||||
#endregion
|
||||
|
||||
excel.SetCellValue(rowId, 0, 起日.ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 1, "~", titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 2, 迄日.ToString("MM月dd日"), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 3, 起時, titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 4, 迄時, titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 5, WDAC.GetStringValue(r["類別"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 6, MinuteToTime(時數), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 7, WDAC.GetStringValue(r["RPAGT"]), titleStyleCenter);
|
||||
excel.SetCellValue(rowId, 8, WDAC.GetStringValue(r["RPRSN"]), bodyStyleCenterS);
|
||||
excel.SetCellValue(rowId, 9, WDAC.GetStringValue(r["RPDOC"]), bodyStyleCenterS);
|
||||
excel.SetRowHeight(rowId, BodyRowHeight);
|
||||
rowId++;
|
||||
}
|
||||
|
||||
#region 底下的統計
|
||||
var summaryRows = summarys.Count + 1;
|
||||
|
||||
excel.MergeCell(rowId + 2, 2, rowId + summaryRows, 3);
|
||||
excel.MergeCell(rowId + 2, 4, rowId + summaryRows, 4);
|
||||
excel.MergeCell(rowId + 2, 5, rowId + summaryRows, 5);
|
||||
excel.SetCellValue(rowId + 2, 2, "總請假時數:", titleStyleRightNoBorder);
|
||||
excel.SetCellValue(rowId + 2, 4, MinuteToTime(總時數), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + 2, 5, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + 2, 2, rowId + summaryRows, 5, BorderStyle.Thin);
|
||||
|
||||
var rr = 2;
|
||||
foreach (var symmary in summarys)
|
||||
{
|
||||
excel.SetCellValue(rowId + rr, 6, symmary.Title + ":", titleStyleLeftNoBorder);
|
||||
excel.SetCellValue(rowId + rr, 7, MinuteToTime(symmary.Minutes), titleStyleCenterNoBorder);
|
||||
excel.SetCellValue(rowId + rr, 8, "hrs", titleStyleLeftNoBorder);
|
||||
excel.SetRangeOuterBorder(rowId + rr, 6, rowId + rr, 8, BorderStyle.Thin);
|
||||
excel.SetRowHeight(rowId + rr, BodyRowHeight);
|
||||
rr++;
|
||||
}
|
||||
|
||||
rowId += summaryRows;
|
||||
#endregion
|
||||
|
||||
#region 表尾批示
|
||||
|
||||
//excel.MergeCell(rowId + 10, 0, rowId + 10, 9);
|
||||
//excel.SetCellValue(rowId + 10, 0, "申請人: 計畫督導: 人事單位:", titleStyleLeftNoBorder);
|
||||
//excel.SetRowHeight(rowId + 10, BodyRowHeight);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 1, rowId + 1, 3);
|
||||
//excel.MergeCell(rowId + 2, 1, rowId + 2, 3);
|
||||
//excel.SetCellValue(rowId + 1, 1, "申請人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 1, rowId + 1, 3, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 1, rowId + 2, 3, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 4, rowId + 1, 6);
|
||||
//excel.MergeCell(rowId + 2, 4, rowId + 2, 6);
|
||||
//excel.SetCellValue(rowId + 1, 4, "公司計畫督導", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 4, rowId + 1, 6, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 4, rowId + 2, 6, BorderStyle.Thin);
|
||||
|
||||
//excel.MergeCell(rowId + 1, 7, rowId + 1, 8);
|
||||
//excel.MergeCell(rowId + 2, 7, rowId + 2, 8);
|
||||
//excel.SetCellValue(rowId + 1, 7, "公司計畫主持人", titleStyleCenter);
|
||||
//excel.SetRangeOuterBorder(rowId + 1, 7, rowId + 1, 8, BorderStyle.Thin);
|
||||
//excel.SetRangeOuterBorder(rowId + 2, 7, rowId + 2, 8, BorderStyle.Thin);
|
||||
|
||||
//excel.SetRowHeight(rowId + 1, BodyRowHeight);
|
||||
//excel.SetRowHeight(rowId + 2, BodyRowHeight);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
excel.SetColumnWidth(0, 11);
|
||||
excel.SetColumnWidth(1, 4);
|
||||
excel.SetColumnWidth(2, 11);
|
||||
excel.SetColumnWidth(3, 11);
|
||||
excel.SetColumnWidth(4, 11);
|
||||
excel.SetColumnWidth(5, 11);
|
||||
excel.SetColumnWidth(6, 18);
|
||||
excel.SetColumnWidth(7, 12);
|
||||
excel.SetColumnWidth(8, 20);
|
||||
excel.SetColumnWidth(9, 15);
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
workbook.Write(ms);
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
|
||||
class Summary
|
||||
{
|
||||
public string Title;
|
||||
public int Minutes;
|
||||
public List<string> RparTyps;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Timers;
|
||||
using System.Net.Mail;
|
||||
using System.Data;
|
||||
using Wellan.Data;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// 定時發送郵件
|
||||
///
|
||||
/// 1. 代理人代理前一天發送郵件通知
|
||||
/// </summary>
|
||||
public class MailTask
|
||||
{
|
||||
private Timer timer1;
|
||||
private static MailTask instance = null;
|
||||
|
||||
private MailTask()
|
||||
{
|
||||
timer1 = new Timer();
|
||||
timer1.Interval = 1000;
|
||||
timer1.AutoReset = true;
|
||||
timer1.Elapsed += Timer1_Elapsed;
|
||||
}
|
||||
|
||||
private void Timer1_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
var nowTime = DateTime.UtcNow.AddHours(8).ToString("HHmmss");
|
||||
|
||||
// 每日定時工作
|
||||
if (nowTime == "000000")
|
||||
{
|
||||
發代理人提醒郵件();
|
||||
}
|
||||
|
||||
// 每小時定時工作
|
||||
if (nowTime.EndsWith("0000"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 每分鐘定時工作
|
||||
if (nowTime.EndsWith("00"))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private static void EnsureInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new MailTask();
|
||||
}
|
||||
|
||||
public static bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureInstance();
|
||||
return instance.timer1.Enabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
EnsureInstance();
|
||||
instance.timer1.Enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void 發代理人提醒郵件()
|
||||
{
|
||||
RparDAC dao = new RparDAC();
|
||||
var notofyList = dao.代理人提醒(DateTime.UtcNow.AddHours(8).Date.AddDays(1));
|
||||
|
||||
// RPPYN 年度接單編號
|
||||
// RPREN 單號
|
||||
// RPNUM 差假員工編號
|
||||
// BPNME 差假員工姓名
|
||||
// BPEML 差假員工電郵
|
||||
// RPTYP 差假類別代碼
|
||||
// BSSCR 差假類別名稱
|
||||
// RPAGT 代理人姓名
|
||||
// RPAGM 代理人電郵
|
||||
// RPRDT 差假開始日期
|
||||
// RPRTM 差假開始時間
|
||||
// RPEDT 差假結束日期
|
||||
// RPETM 差假結束時間
|
||||
|
||||
foreach (DataRow r in notofyList.Rows)
|
||||
{
|
||||
var 單號 = WDAC.GetStringValue(r["RPREN"]);
|
||||
var 類別 = WDAC.GetStringValue(r["RPTYP"]);
|
||||
|
||||
switch (類別.Substring(0, 1))
|
||||
{
|
||||
// 請假
|
||||
case RPAR_TYPE.T0_請假:
|
||||
類別 = "請假";
|
||||
break;
|
||||
// 差旅
|
||||
case RPAR_TYPE.T3_出差:
|
||||
類別 = "差旅";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
MailMessage mm = new MailMessage();
|
||||
mm.Subject = String.Format("{1}代理提醒 [單號:{0}]", 單號, 類別);
|
||||
mm.To.Add(new MailAddress(WDAC.GetStringValue(r["RPAGM"])));
|
||||
mm.BodyEncoding = Encoding.UTF8;
|
||||
mm.IsBodyHtml = true;
|
||||
mm.Body = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Template/代理人提醒.html"))
|
||||
.Replace("{類別}", 類別)
|
||||
.Replace("{單號}", 單號)
|
||||
.Replace("{差勤人}", WDAC.GetStringValue(r["BPNME"]))
|
||||
.Replace("{事由}", 類別 == "請假" ? WDAC.GetStringValue(r["RPRSN"]) : WDAC.GetStringValue(r["RPDOC"]))
|
||||
.Replace("{起日}", String.Format("{0:yyyy-MM-dd}", r["RPRDT"]))
|
||||
.Replace("{起時}", String.Format("{0}", r["RPRTM"]))
|
||||
.Replace("{迄日}", String.Format("{0:yyyy-MM-dd}", r["RPEDT"]))
|
||||
.Replace("{迄時}", String.Format("{0}", r["RPETM"]))
|
||||
;
|
||||
// 發送郵件
|
||||
try
|
||||
{
|
||||
Wellan.Service.WMailSender.GetInstance().Send(mm, string.Format("代理提醒 單號:{0}", 單號));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// wmBpsn 的摘要描述
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://tempuri.org/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[ScriptService]
|
||||
public class wmBpsn : System.Web.Services.WebService
|
||||
{
|
||||
|
||||
public wmBpsn()
|
||||
{
|
||||
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-TW");
|
||||
ci.DateTimeFormat.Calendar = new System.Globalization.TaiwanCalendar();
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
|
||||
}
|
||||
|
||||
private WQuery GetQuery()
|
||||
{
|
||||
string ConnectionConfigName = WConfig.GetConnectionConfigName();
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
string ConnectionString = WConnectionString.GetConnectionString(ConnectionConfigName);
|
||||
string ConnectionType = WConnectionString.GetConnectionType(ConnectionConfigName);
|
||||
return new WQuery(ConnectionType, ConnectionString);
|
||||
}
|
||||
|
||||
private GetDataResponse CheckInput(RPSBItem prev, RPSBSaveItem saveRecord)
|
||||
{
|
||||
var result = 0;
|
||||
var message = "";
|
||||
|
||||
if (!saveRecord.IsValid)
|
||||
{
|
||||
result = -1;
|
||||
message = saveRecord.Message;
|
||||
}
|
||||
else if (prev != null)
|
||||
{
|
||||
if (saveRecord.RPDAT_DATE < prev.RPDAT)
|
||||
{
|
||||
result = -1;
|
||||
message = "異動日期不可小於前一筆的異動日期";
|
||||
}
|
||||
else if (prev.OnBoard && saveRecord.OnBoard)
|
||||
{
|
||||
result = -1;
|
||||
message = "異動類別不合理(連續兩個在職)";
|
||||
}
|
||||
else if (prev.OffBoard && !prev.Quit && saveRecord.OffBoard && !saveRecord.Quit)
|
||||
{
|
||||
result = -1;
|
||||
message = "異動類別不合理(連續兩個留職停薪)";
|
||||
}
|
||||
else if (prev.Quit && saveRecord.Quit)
|
||||
{
|
||||
result = -1;
|
||||
message = "異動類別不合理(連續兩個離職)";
|
||||
}
|
||||
else if (prev.Quit && saveRecord.OffBoard && !saveRecord.Quit)
|
||||
{
|
||||
result = -1;
|
||||
message = "異動類別不合理(離職後留職停薪)";
|
||||
}
|
||||
else if (prev.OffBoard && saveRecord.DeptChange)
|
||||
{
|
||||
result = -1;
|
||||
message = "異動類別不合理(不在職時部門調動)";
|
||||
}
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = -1,
|
||||
Data = null,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
|
||||
public GetDataResponse GetRPSBList(string rpeno)
|
||||
{
|
||||
var query = GetQuery();
|
||||
var dao = new RpsbDAC(query);
|
||||
var d = dao.Select(rpeno);
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 0,
|
||||
Data = Newtonsoft.Json.JsonConvert.SerializeObject(d)
|
||||
};
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public GetDataResponse AddRPSB(string record)
|
||||
{
|
||||
var saveRecord = Newtonsoft.Json.JsonConvert.DeserializeObject<RPSBSaveItem>(record);
|
||||
if (!saveRecord.IsValid)
|
||||
{
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = -1,
|
||||
Data = null,
|
||||
Message = saveRecord.Message
|
||||
};
|
||||
}
|
||||
|
||||
var query = GetQuery();
|
||||
var dao = new RpsbDAC(query);
|
||||
var rpitm = dao.NextRPITM(saveRecord.RPENO);
|
||||
var prev = dao.SelectLast(saveRecord.RPENO, 0);
|
||||
|
||||
var checkResult = CheckInput(prev, saveRecord);
|
||||
if (checkResult != null)
|
||||
{
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
var newRecord = new RPSBItem()
|
||||
{
|
||||
RPENO = saveRecord.RPENO,
|
||||
RPITM = rpitm,
|
||||
RPCLS = saveRecord.RPCLS,
|
||||
RPDAT = saveRecord.RPDAT_DATE,
|
||||
RPODT = saveRecord.DeptChange ? dao.PrevRPDPT(saveRecord.RPENO, rpitm) : "",
|
||||
RPDPT = saveRecord.RPDPT,
|
||||
RPDOC = saveRecord.RPDOC
|
||||
};
|
||||
|
||||
var d = dao.InsertOne(newRecord);
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = d ? 0 : -1,
|
||||
Data = d.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public GetDataResponse UpdateRPSB(string record)
|
||||
{
|
||||
var saveRecord = Newtonsoft.Json.JsonConvert.DeserializeObject<RPSBSaveItem>(record);
|
||||
var query = GetQuery();
|
||||
var dao = new RpsbDAC(query);
|
||||
var prev = dao.SelectLast(saveRecord.RPENO, saveRecord.RPITM);
|
||||
|
||||
var checkResult = CheckInput(prev, saveRecord);
|
||||
if (checkResult != null)
|
||||
{
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
var updateRecord = new RPSBItem()
|
||||
{
|
||||
RPENO = saveRecord.RPENO,
|
||||
RPITM = saveRecord.RPITM,
|
||||
RPCLS = saveRecord.RPCLS,
|
||||
RPDAT = saveRecord.RPDAT_DATE,
|
||||
RPODT = saveRecord.DeptChange ? dao.PrevRPDPT(saveRecord.RPENO, saveRecord.RPITM) : "",
|
||||
RPDPT = saveRecord.RPDPT,
|
||||
RPDOC = saveRecord.RPDOC
|
||||
};
|
||||
|
||||
var d = dao.UpdateOne(updateRecord);
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = d ? 0 : -1,
|
||||
Data = d.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public GetDataResponse DeleteRPSB(string rpeno, int rpitm)
|
||||
{
|
||||
var query = GetQuery();
|
||||
var dao = new RpsbDAC(query);
|
||||
var d = dao.DeleteOne(rpeno, rpitm);
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = d ? 0 : -1,
|
||||
Data = d.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
|
||||
public GetDataResponse GetRASNList(string bpeno)
|
||||
{
|
||||
var query = GetQuery();
|
||||
var dao = new RasnDAC(query);
|
||||
var d = dao.SelectHistoryByEmployee(bpeno);
|
||||
return new GetDataResponse()
|
||||
{
|
||||
Result = 0,
|
||||
Data = Newtonsoft.Json.JsonConvert.SerializeObject(d)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Script.Services;
|
||||
using System.Web.Services;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// wmRyer 的摘要描述
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://tempuri.org/")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[ScriptService]
|
||||
public class wmRyer : System.Web.Services.WebService
|
||||
{
|
||||
|
||||
public wmRyer()
|
||||
{
|
||||
}
|
||||
|
||||
private static WQuery CreateQuery()
|
||||
{
|
||||
string ConnectionConfigName = WConfig.GetConnectionConfigName();
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
string ConnectionString = WConnectionString.GetConnectionString(ConnectionConfigName);
|
||||
string ConnectionType = WConnectionString.GetConnectionType(ConnectionConfigName);
|
||||
WQuery Query = new WQuery(ConnectionType, ConnectionString);
|
||||
return Query;
|
||||
}
|
||||
|
||||
private static void CheckInput(RyerSaveItem item)
|
||||
{
|
||||
if (item.ryd01 <= 0) item.ryd01 = 1;
|
||||
if (item.ryd02 <= 0) item.ryd02 = 1;
|
||||
if (item.ryd03 <= 0) item.ryd03 = 1;
|
||||
if (item.ryd04 <= 0) item.ryd04 = 1;
|
||||
if (item.ryd05 <= 0) item.ryd05 = 1;
|
||||
if (item.ryd06 <= 0) item.ryd06 = 1;
|
||||
if (item.ryd07 <= 0) item.ryd07 = 1;
|
||||
if (item.ryd08 <= 0) item.ryd08 = 1;
|
||||
if (item.ryd09 <= 0) item.ryd09 = 1;
|
||||
if (item.ryd10 <= 0) item.ryd10 = 1;
|
||||
if (item.ryd11 <= 0) item.ryd11 = 1;
|
||||
if (item.ryd12 <= 0) item.ryd12 = 1;
|
||||
|
||||
if (item.ryd01 > 31) item.ryd01 = 31;
|
||||
if (item.ryd02 > 31) item.ryd02 = 31;
|
||||
if (item.ryd03 > 31) item.ryd03 = 31;
|
||||
if (item.ryd04 > 31) item.ryd04 = 31;
|
||||
if (item.ryd05 > 31) item.ryd05 = 31;
|
||||
if (item.ryd06 > 31) item.ryd06 = 31;
|
||||
if (item.ryd07 > 31) item.ryd07 = 31;
|
||||
if (item.ryd08 > 31) item.ryd08 = 31;
|
||||
if (item.ryd09 > 31) item.ryd09 = 31;
|
||||
if (item.ryd10 > 31) item.ryd10 = 31;
|
||||
if (item.ryd11 > 31) item.ryd11 = 31;
|
||||
if (item.ryd12 > 31) item.ryd12 = 31;
|
||||
|
||||
item.ryyst_h = item.ryyst_h ?? 0;
|
||||
item.ryyst_m = item.ryyst_m ?? 0;
|
||||
item.rysly_h = item.rysly_h ?? 0;
|
||||
item.rysly_m = item.rysly_m ?? 0;
|
||||
item.rynxt_h = item.rynxt_h ?? 0;
|
||||
item.rynxt_m = item.rynxt_m ?? 0;
|
||||
|
||||
if (item.ryyst_h < 0)
|
||||
{
|
||||
throw new Exception("年初小時數錯誤,應大於等於 0");
|
||||
}
|
||||
if (item.ryyst_m < 0 || item.ryyst_m > 59)
|
||||
{
|
||||
throw new Exception("年初分鐘數錯誤,應從 0 至 59");
|
||||
}
|
||||
if (item.rysly_h < 0)
|
||||
{
|
||||
throw new Exception("折算薪資小時數錯誤,應大於等於 0");
|
||||
}
|
||||
if (item.rysly_m < 0 || item.rysly_m > 59)
|
||||
{
|
||||
throw new Exception("折算薪資分鐘數錯誤,應從 0 至 59");
|
||||
}
|
||||
if (item.rynxt_h < 0)
|
||||
{
|
||||
throw new Exception("遞延下年小時數錯誤,應大於等於 0");
|
||||
}
|
||||
if (item.rynxt_m < 0 || item.rynxt_m > 59)
|
||||
{
|
||||
throw new Exception("遞延下年分鐘數錯誤,應從 0 至 59");
|
||||
}
|
||||
|
||||
item.ryyst = item.ryyst_h * 60 + item.ryyst_m;
|
||||
item.rysly = item.rysly_h * 60 + item.rysly_m;
|
||||
item.rynxt = item.rynxt_h * 60 + item.rynxt_m;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public RyerSaveItem Save(RyerSaveItem item)
|
||||
{
|
||||
try
|
||||
{
|
||||
CheckInput(item);
|
||||
|
||||
WQuery Query = CreateQuery();
|
||||
RyerDAC ryerdao = new RyerDAC(Query);
|
||||
var nowtime = DateTime.UtcNow.AddHours(8);
|
||||
int month = nowtime.Month;
|
||||
int day = nowtime.Day;
|
||||
if (item.ryyer < nowtime.Year)
|
||||
{
|
||||
month = 12;
|
||||
day = 31;
|
||||
}
|
||||
|
||||
ryerdao.UpdateOne(
|
||||
item.ryeno
|
||||
, item.ryyer
|
||||
, item.ryyst.Value + (item.ryh01 + item.ryh02 + item.ryh03 + item.ryh04 + item.ryh05 + item.ryh06 + item.ryh07 + item.ryh08 + item.ryh09 + item.ryh10 + item.ryh11 + item.ryh12) * 60
|
||||
, item.userid
|
||||
, item.ryyst.Value
|
||||
, item.ryh01 * 60, item.ryh02 * 60, item.ryh03 * 60, item.ryh04 * 60, item.ryh05 * 60, item.ryh06 * 60, item.ryh07 * 60, item.ryh08 * 60, item.ryh09 * 60, item.ryh10 * 60, item.ryh11 * 60, item.ryh12 * 60
|
||||
, item.ryd01, item.ryd02, item.ryd03, item.ryd04, item.ryd05, item.ryd06, item.ryd07, item.ryd08, item.ryd09, item.ryd10, item.ryd11, item.ryd12
|
||||
, item.rysly.Value, item.rynxt.Value, item.ryrmk);
|
||||
|
||||
int 可用特休 = ryerdao.Get可用特休(item.ryeno, item.ryyer, month, day);
|
||||
int 至今生效特休 = ryerdao.Get至今生效特休(item.ryeno, item.ryyer, month, day);
|
||||
int 已休特休 = ryerdao.Get年初特休(item.ryeno, item.ryyer) + 至今生效特休 - 可用特休;
|
||||
|
||||
item.ryyxt_d = String.Format("{0}:{1:00}", Convert.ToInt32(item.ryyxt / 60), item.ryyxt % 60);
|
||||
item.ryvld = String.Format("{0}:{1:00}", Convert.ToInt32(至今生效特休 / 60), 至今生效特休 % 60);
|
||||
item.ryust = String.Format("{0}:{1:00}", Convert.ToInt32(已休特休 / 60), 已休特休 % 60);
|
||||
item.rylft = String.Format("{0}:{1:00}", Convert.ToInt32(可用特休 / 60), 可用特休 % 60);
|
||||
item.result = 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.result = -1;
|
||||
item.message = ex.Message;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
[WebMethod(EnableSession = true)]
|
||||
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
||||
public RyerSaveItem Final(RyerSaveItem item)
|
||||
{
|
||||
try
|
||||
{
|
||||
CheckInput(item);
|
||||
|
||||
WQuery Query = CreateQuery();
|
||||
RyerDAC ryerdao = new RyerDAC(Query);
|
||||
var nowtime = DateTime.UtcNow.AddHours(8);
|
||||
int month = nowtime.Month;
|
||||
int day = nowtime.Day;
|
||||
if (item.ryyer < nowtime.Year)
|
||||
{
|
||||
month = 12;
|
||||
day = 31;
|
||||
}
|
||||
|
||||
ryerdao.UpdateOne(
|
||||
item.ryeno
|
||||
, item.ryyer
|
||||
, item.ryyst.Value + (item.ryh01 + item.ryh02 + item.ryh03 + item.ryh04 + item.ryh05 + item.ryh06 + item.ryh07 + item.ryh08 + item.ryh09 + item.ryh10 + item.ryh11 + item.ryh12) * 60
|
||||
, item.userid
|
||||
, item.ryyst.Value
|
||||
, item.ryh01 * 60, item.ryh02 * 60, item.ryh03 * 60, item.ryh04 * 60, item.ryh05 * 60, item.ryh06 * 60, item.ryh07 * 60, item.ryh08 * 60, item.ryh09 * 60, item.ryh10 * 60, item.ryh11 * 60, item.ryh12 * 60
|
||||
, item.ryd01, item.ryd02, item.ryd03, item.ryd04, item.ryd05, item.ryd06, item.ryd07, item.ryd08, item.ryd09, item.ryd10, item.ryd11, item.ryd12
|
||||
, item.rysly.Value, item.rynxt.Value, item.ryrmk);
|
||||
|
||||
var finalResult = ryerdao.Final(
|
||||
item.ryeno
|
||||
, item.ryyer
|
||||
, item.userid);
|
||||
|
||||
int 可用特休 = ryerdao.Get可用特休(item.ryeno, item.ryyer, month, day);
|
||||
int 至今生效特休 = ryerdao.Get至今生效特休(item.ryeno, item.ryyer, month, day);
|
||||
int 已休特休 = ryerdao.Get年初特休(item.ryeno, item.ryyer) + 至今生效特休 - 可用特休;
|
||||
item.ryyxt_d = String.Format("{0}:{1:00}", Convert.ToInt32(item.ryyxt / 60), item.ryyxt % 60);
|
||||
item.ryvld = String.Format("{0}:{1:00}", Convert.ToInt32(至今生效特休 / 60), 至今生效特休 % 60);
|
||||
item.ryust = String.Format("{0}:{1:00}", Convert.ToInt32(已休特休 / 60), 已休特休 % 60);
|
||||
item.rylft = String.Format("{0}:{1:00}", Convert.ToInt32(可用特休 / 60), 可用特休 % 60);
|
||||
item.result = 0;
|
||||
if (finalResult == "年度結算")
|
||||
item.message = string.Format("人員編號 {0} 年度 {1} 結算成功", item.ryeno, item.ryyer - 1911);
|
||||
if (finalResult == "離職結算")
|
||||
item.message = string.Format("人員編號 {0} 離職結算成功", item.ryeno);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
item.result = -1;
|
||||
item.message = string.Format("人員編號 {0} 結算失敗:{1}", item.ryeno, ex.Message);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user