208 lines
8.2 KiB
C#
208 lines
8.2 KiB
C#
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
|
|
{
|
|
private DAC_訓練課程內容 Dao訓練課程內容;
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
FunctionName = "講師行前通知";
|
|
Dao訓練課程內容 = new DAC_訓練課程內容(conn);
|
|
|
|
if (IsPostBack)
|
|
{
|
|
gv講師.DataBind();
|
|
}
|
|
|
|
RegisterPostbackTrigger(btn發送);
|
|
}
|
|
|
|
protected void btn查詢_Click(object sender, EventArgs e)
|
|
{
|
|
if (訓練企劃搜尋.訓練企劃編號 == 0)
|
|
{
|
|
Panel1.Visible = false;
|
|
lbMessage.Text = "請選擇課程企劃";
|
|
return;
|
|
}
|
|
|
|
gv講師.DataBind();
|
|
Get課程資料();
|
|
}
|
|
|
|
protected void btn發送_Click(object sender, EventArgs e)
|
|
{
|
|
int 課程企劃id = 訓練企劃搜尋.訓練企劃編號;
|
|
發送郵件 發送郵件 = new 發送郵件();
|
|
發送郵件.Context = this.Context;
|
|
|
|
訓練課程企劃List 訓練課程企劃 = Dao訓練課程企劃.SelectOne(課程企劃id);
|
|
string 場地名稱 = GetData.取得選定場地(課程企劃id).場地名稱;
|
|
|
|
// 檢查是否有勾選
|
|
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要發送");
|
|
HiddenField hf課程序號 = FindControl<HiddenField>(row.Cells[0], "hf課程序號");
|
|
HiddenField hf訓練日期 = FindControl<HiddenField>(row.Cells[0], "hf訓練日期");
|
|
HiddenField hf時間起 = FindControl<HiddenField>(row.Cells[0], "hf時間起");
|
|
HiddenField hf時間迄 = FindControl<HiddenField>(row.Cells[0], "hf時間迄");
|
|
Label lb講師姓名 = FindControl<Label>(row.Cells[1], "lb講師姓名");
|
|
TextBox txt電子郵件 = FindControl<TextBox>(row.Cells[2], "txt電子郵件");
|
|
CheckBox cb酬勞_講師費 = FindControl<CheckBox>(row.Cells[4], "cb酬勞_講師費");
|
|
CheckBox cb酬勞_交通費 = FindControl<CheckBox>(row.Cells[4], "cb酬勞_交通費");
|
|
RadioButtonList rb給付方式 = FindControl<RadioButtonList>(row.Cells[4], "cb給付方式");
|
|
TextBox txt講師費 = FindControl<TextBox>(row.Cells[4], "txt講師費");
|
|
TextBox txt交通費 = FindControl<TextBox>(row.Cells[4], "txt交通費");
|
|
TextBox txt費用合計 = FindControl<TextBox>(row.Cells[4], "txt費用合計");
|
|
DateTextBox txt給付日 = FindControl<DateTextBox>(row.Cells[4], "txt給付日");
|
|
|
|
DateTime 備課時間 = new DateTime();
|
|
try
|
|
{
|
|
備課時間 = new DateTime(2000, 1, 1, DAC.GetInt32(hf時間起.Value.Substring(0, 2)),
|
|
DAC.GetInt32(hf時間起.Value.Substring(hf時間起.Value.Length - 2, 2)), 0).AddMinutes(-20);
|
|
}
|
|
catch
|
|
{
|
|
// do nothing
|
|
}
|
|
|
|
if (cb要發送 == null)
|
|
continue;
|
|
|
|
if (cb要發送.Checked)
|
|
{
|
|
講師行前郵件Data 講師行前郵件Data = new 講師行前郵件Data(){
|
|
收件人姓名 = lb講師姓名.Text,
|
|
收件人Email = txt電子郵件.Text,
|
|
聯絡人姓名 = txt聯絡人.Text,
|
|
聯絡人電話 = txt聯絡人電話.Text,
|
|
聯絡人Email = txt聯絡人email.Text,
|
|
公司名稱 = CompanyName,
|
|
// 訓練日期 = 訓練課程企劃[0].訓練日期,
|
|
// 訓練日期迄 = 訓練課程企劃[0].訓練日期迄,
|
|
訓練日期 = DAC.GetDateTime(hf訓練日期.Value),
|
|
訓練日期迄 = new DateTime(),
|
|
訓練時間 = hf時間起.Value,
|
|
訓練時間迄 = hf時間迄.Value,
|
|
備課時間 = 備課時間.Ticks > 0 ? 備課時間.ToString("HH:mm") : hf時間起.Value,
|
|
訓練名稱 = 訓練課程企劃[0].訓練名稱,
|
|
訓練地點 = txt訓練地點名稱.Text,
|
|
訓練地址 = txt訓練地點地址.Text,
|
|
是否攜帶筆電 = cb攜帶設備_筆記型電腦.Checked,
|
|
是否攜帶簡報 = cb攜帶設備_課程簡報檔.Checked,
|
|
是否攜帶其他 = cb攜帶設備_其他.Checked,
|
|
攜帶其他 = txt攜帶設備_其他.Text,
|
|
是否場地投影機 = cb場地設備_投影機.Checked,
|
|
是否場地麥克風 = cb場地設備_麥克風.Checked,
|
|
是否場地雷射筆 = cb場地設備_雷射筆.Checked,
|
|
是否場地筆電 = cb場地設備_筆記型電腦.Checked,
|
|
是否場地座位安排 = cb場地設備_座位安排.Checked,
|
|
是否場地白紙 = cb場地設備_白紙.Checked,
|
|
是否場地其他 = cb場地設備_其他.Checked,
|
|
場地其他 = txt場地設備_其他.Text,
|
|
是否講師費 = cb酬勞_講師費.Checked,
|
|
講師費 = txt講師費.Text,
|
|
是否交通費 = cb酬勞_交通費.Checked,
|
|
交通費 = txt交通費.Text,
|
|
合計 = txt費用合計.Text,
|
|
是否現金 = rb給付方式.SelectedValue == "現金",
|
|
是否匯款 = rb給付方式.SelectedValue == "匯款",
|
|
給付日 = txt給付日.Value.HasValue ? txt給付日.Value.Value : new DateTime(),
|
|
是否交通安排 = cb其他_交通安排.Checked,
|
|
交通安排 = txt交通安排.Text,
|
|
是否用餐 = cb其他_用餐.Checked,
|
|
用餐 = txt用餐.Text };
|
|
|
|
// 發送行前通知郵件
|
|
if (fuAttach.HasFile)
|
|
{
|
|
MemoryStream ms = new MemoryStream();
|
|
ms.Write(fuAttach.FileBytes, 0, fuAttach.FileBytes.Length);
|
|
ms.Position = 0;
|
|
|
|
講師行前郵件Data.附件檔名 = fuAttach.FileName;
|
|
講師行前郵件Data.附件內容 = ms;
|
|
}
|
|
else
|
|
{
|
|
講師行前郵件Data.附件檔名 = "";
|
|
講師行前郵件Data.附件內容 = null;
|
|
}
|
|
|
|
發送郵件.發送講師行前通知郵件(講師行前郵件Data);
|
|
|
|
// 標記已發送
|
|
Dao訓練課程內容.標記已發送講師通知(課程企劃id, DAC.GetInt32(hf課程序號.Value), UserId);
|
|
}
|
|
}
|
|
gv講師.DataBind();
|
|
ClientShowMessage("講師行前通知發送完畢");
|
|
}
|
|
|
|
protected void gv講師_DataBound(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
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].承辦);
|
|
|
|
場地 選定場地 = GetData.取得選定場地(課程企劃id);
|
|
txt訓練地點名稱.Text = 選定場地.場地名稱;
|
|
txt訓練地點地址.Text = String.Format("({0}){1}{2}{3}", 選定場地.地址_郵編, 選定場地.地址_縣市, 選定場地.地址_鄉鎮市區, 選定場地.地址_街道地址);
|
|
|
|
Panel1.Visible = true;
|
|
}
|
|
}
|
|
|
|
protected void ds已截止未上課_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
|
{
|
|
e.ObjectInstance = Dao訓練課程企劃;
|
|
}
|
|
|
|
protected void ds上課講師_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
|
{
|
|
e.ObjectInstance = Dao訓練課程內容;
|
|
}
|
|
}
|
|
}
|