chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Transactions;
|
||||
using WebLib;
|
||||
|
||||
namespace Education.Forms.辦訓狀況
|
||||
{
|
||||
public partial class 學員出席登錄 : FormBase
|
||||
{
|
||||
private DAC_學員出席 Dao學員出席;
|
||||
|
||||
protected void Page_Init(object sender, EventArgs e)
|
||||
{
|
||||
Dao學員出席 = new DAC_學員出席(conn);
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
FunctionName = "學員出席登錄";
|
||||
|
||||
if (IsPostBack)
|
||||
{
|
||||
gv學員.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected void btn查詢_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (訓練企劃搜尋.訓練企劃編號 == 0)
|
||||
{
|
||||
Panel1.Visible = false;
|
||||
lbMessage.Text = "請選擇課程企劃";
|
||||
return;
|
||||
}
|
||||
|
||||
Panel1.Visible = true;
|
||||
ddl計畫.DataBind();
|
||||
gv學員.DataBind();
|
||||
}
|
||||
|
||||
protected void btn查詢學員_Click(object sender, EventArgs e)
|
||||
{
|
||||
gv學員.DataBind();
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridView gv出席狀況;
|
||||
RadioButtonList rb出席狀況;
|
||||
TextBox txt請假原因;
|
||||
|
||||
學員出席List values = new 學員出席List();
|
||||
|
||||
// 檢查是否有請假原因沒有填寫的
|
||||
bool valid = true;
|
||||
foreach (GridViewRow r in gv學員.Rows)
|
||||
{
|
||||
if (r.RowType != DataControlRowType.DataRow)
|
||||
continue;
|
||||
|
||||
gv出席狀況 = FindControl<GridView>(r.Cells[4], "gv出席狀況");
|
||||
|
||||
if (gv出席狀況 != null)
|
||||
{
|
||||
foreach (GridViewRow r1 in gv出席狀況.Rows)
|
||||
{
|
||||
if (r1.RowType != DataControlRowType.DataRow)
|
||||
continue;
|
||||
|
||||
rb出席狀況 = FindControl<RadioButtonList>(r1.Cells[1], "rb出席狀況");
|
||||
txt請假原因 = FindControl<TextBox>(r1.Cells[1], "txt請假原因");
|
||||
|
||||
if (rb出席狀況.SelectedValue == "")
|
||||
{
|
||||
valid = false;
|
||||
FindControl<ITextControl>(r1.Cells[1], "lbMessage").Text = "請選擇出席狀況";
|
||||
}
|
||||
else if (rb出席狀況.SelectedValue == "L" && txt請假原因.Text.Trim().Length == 0)
|
||||
{
|
||||
valid = false;
|
||||
FindControl<ITextControl>(r1.Cells[1], "lbMessage").Text = "請填寫請假原因";
|
||||
}
|
||||
else
|
||||
{
|
||||
values.Add(new 學員出席()
|
||||
{
|
||||
訓練課程編號 = 訓練企劃搜尋.訓練企劃編號,
|
||||
課程日期 = DAC.GetDateTime(r1.Cells[0].Text),
|
||||
學員編號 = r.Cells[0].Text,
|
||||
出席狀況 = rb出席狀況.SelectedValue,
|
||||
請假事由 = txt請假原因.Text
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
{
|
||||
lbMessage2.Text = "有部份填寫不完全,請填寫完全之後再確定儲存!";
|
||||
lbMessage3.Text = "有部份填寫不完全,請填寫完全之後再確定儲存!";
|
||||
return;
|
||||
}
|
||||
|
||||
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
|
||||
{
|
||||
foreach (學員出席 item in values)
|
||||
{
|
||||
Dao學員出席.Update(item);
|
||||
}
|
||||
ts.Complete();
|
||||
}
|
||||
|
||||
lbMessage2.Text = "儲存完畢!";
|
||||
lbMessage3.Text = "儲存完畢!";
|
||||
|
||||
/*
|
||||
foreach (GridViewRow r in gv學員.Rows)
|
||||
{
|
||||
if (r.RowType != DataControlRowType.DataRow)
|
||||
continue;
|
||||
|
||||
學員編號 = r.Cells[0].Text;
|
||||
rb出席狀況 = FindControl<RadioButtonList>(r.Cells[4], "rb出席狀況");
|
||||
txt請假原因 = FindControl<TextBox>(r.Cells[4], "txt請假原因");
|
||||
|
||||
Dao課程報名.Update出席狀況(學員編號, DAC.GetInt32(ddl課程企劃.SelectedValue), rb出席狀況.SelectedValue, txt請假原因.Text, UserId);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected void ds已上課_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao訓練課程企劃;
|
||||
}
|
||||
|
||||
protected void ds報名學員_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao課程報名;
|
||||
}
|
||||
|
||||
protected void gv出席狀況_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if (e.Row.RowType != DataControlRowType.DataRow)
|
||||
return;
|
||||
|
||||
RadioButtonList rb出席狀況 = FindControl<RadioButtonList>(e.Row.Cells[1], "rb出席狀況");
|
||||
rb出席狀況.Items[0].Attributes["style"] = "display:none";
|
||||
TextBox txt請假原因 = FindControl<TextBox>(e.Row.Cells[1], "txt請假原因");
|
||||
|
||||
string 學員編號 = DAC.GetString((((sender as Control).Parent.Parent as GridViewRow).DataItem as System.Data.DataRowView)[0]);
|
||||
int 訓練課程編號 = 訓練企劃搜尋.訓練企劃編號;
|
||||
DateTime 課程日期 = DAC.GetDateTime(e.Row.DataItem).Date;
|
||||
|
||||
學員出席List d = Dao學員出席.SelectOne(學員編號, 訓練課程編號, 課程日期);
|
||||
|
||||
if (d.Count > 0)
|
||||
{
|
||||
rb出席狀況.SelectedValue = d[0].出席狀況;
|
||||
txt請假原因.Text = d[0].請假事由;
|
||||
}
|
||||
else
|
||||
{
|
||||
rb出席狀況.SelectedValue = "";
|
||||
txt請假原因.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user