using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using WebLib; namespace Education.Forms.辦訓狀況 { public partial class 滿意度調查表及心得報告 : FormBase { private DAC_滿意度調查 Dao滿意度調查; private DAC_心得報告 Dao心得報告; private DAC_訓練課程內容 Dao訓練課程內容; private DataListItem footerItem; private int 課程ID; private string 學員ID; protected void Page_Load(object sender, EventArgs e) { FunctionName = "滿意度調查表及心得報告"; Dao滿意度調查 = new DAC_滿意度調查(conn); Dao心得報告 = new DAC_心得報告(conn); Dao訓練課程內容 = new DAC_訓練課程內容(conn); hf課程編號.Value = Request["course"]; hf學員.Value = Request["student"]; 課程ID = DAC.GetInt32(hf課程編號.Value); 學員ID = hf學員.Value; if (!IsPostBack) { 訓練課程企劃List d1 = Dao訓練課程企劃.SelectOne(課程ID); if (d1.Count > 0) { lb課程企劃.Text = String.Format("{0} {1}", d1[0].顯示編號, d1[0].訓練名稱); } lb學員.Text = String.Format("{0} {1}", 學員ID, Get員工姓名(學員ID)); 心得報告List d = Dao心得報告.Select(false, 課程ID, 學員ID); if (d.Count > 0) { txt心得.Text = d[0].心得; txt建議.Text = d[0].建議; } else { txt心得.Text = ""; txt建議.Text = ""; } DataList1.ItemDataBound += new DataListItemEventHandler(DataList1_ItemDataBound); } else { DataList1.ItemDataBound -= new DataListItemEventHandler(DataList1_ItemDataBound); DataList1.DataBind(); } if (Master is PopupForm popupForm) { popupForm.RefreshOpener = true; } } protected void btnSave_Click(object sender, EventArgs e) { if (!IsValid) { lbMessage1.Text = "尚有項目未填寫完整,請填寫完整再儲存!"; ClientShowMessage("尚有項目未填寫完整,請填寫完整再儲存!"); return; } DAC_滿意度調查講師 Dao滿意度調查講師 = new DAC_滿意度調查講師(conn); foreach (DataListItem item in DataList1.Items) { int 課程序號 = DAC.GetInt32(FindControl(item, "hf課程序號").Value); RadioButtonList rbl1 = FindControl(item, "rbl1"); RadioButtonList rbl2 = FindControl(item, "rbl2"); RadioButtonList rbl3 = FindControl(item, "rbl3"); RadioButtonList rbl4 = FindControl(item, "rbl4"); Dao滿意度調查.Update(課程ID, 學員ID, 課程序號, 1, DAC.GetInt32(rbl1.SelectedValue), UserId); Dao滿意度調查.Update(課程ID, 學員ID, 課程序號, 2, DAC.GetInt32(rbl2.SelectedValue), UserId); Dao滿意度調查.Update(課程ID, 學員ID, 課程序號, 3, DAC.GetInt32(rbl3.SelectedValue), UserId); Dao滿意度調查.Update(課程ID, 學員ID, 課程序號, 4, DAC.GetInt32(rbl4.SelectedValue), UserId); Dao滿意度調查講師.Update(課程ID, 學員ID, 課程序號, UserId); } RadioButtonList frbl1 = FindControl(footerItem, "rbl1"); RadioButtonList frbl2 = FindControl(footerItem, "rbl2"); RadioButtonList frbl3 = FindControl(footerItem, "rbl3"); RadioButtonList frbl4 = FindControl(footerItem, "rbl4"); Dao滿意度調查.Update(課程ID, 學員ID, 0, 1, DAC.GetInt32(frbl1.SelectedValue), UserId); Dao滿意度調查.Update(課程ID, 學員ID, 0, 2, DAC.GetInt32(frbl2.SelectedValue), UserId); Dao滿意度調查.Update(課程ID, 學員ID, 0, 3, DAC.GetInt32(frbl3.SelectedValue), UserId); Dao滿意度調查.Update(課程ID, 學員ID, 0, 4, DAC.GetInt32(frbl4.SelectedValue), UserId); new DAC_滿意度調查課程企劃(conn).Update(課程ID, 學員ID, UserId); Dao心得報告.Update(課程ID, 學員ID, txt建議.Text, txt心得.Text, UserId); MultiView1.ActiveViewIndex = 1; } protected void DataList1_ItemCreated(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Footer) { footerItem = e.Item; } if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Footer) { RadioButtonList rbl1 = FindControl(e.Item, "rbl1"); RadioButtonList rbl2 = FindControl(e.Item, "rbl2"); RadioButtonList rbl3 = FindControl(e.Item, "rbl3"); RadioButtonList rbl4 = FindControl(e.Item, "rbl4"); rbl1.Items[0].Attributes["style"] = "display:none"; rbl2.Items[0].Attributes["style"] = "display:none"; rbl3.Items[0].Attributes["style"] = "display:none"; rbl4.Items[0].Attributes["style"] = "display:none"; } } protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Footer) { RadioButtonList rbl1 = FindControl(e.Item, "rbl1"); RadioButtonList rbl2 = FindControl(e.Item, "rbl2"); RadioButtonList rbl3 = FindControl(e.Item, "rbl3"); RadioButtonList rbl4 = FindControl(e.Item, "rbl4"); int 課程序號 = 0; if (e.Item.ItemType != ListItemType.Footer) 課程序號 = DAC.GetInt32(FindControl(e.Item, "hf課程序號").Value); 滿意度調查List d1 = Dao滿意度調查.SelectOne(課程ID, 學員ID, 課程序號, 1); 滿意度調查List d2 = Dao滿意度調查.SelectOne(課程ID, 學員ID, 課程序號, 2); 滿意度調查List d3 = Dao滿意度調查.SelectOne(課程ID, 學員ID, 課程序號, 3); 滿意度調查List d4 = Dao滿意度調查.SelectOne(課程ID, 學員ID, 課程序號, 4); if (d1.Count > 0) rbl1.SelectedValue = DAC.GetString(d1[0].分數); else rbl1.SelectedValue = ""; if (d2.Count > 0) rbl2.SelectedValue = DAC.GetString(d2[0].分數); else rbl2.SelectedValue = ""; if (d3.Count > 0) rbl3.SelectedValue = DAC.GetString(d3[0].分數); else rbl3.SelectedValue = ""; if (d4.Count > 0) rbl4.SelectedValue = DAC.GetString(d4[0].分數); else rbl4.SelectedValue = ""; } } protected void ds課程內容_ObjectCreating(object sender, ObjectDataSourceEventArgs e) { e.ObjectInstance = Dao訓練課程內容; } } }