You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
244 lines
8.9 KiB
244 lines
8.9 KiB
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 System.Web.Services;
|
|
using System.Web.Script.Services;
|
|
using Newtonsoft.Json;
|
|
|
|
#region 程式異動記錄
|
|
///程式代號:Menu
|
|
///程式名稱:系統菜單頁面
|
|
///程式說明:
|
|
///xx.YYYY/MM/DD VER AUTHOR COMMENTS(說明修改的內容)
|
|
///01.2012/07/25 1.0 Ethan CREATE
|
|
#endregion
|
|
|
|
namespace OT.Web
|
|
{
|
|
public partial class Menu : Ap_Code.BasePage
|
|
{
|
|
#region 自定義變量區
|
|
// 自定義變量區
|
|
|
|
#endregion
|
|
|
|
#region 公有方法區
|
|
// 公有方法區
|
|
|
|
#endregion
|
|
|
|
#region 私有方法區
|
|
// 私有方法區
|
|
#region LoadGridViewDate
|
|
/// <summary>
|
|
/// 加載GridView的資料
|
|
/// </summary>
|
|
private void LoadGridViewDate()
|
|
{
|
|
OT.BLL.OTB_SYS_ProgramList o_OTB_SYS_ProgramList_BLL = new OT.BLL.OTB_SYS_ProgramList();
|
|
int intEndRecordIndex = o_OTB_SYS_ProgramList_BLL.GetListCount("", "", "");
|
|
DataTable dbProgramLs = new DataTable();
|
|
dbProgramLs = fnDataSetToDataTable(o_OTB_SYS_ProgramList_BLL.GetList(0, intEndRecordIndex, "", "", "", ""));
|
|
string strHTML=string.Empty;
|
|
strHTML += "<table id='gvSearchResult' >";
|
|
for (int intRows = 0; intRows < dbProgramLs.Rows.Count; intRows++)
|
|
{
|
|
strHTML += "<tr>";
|
|
for (int intCount = 0; intCount < dbProgramLs.Columns.Count; intCount++)
|
|
{
|
|
strHTML += "<td>" + dbProgramLs.Rows[intRows][intCount].ToString();
|
|
strHTML += "</td>";
|
|
}
|
|
strHTML += "</tr>";
|
|
}
|
|
strHTML += "</table>";
|
|
ProgramList.InnerHtml = (strHTML);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region LoadModuleList
|
|
/// <summary>
|
|
/// 加載模組下拉選單資料
|
|
/// </summary>
|
|
private void LoadModuleList()
|
|
{
|
|
OT.BLL.CommonClass o_CommonClass_BLL = new OT.BLL.CommonClass();
|
|
DataSet dsCommonClass = o_CommonClass_BLL.GetDDLModuleList(gstrUserID);//gstrUserRoleId-->gstrUserID
|
|
ddlModuleList.DataSource = dsCommonClass;
|
|
//ddlModuleList.DataMember = "ModuleList";
|
|
ddlModuleList.DataTextField = "ModuleName";
|
|
ddlModuleList.DataValueField = "ModuleID";
|
|
ddlModuleList.DataBind();
|
|
|
|
// string strFrameName = "Menu";
|
|
// string strGoUrl = "./Menu.aspx?ModuleID=";
|
|
// ScriptManager.RegisterStartupScript(Page, Page.GetType(), "LoadMenuJs", "<script defer=\"defer\">fnFrameGoUrl('" + strFrameName + "','" + strGoUrl + "'+document.getElementById(\"ddlModuleList\").value);</script>", false);
|
|
}
|
|
#endregion
|
|
|
|
#region BindMenu
|
|
/// <summary>
|
|
/// 綁定菜單
|
|
/// </summary>
|
|
private void BindMenu(string strModuleID)
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(strModuleID))
|
|
{
|
|
strModuleID = ddlModuleList.SelectedValue;
|
|
}
|
|
OT.BLL.CommonClass o_CommonClass_BLL = new OT.BLL.CommonClass();
|
|
DataSet dsMenuFun = o_CommonClass_BLL.GetProgramListByModuleID(strModuleID, gstrUserID); //gstrUserRoleId-->gstrUserID
|
|
|
|
DataRelation l_relation = new DataRelation("myreleation", dsMenuFun.Tables["ds"].Columns["ModuleID"], dsMenuFun.Tables["ds1"].Columns["ModuleID"], false);
|
|
dsMenuFun.Relations.Add(l_relation);
|
|
|
|
#region Treeview Test
|
|
//TreeView1.Nodes.Clear();
|
|
//dsMenuFun.Relations.Add("NodeRelation", dsMenuFun.Tables["ds3"].Columns["ModuleID"], dsMenuFun.Tables["ds3"].Columns["ParentID"]);
|
|
//foreach (DataRow dbRow in dsMenuFun.Tables["ds3"].Rows)
|
|
//{
|
|
// if (dbRow["ParentId"].ToString() == "")
|
|
// {
|
|
// TreeNode newNode = CreateNode(dbRow["ModuleName"].ToString(), dbRow["ModuleID"].ToString(), true);
|
|
// TreeView1.Nodes.Add(newNode);
|
|
// PopulateSubTree(dbRow, newNode);
|
|
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
//parentRepeater.DataSource = dsMenuFun.Tables["ds"];
|
|
Page.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region GetMenu
|
|
/// <summary>
|
|
/// 取回GetMenu資料
|
|
/// </summary>
|
|
[WebMethod]
|
|
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
|
public static string GetMenu(string strModuleID, string strUser)
|
|
{
|
|
OT.BLL.CommonClass o_CommonClass_BLL = new OT.BLL.CommonClass();
|
|
DataSet dsMenuFun = o_CommonClass_BLL.GetProgramListByModuleID(strModuleID, strUser); //gstrUserRoleId-->gstrUserID
|
|
string str_json = string.Empty;
|
|
//DataTable tb = new DataTable();
|
|
if (dsMenuFun.Tables.Count > 0)
|
|
{
|
|
dsMenuFun.Tables[0].TableName = "Module";
|
|
dsMenuFun.Tables[1].TableName = "Program";
|
|
str_json = JsonConvert.SerializeObject(dsMenuFun, Newtonsoft.Json.Formatting.Indented);
|
|
}
|
|
return str_json; //回傳字串
|
|
}
|
|
#endregion
|
|
#region GetSession
|
|
/// <summary>
|
|
/// 取回Session資料
|
|
/// </summary>
|
|
[WebMethod(EnableSession = true)]
|
|
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
|
|
public static string GetSession(string strKey)
|
|
{
|
|
string strReturn = "{}";
|
|
if (HttpContext.Current.Session[strKey] != null)
|
|
{
|
|
strReturn = HttpContext.Current.Session[strKey].ToString();
|
|
}
|
|
return strReturn;
|
|
}
|
|
#endregion
|
|
|
|
//#region gvSearchResult_RowDataBound
|
|
///// <summary>
|
|
///// 資料行綁定事件
|
|
///// </summary>
|
|
///// <param name="sender"></param>
|
|
///// <param name="e"></param>
|
|
//protected void gvSearchResult_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
//{
|
|
// if (e.Row.RowType == DataControlRowType.Header)
|
|
// {
|
|
// //表頭
|
|
// if (((GridView)sender).AllowSorting == true && ViewState["GridViewSortDirection"] != null && ViewState["GridViewSortExpression"] != null)
|
|
// {
|
|
// //如果有選擇排序,則在該欄位後添加圖示
|
|
// int intIndex = fnGetSortColumnIndex(gvSearchResult, ViewState["GridViewSortExpression"].ToString());
|
|
// fnAddSortImage(intIndex, ViewState["GridViewSortDirection"].ToString(), e.Row); //添加圖示
|
|
// }
|
|
// }
|
|
// else if (e.Row.RowType == DataControlRowType.DataRow)
|
|
// {
|
|
// //程式類別
|
|
|
|
// }
|
|
//}
|
|
//#endregion
|
|
#region Treeview Test
|
|
|
|
//private void PopulateSubTree(DataRow dbRow, TreeNode node)
|
|
//{
|
|
|
|
// foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation"))
|
|
// {
|
|
// TreeNode childNode = CreateNode(childRow["ModuleName"].ToString(), childRow["ModuleID"].ToString(), true);
|
|
// //int intTest = childNode.ChildNodes.Count;
|
|
// //childNode.NavigateUrl = "javascript:parent.OpenPageTab('" + childRow["ModuleID"].ToString() + "','ModuleDefault');";
|
|
// // int intTest = childNode.GetChildRows("NodeRelation").;
|
|
|
|
// childNode.NavigateUrl = "javascript:parent.OpenPageTab('" + childRow["ModuleID"].ToString() + "');";
|
|
// node.ChildNodes.Add(childNode);
|
|
// PopulateSubTree(childRow, childNode);
|
|
// }
|
|
//}
|
|
//private TreeNode CreateNode(string text, string id, bool expanded)
|
|
//{
|
|
// TreeNode node = new TreeNode(); ;
|
|
// node.Text = text;
|
|
// node.Value = id;
|
|
// node.Expanded = true;
|
|
// return node;
|
|
//}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 頁面事件觸發區
|
|
// 頁面事件觸發區
|
|
|
|
#region Page_Load
|
|
/// <summary>
|
|
/// 頁面加載事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
//頁面第一次加載
|
|
LoadGridViewDate();
|
|
LoadModuleList(); //加載模組下拉選單資料
|
|
//BindMenu(""); //綁定菜單
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
protected void ddlModuleList_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
//BindMenu(ddlModuleList.SelectedValue.ToString()); //綁定菜單
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|