chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,328 @@
|
||||
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 System.Data.Common;
|
||||
using Wellan.Data;
|
||||
using System.ComponentModel;
|
||||
using Wellan.Common;
|
||||
|
||||
/// <summary>
|
||||
/// 獎金輸入用控制項
|
||||
/// </summary>
|
||||
public partial class forms_worker_ucBonusInput : Wellan.Web.UI.WUserControlBase
|
||||
{
|
||||
private bool _isHeader = true;
|
||||
private DbCommand cmdReadRasn;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsHeader
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isHeader;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isHeader = value;
|
||||
if (_isHeader)
|
||||
MultiView1.ActiveViewIndex = 1;
|
||||
else
|
||||
MultiView1.ActiveViewIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 員工編號
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string Sseno
|
||||
{
|
||||
get
|
||||
{
|
||||
return lbSSENO.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
lbSSENO.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 員工姓名
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string SsenoName
|
||||
{
|
||||
get
|
||||
{
|
||||
return lbSSENOX.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
lbSSENOX.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 獎金年月
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string Yymm
|
||||
{
|
||||
get
|
||||
{
|
||||
return hfYymm.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
hfYymm.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 年度專案編號
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string Sspyn
|
||||
{
|
||||
get
|
||||
{
|
||||
return hfSspyn.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
hfSspyn.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 稅率
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string TaxRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return hfTaxRate.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
hfTaxRate.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 獎金次數
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string BonusTimes
|
||||
{
|
||||
get
|
||||
{
|
||||
return hfBonusTimes.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
hfBonusTimes.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 備註
|
||||
/// </summary>
|
||||
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
||||
public string Memo
|
||||
{
|
||||
get
|
||||
{
|
||||
return txtSSC07.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
txtSSC07.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime YyMm
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToDateTime(hfYymm.Value).AddDays(Convert.ToInt32(hfBonusTimes.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(WQuery query)
|
||||
{
|
||||
this.Query = query;
|
||||
SsmsDAC ssmsDao = new SsmsDAC(Query);
|
||||
SsmsRecord ssmsRec = ssmsDao.SelectOne(null, YyMm, lbSSENO.Text, hfSspyn.Value, "001");
|
||||
|
||||
if (ssmsRec != null)
|
||||
{
|
||||
txtSSP13.Text = ssmsRec.SSP13.ToString("#########0");
|
||||
lbSSS03.Text = ssmsRec.SSS03.ToString("#########0");
|
||||
lbSSTOT.Text = (ssmsRec.SSP13 - ssmsRec.SSS03).ToString("#########0");
|
||||
string[] values = ssmsRec.SSC07.Split('|');
|
||||
if (values.Length > 1)
|
||||
txtSSC07.Text = values[1];
|
||||
else
|
||||
txtSSC07.Text = "";
|
||||
hfOldSSP13.Value = ssmsRec.SSP13.ToString("#########0");
|
||||
}
|
||||
else
|
||||
{
|
||||
txtSSP13.Text = "";
|
||||
lbSSS03.Text = "";
|
||||
lbSSTOT.Text = "";
|
||||
txtSSC07.Text = "";
|
||||
hfOldSSP13.Value = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected void GetRasnData(DbTransaction tran, string sseno, out string ssjno, out string sscno, out string ssbrh)
|
||||
{
|
||||
if (cmdReadRasn == null)
|
||||
{
|
||||
cmdReadRasn = Query.NewCommand(
|
||||
@"SELECT A.RANUM, A.RAJNO, A.RACNO, A.RABRH
|
||||
FROM RASN A
|
||||
INNER JOIN BPJB B ON A.RAPYN=B.BPPYN AND A.RAJNO=B.BPJNO AND A.RACNO=B.BPCNO
|
||||
WHERE A.RAPYN = @BPPYN AND A.RANUM=@RANUM
|
||||
AND ((A.RASDT <= @YYMM1 AND A.RAEDT >= @YYMM2)
|
||||
OR (A.RASDT <= @YYMM1 AND A.RAEDT IS NULL)
|
||||
OR (A.RASDT <= @YYMM1 AND A.RAEDT >= @YYMM1 AND A.RAEDT <= @YYMM2)
|
||||
OR (A.RASDT >= @YYMM1 AND A.RASDT <= @YYMM2 AND A.RAEDT >= @YYMM2)
|
||||
OR (A.RASDT >= @YYMM1 AND A.RASDT <= @YYMM2 AND A.RAEDT IS NULL)
|
||||
OR (A.RASDT >= @YYMM1 AND A.RASDT <= @YYMM2 AND A.RAEDT >= @YYMM1 AND A.RAEDT <= @YYMM2))
|
||||
ORDER BY A.RANUM");
|
||||
cmdReadRasn.Parameters.Add(Query.NewParameter("BPPYN", hfSspyn.Value));
|
||||
cmdReadRasn.Parameters.Add(Query.NewParameter("RANUM", DbType.String));
|
||||
cmdReadRasn.Parameters.Add(Query.NewParameter("YYMM1", WGuard1.GetMonthBegin(Convert.ToDateTime(hfYymm.Value), 0)));
|
||||
cmdReadRasn.Parameters.Add(Query.NewParameter("YYMM2", WGuard1.GetMonthEnd(Convert.ToDateTime(hfYymm.Value), 0)));
|
||||
}
|
||||
|
||||
cmdReadRasn.Parameters["RANUM"].Value = sseno;
|
||||
DataTable rasn;
|
||||
|
||||
if (tran != null)
|
||||
{
|
||||
cmdReadRasn.Connection = tran.Connection;
|
||||
cmdReadRasn.Transaction = tran;
|
||||
rasn = Query.Select(tran.Connection, cmdReadRasn);
|
||||
}
|
||||
else
|
||||
{
|
||||
rasn = Query.Select(cmdReadRasn);
|
||||
}
|
||||
|
||||
if (rasn.Rows.Count > 0)
|
||||
{
|
||||
ssjno = rasn.Rows[0]["RAJNO"].ToString();
|
||||
sscno = rasn.Rows[0]["RACNO"].ToString();
|
||||
ssbrh = rasn.Rows[0]["RABRH"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ssjno = "";
|
||||
sscno = "";
|
||||
ssbrh = "";
|
||||
}
|
||||
}
|
||||
|
||||
// 計算所得稅,若小於 WSetR(Query, "UNBONUSTAXFREE", 1) 的設定,則免稅
|
||||
private int CalculateTax(int amt)
|
||||
{
|
||||
double taxRate = Convert.ToDouble(hfTaxRate.Value);
|
||||
string s = WGuard1.WSetR(Query, "UNBONUSTAXFREE", 1).Trim();
|
||||
int taxFreeBoundry;
|
||||
|
||||
if (s.Length == 0)
|
||||
taxFreeBoundry = 2000;
|
||||
else
|
||||
taxFreeBoundry = Convert.ToInt32(s);
|
||||
|
||||
/* 原先使用稅額小於 taxFreeBoundry 才免稅,改成金額小於 taxFreeBoundry 免稅
|
||||
int tax = Convert.ToInt32(Math.Round(amt * taxRate, 0, MidpointRounding.AwayFromZero));
|
||||
if (tax < taxFreeBoundry)
|
||||
return 0;
|
||||
else
|
||||
return tax;
|
||||
*/
|
||||
|
||||
if (amt <= taxFreeBoundry)
|
||||
return 0;
|
||||
else
|
||||
return Convert.ToInt32(Math.Round(amt * taxRate, 0, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
public void Save(DbTransaction tran, WQuery query)
|
||||
{
|
||||
this.Query = query;
|
||||
DateTime aYymm = YyMm;
|
||||
SsmsDAC ssmsDao = new SsmsDAC(Query);
|
||||
SsmsRecord ssmsRec;
|
||||
|
||||
// 新增
|
||||
if (hfOldSSP13.Value.Length == 0 && txtSSP13.Text.Trim().Length > 0)
|
||||
{
|
||||
ssmsRec = new SsmsRecord();
|
||||
ssmsRec.SSPYN = hfSspyn.Value;
|
||||
ssmsRec.SSENO = lbSSENO.Text;
|
||||
ssmsRec.SSYMM = aYymm;
|
||||
ssmsRec.SSP13 = Convert.ToInt32(txtSSP13.Text.Trim());
|
||||
ssmsRec.SSS03 = CalculateTax(ssmsRec.SSP13);
|
||||
ssmsRec.SSC07 = hfTaxRate.Value + "|" + txtSSC07.Text;
|
||||
ssmsDao.InsertOne(tran, ssmsRec);
|
||||
}
|
||||
// 更正
|
||||
else if (hfOldSSP13.Value.Length > 0 && txtSSP13.Text.Trim().Length > 0)
|
||||
{
|
||||
ssmsRec = new SsmsRecord();
|
||||
ssmsRec.SSPYN = hfSspyn.Value;
|
||||
ssmsRec.SSENO = lbSSENO.Text;
|
||||
ssmsRec.SSYMM = aYymm;
|
||||
ssmsRec.SSITM = "001";
|
||||
ssmsRec.SSP13 = Convert.ToInt32(txtSSP13.Text.Trim());
|
||||
ssmsRec.SSS03 = CalculateTax(ssmsRec.SSP13);
|
||||
ssmsRec.SSC07 = hfTaxRate.Value + "|" + txtSSC07.Text;
|
||||
ssmsDao.UpdateOne(tran, ssmsRec);
|
||||
}
|
||||
// 刪除
|
||||
else if (hfOldSSP13.Value.Length > 0 && txtSSP13.Text.Trim().Length == 0)
|
||||
{
|
||||
ssmsDao.DeleteOne(tran, aYymm, lbSSENO.Text, hfSspyn.Value, "001");
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckInput()
|
||||
{
|
||||
lbMessage.Visible = false;
|
||||
lbMessage.Text = "";
|
||||
|
||||
if (txtSSP13.Text.Trim().Length > 0)
|
||||
{
|
||||
int i;
|
||||
if (!int.TryParse(txtSSP13.Text.Trim(), out i))
|
||||
{
|
||||
lbMessage.Visible = true;
|
||||
lbMessage.Text = "請輸入正確的金額";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user