using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using WebLib; namespace Education.Forms.基本資料 { public partial class 課程基本資料 : FormBase { protected void Page_Load(object sender, EventArgs e) { FunctionName = "課程基本資料"; Form_View = FormView1; Grid_View = GridView1; FormView_DataSource = dsForm; GridView_DataSource = dsGrid; AddTabButton(MultiView1, View處理, tab處理); AddTabButton(MultiView1, View查詢, tab查詢); if (!IsPostBack) { ActivateTab(MultiView1, View處理); } else { Grid_View.DataBind(); Form_View.DataBind(); } if (Form_View.CurrentMode != FormViewMode.ReadOnly) { Grid_View.Visible = false; } } protected void btnSearch_Click(object sender, EventArgs e) { Grid_View.PageIndex = 0; Grid_View.DataBind(); } protected void btnClear_Click(object sender, EventArgs e) { txt訓練對象_Search.Text = ""; txt課程名稱_Search.Text = ""; txt課程編號_Search.Text = ""; ddl課程類別_Search.SelectedValue = ""; } protected override void FormView_InsertDataBound(object sender, EventArgs e) { base.FormView_InsertDataBound(sender, e); FindControl(Form_View, "txt課程時數").Text = "0"; } protected override void FormView_ItemDeleting(object sender, FormViewDeleteEventArgs e) { base.FormView_ItemDeleting(sender, e); if (Dao課程.IsOccipued(DAC.GetString(e.Keys["課程編號"]))) { ClientShowMessage("此課程已經選用過,不可刪除!"); e.Cancel = true; } } protected override void GridView_DataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e) { base.GridView_DataSource_Selected(sender, e); if (MultiView1.ActiveViewIndex == 0) { if (e.ReturnValue is 課程List list && list.Count > 0) ActivateTab(MultiView1, View處理); else lbMessage.Text = "找不到合乎條件的資料"; } } protected void dsForm_ObjectCreating(object sender, ObjectDataSourceEventArgs e) { e.ObjectInstance = Dao課程; } protected void dsGrid_ObjectCreating(object sender, ObjectDataSourceEventArgs e) { e.ObjectInstance = Dao課程; } protected void dsBCLS_ObjectCreating(object sender, ObjectDataSourceEventArgs e) { e.ObjectInstance = Dao類別; } } }