chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,212 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.IO;
|
||||
using WebLib;
|
||||
|
||||
namespace Education.Forms.辦訓前置作業
|
||||
{
|
||||
public partial class 學員行前通知 : FormBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
FunctionName = "學員行前通知";
|
||||
|
||||
if (IsPostBack)
|
||||
{
|
||||
gv學員.DataBind();
|
||||
}
|
||||
|
||||
RegisterPostbackTrigger(btn發送);
|
||||
}
|
||||
|
||||
protected void btn查詢_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (訓練企劃搜尋.訓練企劃編號 == 0)
|
||||
{
|
||||
Panel1.Visible = false;
|
||||
lbMessage.Text = "請選擇課程企劃";
|
||||
return;
|
||||
}
|
||||
|
||||
Get課程資料();
|
||||
ddl計畫.DataBind();
|
||||
}
|
||||
|
||||
protected void btn查詢學員_Click(object sender, EventArgs e)
|
||||
{
|
||||
gv學員.DataBind();
|
||||
}
|
||||
|
||||
protected void gv學員_DataBound(object sender, EventArgs e)
|
||||
{
|
||||
btn全選.Visible = gv學員.Rows.Count > 0;
|
||||
btn不選.Visible = btn全選.Visible;
|
||||
btn發送.Visible = btn全選.Visible;
|
||||
|
||||
SetSelected(true, true);
|
||||
}
|
||||
|
||||
private void Get課程資料()
|
||||
{
|
||||
int 課程企劃id = 訓練企劃搜尋.訓練企劃編號;
|
||||
訓練課程企劃List 訓練課程企劃 = Dao訓練課程企劃.SelectOne(課程企劃id);
|
||||
|
||||
if (訓練課程企劃.Count > 0)
|
||||
{
|
||||
txt聯絡人.Text = Dao員工.Get員工姓名(訓練課程企劃[0].承辦);
|
||||
txt聯絡人電話.Text = Dao員工.Get公司電話(訓練課程企劃[0].承辦);
|
||||
txt聯絡人email.Text = Dao員工.Get電子郵件(訓練課程企劃[0].承辦);
|
||||
|
||||
Panel1.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSelected(bool selected, bool 跳過已寄送過 = false)
|
||||
{
|
||||
foreach (GridViewRow row in gv學員.Rows)
|
||||
{
|
||||
if (row.RowType != DataControlRowType.DataRow)
|
||||
continue;
|
||||
|
||||
CheckBox cb = FindControl<CheckBox>(row.Cells[0], "cb寄送");
|
||||
HiddenField hf = FindControl<HiddenField>(row.Cells[3], "hf通知發送狀態");
|
||||
|
||||
if (cb == null || hf == null)
|
||||
continue;
|
||||
|
||||
cb.Checked = selected;
|
||||
if (selected && 跳過已寄送過 && hf.Value == "Y")
|
||||
cb.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void btn全選_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetSelected(true);
|
||||
}
|
||||
|
||||
protected void btn不選_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetSelected(false);
|
||||
}
|
||||
|
||||
protected void btn發送_Click(object sender, EventArgs e)
|
||||
{
|
||||
int 課程企劃id = 訓練企劃搜尋.訓練企劃編號;
|
||||
發送郵件 發送郵件 = new 發送郵件();
|
||||
發送郵件.Context = this.Context;
|
||||
|
||||
訓練課程企劃List 訓練課程企劃 = Dao訓練課程企劃.SelectOne(課程企劃id);
|
||||
|
||||
DAC_訓練課程內容 Dao訓練課程內容 = new DAC_訓練課程內容(conn);
|
||||
訓練課程內容List 課程內容 = Dao訓練課程內容.SelectBy課程企劃(課程企劃id);
|
||||
|
||||
string 場地名稱 = GetData.取得選定場地(課程企劃id).場地名稱;
|
||||
string 公司名稱 = new DAC_公司別().GetName(CompanyId);
|
||||
|
||||
DAC_講師遴選 Dao講師遴選 = new DAC_講師遴選(conn);
|
||||
|
||||
// 拿課程類別來存放講師姓名
|
||||
foreach (訓練課程內容 item in 課程內容)
|
||||
{
|
||||
item.課程類別 = GetData.取得選定講師(item.訓練課程企劃編號, item.課程序號).姓名;
|
||||
}
|
||||
|
||||
// 檢查是否有勾選
|
||||
bool hasChecked = false;
|
||||
foreach (GridViewRow row in gv學員.Rows)
|
||||
{
|
||||
if (row.RowType != DataControlRowType.DataRow)
|
||||
continue;
|
||||
CheckBox cb寄送 = FindControl<CheckBox>(row.Cells[0], "cb寄送");
|
||||
if (cb寄送 == null || !cb寄送.Checked)
|
||||
continue;
|
||||
hasChecked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasChecked)
|
||||
{
|
||||
ClientShowMessage("請勾選要發送行前通知的學員");
|
||||
return;
|
||||
}
|
||||
|
||||
// 發送學員通知
|
||||
foreach (GridViewRow row in gv學員.Rows)
|
||||
{
|
||||
if (row.RowType != DataControlRowType.DataRow)
|
||||
continue;
|
||||
|
||||
CheckBox cb寄送 = FindControl<CheckBox>(row.Cells[0], "cb寄送");
|
||||
Label 姓名 = FindControl<Label>(row.Cells[1], "lb學員姓名");
|
||||
HiddenField 學員編號 = FindControl<HiddenField>(row.Cells[1], "hf學員編號");
|
||||
TextBox 電子郵件 = FindControl<TextBox>(row.Cells[1], "txt電子郵件");
|
||||
|
||||
if (cb寄送 == null)
|
||||
continue;
|
||||
|
||||
if (cb寄送.Checked)
|
||||
{
|
||||
// 發送行前通知郵件
|
||||
if (fuAttach.HasFile)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.Write(fuAttach.FileBytes, 0, fuAttach.FileBytes.Length);
|
||||
ms.Position = 0;
|
||||
|
||||
發送郵件.發送學員行前通知郵件(姓名.Text, 電子郵件.Text,
|
||||
txt聯絡人.Text, txt聯絡人電話.Text, txt聯絡人email.Text, 公司名稱,
|
||||
訓練課程企劃[0].訓練日期, 訓練課程企劃[0].訓練日期迄, 訓練課程企劃[0].訓練名稱, 場地名稱,
|
||||
訓練課程企劃[0].訓練時數, 課程內容, fuAttach.FileName, ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
發送郵件.發送學員行前通知郵件(姓名.Text, 電子郵件.Text,
|
||||
txt聯絡人.Text, txt聯絡人電話.Text, txt聯絡人email.Text, 公司名稱,
|
||||
訓練課程企劃[0].訓練日期, 訓練課程企劃[0].訓練日期迄, 訓練課程企劃[0].訓練名稱, 場地名稱,
|
||||
訓練課程企劃[0].訓練時數, 課程內容, "", null);
|
||||
}
|
||||
|
||||
// 標記已發送
|
||||
Dao課程報名.標記已發送學員通知(學員編號.Value, 課程企劃id, UserId);
|
||||
}
|
||||
}
|
||||
|
||||
// 發送一份給承辦人存查
|
||||
if (fuAttach.HasFile)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.Write(fuAttach.FileBytes, 0, fuAttach.FileBytes.Length);
|
||||
ms.Position = 0;
|
||||
|
||||
發送郵件.發送學員行前通知郵件(txt聯絡人.Text, txt聯絡人email.Text,
|
||||
txt聯絡人.Text, txt聯絡人電話.Text, txt聯絡人email.Text, 公司名稱,
|
||||
訓練課程企劃[0].訓練日期, 訓練課程企劃[0].訓練日期迄, 訓練課程企劃[0].訓練名稱, 場地名稱,
|
||||
訓練課程企劃[0].訓練時數, 課程內容, fuAttach.FileName, ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
發送郵件.發送學員行前通知郵件(txt聯絡人.Text, txt聯絡人email.Text,
|
||||
txt聯絡人.Text, txt聯絡人電話.Text, txt聯絡人email.Text, 公司名稱,
|
||||
訓練課程企劃[0].訓練日期, 訓練課程企劃[0].訓練日期迄, 訓練課程企劃[0].訓練名稱,
|
||||
場地名稱, 訓練課程企劃[0].訓練時數, 課程內容, "", null);
|
||||
}
|
||||
gv學員.DataBind();
|
||||
ClientShowMessage("學員行前通知發送完畢");
|
||||
}
|
||||
|
||||
protected void ds已截止未上課_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao訓練課程企劃;
|
||||
}
|
||||
|
||||
protected void ds報名學員_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao課程報名;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user