chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,307 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
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 Wellan.Common;
|
||||
using Wellan.Data;
|
||||
using System.Data.Common;
|
||||
using CRAX;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// 差勤系統月報表
|
||||
/// </summary>
|
||||
public partial class forms_report_fmCardReport : Wellan.Web.UI.WUserControlBase
|
||||
{
|
||||
private DataTable reportData = null;
|
||||
private DataTable reportData1 = null;
|
||||
private string reportName = "";
|
||||
private string dataFileName = "";
|
||||
private string reportTitle = "";
|
||||
private DateTime aYYMM;
|
||||
private RparDAC rparDao;
|
||||
private BhrdDAC bhrdDao;
|
||||
private RpadDAC rpadDao;
|
||||
private RtmeDAC rtmeDao;
|
||||
private string 專案編號;
|
||||
private string 公司名稱;
|
||||
private string 專案名稱;
|
||||
private string 客戶名稱;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
|
||||
if (txtYYMM.Text.Length == 0)
|
||||
txtYYMM.Text = DateTime.UtcNow.AddHours(8).Date.ToString("yyyyMM");
|
||||
|
||||
SetClientFocus(txtYYMM);
|
||||
rparDao = new RparDAC(Query);
|
||||
bhrdDao = new BhrdDAC(Query);
|
||||
rpadDao = new RpadDAC(Query);
|
||||
rtmeDao = new RtmeDAC(Query);
|
||||
}
|
||||
|
||||
protected void btnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool result = true;
|
||||
cvMessage.IsValid = true;
|
||||
cvMessage.ErrorMessage = "";
|
||||
|
||||
aYYMM = CheckDate(txtYYMM.Text + "01", "請輸入正確的年月", ref result, cvMessage);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
if (aYYMM.ToString("yyyyMM").CompareTo("10104") < 0)
|
||||
{
|
||||
cvMessage.IsValid = false;
|
||||
cvMessage.ErrorMessage = "注意!101 年 4 月之後的資料才可以使用此功能";
|
||||
return;
|
||||
}
|
||||
|
||||
專案編號 = new BpsnDAC(Query).GetProjectByDate(UserId, aYYMM);
|
||||
專案名稱 = GetLookup("BPAA", 專案編號, "BPPYM");
|
||||
|
||||
// 取得客戶名稱、公司別
|
||||
公司名稱 = CompanyDAC.GetCompanyName(WDAC.GetStringValue(Query.ExecuteScalar(
|
||||
@"SELECT BPCPY FROM BPRJ B
|
||||
INNER JOIN BPAA C ON B.BPPNM=C.BPPNM
|
||||
WHERE C.BPPYN='" + 專案編號 + "'"))); ;
|
||||
|
||||
客戶名稱 = WDAC.GetStringValue(Query.ExecuteScalar(
|
||||
@"SELECT BCNAM FROM BCUS A
|
||||
INNER JOIN BPRJ B ON A.BCNUM=B.BPNUM
|
||||
INNER JOIN BPAA C ON B.BPPNM=C.BPPNM
|
||||
WHERE C.BPPYN='" + 專案編號 + "'"));
|
||||
|
||||
string[] tmp = ddlReportSelect.SelectedValue.Split(',');
|
||||
reportName = tmp[0];
|
||||
dataFileName = tmp[1];
|
||||
reportTitle = tmp[2];
|
||||
|
||||
bool hasData = false;
|
||||
switch (dataFileName)
|
||||
{
|
||||
case "RPAR": // 差勤月報表
|
||||
hasData = Get月差勤表資料();
|
||||
break;
|
||||
case "RPAR_0": // 請假申請單
|
||||
hasData = Get出勤資料("請假");
|
||||
break;
|
||||
case "RPAR_1": // 加班申請單, 加班費印領清冊
|
||||
hasData = Get出勤資料("加班");
|
||||
if (reportName == "RPAR_CARD_06")
|
||||
hasData = reportData.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").Length > 0;
|
||||
break;
|
||||
case "RPAR_3": // 公差申請單
|
||||
hasData = Get出勤資料("公差");
|
||||
break;
|
||||
case "RPAR_31": // 差旅費報告單
|
||||
hasData = Get出勤資料("差旅費");
|
||||
Get出差費用資料();
|
||||
break;
|
||||
}
|
||||
|
||||
if (hasData)
|
||||
{
|
||||
Do月差勤表(reportTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvMessage.IsValid = false;
|
||||
cvMessage.ErrorMessage = "無符合條件的資料";
|
||||
}
|
||||
}
|
||||
|
||||
private void Do月差勤表(string 類別)
|
||||
{
|
||||
ExcelReportBase 報表 = null;
|
||||
bool 以時分顯示時數 = true;
|
||||
|
||||
switch (類別)
|
||||
{
|
||||
case "差勤月報表":
|
||||
報表 = new 差勤月報表();
|
||||
break;
|
||||
case "請假申請單":
|
||||
報表 = new 請假申請單();
|
||||
以時分顯示時數 = false;
|
||||
break;
|
||||
case "加班申請單":
|
||||
報表 = new 加班申請單();
|
||||
break;
|
||||
case "公差申請單":
|
||||
報表 = new 出差申請單();
|
||||
break;
|
||||
case "差旅費報告單":
|
||||
報表 = new 支出憑證黏存單();
|
||||
break;
|
||||
case "加班費印領清冊":
|
||||
報表 = new 加班費印領清冊();
|
||||
break;
|
||||
}
|
||||
|
||||
if (報表 == null)
|
||||
return;
|
||||
|
||||
報表.資料來源.Tables.Add(reportData);
|
||||
if (reportData1 != null)
|
||||
報表.資料來源.Tables.Add(reportData1);
|
||||
報表.報表時間 = aYYMM;
|
||||
報表.公司名稱 = 公司名稱;
|
||||
報表.客戶名稱 = 客戶名稱;
|
||||
報表.專案名稱 = 專案名稱;
|
||||
報表.專案編號 = 專案編號;
|
||||
報表.以時分顯示時數 = 以時分顯示時數 || new GetData(Query).GetOverTimeToMinutes(專案編號);
|
||||
|
||||
MemoryStream ms = 報表.產生報表();
|
||||
ResponseWriteFile(ms, String.Format("{0}_{1}_{2}.xls", UserId, txtYYMM.Text, 類別));
|
||||
}
|
||||
|
||||
protected bool Get月差勤表資料()
|
||||
{
|
||||
DateTime 日期 = aYYMM;
|
||||
DateTime 下月 = aYYMM.AddMonths(1);
|
||||
reportData = new DataTable();
|
||||
reportData.Columns.Add("日期", typeof(DateTime));
|
||||
reportData.Columns.Add("出勤別", typeof(String));
|
||||
reportData.Columns.Add("員編", typeof(String));
|
||||
reportData.Columns.Add("單位", typeof(String));
|
||||
reportData.Columns.Add("職稱", typeof(String));
|
||||
reportData.Columns.Add("姓名", typeof(String));
|
||||
reportData.Columns.Add("上班", typeof(String));
|
||||
reportData.Columns.Add("下班", typeof(String));
|
||||
reportData.Columns.Add("請假", typeof(String));
|
||||
reportData.Columns.Add("加班", typeof(String));
|
||||
reportData.Columns.Add("公差", typeof(String));
|
||||
reportData.Columns.Add("出差外出", typeof(String));
|
||||
reportData.Columns.Add("出差返回", typeof(String));
|
||||
reportData.Columns.Add("班別名稱", typeof(String));
|
||||
reportData.Columns.Add("班別時間", typeof(String));
|
||||
reportData.Columns.Add("出勤異常", typeof(String));
|
||||
|
||||
BatchService batchService = new BatchService();
|
||||
|
||||
while (日期 < 下月)
|
||||
{
|
||||
DataTable 一天資料 = rparDao.Select出勤資料By人員(日期, UserId);
|
||||
bool 要上班 = !bhrdDao.IsHoliday(UserId, 日期);
|
||||
string 出勤別 = 要上班 ? "上班" : "休假";
|
||||
var btmeItem = rtmeDao.SelectBtmeDay(UserId, 日期);
|
||||
foreach (DataRow r in 一天資料.Rows)
|
||||
{
|
||||
DataRow newRow = reportData.NewRow();
|
||||
newRow["日期"] = 日期;
|
||||
newRow["出勤別"] = 出勤別;
|
||||
newRow["員編"] = r["RANUM"];
|
||||
newRow["單位"] = r["單位"];
|
||||
newRow["職稱"] = r["職稱"];
|
||||
newRow["姓名"] = r["BPNME"];
|
||||
newRow["上班"] = r["RCC01"];
|
||||
newRow["下班"] = r["RCC02"];
|
||||
newRow["請假"] = string.Format("{0:#0}:{1:00}", r["請假時數"], r["請假分數"]);
|
||||
newRow["加班"] = string.Format("{0:#0}:{1:00}", r["加班時數"], r["加班分數"]);
|
||||
newRow["公差"] = string.Format("{0:#0}:{1:00}", r["出差時數"], r["出差分數"]);
|
||||
newRow["出差外出"] = r["RCC07"];
|
||||
newRow["出差返回"] = r["RCC08"];
|
||||
newRow["班別名稱"] = btmeItem != null ? btmeItem.BTNME : "";
|
||||
newRow["班別時間"] = btmeItem != null ? string.Format("{0}-{1}", btmeItem.BTSTM, btmeItem.BTETM) : "";
|
||||
var rapyn = BhrdDAC.GetStringValue(r["RAPYN"]);
|
||||
|
||||
if (!rparDao.IsPunchcardNormal(
|
||||
日期
|
||||
, UserId
|
||||
, rapyn
|
||||
, 要上班
|
||||
, WDAC.GetStringValue(r["RCC01"])
|
||||
, WDAC.GetStringValue(r["RCC02"])
|
||||
, WDAC.GetStringValue(r["RCC07"])
|
||||
, WDAC.GetStringValue(r["RCC08"])
|
||||
).正常)
|
||||
{
|
||||
newRow["出勤異常"] = "(出勤異常)";
|
||||
}
|
||||
|
||||
reportData.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
日期 = 日期.AddDays(1);
|
||||
}
|
||||
|
||||
return reportData.Rows.Count > 0;
|
||||
}
|
||||
|
||||
protected bool Get出勤資料(string 類型)
|
||||
{
|
||||
reportData = rparDao.Select報表資料_013By人員(aYYMM, UserId, 類型);
|
||||
return reportData.Rows.Count > 0;
|
||||
}
|
||||
|
||||
protected void Get出差費用資料()
|
||||
{
|
||||
reportData1 = new DataTable();
|
||||
reportData1.Columns.Add("單號", typeof(String));
|
||||
reportData1.Columns.Add("項次", typeof(Int32));
|
||||
reportData1.Columns.Add("日期", typeof(DateTime));
|
||||
reportData1.Columns.Add("起地點", typeof(String));
|
||||
reportData1.Columns.Add("迄地點", typeof(String));
|
||||
reportData1.Columns.Add("工作摘要", typeof(String));
|
||||
reportData1.Columns.Add("捷運", typeof(Int32));
|
||||
reportData1.Columns.Add("汽車", typeof(Int32));
|
||||
reportData1.Columns.Add("火車", typeof(Int32));
|
||||
reportData1.Columns.Add("高鐵", typeof(Int32));
|
||||
reportData1.Columns.Add("飛機", typeof(Int32));
|
||||
reportData1.Columns.Add("住宿費", typeof(Int32));
|
||||
reportData1.Columns.Add("過路費", typeof(Int32));
|
||||
reportData1.Columns.Add("雜費", typeof(Int32));
|
||||
reportData1.Columns.Add("總計", typeof(Int32));
|
||||
reportData1.Columns.Add("單據號數", typeof(String));
|
||||
reportData1.Columns.Add("備註", typeof(String));
|
||||
|
||||
foreach (DataRow r1 in reportData.Rows)
|
||||
{
|
||||
DataTable t2 = rpadDao.SelectRpar(WDAC.GetStringValue(r1["RPREN"]));
|
||||
foreach (DataRow r2 in t2.Rows)
|
||||
{
|
||||
DataRow newRow = reportData1.NewRow();
|
||||
newRow["單號"] = r2["RPREN"];
|
||||
newRow["項次"] = r2["RPITM"];
|
||||
newRow["日期"] = r2["RPDAT"];
|
||||
newRow["起地點"] = r2["RPSTP"];
|
||||
newRow["迄地點"] = r2["RPEDP"];
|
||||
newRow["工作摘要"] = r1["RPRSN"];
|
||||
newRow["捷運"] = r2["RPF03"];
|
||||
newRow["汽車"] = r2["RPF01"];
|
||||
newRow["火車"] = r2["RPF02"];
|
||||
newRow["高鐵"] = r2["RPF04"];
|
||||
newRow["飛機"] = r2["RPF07"];
|
||||
newRow["住宿費"] = r2["RPF05"];
|
||||
newRow["過路費"] = r2["RPF08"];
|
||||
newRow["雜費"] = r2["RPF06"];
|
||||
newRow["總計"] = r2["RPSUM"];
|
||||
newRow["單據號數"] = r2["RPVCH"];
|
||||
newRow["備註"] = r2["RPDOC"];
|
||||
|
||||
reportData1.Rows.Add(newRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user