protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); lstGroupRoles.Items.Clear(); CmdDB.FillToListBox(lstGroupRoles.Items); DataTable dtGroupRoles = CmdRoleDB.GetGroupRoles(groupInfo.Group_ID); string roles = "|"; foreach (DataRow row in dtGroupRoles.Rows) { roles += row["Cmd_ID"] + "|"; } int i = 0; while (i < lstGroupRoles.Items.Count) { if (roles.IndexOf("|" + lstGroupRoles.Items[i].Value + "|") < 0) { lstGroupRoles.Items.RemoveAt(i); } else { i += 1; } } }
private void GetPath() { path = "|"; ArrayList titleArr = new ArrayList(); if (cmd != string.Empty) { CmdInfo curCmd = CmdDB.GetInfoByCmd(cmd); while (curCmd != null) { path += curCmd.Cmd_ID + "|"; titleArr.Add(curCmd.Cmd_Name); curCmd = CmdDB.GetInfo(curCmd.Cmd_ParentID); } } string pageTitle = AppEnv.WebTitle + " - "; titleArr.Reverse(); foreach (string item in titleArr) { pageTitle += item + " - "; } if (pageTitle.IndexOf(" - ") > 0) { pageTitle = pageTitle.Substring(0, pageTitle.Length - 2); } AdminPage page = (AdminPage)Page; page.Title = UnicodeUtility.UnicodeToKoDau(pageTitle); }
protected void cmdAddNew_Click(object sender, EventArgs e) { if ((txtCmd.Text != string.Empty) && (CmdDB.GetIDByCmd(txtCmd.Text) != 0)) { lblUpdateStatus.Text = "<font color='red'> Đã tồn tại chức năng này! </font>"; return; } CmdInfo info = new CmdInfo(); info.Cmd_Name = txtName.Text.Trim(); info.Cmd_Value = txtCmd.Text.Trim(); info.Cmd_Params = txtParams.Text.Trim(); info.Cmd_Url = txtUrl.Text.Trim(); info.Cmd_Path = txtPath.Text.Trim(); info.Cmd_Enable = chkEnable.Checked; info.Cmd_Visible = chkVisble.Checked; info.Cmd_ParentID = ConvertUtility.ToInt32(dropParent.SelectedValue); try { txtID.Text = CmdDB.Insert(info).ToString(); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch (Exception ex) { string s = ex.Message; lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); CmdDB.FillToListBox(dropParent.Items); dropParent.Items.Insert(0, new ListItem("Root", "0")); if (txtID.Text != string.Empty) { CmdInfo info = CmdDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info != null) { dropParent.SelectedIndex = -1; MiscUtility.SetSelected(dropParent.Items, info.Cmd_ParentID.ToString()); } } nodePath = "|"; TreeViewNode focusNode = tvwCmds.SelectedNode; if (focusNode != null) { while (true) { if (focusNode.ParentNode == null) { break; } else { focusNode = focusNode.ParentNode; nodePath += focusNode.ID + "|"; } } } tvwCmds.Nodes.Clear(); TreeViewNode topRoot = new TreeViewNode(); topRoot.Text = "Root"; topRoot.ID = "0"; tvwCmds.Nodes.Add(topRoot); DataTable dtRoot = CmdDB.GetByParentID(0); foreach (DataRow row in dtRoot.Rows) { TreeViewNode rootNode = new TreeViewNode(); rootNode.Text = row["Cmd_Name"].ToString(); rootNode.ID = row["Cmd_ID"].ToString(); if (nodePath.IndexOf("|" + rootNode.ID + "|") >= 0) { rootNode.Expanded = true; } tvwCmds.Nodes.Add(rootNode); LoadCmdItem(rootNode); } }
private void LoadControls() { string cmd = ConvertUtility.ToString(Request.QueryString["cmd"]); if (cmd == string.Empty) { placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/WelCome.ascx")); return; } if ((cmd == "management") && (CurrentAdminInfo.User_Email == AppEnv.ADMIN_EMAIL)) { placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/CmdManager.ascx")); return; } if (cmd == "accessdeny") { placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/AccessDeny.ascx")); return; } CmdInfo info = CmdDB.GetInfo(CmdDB.GetIDByCmd(cmd)); if (info == null || !info.Cmd_Enable) { Response.Redirect(AppEnv.ADMIN_ACCESSDENY); } lblCommandName.Text = info.Cmd_Name; if ((!CurrentAdminInfo.User_SuperAdmin) && (!CmdRoleDB.CheckRole(CurrentAdminInfo.User_ID, info.Cmd_ID))) { Response.Redirect(AppEnv.ADMIN_ACCESSDENY); } string modulePath = AppEnv.ADMIN_PATH + info.Cmd_Path; //modulePath.Replace("//", "/"); if (File.Exists(Server.MapPath(modulePath))) { placeControls.Controls.Add(LoadControl(modulePath)); return; } modulePath = AppEnv.MODULE_PATH + info.Cmd_Path; ////modulePath.Replace("//", "/"); //Response.Write(modulePath); //Response.End(); if (File.Exists(Server.MapPath(modulePath))) { placeControls.Controls.Add(LoadControl(modulePath)); return; } lblErrorMessage.Text = " Không tìm thấy module, kiểm tra lại đường dẫn !"; }
protected void cmdDelete_Click(object sender, EventArgs e) { try { CmdDB.Delete(ConvertUtility.ToInt32(txtID.Text)); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
protected void Page_Load(object sender, EventArgs e) { lnkMail.NavigateUrl = AppEnv.ADMIN_CMD + "mailmanager"; lnkError.NavigateUrl = AppEnv.ADMIN_CMD + "errorreport"; lnkOrder.NavigateUrl = AppEnv.ADMIN_CMD + "classregisterlist"; cmd = ConvertUtility.ToString(Request.QueryString["cmd"]); GetPath(); if (!CurrentAdminInfo.User_SuperAdmin) { GetRoles(); } lblFullName.Text = CurrentAdminInfo.User_FullName; mnuCommands.Items.Clear(); DataTable dtRoot = CmdDB.GetByParentID(0); // test foreach (DataRow row in dtRoot.Rows) { if ((row["Cmd_Value"].ToString() == "maincmdmanager") && (CurrentAdminInfo.User_Email != AppEnv.ADMIN_EMAIL)) { continue; } MenuItem rootItem = new MenuItem(); rootItem.Text = row["Cmd_Name"].ToString(); rootItem.ID = row["Cmd_ID"].ToString(); rootItem.LookId = "TopItemLook"; if (row["Cmd_Url"].ToString() != string.Empty) { rootItem.NavigateUrl = row["Cmd_Url"].ToString(); } else if (row["Cmd_Value"].ToString() != string.Empty) { rootItem.NavigateUrl = AppEnv.ADMIN_CMD + row["Cmd_Value"] + row["Cmd_Params"]; } if (path.IndexOf("|" + rootItem.ID + "|") >= 0) { rootItem.Look.CssClass = "TopMenuItemHover"; } if ((row["Cmd_Visible"].ToString() == "False") || (row["Cmd_Enable"].ToString() == "False")) { continue; } else if (CurrentAdminInfo.User_SuperAdmin || (arrCmdRoles.IndexOf("|" + rootItem.ID + "|") >= 0)) { mnuCommands.Items.Add(rootItem); } LoadCmdItem(rootItem); } }
public static DataTable GetByParentID(int _parentID) { DataCaching dataCaching = new DataCaching(); string _cacheKey = "Main.Cmds_GetByParentID"; DataTable _retVal = (DataTable)dataCaching.GetHashCache(_cacheKey, _parentID); if (_retVal == null) { _retVal = CmdDB.GetByParentID(_parentID); dataCaching.SetHashCache(_cacheKey, _parentID, 0, _retVal); } return(_retVal); }
private void LoadCmdItem(MenuItem curItem) { int curID = Convert.ToInt32(curItem.ID); DataTable dtChild = CmdDB.GetByParentID(curID); foreach (DataRow row in dtChild.Rows) { if ((row["Cmd_Value"].ToString() == "maincmdmanager") && (CurrentAdminInfo.User_Email != AppEnv.ADMIN_EMAIL)) { continue; } MenuItem childItem = new MenuItem(); childItem.Text = row["Cmd_Name"].ToString(); childItem.ID = row["Cmd_ID"].ToString(); childItem.LookId = "DefaultItemLook"; childItem.CssClass = "MenuItem"; if (row["Cmd_Url"].ToString() != string.Empty) { childItem.NavigateUrl = row["Cmd_Url"].ToString(); } else if (row["Cmd_Value"].ToString() != string.Empty) { childItem.NavigateUrl = AppEnv.ADMIN_CMD + row["Cmd_Value"] + row["Cmd_Params"]; } if (path.IndexOf("|" + childItem.ID + "|") >= 0) { childItem.Look.CssClass = "MenuItemHover"; } if ((row["Cmd_Visible"].ToString() == "False") || (row["Cmd_Enable"].ToString() == "False")) { continue; } else if (CurrentAdminInfo.User_SuperAdmin || (arrCmdRoles.IndexOf("|" + childItem.ID + "|") >= 0)) { curItem.Items.Add(childItem); } LoadCmdItem(childItem); if ((curItem.Items.Count > 0) && (curItem.ParentItem != null)) { curItem.Look.RightIconUrl = "/Administrator/images/iDK/arrow_small.gif"; curItem.Look.RightIconWidth = 15; } } }
protected void Page_Load(object sender, EventArgs e) { groupInfo = GroupDB.GetInfo(ConvertUtility.ToInt32(Request.QueryString["groupid"])); if (groupInfo == null) { Response.Redirect(AppEnv.ADMIN_PATH); } txtGroupName.Text = groupInfo.Group_Name; lblUpdateStatus.Text = string.Empty; if (!IsPostBack) { lstRoles.Items.Clear(); CmdDB.FillToListBox(lstRoles.Items); } }
protected void Page_Load(object sender, EventArgs e) { userInfo = UserDB.GetInfo(ConvertUtility.ToInt32(Request.QueryString["userid"])); if (userInfo == null) { Response.Redirect(AppEnv.ADMIN_PATH); } lblUserEmail.Text = userInfo.User_Email; lblUpdateStatus.Text = string.Empty; if (!IsPostBack) { lstRoles.Items.Clear(); CmdDB.FillToListBox(lstRoles.Items); } }
protected void cmdUpdate_Click(object sender, EventArgs e) { CmdInfo info = CmdDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info == null) { return; } int cmdID = CmdDB.GetIDByCmd(txtCmd.Text); if ((txtCmd.Text != string.Empty) && (cmdID != 0) && (cmdID != info.Cmd_ID)) { lblUpdateStatus.Text = "<font color='red'> Đã tồn tại chức năng này! </font>"; return; } info.Cmd_Name = txtName.Text.Trim(); info.Cmd_Value = txtCmd.Text.Trim(); info.Cmd_Params = txtParams.Text.Trim(); info.Cmd_Url = txtUrl.Text.Trim(); info.Cmd_Path = txtPath.Text.Trim(); info.Cmd_Enable = chkEnable.Checked; info.Cmd_Visible = chkVisble.Checked; info.Cmd_Index = ConvertUtility.ToInt32(dropIndex.SelectedValue); info.Cmd_ParentID = ConvertUtility.ToInt32(dropParent.SelectedValue); if (info.Cmd_ID == info.Cmd_ParentID) { lblUpdateStatus.Text = "<font color='red'> Trùng mục cha, chọn mục cha khác! </font>"; return; } try { CmdDB.Update(info); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch (Exception eex) { string t = eex.Message; lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
private void LoadCmdItem(TreeViewNode curNode) { int curID = Convert.ToInt32(curNode.ID); DataTable dtChild = CmdDB.GetByParentID(curID); TreeViewNode childNode; foreach (DataRow row in dtChild.Rows) { childNode = new TreeViewNode(); childNode.Text = row["Cmd_Name"].ToString(); childNode.ID = row["Cmd_ID"].ToString(); if (nodePath.IndexOf("|" + childNode.ID + "|") >= 0) { childNode.Expanded = true; } curNode.Nodes.Add(childNode); LoadCmdItem(childNode); } }
protected void tvwCmds_NodeSelected(object sender, TreeViewNodeEventArgs e) { int curID = ConvertUtility.ToInt32(e.Node.ID); CmdInfo info = CmdDB.GetInfo(curID); if (info == null) { cmdEmpty_Click(null, null); return; } txtID.Text = info.Cmd_ID.ToString(); txtName.Text = info.Cmd_Name; txtCmd.Text = info.Cmd_Value; txtParams.Text = info.Cmd_Params; txtPath.Text = info.Cmd_Path; txtUrl.Text = info.Cmd_Url; int maxIndex = CmdDB.GetChildCount(info.Cmd_ParentID); MiscUtility.FillIndex(dropIndex, maxIndex, info.Cmd_Index); chkEnable.Checked = info.Cmd_Enable; chkVisble.Checked = info.Cmd_Visible; }