/// <summary> /// 获得模块所在级别 /// </summary> /// <param name="moduleid">模块id</param> /// <param name="level">级别</param> private static void GetLevel(int moduleid, ref int level) { //BusinessFacade.sys_ModuleDisp(moduleid); sys_ModuleTable mt = new sys_ModuleTable(); if (sys_Module_Cache.Sys_moduleCache.TryGetValue(moduleid, out mt)) { level++; GetLevel(mt.M_ParentID, ref level); } }
protected void Button1_Click(object sender, EventArgs e) { sys_ModuleTable smt = new sys_ModuleTable(); smt = BusinessFacade.sys_ModuleDisp(ModuleID); smt.M_ApplicationID = S_ID; smt.M_Close = (int) Common.sink(this.M_Close.UniqueID,MethodType.Post,255,1,DataType.Int); smt.M_CName = (string)Common.sink(this.M_CName.UniqueID, MethodType.Post, 50, 1, DataType.Str); smt.M_Directory = (string) Common.sink(this.M_Directory.UniqueID,MethodType.Post,255,0,DataType.Str); //smt.M_IsSystem = (int) Common.sink(this.M_IsSystem.UniqueID,MethodType.Post,255,1,DataType.Int); smt.M_PageCode = (string) Common.sink(this.M_PageCode.UniqueID,MethodType.Post,6,1,DataType.CharAndNum); if (CMD == "New") { if (BusinessFacade.sys_Module_CheckPK(smt.M_ApplicationID, smt.M_PageCode,0)) EventMessage.MessageBox(1, "�����������", string.Format("������ͬ��ģ�����({0})", smt.M_PageCode) , Icon_Type.Error, "history.back()", UrlType.JavaScript); QueryParam qp = new QueryParam(); qp.Orderfld = "M_OrderLevel"; qp.PageIndex = 1; qp.PageSize = 1; qp.Where = string.Format("Where M_ParentID={0} and M_Applicationid={1}", ModuleID, S_ID); int RecordCount = 0; ArrayList lst = BusinessFacade.sys_ModuleList(qp, out RecordCount); if (ModuleID == 0) { if (RecordCount != 0) RecordCount = Convert.ToInt32(((sys_ModuleTable)lst[0]).M_OrderLevel.Substring(0,2))+1; smt.M_OrderLevel = Common.FillZero(RecordCount.ToString(), 2) + "00"; } else { if (RecordCount !=0) RecordCount = Convert.ToInt32(((sys_ModuleTable)lst[0]).M_OrderLevel.Substring(2, 2)); RecordCount++; smt.M_OrderLevel = smt.M_OrderLevel.Substring(0, 2) + Common.FillZero(RecordCount.ToString(), 2); } smt.M_ParentID = ModuleID; smt.DB_Option_Action_ = "Insert"; } else if (CMD == "Edit") { if (BusinessFacade.sys_Module_CheckPK(smt.M_ApplicationID, smt.M_PageCode,ModuleID)) EventMessage.MessageBox(1, "�����������", string.Format("������ͬ��ģ�����({0})", smt.M_PageCode) , Icon_Type.Error, "history.back()", UrlType.JavaScript); smt.DB_Option_Action_ = "Update"; } smt.ModuleID = ModuleID; if (smt.M_IsSystem!=1) BusinessFacade.sys_ModuleInsertUpdate(smt); EventMessage.MessageBox(1, "�����ɹ�", string.Format("����/��ģ��ID({0})�ɹ�!", ModuleID), Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("ModuleList.aspx?S_ID={0}&AppName={1}", S_ID, S_ID_Name))); }
/// <summary> /// 获得所有叶节点实体类 /// </summary> /// <param name="moduleid">模块id</param> /// <param name="lastIds">节点实体类集合</param> private static void GetLastIDs(int moduleid, List<sys_ModuleTable> lastIds) { sys_ModuleTable mt = new sys_ModuleTable(); if (sys_Module_Cache.Sys_moduleCache.TryGetValue(moduleid, out mt)) { /* QueryParam qp = new QueryParam(); qp.Orderfld = " M_Applicationid,M_OrderLevel "; qp.OrderType = 0; qp.Where = string.Format("Where M_ParentID={0}", moduleid); int RecordCount = 0; ArrayList lst = BusinessFacade.sys_ModuleList(qp, out RecordCount); */ List<sys_ModuleTable> lst = sys_Module_Cache.Sys_moduleTreeCache[moduleid]; if (lst.Count > 0) { foreach (sys_ModuleTable var in lst) { GetLastIDs(var.ModuleID, lastIds); } } else { if (mt.M_ParentID != 0) lastIds.Add(mt); } } }
/// <summary> /// 根据模块ID,获取模块ID的全路径id集合 /// </summary> /// <param name="ModuleID">模块ID</param> /// <param name="lst">路径id集合</param> /// <returns></returns> private static void GetSubModuleIds(int ModuleID, List<int> lst) { //sys_ModuleTable mt = BusinessFacade.sys_ModuleDisp(ModuleID); //if (mt.ModuleID > 0) sys_ModuleTable mt = new sys_ModuleTable(); if (sys_Module_Cache.Sys_moduleCache.TryGetValue(ModuleID, out mt)) { lst.Add(mt.ModuleID); if (mt.M_ParentID != 0) GetSubModuleIds(mt.M_ParentID, lst); } }
/// <summary> /// 新增/删除/修改 sys_Module /// </summary> /// <param name="fam">sys_ModuleTable实体类</param> /// <returns>返回0操正常</returns> public override int sys_ModuleInsertUpdate(sys_ModuleTable fam) { int rInt = 0; using (OracleConnection Conn = GetSqlConnection()) { string CommTxt; OracleCommand cmd = new OracleCommand(); cmd.Connection = Conn; if (fam.DB_Option_Action_ == "Insert") { CommTxt = "Insert into sys_Module(ModuleID,M_ApplicationID,M_ParentID,M_PageCode,M_CName,M_Directory,M_OrderLevel,M_IsSystem,M_Close,M_Icon)VALUES(SEQ_sys_Module_ID.NEXTVAL,:M_ApplicationID,:M_ParentID,:M_PageCode,:M_CName,:M_Directory,:M_OrderLevel,:M_IsSystem,:M_Close,:M_Icon)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("M_ApplicationID", OracleType.Int32).Value = fam.M_ApplicationID; //所属应用程序ID cmd.Parameters.Add("M_ParentID", OracleType.Int32).Value = fam.M_ParentID; //所属父级模块ID与ModuleID关联,0为顶级 cmd.Parameters.Add("M_PageCode", OracleType.VarChar).Value = fam.M_PageCode + ""; //模块编码Parent为0,则为S00(xx),否则为S00M00(xx) cmd.Parameters.Add("M_CName", OracleType.NVarChar).Value = fam.M_CName + ""; //模块/栏目名称当ParentID为0为模块名称 cmd.Parameters.Add("M_Directory", OracleType.NVarChar).Value = fam.M_Directory + ""; //模块/栏目目录名 cmd.Parameters.Add("M_OrderLevel", OracleType.VarChar).Value = fam.M_OrderLevel + ""; //当前所在排序级别支持双层99级菜单 cmd.Parameters.Add("M_IsSystem", OracleType.SByte).Value = fam.M_IsSystem; //是否为系统模块1:是0:否如为系统则无法修改 cmd.Parameters.Add("M_Close", OracleType.SByte).Value = fam.M_Close; //是否关闭1:是0:否 cmd.Parameters.Add("M_Icon", OracleType.NVarChar).Value = fam.M_Icon + ""; //默认显示图标 } else if (fam.DB_Option_Action_ == "Update") { CommTxt = "UPDATE sys_Module SET M_ApplicationID = :M_ApplicationID,M_ParentID = :M_ParentID,M_PageCode = :M_PageCode,M_CName = :M_CName,M_Directory = :M_Directory,M_OrderLevel = :M_OrderLevel,M_IsSystem = :M_IsSystem,M_Close = :M_Close,M_Icon = :M_Icon WHERE (ModuleID = :ModuleID)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("M_ApplicationID", OracleType.Int32).Value = fam.M_ApplicationID; //所属应用程序ID cmd.Parameters.Add("M_ParentID", OracleType.Int32).Value = fam.M_ParentID; //所属父级模块ID与ModuleID关联,0为顶级 cmd.Parameters.Add("M_PageCode", OracleType.VarChar).Value = fam.M_PageCode + ""; //模块编码Parent为0,则为S00(xx),否则为S00M00(xx) cmd.Parameters.Add("M_CName", OracleType.NVarChar).Value = fam.M_CName + ""; //模块/栏目名称当ParentID为0为模块名称 cmd.Parameters.Add("M_Directory", OracleType.NVarChar).Value = fam.M_Directory + ""; //模块/栏目目录名 cmd.Parameters.Add("M_OrderLevel", OracleType.VarChar).Value = fam.M_OrderLevel + ""; //当前所在排序级别支持双层99级菜单 cmd.Parameters.Add("M_IsSystem", OracleType.SByte).Value = fam.M_IsSystem; //是否为系统模块1:是0:否如为系统则无法修改 cmd.Parameters.Add("M_Close", OracleType.SByte).Value = fam.M_Close; //是否关闭1:是0:否 cmd.Parameters.Add("M_Icon", OracleType.NVarChar).Value = fam.M_Icon + ""; //默认显示图标 cmd.Parameters.Add("ModuleID", OracleType.Int32).Value = fam.ModuleID; } else if (fam.DB_Option_Action_ == "Delete") { CommTxt = "Delete from sys_Module WHERE (ModuleID = :ModuleID)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("ModuleID", OracleType.Int32).Value = fam.ModuleID; } else throw new ApplicationException("无法识别的操作命令!"); Conn.Open(); OracleTransaction Tran = Conn.BeginTransaction(); cmd.Transaction = Tran; try { rInt = cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); if (fam.DB_Option_Action_ == "Insert") { cmd.CommandText = "select SEQ_sys_Module_ID.CURRVAL from dual"; rInt = Convert.ToInt32(cmd.ExecuteScalar()); } Tran.Commit(); } catch (Exception ex) { Tran.Rollback(); throw new ApplicationException(ex.ToString()); } finally { Tran.Dispose(); cmd.Dispose(); Conn.Dispose(); Conn.Close(); } } return rInt; }
private void OnStart() { if (FrameWorkMenuTree.GetModuleLevel(ModuleID) >= 3) { MessageLit.Text = "<font color=red>以下模块超过3层,只有当菜单样式为\"多级菜单\"才能正常显示出来!</font>"; } if (CMD == string.Empty) { //TabOptionWebControls1.SelectIndex = 1; TabOptionItem3.Visible = true; } //填充数据 sys_ModuleTable SMT = new sys_ModuleTable(); SMT = BusinessFacade.sys_ModuleDisp(ModuleID); this.M_ApplicationID_Txt.Text = S_ID_Name; if (ModuleID == 0) this.M_PageCode.Text = SMT.M_PageCode; if (CMD == "New" && ModuleID != 0) { this.M_ParentID_Txt.Text = SMT.M_CName + "(" + SMT.M_PageCode + ")"; } else { this.M_ParentID_Txt.Text = SMT.M_ParentID == 0 ? "无" : BusinessFacade.sys_ModuleDisp(SMT.M_ParentID).M_CName; } this.M_PageCode_Txt.Text = SMT.M_PageCode; this.M_CName_Txt.Text = SMT.M_CName; this.M_Directory_Txt.Text = SMT.M_Directory; this.M_IsSystem_Txt.Text = SMT.M_IsSystem == 0 ? "否" : "是"; this.M_Close_Txt.Text = SMT.M_Close == 0 ? "否" : "是"; this.M_Icon_Txt.Text = SMT.M_Icon; if (CMD == "Edit") { this.M_PageCode.Text = SMT.M_PageCode; this.M_CName.Text = SMT.M_CName; this.M_Directory.Text = SMT.M_Directory; this.M_Icon.Text = SMT.M_Icon; ListItem ditem1 = this.M_IsSystem.Items.FindByValue(SMT.M_IsSystem.ToString()); if (ditem1 != null) ditem1.Selected = true; ListItem ditem2 = this.M_Close.Items.FindByValue(SMT.M_Close.ToString()); if (ditem2 != null) ditem2.Selected = true; } //绑定子模块 QueryParam qp = new QueryParam(); qp.Orderfld = " M_Applicationid,M_OrderLevel "; qp.OrderType = 0; qp.Where = string.Format("Where M_ParentID={0} and M_Applicationid={1}", ModuleID, S_ID); int RecordCount = 0; ArrayList lst = BusinessFacade.sys_ModuleList(qp, out RecordCount); GridView1.DataSource = lst; GridView1.DataBind(); //绑定排序 OrderByListItems.DataSource = lst; OrderByListItems.DataTextField = "M_CName"; OrderByListItems.DataValueField = "ModuleID"; OrderByListItems.DataBind(); if (lst.Count > 0) OrderByListItems.Rows = lst.Count; //判断是否隐藏数据 if (CMD == "New" || CMD == "Edit") HiddenDisp(); else { HiddenInput(); SubmitTr.Visible = false; } //if (ModuleID !=0 && SMT.M_OrderLevel.Substring(2, 2) != "00") //{ // TabOptionWebControls1.SelectIndex = 0; // TabOptionItem2.Visible = false; // TabOptionItem3.Visible = false; // if (CMD!="New" && CMD!="Edit") // TabOptionItem4.Visible = true; // BindPermissionList(); // if (CMD == "Edit") // { // HeadMenuButtonItem m5 = new HeadMenuButtonItem(); // m5.ButtonIcon = "back.gif"; // m5.ButtonName = "返回"; // m5.ButtonPopedom = PopedomType.List; // m5.ButtonUrl = string.Format("?ModuleID={0}&S_ID={1}", ModuleID, S_ID); // HeadMenuWebControls1.ButtonList.Add(m5); // } //} //生成修改按钮 if (ModuleID != 0 && CMD == "") { HeadMenuButtonItem m3 = new HeadMenuButtonItem(); m3.ButtonName = "模块"; m3.ButtonPopedom = PopedomType.Edit; m3.ButtonUrl = string.Format("?CMD=Edit&ModuleID={0}&S_ID={1}", ModuleID, S_ID); HeadMenuWebControls1.ButtonList.Add(m3); //if (FrameWorkMenuTree.CheckModuleLastLevel(ModuleID)) if (BusinessFacade.GetSuBCount(ModuleID)==0) { HeadMenuButtonItem m6 = new HeadMenuButtonItem(); m6.ButtonName = "设定模块扩展权限"; m6.ButtonIcon = "b.gif"; m6.ButtonPopedom = PopedomType.Edit; m6.ButtonUrl = string.Format("?CMD=ExtPermission&ModuleID={0}&S_ID={1}", ModuleID, S_ID); HeadMenuWebControls1.ButtonList.Add(m6); } } //生成删除按钮 if (CMD == "Edit") { HeadMenuButtonItem m4 = new HeadMenuButtonItem(); m4.ButtonPopedom = PopedomType.Delete; m4.ButtonUrl = string.Format("DelData('?CMD=Delete&S_ID={0}&ModuleID={1}')", S_ID, ModuleID); m4.ButtonUrlType = UrlType.JavaScript; HeadMenuWebControls1.ButtonList.Add(m4); } //判断是否执行删除 if (CMD == "Delete") { SMT.DB_Option_Action_ = "Delete"; if (SMT.M_IsSystem != 1) { BusinessFacade.DeleteModule(ModuleID); } sys_Module_Cache.ReLoadCache(); //重新加载模块缓存 EventMessage.MessageBox(1, "操作成功", "删除记录ID:(" + ModuleID + ")成功!", Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("ModuleList.aspx?S_ID={0}&AppName={1}", S_ID, S_ID_Name))); } //Button1.Attributes.Add("Onclick", "javascript:return checkForm(aspnetForm);"); if (CMD == "ExtPermission") { TabOptionItem2.Visible = false; TabOptionItem4.Visible = true; TabOptionWebControls1.SelectIndex = 3; BindPermissionList(); } }
private void OnStart() { if (CMD == string.Empty) { TabOptionWebControls1.SelectIndex = 1; } //������� sys_ModuleTable SMT = new sys_ModuleTable(); SMT = BusinessFacade.sys_ModuleDisp(ModuleID); this.M_ApplicationID_Txt.Text = S_ID_Name; if (ModuleID==0) this.M_PageCode.Text = SMT.M_PageCode; if (CMD == "New" && ModuleID != 0) { this.M_ParentID_Txt.Text = SMT.M_CName; } else { this.M_ParentID_Txt.Text = SMT.M_ParentID == 0 ? "��" : BusinessFacade.sys_ModuleDisp(SMT.M_ParentID).M_CName; } this.M_PageCode_Txt.Text = SMT.M_PageCode; this.M_CName_Txt.Text = SMT.M_CName; this.M_Directory_Txt.Text = SMT.M_Directory; this.M_IsSystem_Txt.Text = SMT.M_IsSystem == 0 ? "��" : "��"; this.M_Close_Txt.Text = SMT.M_Close == 0 ? "��" : "��"; if (CMD == "Edit") { this.M_PageCode.Text = SMT.M_PageCode; this.M_CName.Text = SMT.M_CName; this.M_Directory.Text = SMT.M_Directory; ListItem ditem1 = this.M_IsSystem.Items.FindByValue(SMT.M_IsSystem.ToString()); if (ditem1 != null) ditem1.Selected = true; ListItem ditem2 = this.M_Close.Items.FindByValue(SMT.M_Close.ToString()); if (ditem2 != null) ditem2.Selected = true; } //����ģ�� QueryParam qp = new QueryParam(); qp.Orderfld = " M_Applicationid,M_OrderLevel "; qp.OrderType = 0; qp.Where = string.Format("Where M_ParentID={0} and M_Applicationid={1}", ModuleID,S_ID); int RecordCount = 0; ArrayList lst = BusinessFacade.sys_ModuleList(qp, out RecordCount); GridView1.DataSource = lst; GridView1.DataBind(); //������ OrderByListItems.DataSource = lst; OrderByListItems.DataTextField = "M_CName"; OrderByListItems.DataValueField = "ModuleID"; OrderByListItems.DataBind(); if (lst.Count > 0) OrderByListItems.Rows = lst.Count; //�ж��Ƿ��������� if (CMD == "New" || CMD == "Edit") HiddenDisp(); else { HiddenInput(); SubmitTr.Visible = false; } //�ж��Ƿ�����������ģ�鰴ť if (CMD!="New" && ModuleID !=0 && SMT.M_OrderLevel.Substring(2, 2) == "00") { HeadMenuButtonItem m2 = new HeadMenuButtonItem(); m2.ButtonName = "ģ��"; m2.ButtonPopedom = PopedomType.New; m2.ButtonUrl = string.Format("?CMD=New&ModuleID={0}&S_ID={1}", ModuleID, S_ID); HeadMenuWebControls1.ButtonList.Add(m2); } if (ModuleID !=0 && SMT.M_OrderLevel.Substring(2, 2) != "00") { TabOptionWebControls1.SelectIndex = 0; TabOptionItem2.Visible = false; TabOptionItem3.Visible = false; if (CMD == "Edit") { HeadMenuButtonItem m5 = new HeadMenuButtonItem(); m5.ButtonIcon = "back.gif"; m5.ButtonName = "����"; m5.ButtonPopedom = PopedomType.List; m5.ButtonUrl = string.Format("?ModuleID={0}&S_ID={1}", ModuleID, S_ID); HeadMenuWebControls1.ButtonList.Add(m5); } } //�����İ�ť if (ModuleID != 0 && CMD=="") { HeadMenuButtonItem m3 = new HeadMenuButtonItem(); m3.ButtonName = ""; m3.ButtonPopedom = PopedomType.Edit; m3.ButtonUrl = string.Format("?CMD=Edit&ModuleID={0}&S_ID={1}",ModuleID,S_ID); HeadMenuWebControls1.ButtonList.Add(m3); } //����ɾ����ť if (CMD == "Edit") { HeadMenuButtonItem m4 = new HeadMenuButtonItem(); m4.ButtonPopedom = PopedomType.Delete; m4.ButtonUrl = string.Format("DelData('?CMD=Delete&S_ID={0}&ModuleID={1}')", S_ID,ModuleID); m4.ButtonUrlType = UrlType.JavaScript; HeadMenuWebControls1.ButtonList.Add(m4); } //�ж��Ƿ�ִ��ɾ�� if (CMD == "Delete") { SMT.DB_Option_Action_ = "Delete"; if (SMT.M_IsSystem != 1) { BusinessFacade.sys_ModuleInsertUpdate(SMT); //ɾ����ɫȨ�ޱ� BusinessFacade.sys_RolePermission_DeleteForm(SMT.M_ApplicationID, SMT.M_PageCode); if (lst.Count > 0) { foreach (sys_ModuleTable var in lst) { SMT.ModuleID = var.ModuleID; BusinessFacade.sys_ModuleInsertUpdate(SMT); //ɾ����ɫȨ�ޱ� BusinessFacade.sys_RolePermission_DeleteForm(var.M_ApplicationID, var.M_PageCode); } } } EventMessage.MessageBox(1, "�����ɹ�", "ɾ����¼ID:(" + ModuleID + ")�ɹ���", Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("ModuleList.aspx?S_ID={0}&AppName={1}",S_ID,S_ID_Name))); } //Button1.Attributes.Add("Onclick", "javascript:return checkForm(aspnetForm);"); }
/// <summary> /// 新增/删除/修改 sys_Module /// </summary> /// <param name="fam">sys_ModuleTable实体类</param> /// <returns>返回0操正常</returns> public abstract int sys_ModuleInsertUpdate(sys_ModuleTable fam);
/// <summary> /// 新增/删除/修改 sys_Module /// </summary> /// <param name="fam">sys_ModuleTable实体类</param> /// <returns>返回0操正常</returns> public override int sys_ModuleInsertUpdate(sys_ModuleTable fam) { int rInt = 0; using (OleDbConnection Conn = GetSqlConnection()) { string CommTxt; OleDbCommand cmd = new OleDbCommand(); cmd.Connection = Conn; if (fam.DB_Option_Action_ == "Insert") { CommTxt = "Insert into sys_Module(M_ApplicationID,M_ParentID,M_PageCode,M_CName,M_Directory,M_OrderLevel,M_IsSystem,M_Close,M_Icon)VALUES(@M_ApplicationID,@M_ParentID,@M_PageCode,@M_CName,@M_Directory,@M_OrderLevel,@M_IsSystem,@M_Close,@M_Icon)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("@M_ApplicationID", OleDbType.Integer).Value = fam.M_ApplicationID; //所属应用程序ID cmd.Parameters.Add("@M_ParentID", OleDbType.Integer).Value = fam.M_ParentID; //所属父级模块ID与ModuleID关联,0为顶级 cmd.Parameters.Add("@M_PageCode", OleDbType.VarWChar).Value = fam.M_PageCode + ""; //模块编码Parent为0,则为S00(xx),否则为S00M00(xx) cmd.Parameters.Add("@M_CName", OleDbType.VarWChar).Value = fam.M_CName + ""; //模块/栏目名称当ParentID为0为模块名称 cmd.Parameters.Add("@M_Directory", OleDbType.VarWChar).Value = fam.M_Directory + ""; //模块/栏目目录名 cmd.Parameters.Add("@M_OrderLevel", OleDbType.VarWChar).Value = fam.M_OrderLevel + ""; //当前所在排序级别支持双层99级菜单 cmd.Parameters.Add("@M_IsSystem", OleDbType.LongVarWChar).Value = fam.M_IsSystem + ""; //是否为系统模块1:是0:否如为系统则无法修改 cmd.Parameters.Add("@M_Close", OleDbType.LongVarWChar).Value = fam.M_Close + ""; //是否关闭1:是0:否 cmd.Parameters.Add("@M_Icon", OleDbType.LongVarWChar).Value = fam.M_Icon + ""; //默认显示图标名称 } else if (fam.DB_Option_Action_ == "Update") { CommTxt = "UPDATE sys_Module SET M_ApplicationID = @M_ApplicationID,M_ParentID = @M_ParentID,M_PageCode = @M_PageCode,M_CName = @M_CName,M_Directory = @M_Directory,M_OrderLevel = @M_OrderLevel,M_IsSystem = @M_IsSystem,M_Close = @M_Close,M_Icon = @M_Icon WHERE (ModuleID = @ModuleID)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("@M_ApplicationID", OleDbType.Integer).Value = fam.M_ApplicationID; //所属应用程序ID cmd.Parameters.Add("@M_ParentID", OleDbType.Integer).Value = fam.M_ParentID; //所属父级模块ID与ModuleID关联,0为顶级 cmd.Parameters.Add("@M_PageCode", OleDbType.VarWChar).Value = fam.M_PageCode + ""; //模块编码Parent为0,则为S00(xx),否则为S00M00(xx) cmd.Parameters.Add("@M_CName", OleDbType.VarWChar).Value = fam.M_CName + ""; //模块/栏目名称当ParentID为0为模块名称 cmd.Parameters.Add("@M_Directory", OleDbType.VarWChar).Value = fam.M_Directory + ""; //模块/栏目目录名 cmd.Parameters.Add("@M_OrderLevel", OleDbType.VarWChar).Value = fam.M_OrderLevel + ""; //当前所在排序级别支持双层99级菜单 cmd.Parameters.Add("@M_IsSystem", OleDbType.LongVarWChar).Value = fam.M_IsSystem + ""; //是否为系统模块1:是0:否如为系统则无法修改 cmd.Parameters.Add("@M_Close", OleDbType.LongVarWChar).Value = fam.M_Close + ""; //是否关闭1:是0:否 cmd.Parameters.Add("@M_Icon", OleDbType.LongVarWChar).Value = fam.M_Icon + ""; //默认显示图标名称 cmd.Parameters.Add("@ModuleID", OleDbType.Integer).Value = fam.ModuleID; } else if (fam.DB_Option_Action_ == "Delete") { CommTxt = "Delete from sys_Module WHERE (ModuleID = @ModuleID)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("@ModuleID", OleDbType.Integer).Value = fam.ModuleID; } else throw new ApplicationException("无法识别的操作命令!"); Conn.Open(); rInt = cmd.ExecuteNonQuery(); if (fam.DB_Option_Action_ == "Insert") { cmd.CommandText = "SELECT @@identity"; rInt = Convert.ToInt32(cmd.ExecuteScalar()); } cmd.Dispose(); Conn.Dispose(); Conn.Close(); } return rInt; }
/// <summary> /// 根据ID返回 sys_ModuleTable实体类 单笔资料 /// </summary> /// <param name="ModuleID">功能模块ID号</param> /// <returns>返回sys_ModuleTable实体类 ModuleID为0则无记录</returns> public static sys_ModuleTable sys_ModuleDisp(int ModuleID) { sys_ModuleTable fam = new sys_ModuleTable(); QueryParam qp = new QueryParam(); qp.PageIndex = 1; qp.PageSize = 1; qp.Where = " Where sys_Module.ModuleID = " + ModuleID; int RecordCount = 0; ArrayList lst = sys_ModuleList(qp, out RecordCount); if (RecordCount > 0) { fam = (sys_ModuleTable)lst[0]; } return fam; }
/// <summary> /// 新增/删除/修改 sys_Module /// </summary> /// <param name="fam">sys_ModuleTable实体类</param> /// <returns>返回0操正常</returns> public override int sys_ModuleInsertUpdate(sys_ModuleTable fam) { int rInt = 0; using (SqlConnection Conn = GetSqlConnection()) { SqlCommand cmd = new SqlCommand("sys_ModuleInsertUpdateDelete", Conn); cmd.CommandType = CommandType.StoredProcedure; //设置参数 cmd.Parameters.Add("@DB_Option_Action_", SqlDbType.NVarChar).Value = fam.DB_Option_Action_; //操作方法 Insert:增加 Update:修改 Delete:删除 Disp:显示单笔记录 cmd.Parameters.Add("@ModuleID", SqlDbType.Int).Value = fam.ModuleID; //功能模块ID号 cmd.Parameters.Add("@M_ApplicationID", SqlDbType.Int).Value = fam.M_ApplicationID; //所属应用程序ID cmd.Parameters.Add("@M_ParentID", SqlDbType.Int).Value = fam.M_ParentID; //所属父级模块ID与ModuleID关联,0为顶级 cmd.Parameters.Add("@M_PageCode", SqlDbType.VarChar).Value = fam.M_PageCode; //模块编码Parent为0,则为S00(xx),否则为S00M00(xx) cmd.Parameters.Add("@M_CName", SqlDbType.NVarChar).Value = fam.M_CName; //模块/栏目名称当ParentID为0为模块名称 cmd.Parameters.Add("@M_Directory", SqlDbType.NVarChar).Value = fam.M_Directory; //模块/栏目目录名 cmd.Parameters.Add("@M_OrderLevel", SqlDbType.VarChar).Value = fam.M_OrderLevel; //当前所在排序级别支持双层99级菜单 cmd.Parameters.Add("@M_IsSystem", SqlDbType.Int).Value = fam.M_IsSystem; //是否为系统模块1:是0:否如为系统则无法修改 cmd.Parameters.Add("@M_Close", SqlDbType.Int).Value = fam.M_Close; //是否关闭1:是0:否 cmd.Parameters.Add("@M_Icon", SqlDbType.NVarChar).Value = fam.M_Icon; //默认显示图标 Conn.Open(); rInt = Convert.ToInt32(cmd.ExecuteScalar()); cmd.Dispose(); Conn.Dispose(); Conn.Close(); } return rInt; }
/// <summary> /// 设置一级模块缓存 /// </summary> /// <param name="m"></param> static void setTopModuleCache(sys_ModuleTable m) { //更新一级菜单 if (m.M_ParentID == 0) { if (Sys_moduletopCache.ContainsKey(m.M_ApplicationID)) { Sys_moduletopCache[m.M_ApplicationID].Add(m); } //else //{ // List<sys_ModuleTable> mod = new List<sys_ModuleTable>(); // mod.Add(m); // Sys_moduletopCache.Add(m.M_ApplicationID, mod); //} } }
/// <summary> /// 更新模块子模块数 /// </summary> /// <param name="m">模块实体类</param> static void setModuleTreeCache(sys_ModuleTable m) { if (m.M_ParentID != 0) { if (Sys_moduleTreeCache.ContainsKey(m.M_ParentID)) { Sys_moduleTreeCache[m.M_ParentID].Add(m); } } }
/// <summary> /// 设置模块缓存 /// </summary> /// <param name="m">设置模块</param> static void setModuleCache(sys_ModuleTable m) { Sys_moduleCache.Add(m.ModuleID, m); //初始化模块缓存 Sys_moduleTreeCache.Add(m.ModuleID, new List<sys_ModuleTable>()); //初始化树状模块缓存 }
/// <summary> /// 获取模块标题路径 /// </summary> /// <param name="ModuleID">模块ID</param> /// <returns></returns> public static string GetModuleTitle(int ModuleID) { /* int TotalRecord = 0; QueryParam qp = new QueryParam(); qp.Where = " where ModuleID = " + ModuleID; qp.PageIndex = 1; qp.PageSize = 1; ArrayList lst = BusinessFacade.sys_ModuleList(qp, out TotalRecord); if (TotalRecord == 1) { foreach (sys_ModuleTable x in lst) { if (x.M_ParentID != 0) return GetModuleTitle(x.M_ParentID) + ">" + x.M_CName; else return GetModuleTitle(x.M_ParentID); } } return ""; */ sys_ModuleTable x = new sys_ModuleTable(); if (sys_Module_Cache.Sys_moduleCache.TryGetValue(ModuleID, out x)) { if (x.M_ParentID != 0) return GetModuleTitle(x.M_ParentID) + ">" + x.M_CName; else return ""; } else { return ""; } }
/// <summary> /// 根据M_ApplicationID和M_PageCode返回 sys_ModuleTable实体类 单笔资料 /// </summary> /// <param name="M_ApplicationID">功能模块ID号</param> /// <param name="M_PageCode">M_PageCode</param> /// <returns>返回sys_ModuleTable实体类 ModuleID为0则无记录</returns> public static sys_ModuleTable sys_ModuleDisp(int M_ApplicationID, string M_PageCode) { sys_ModuleTable fam = new sys_ModuleTable(); QueryParam qp = new QueryParam(); qp.PageIndex = 1; qp.PageSize = 1; qp.Where = string.Format(" Where sys_Module.M_ApplicationID = {0} and M_PageCode = '{1}'", M_ApplicationID, Common.inSQL(M_PageCode)); int RecordCount = 0; ArrayList lst = sys_ModuleList(qp, out RecordCount); if (RecordCount > 0) { fam = (sys_ModuleTable)lst[0]; } return fam; }
/// <summary> /// 新增/删除/修改 sys_Module /// </summary> /// <param name="fam">sys_ModuleTable实体类</param> /// <returns>返回0操正常</returns> public static int sys_ModuleInsertUpdate(sys_ModuleTable fam) { return DataProvider.Instance().sys_ModuleInsertUpdate(fam); }
/// <summary> /// ����/ɾ��/�� sys_Module /// </summary> /// <param name="fam">sys_ModuleTableʵ����</param> /// <returns>����0������</returns> public override int sys_ModuleInsertUpdate(sys_ModuleTable fam) { int rInt = 0; using (OracleConnection Conn = GetSqlConnection()) { string CommTxt; OracleCommand cmd = new OracleCommand(); cmd.Connection = Conn; if (fam.DB_Option_Action_ == "Insert") { CommTxt = "Insert into sys_Module(ModuleID,M_ApplicationID,M_ParentID,M_PageCode,M_CName,M_Directory,M_OrderLevel,M_IsSystem,M_Close,M_Icon)VALUES(SEQ_sys_Module_ID.NEXTVAL,:M_ApplicationID,:M_ParentID,:M_PageCode,:M_CName,:M_Directory,:M_OrderLevel,:M_IsSystem,:M_Close,:M_Icon)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("M_ApplicationID", OracleType.Int32).Value = fam.M_ApplicationID; //����Ӧ�ó���ID cmd.Parameters.Add("M_ParentID", OracleType.Int32).Value = fam.M_ParentID; //�������ģ��ID��ModuleID����,0Ϊ���� cmd.Parameters.Add("M_PageCode", OracleType.VarChar).Value = fam.M_PageCode + ""; //ģ�����ParentΪ0,��ΪS00(xx),����ΪS00M00(xx) cmd.Parameters.Add("M_CName", OracleType.NVarChar).Value = fam.M_CName + ""; //ģ��/��Ŀ���Ƶ�ParentIDΪ0Ϊģ������ cmd.Parameters.Add("M_Directory", OracleType.NVarChar).Value = fam.M_Directory + ""; //ģ��/��ĿĿ¼�� cmd.Parameters.Add("M_OrderLevel", OracleType.VarChar).Value = fam.M_OrderLevel + ""; //��ǰ��������֧��˫��99���˵� cmd.Parameters.Add("M_IsSystem", OracleType.SByte).Value = fam.M_IsSystem; //�Ƿ�Ϊϵͳģ��1:��0:����Ϊϵͳ������ cmd.Parameters.Add("M_Close", OracleType.SByte).Value = fam.M_Close; //�Ƿ�ر�1:��0:�� cmd.Parameters.Add("M_Icon", OracleType.NVarChar).Value = fam.M_Icon + ""; //Ĭ����ʾͼ�� } else if (fam.DB_Option_Action_ == "Update") { CommTxt = "UPDATE sys_Module SET M_ApplicationID = :M_ApplicationID,M_ParentID = :M_ParentID,M_PageCode = :M_PageCode,M_CName = :M_CName,M_Directory = :M_Directory,M_OrderLevel = :M_OrderLevel,M_IsSystem = :M_IsSystem,M_Close = :M_Close,M_Icon = :M_Icon WHERE (ModuleID = :ModuleID)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("M_ApplicationID", OracleType.Int32).Value = fam.M_ApplicationID; //����Ӧ�ó���ID cmd.Parameters.Add("M_ParentID", OracleType.Int32).Value = fam.M_ParentID; //�������ģ��ID��ModuleID����,0Ϊ���� cmd.Parameters.Add("M_PageCode", OracleType.VarChar).Value = fam.M_PageCode + ""; //ģ�����ParentΪ0,��ΪS00(xx),����ΪS00M00(xx) cmd.Parameters.Add("M_CName", OracleType.NVarChar).Value = fam.M_CName + ""; //ģ��/��Ŀ���Ƶ�ParentIDΪ0Ϊģ������ cmd.Parameters.Add("M_Directory", OracleType.NVarChar).Value = fam.M_Directory + ""; //ģ��/��ĿĿ¼�� cmd.Parameters.Add("M_OrderLevel", OracleType.VarChar).Value = fam.M_OrderLevel + ""; //��ǰ��������֧��˫��99���˵� cmd.Parameters.Add("M_IsSystem", OracleType.SByte).Value = fam.M_IsSystem; //�Ƿ�Ϊϵͳģ��1:��0:����Ϊϵͳ������ cmd.Parameters.Add("M_Close", OracleType.SByte).Value = fam.M_Close; //�Ƿ�ر�1:��0:�� cmd.Parameters.Add("M_Icon", OracleType.NVarChar).Value = fam.M_Icon + ""; //Ĭ����ʾͼ�� cmd.Parameters.Add("ModuleID", OracleType.Int32).Value = fam.ModuleID; } else if (fam.DB_Option_Action_ == "Delete") { CommTxt = "Delete from sys_Module WHERE (ModuleID = :ModuleID)"; cmd.CommandText = CommTxt; cmd.Parameters.Add("ModuleID", OracleType.Int32).Value = fam.ModuleID; } else throw new ApplicationException("��ʶ��IJ�������!"); Conn.Open(); OracleTransaction Tran = Conn.BeginTransaction(); cmd.Transaction = Tran; try { rInt = cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); if (fam.DB_Option_Action_ == "Insert") { cmd.CommandText = "select SEQ_sys_Module_ID.CURRVAL from dual"; rInt = Convert.ToInt32(cmd.ExecuteScalar()); } Tran.Commit(); } catch (Exception ex) { Tran.Rollback(); throw new ApplicationException(ex.ToString()); } finally { Tran.Dispose(); cmd.Dispose(); Conn.Dispose(); Conn.Close(); } } return rInt; }
protected void Button1_Click(object sender, EventArgs e) { sys_ModuleTable smt = new sys_ModuleTable(); smt = BusinessFacade.sys_ModuleDisp(ModuleID); string OldPageCode = smt.M_PageCode; smt.M_ApplicationID = S_ID; smt.M_Close = (int)Common.sink(this.M_Close.UniqueID, MethodType.Post, 255, 1, DataType.Int); smt.M_CName = (string)Common.sink(this.M_CName.UniqueID, MethodType.Post, 50, 1, DataType.Str); smt.M_Directory = (string)Common.sink(this.M_Directory.UniqueID, MethodType.Post, 255, 0, DataType.Str); smt.M_Icon = (string)Common.sink(this.M_Icon.UniqueID, MethodType.Post, 255, 0, DataType.Str); //smt.M_IsSystem = (int) Common.sink(this.M_IsSystem.UniqueID,MethodType.Post,255,1,DataType.Int); smt.M_PageCode = (string)Common.sink(this.M_PageCode.UniqueID, MethodType.Post, 6, 1, DataType.CharAndNum); if (CMD == "New") { if (BusinessFacade.sys_Module_CheckPK(smt.M_ApplicationID, smt.M_PageCode, 0)) EventMessage.MessageBox(1, "数据输入出错", string.Format("存在相同的模块编码({0})", smt.M_PageCode) , Icon_Type.Error, "history.back()", UrlType.JavaScript); QueryParam qp = new QueryParam(); qp.Orderfld = "M_OrderLevel"; qp.PageIndex = 1; qp.PageSize = 1; qp.Where = string.Format("Where M_ParentID={0} and M_Applicationid={1}", ModuleID, S_ID); int RecordCount = 0; ArrayList lst = BusinessFacade.sys_ModuleList(qp, out RecordCount); if (ModuleID == 0) { if (RecordCount != 0) RecordCount = Convert.ToInt32(((sys_ModuleTable)lst[0]).M_OrderLevel.Substring(0, 2)) + 1; smt.M_OrderLevel = Common.FillZero(RecordCount.ToString(), 2) + "00"; } else { if (RecordCount != 0) RecordCount = Convert.ToInt32(((sys_ModuleTable)lst[0]).M_OrderLevel.Substring(2, 2)); RecordCount++; smt.M_OrderLevel = smt.M_OrderLevel.Substring(0, 2) + Common.FillZero(RecordCount.ToString(), 2); } smt.M_ParentID = ModuleID; smt.DB_Option_Action_ = "Insert"; } else if (CMD == "Edit") { if (BusinessFacade.sys_Module_CheckPK(smt.M_ApplicationID, smt.M_PageCode, ModuleID)) EventMessage.MessageBox(1, "数据输入出错", string.Format("存在相同的模块编码({0})", smt.M_PageCode) , Icon_Type.Error, "history.back()", UrlType.JavaScript); smt.DB_Option_Action_ = "Update"; } smt.ModuleID = ModuleID; if (smt.M_IsSystem != 1) BusinessFacade.sys_ModuleInsertUpdate(smt); if (!string.IsNullOrEmpty(OldPageCode) && OldPageCode != smt.M_PageCode) { //清除旧有PageCode所在用户的权限. BusinessFacade.sys_RolePermission_DeleteForm(smt.M_ApplicationID, OldPageCode); } sys_Module_Cache.ReLoadCache(); //重新加载模块缓存 EventMessage.MessageBox(1, "操作成功", string.Format("增加/修改模块ID({0})成功!", ModuleID), Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("ModuleManager.aspx?ModuleID={0}&S_ID={1}", ModuleID, S_ID))); }
/// <summary> /// 将记录集转为sys_ModuleTable实体类 /// </summary> /// <param name="dr">记录集</param> /// <returns>sys_ModuleTable</returns> protected object Populatesys_Module(IDataReader dr) { sys_ModuleTable nc = new sys_ModuleTable(); if (!Convert.IsDBNull(dr["ModuleID"])) nc.ModuleID = Convert.ToInt32(dr["ModuleID"]); // 功能模块ID号 if (!Convert.IsDBNull(dr["M_ApplicationID"])) nc.M_ApplicationID = Convert.ToInt32(dr["M_ApplicationID"]); // 所属应用程序ID if (!Convert.IsDBNull(dr["M_ParentID"])) nc.M_ParentID = Convert.ToInt32(dr["M_ParentID"]); // 所属父级模块ID与ModuleID关联,0为顶级 if (!Convert.IsDBNull(dr["M_PageCode"])) nc.M_PageCode = Convert.ToString(dr["M_PageCode"]).Trim(); // 模块编码Parent为0,则为S00(xx),否则为S00M00(xx) if (!Convert.IsDBNull(dr["M_CName"])) nc.M_CName = Convert.ToString(dr["M_CName"]).Trim(); // 模块/栏目名称当ParentID为0为模块名称 if (!Convert.IsDBNull(dr["M_Directory"])) nc.M_Directory = Convert.ToString(dr["M_Directory"]).Trim(); // 模块/栏目目录名 if (!Convert.IsDBNull(dr["M_OrderLevel"])) nc.M_OrderLevel = Convert.ToString(dr["M_OrderLevel"]).Trim(); // 当前所在排序级别支持双层99级菜单 if (!Convert.IsDBNull(dr["M_IsSystem"])) nc.M_IsSystem = Convert.ToInt32(dr["M_IsSystem"]); // 是否为系统模块1:是0:否如为系统则无法修改 if (!Convert.IsDBNull(dr["M_Close"])) nc.M_Close = Convert.ToInt32(dr["M_Close"]); // 是否关闭1:是0:否 if (!Convert.IsDBNull(dr["M_Icon"])) nc.M_Icon = dr["M_Icon"].ToString().Trim(); // 模块/栏目名称当ParentID为0为模块名称 return nc; }
/// <summary> /// ����ģ�黺�� /// </summary> /// <param name="m">����ģ��</param> static void setModuleCache(sys_ModuleTable m) { try { if (!Sys_moduleCache.ContainsKey(m.ModuleID)) { Sys_moduleCache.Add(m.ModuleID, m); //��ʼ��ģ�黺��,bug } if (!Sys_moduleTreeCache.ContainsKey(m.ModuleID)) { Sys_moduleTreeCache.Add(m.ModuleID, new List<sys_ModuleTable>()); //��ʼ����״ģ�黺�� } } catch (Exception) { } }