chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Data;
|
||||
using WebLib;
|
||||
|
||||
namespace Education.Forms.辦訓狀況
|
||||
{
|
||||
public partial class 訓練檢討報告處理 : FormBase
|
||||
{
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
FunctionName = "訓練檢討報告處理";
|
||||
|
||||
Form_View = FormView1;
|
||||
FormView_DataSource = ds訓練檢討報告;
|
||||
|
||||
if (IsPostBack)
|
||||
{
|
||||
Panel1.Visible = 訓練企劃搜尋.訓練企劃編號 > 0;
|
||||
if (Panel1.Visible)
|
||||
Form_View.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected void ds已上課_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao訓練課程企劃;
|
||||
}
|
||||
|
||||
protected void btn查詢_Click(object sender, EventArgs e)
|
||||
{
|
||||
Form_View.DataBind();
|
||||
}
|
||||
|
||||
protected override void FormView_ReadOnlyDataBound(object sender, EventArgs e)
|
||||
{
|
||||
base.FormView_ReadOnlyDataBound(sender, e);
|
||||
|
||||
if (訓練企劃搜尋.訓練企劃編號 > 0 && FindControl<Label>(Form_View, "lb學員出席率") != null)
|
||||
{
|
||||
int 課程企劃ID = 訓練企劃搜尋.訓練企劃編號;
|
||||
|
||||
FindControl<Label>(Form_View, "lb學員出席率").Text = String.Format("{0:##0.00}%", Dao課程報名.Get出席率(課程企劃ID));
|
||||
|
||||
DAC_課程經費 Dao課程經費 = new DAC_課程經費(conn);
|
||||
FindControl<Label>(Form_View, "lb訓練經費").Text = String.Format("{0:###,###,##0}", Dao課程經費.Get經費合計(課程企劃ID));
|
||||
|
||||
DAC_滿意度調查課程企劃 Dao滿意度調查課程企劃 = new DAC_滿意度調查課程企劃(conn);
|
||||
DataTable d1 = Dao滿意度調查課程企劃.Select滿意度統計(課程企劃ID);
|
||||
|
||||
if (d1.Rows.Count > 0)
|
||||
{
|
||||
int 回收數 = DAC.GetInt32(d1.Rows[0]["回收數"]);
|
||||
DAC_學員出席 Dao學員出席 = new DAC_學員出席(conn);
|
||||
// int 參與人數 = Dao學員出席.Get參與人數(課程企劃ID);
|
||||
int 參與人數 = Dao課程報名.Get報名人數(課程企劃ID);
|
||||
|
||||
FindControl<Label>(Form_View, "lb行政滿意度").Text = String.Format("{0:##0.00}", d1.Rows[0]["行政滿意度"]);
|
||||
FindControl<Label>(Form_View, "lb餐點滿意度").Text = String.Format("{0:##0.00}", d1.Rows[0]["餐點滿意度"]);
|
||||
FindControl<Label>(Form_View, "lb場地滿意度").Text = String.Format("{0:##0.00}", d1.Rows[0]["場地滿意度"]);
|
||||
FindControl<Label>(Form_View, "lb整體滿意度").Text = String.Format("{0:##0.00}", d1.Rows[0]["整體滿意度"]);
|
||||
FindControl<Label>(Form_View, "lb參與人數").Text = String.Format("{0}", 參與人數);
|
||||
FindControl<Label>(Form_View, "lb回收數").Text = String.Format("{0}", 回收數);
|
||||
FindControl<Label>(Form_View, "lb回收率").Text = 參與人數 > 0 ? String.Format("{0:##0.00}", DAC.GetDecimal(回收數) / DAC.GetDecimal(參與人數) * 100) : "--";
|
||||
}
|
||||
else
|
||||
{
|
||||
FindControl<Label>(Form_View, "lb行政滿意度").Text = "";
|
||||
FindControl<Label>(Form_View, "lb餐點滿意度").Text = "";
|
||||
FindControl<Label>(Form_View, "lb場地滿意度").Text = "";
|
||||
FindControl<Label>(Form_View, "lb整體滿意度").Text = "";
|
||||
FindControl<Label>(Form_View, "lb參與人數").Text = "";
|
||||
FindControl<Label>(Form_View, "lb回收數").Text = "";
|
||||
FindControl<Label>(Form_View, "lb回收率").Text = "";
|
||||
}
|
||||
|
||||
DAC_滿意度調查講師 Dao滿意度調查講師 = new DAC_滿意度調查講師(conn);
|
||||
FindControl<GridView>(Form_View, "gv講師滿意度").DataSource = Dao滿意度調查講師.Select滿意度統計(課程企劃ID);
|
||||
FindControl<GridView>(Form_View, "gv講師滿意度").DataBind();
|
||||
}
|
||||
|
||||
if (Form_View.SelectedValue != null)
|
||||
{
|
||||
訓練課程企劃List d = Dao訓練課程企劃.SelectOne(訓練企劃搜尋.訓練企劃編號);
|
||||
|
||||
送簽1.表單ID = Form_View.SelectedValue.ToString();
|
||||
送簽1.訓練課程企劃編號 = DAC.GetInt32(Form_View.SelectedValue);
|
||||
送簽1.編號2 = 0;
|
||||
送簽1.表單ID格式 = String.Format("[{0}] {1}", d[0].顯示編號, d[0].訓練名稱);
|
||||
|
||||
// 課程企劃的承辦人可送簽
|
||||
送簽1.可送簽 = d[0].承辦.CompareTo(UserId) == 0;
|
||||
送簽1.Refresh();
|
||||
}
|
||||
送簽1.Visible = Form_View.SelectedValue != null;
|
||||
}
|
||||
|
||||
protected override void FormView_InsertDataBound(object sender, EventArgs e)
|
||||
{
|
||||
base.FormView_InsertDataBound(sender, e);
|
||||
FindControl<HiddenField>(Form_View, "hf課程企劃編號").Value = 訓練企劃搜尋.訓練企劃編號.ToString();
|
||||
FindControl<DateTextBox>(Form_View, "txt填表日期").Value = DateTime.UtcNow.AddHours(8).Date;
|
||||
FindControl<LookupTextBox>(Form_View, "txt填表人員").Text = UserId;
|
||||
FindControl<Label>(Form_View, "lb填表人員X").Text = Get員工姓名(UserId);
|
||||
Bind改善措施CheckBoxLists();
|
||||
送簽1.Visible = false;
|
||||
}
|
||||
|
||||
protected override void FormView_EditDataBound(object sender, EventArgs e)
|
||||
{
|
||||
base.FormView_EditDataBound(sender, e);
|
||||
Bind改善措施CheckBoxLists();
|
||||
送簽1.Visible = false;
|
||||
}
|
||||
|
||||
protected override void FormView_ItemCommand(object sender, FormViewCommandEventArgs e)
|
||||
{
|
||||
base.FormView_ItemCommand(sender, e);
|
||||
|
||||
if (e.CommandName == "帶入建議")
|
||||
{
|
||||
TextBox txt學員建議 = FindControl<TextBox>(Form_View, "txt學員建議");
|
||||
GridView gv心得報告 = FindControl<GridView>(Form_View, "gv心得報告");
|
||||
|
||||
if (txt學員建議 != null && gv心得報告 != null)
|
||||
{
|
||||
string s = "";
|
||||
|
||||
foreach (GridViewRow row in gv心得報告.Rows)
|
||||
{
|
||||
if (row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
if (FindControl<CheckBox>(row.Cells[0], "cb選擇").Checked)
|
||||
s += row.Cells[1].Text + "\r\n";
|
||||
}
|
||||
}
|
||||
if (s.Length > 0)
|
||||
{
|
||||
s = s.Remove(s.Length - 2, 2);
|
||||
txt學員建議.Text += s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 改善措施 CheckBoxList 輔助方法
|
||||
|
||||
private string GetCheckBoxListValue(CheckBoxList cbl)
|
||||
{
|
||||
if (cbl == null) return "";
|
||||
List<string> values = new List<string>();
|
||||
foreach (ListItem item in cbl.Items)
|
||||
{
|
||||
if (item.Selected)
|
||||
values.Add(item.Value);
|
||||
}
|
||||
return string.Join(",", values.ToArray());
|
||||
}
|
||||
|
||||
private void Bind改善措施CheckBoxLists()
|
||||
{
|
||||
string[] categories = { "學員", "講師", "教材及教具", "教學方法", "場地及設備", "行政流程" };
|
||||
foreach (string cat in categories)
|
||||
{
|
||||
CheckBoxList cbl = FindControl<CheckBoxList>(Form_View, "cbl" + cat + "改善內容");
|
||||
HiddenField hf = FindControl<HiddenField>(Form_View, "hf" + cat + "改善內容");
|
||||
if (cbl != null)
|
||||
{
|
||||
cbl.DataBind();
|
||||
if (hf != null && !string.IsNullOrEmpty(hf.Value))
|
||||
{
|
||||
string[] values = hf.Value.Split(',');
|
||||
foreach (string v in values)
|
||||
{
|
||||
foreach (ListItem item in cbl.Items)
|
||||
{
|
||||
if (item.Value == v.Trim())
|
||||
{
|
||||
item.Selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void FormView_ItemInserting(object sender, FormViewInsertEventArgs e)
|
||||
{
|
||||
base.FormView_ItemInserting(sender, e);
|
||||
if (!Validate改善措施())
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
string[] categories = { "學員", "講師", "教材及教具", "教學方法", "場地及設備", "行政流程" };
|
||||
foreach (string cat in categories)
|
||||
{
|
||||
CheckBoxList cbl = FindControl<CheckBoxList>(Form_View, "cbl" + cat + "改善內容");
|
||||
if (cbl != null)
|
||||
e.Values["改善措施_" + cat + "_改善內容"] = GetCheckBoxListValue(cbl);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void FormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
|
||||
{
|
||||
base.FormView_ItemUpdating(sender, e);
|
||||
if (!Validate改善措施())
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
|
||||
string[] categories = { "學員", "講師", "教材及教具", "教學方法", "場地及設備", "行政流程" };
|
||||
foreach (string cat in categories)
|
||||
{
|
||||
CheckBoxList cbl = FindControl<CheckBoxList>(Form_View, "cbl" + cat + "改善內容");
|
||||
if (cbl != null)
|
||||
e.NewValues["改善措施_" + cat + "_改善內容"] = GetCheckBoxListValue(cbl);
|
||||
}
|
||||
}
|
||||
|
||||
private bool Validate改善措施()
|
||||
{
|
||||
string[] categories = { "學員", "講師", "教材及教具", "教學方法", "場地及設備", "行政流程" };
|
||||
foreach (string category in categories)
|
||||
{
|
||||
CheckBoxList contentList = FindControl<CheckBoxList>(Form_View, "cbl" + category + "改善內容");
|
||||
RadioButtonList methodList = FindControl<RadioButtonList>(Form_View, "ddl" + category + "改善作法");
|
||||
TextBox contentOther = FindControl<TextBox>(Form_View, "txt" + category + "改善內容其他");
|
||||
TextBox methodOther = FindControl<TextBox>(Form_View, "txt" + category + "改善作法其他");
|
||||
|
||||
bool contentHasOther = contentList != null && contentList.Items.FindByValue("9") != null
|
||||
&& contentList.Items.FindByValue("9").Selected;
|
||||
bool methodHasOther = methodList != null && methodList.Items.FindByValue("9") != null
|
||||
&& methodList.Items.FindByValue("9").Selected;
|
||||
|
||||
if (contentHasOther && (contentOther == null || String.IsNullOrEmpty(contentOther.Text.Trim())))
|
||||
{
|
||||
lbMessage.Text = String.Format("請填寫{0}的改善內容其他說明。", category);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (methodHasOther && (methodOther == null || String.IsNullOrEmpty(methodOther.Text.Trim())))
|
||||
{
|
||||
lbMessage.Text = String.Format("請填寫{0}的改善作法其他說明。", category);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user