chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
public partial class forms_basedata_fmRTME : Wellan.Web.UI.WUserControlBase
|
||||
{
|
||||
private BtmeDAC Btme;
|
||||
private RtmeDAC Rtme;
|
||||
private BhrdDAC Bhrd;
|
||||
private List<BtmeItem> BtmeList;
|
||||
private List<RtmeItem> RtmeList;
|
||||
private string monthBhrd;
|
||||
private string[] holidayData = null;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Btme = new BtmeDAC(Query);
|
||||
Rtme = new RtmeDAC(Query);
|
||||
Bhrd = new BhrdDAC(Query);
|
||||
|
||||
if (txtYear.Text == "")
|
||||
{
|
||||
txtYear.Text = DateTime.UtcNow.AddHours(8).ToString("yyyy");
|
||||
ddlMonth.SelectedValue = DateTime.UtcNow.AddHours(8).ToString("MM");
|
||||
Calendar1.VisibleDate = DateTime.UtcNow.AddHours(8).Date;
|
||||
StoreYYMM();
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreYYMM()
|
||||
{
|
||||
hfYear.Value = Calendar1.VisibleDate.ToString("yyyy", WGuard1.InvariantCulture);
|
||||
hfMonth.Value = Calendar1.VisibleDate.ToString("MM");
|
||||
}
|
||||
|
||||
protected void btnGoto_Click(object sender, EventArgs e)
|
||||
{
|
||||
Calendar1.VisibleDate = Convert.ToDateTime(txtYear.Text + "/" + ddlMonth.SelectedValue + "/01");
|
||||
StoreYYMM();
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 1; i <= 31; i++)
|
||||
{
|
||||
if (Request[String.Format("BTME{0:00}", i)] != null)
|
||||
{
|
||||
var rttid = WDAC.GetStringValue(Request[String.Format("BTME{0:00}", i)]);
|
||||
|
||||
Rtme.SetDay(UserId, new DateTime(Convert.ToInt32(hfYear.Value), Convert.ToInt32(hfMonth.Value), i),
|
||||
rttid, UserId);
|
||||
}
|
||||
}
|
||||
|
||||
Calendar1.VisibleDate = Convert.ToDateTime(hfYear.Value + "/" + hfMonth.Value + "/01", WGuard1.InvariantCulture);
|
||||
}
|
||||
|
||||
protected void Calendar1_PreRender(object sender, EventArgs e)
|
||||
{
|
||||
// 取得班表資料
|
||||
BtmeList = Btme.SelectAll();
|
||||
BtmeList.Insert(0, new BtmeItem()
|
||||
{
|
||||
BTTID = "",
|
||||
BTNME = "預設班表",
|
||||
BTSTM = WGuard1.WSetR("UNRPARTIME", 1),
|
||||
BTETM = WGuard1.WSetR("UNRPARTIME", 2),
|
||||
BTRST = WGuard1.WSetR("UNRPARTIME", 3),
|
||||
BTRED = WGuard1.WSetR("UNRPARTIME", 4)
|
||||
});
|
||||
gvBTME.DataSource = BtmeList;
|
||||
gvBTME.DataBind();
|
||||
|
||||
ddBhrd.DataSource = BtmeList;
|
||||
ddBhrd.DataTextField = "BTTID";
|
||||
ddBhrd.DataValueField = "BTTID";
|
||||
ddBhrd.DataBind();
|
||||
|
||||
// 取得員工班表資料
|
||||
RtmeList = Rtme.SelectMonth(UserId, Calendar1.VisibleDate);
|
||||
monthBhrd = Bhrd.GetMonth(Calendar1.VisibleDate.Year, Calendar1.VisibleDate.Month);
|
||||
|
||||
// 取得節假日資料
|
||||
holidayData = new BhrdDAC().GetYear(Calendar1.VisibleDate.Year);
|
||||
}
|
||||
|
||||
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
|
||||
{
|
||||
e.Cell.Style["padding"] = "3px";
|
||||
e.Cell.Style["border"] = "2px solid white";
|
||||
|
||||
// 非本月,結束處理
|
||||
if (e.Day.IsOtherMonth)
|
||||
return;
|
||||
|
||||
// 本月,清除重畫
|
||||
e.Cell.Controls.Clear();
|
||||
Label aLabel = new Label();
|
||||
aLabel.Text = e.Day.Date.Day.ToString();
|
||||
aLabel.Font.Name = "Tahoma";
|
||||
aLabel.Font.Size = new FontUnit("16pt");
|
||||
aLabel.Font.Bold = true;
|
||||
aLabel.ForeColor = System.Drawing.Color.Black;
|
||||
e.Cell.Controls.Add(aLabel);
|
||||
|
||||
// 加入換行的 Literal
|
||||
Literal aBR = new Literal();
|
||||
aBR.Text = "<br/>";
|
||||
e.Cell.Controls.Add(aBR);
|
||||
|
||||
//加入 DropDownList 用以挑選班別
|
||||
DropDownList aDDL = new DropDownList();
|
||||
aDDL.ID = String.Format("BTME{0:00}", e.Day.Date.Day);
|
||||
aDDL.Style.Add("width", "95%");
|
||||
aDDL.Style.Add("top", "2px");
|
||||
aDDL.Style.Add("font-size", "9pt");
|
||||
|
||||
if (monthBhrd == null)
|
||||
{
|
||||
if (!e.Day.IsWeekend)
|
||||
aDDL.CssClass = "NORMAL";
|
||||
}
|
||||
else
|
||||
{
|
||||
var d = monthBhrd.Substring(e.Day.Date.Day - 1, 1);
|
||||
if (d == "-" || d == "B")
|
||||
aDDL.CssClass = "NORMAL";
|
||||
}
|
||||
|
||||
BtmeList.ForEach(btmeItem =>
|
||||
{
|
||||
aDDL.Items.Add(new ListItem(btmeItem.BTTID, btmeItem.BTTID));
|
||||
});
|
||||
|
||||
var rtmeItem = RtmeList.FirstOrDefault(p => p.RTDAT == e.Day.Date);
|
||||
if (rtmeItem != null)
|
||||
{
|
||||
aDDL.SelectedValue = rtmeItem.RTTID;
|
||||
}
|
||||
else
|
||||
{
|
||||
aDDL.SelectedValue = "";
|
||||
}
|
||||
|
||||
e.Cell.Controls.Add(aDDL);
|
||||
|
||||
var dayType = "-";
|
||||
if (holidayData == null)
|
||||
{
|
||||
if (e.Day.IsWeekend)
|
||||
dayType = "H";
|
||||
else
|
||||
dayType = "-";
|
||||
}
|
||||
else
|
||||
{
|
||||
dayType = holidayData[e.Day.Date.Month - 1].Substring(e.Day.Date.Day - 1, 1);
|
||||
}
|
||||
|
||||
switch (dayType)
|
||||
{
|
||||
case "-":
|
||||
e.Cell.BackColor = System.Drawing.Color.White;
|
||||
break;
|
||||
case "H":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0xFF99CC);
|
||||
break;
|
||||
case "B":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0xFFFF99);
|
||||
break;
|
||||
case "N":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0x0099FF);
|
||||
break;
|
||||
case "V":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0xFF9900);
|
||||
break;
|
||||
case "O":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0x99CC00);
|
||||
break;
|
||||
case "T":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0x999999);
|
||||
break;
|
||||
case "E":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0xCC7FFF);
|
||||
break;
|
||||
case "A":
|
||||
e.Cell.BackColor = System.Drawing.Color.FromArgb(0x7FCCFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
|
||||
{
|
||||
txtYear.Text = Calendar1.VisibleDate.ToString("yyyy");
|
||||
ddlMonth.SelectedValue = Calendar1.VisibleDate.ToString("MM");
|
||||
StoreYYMM();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user