chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
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.Text;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// 獎金發放作業
|
||||
/// </summary>
|
||||
public partial class forms_worker_fmBonus : Wellan.Web.UI.WUserControlBase
|
||||
{
|
||||
protected DateTime _YYMM;
|
||||
protected string _SSENO = "";
|
||||
protected string _SSPYN = "";
|
||||
protected int _BonusTimes = 0;
|
||||
|
||||
private List<forms_worker_ucBonusInput> inputCtrls = new List<forms_worker_ucBonusInput>();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
_SSENO = GetStringViewState("RSENO");
|
||||
_SSPYN = GetStringViewState("RSPYN");
|
||||
_YYMM = GetDateTimeViewState("YYMM");
|
||||
_BonusTimes = GetIntViewState("BonusTimes");
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
// 讀取稅額起點
|
||||
txtTaxBegin.Text = WGuard1.WSetR(Query, "UNBONUSTAXFREE", 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
dsSSMS_SSENO.ConnectionString = ConnectionString;
|
||||
dsSSMS_SSENO.SelectCommand =
|
||||
@"IF @RSPYN<> '000000001'
|
||||
BEGIN
|
||||
SELECT DISTINCT A.BPENO, A.BPNME
|
||||
FROM BPSNView A INNER JOIN RASN B ON A.BPENO = B.RANUM
|
||||
WHERE B.RAPYN = @RSPYN
|
||||
ORDER BY A.BPENO
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SELECT DISTINCT BPENO, BPNME, BPSDY, BPEDY FROM BPSNView
|
||||
WHERE((BPSDY <= @YYMM1 AND BPEDY >= @YYMM2)
|
||||
OR(BPSDY <= @YYMM1 AND BPEDY IS NULL)
|
||||
OR(BPSDY <= @YYMM1 AND BPEDY >= @YYMM1 AND BPEDY <= @YYMM2)
|
||||
OR(BPSDY >= @YYMM1 AND BPSDY <= @YYMM2 AND BPEDY >= @YYMM2)
|
||||
OR(BPSDY >= @YYMM1 AND BPSDY <= @YYMM2 AND BPEDY IS NULL)
|
||||
OR(BPSDY >= @YYMM1 AND BPSDY <= @YYMM2 AND BPEDY >= @YYMM1 AND BPEDY <= @YYMM2))
|
||||
AND BPENO NOT IN
|
||||
(SELECT RANUM FROM RASN
|
||||
WHERE ((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 BPENO
|
||||
END";
|
||||
|
||||
ListItem item = ddlSSPYN.Items.FindByValue(_SSPYN);
|
||||
if (item != null)
|
||||
item.Selected = true;
|
||||
|
||||
GetRsenoDropDownData();
|
||||
}
|
||||
|
||||
private void GetRsenoDropDownData()
|
||||
{
|
||||
if (_YYMM.Ticks != 0)
|
||||
{
|
||||
dsSSMS_SSENO.SelectParameters["RSPYN"].DefaultValue = _SSPYN;
|
||||
dsSSMS_SSENO.SelectParameters["YYMM1"].DefaultValue = WGuard1.GetMonthBegin(_YYMM, -1).ToString("yyyy/MM/dd", WGuard1.InvariantCulture); // 上個月月初日
|
||||
dsSSMS_SSENO.SelectParameters["YYMM2"].DefaultValue = WGuard1.GetMonthEnd(_YYMM, 1).ToString("yyyy/MM/dd", WGuard1.InvariantCulture); // 本月月底日
|
||||
}
|
||||
}
|
||||
|
||||
protected new bool CheckInput(System.Collections.Specialized.IOrderedDictionary values)
|
||||
{
|
||||
cvMessage.ErrorMessage = "";
|
||||
cvMessage.IsValid = true;
|
||||
|
||||
bool result = true;
|
||||
values["RSYMM"] = CheckDate(values["RSYMM"] + "01", "請輸入正確的年月", ref result, cvMessage);
|
||||
|
||||
ProcessCustomValidatorMessage(cvMessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!cvTaxRate.IsValid)
|
||||
return;
|
||||
|
||||
string sspyn = ddlSSPYN.SelectedValue;
|
||||
ViewState["SSPYN"] = sspyn;
|
||||
ViewState["BonusTimes"] = Convert.ToInt32(ddlBonusTimes.SelectedValue);
|
||||
_SSPYN = sspyn;
|
||||
|
||||
// 檢查此使用者是否有權限處理這個專案
|
||||
BprmDAC bprm = new BprmDAC(Query);
|
||||
if (!bprm.GetRight(sspyn, UserId))
|
||||
{
|
||||
DataList1.Visible = false;
|
||||
cvMessage.ErrorMessage = "對不起,你沒有處理這個專案的權限!";
|
||||
cvMessage.IsValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
DataList1.Visible = true;
|
||||
GetRsenoDropDownData();
|
||||
DataList1.DataBind();
|
||||
|
||||
foreach (DataListItem listItem in DataList1.Items)
|
||||
{
|
||||
foreach (Control ctrl in listItem.Controls)
|
||||
{
|
||||
if (ctrl is forms_worker_ucBonusInput)
|
||||
{
|
||||
(ctrl as forms_worker_ucBonusInput).Read(Query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 存檔
|
||||
// 1. 檢查各組輸入
|
||||
bool valid = true;
|
||||
cvMessage.ErrorMessage = "";
|
||||
cvMessage.IsValid = true;
|
||||
|
||||
foreach (DataListItem listItem in DataList1.Items)
|
||||
{
|
||||
foreach (Control ctrl in listItem.Controls)
|
||||
{
|
||||
if (ctrl is forms_worker_ucBonusInput)
|
||||
{
|
||||
valid &= (ctrl as forms_worker_ucBonusInput).CheckInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
{
|
||||
cvMessage.IsValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 存入稅額起點
|
||||
WGuard1.WSetW(Query, "UNBONUSTAXFREE", 1, txtTaxBegin.Text, UserId);
|
||||
|
||||
DbConnection conn = Query.NewConnection(ConnectionString);
|
||||
conn.Open();
|
||||
DbTransaction tran = conn.BeginTransaction();
|
||||
try
|
||||
{
|
||||
foreach (DataListItem listItem in DataList1.Items)
|
||||
{
|
||||
foreach (Control ctrl in listItem.Controls)
|
||||
{
|
||||
if (ctrl is forms_worker_ucBonusInput)
|
||||
{
|
||||
(ctrl as forms_worker_ucBonusInput).Save(tran, Query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tran.Commit();
|
||||
|
||||
cvMessage.ErrorMessage = "存檔完成";
|
||||
cvMessage.IsValid = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
cvMessage.ErrorMessage = ex.Message;
|
||||
cvMessage.IsValid = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
// 重新讀取資料
|
||||
foreach (DataListItem listItem in DataList1.Items)
|
||||
{
|
||||
foreach (Control ctrl in listItem.Controls)
|
||||
{
|
||||
if (ctrl is forms_worker_ucBonusInput)
|
||||
{
|
||||
(ctrl as forms_worker_ucBonusInput).Read(Query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnSSMS_Click(object sender, EventArgs e)
|
||||
{
|
||||
cvMessage.IsValid = true;
|
||||
cvMessage.ErrorMessage = "";
|
||||
bool result = true;
|
||||
DateTime aYYMM = CheckDate(txtYYMM.Text + "01", "請輸入正確的年月", ref result, cvMessage);
|
||||
|
||||
if (result)
|
||||
{
|
||||
ViewState["YYMM"] = aYYMM;
|
||||
_YYMM = aYYMM;
|
||||
ddlSSPYN.DataSource = new BpaaDAC().GetBpaaWithTY(aYYMM.Year);
|
||||
ddlSSPYN.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected void cvTaxRate_ServerValidate(object source, ServerValidateEventArgs args)
|
||||
{
|
||||
if (args.Value.Trim().Length == 0)
|
||||
{
|
||||
(source as CustomValidator).ErrorMessage = "請輸入稅率";
|
||||
args.IsValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
double result;
|
||||
if (!double.TryParse(args.Value, out result) || result < 0 || result > 1)
|
||||
{
|
||||
(source as CustomValidator).ErrorMessage = "請輸入正確的稅率 (0 至 1 之間,輸入 0.06 代表 6%)";
|
||||
args.IsValid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected void cvTxtTaxBegin_ServerValidate(object source, ServerValidateEventArgs args)
|
||||
{
|
||||
if (args.Value.Trim().Length == 0)
|
||||
{
|
||||
(source as CustomValidator).ErrorMessage = "請輸入稅額起徵點";
|
||||
args.IsValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
double result;
|
||||
if (!double.TryParse(args.Value, out result) || result < 0)
|
||||
{
|
||||
(source as CustomValidator).ErrorMessage = "稅額起徵點需大於或等於 0";
|
||||
args.IsValid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user