/// <summary> /// 初始化页面 /// </summary> private void InitPages() { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUrlAndUserGroupLink(GroupGuid, UrlGuid, string.Empty, null); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in dataSet.Tables[0].Rows) { TextBoxUrl.Text = row["Url"].ToString(); TextBoxUrlCode.Text = row["UrlCode"].ToString(); TextBoxParams.Text = row["UrlParams"].ToString(); TextBoxUrlName.Text = row["UrlName"].ToString(); TextBoxProirotyLevel.Text = string.IsNullOrEmpty(row["PriorityLevel"].ToString()) ? "100" : row["PriorityLevel"].ToString(); string val = "-1"; if (!String.IsNullOrEmpty(row["Forbidden"].ToString())) { val = Convert.ToBoolean(row["Forbidden"].ToString()) ? "0" : "1"; } DropDownListStatus.Items.FindByValue(val).Selected = true; } }
/// <summary> /// 添加至权限组按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonAddToGroup_Click(object sender, EventArgs e) { if (DropDownListGroup.SelectedValue == "0") { //提示请选择要添加的用户组 Show(Page, "请选择要添加到的权限组"); return; } WebBean bean = WebBean.GetInstance(); int count = 0; foreach (RepeaterItem item in Repeater1.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var chk = (CheckBox)item.FindControl("CheckBoxItemID"); if (chk.Checked) { count++; var hf = (HiddenField)item.FindControl("HiddenFieldGUID"); bean.AddUserToUserGroup(hf.Value, DropDownListGroup.SelectedValue, !RadioButtonIsTrue.Checked); } } } if (count > 0) { Show(Page, "添加成功!"); DataBind(); } else { //提示请选择要添加的用户 Show(Page, "请选择要添加的用户"); } }
/// <summary> /// 初始化权限组信息 /// </summary> private void InitUserGroup() { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUserGroupList(String.Empty, string.Empty); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in dataSet.Tables[0].Rows) { CheckBoxListUserGroups.Items.Add(new ListItem(row["UserGroupName"].ToString(), row["GUID"].ToString())); } if (!String.IsNullOrEmpty(UserGuid)) { DataSet myDataSet = bean.Select_UserGroup_Type_User_Data(UserGuid); if (myDataSet == null || myDataSet.Tables.Count <= 0 || myDataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in myDataSet.Tables[0].Rows) { CheckBoxListUserGroups.Items.FindByValue(row["UserGroup_GUID"].ToString()).Selected = true; } } }
/// <summary> /// 行点击事件 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { string guid = e.CommandArgument.ToString(); switch (e.CommandName) { case "delete": WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.SaveUserGroupData(guid, string.Empty, "delete"); Repeater1.DataSource = dataSet; Repeater1.DataBind(); break; case "assign": Response.Redirect("AssignPermission.aspx?guid=" + guid); break; case "usermanager": Response.Redirect("ManagerUser.aspx?guid=" + guid); break; default: break; } }
/// <summary> /// 数据绑定到列表 /// </summary> private void DataBind() { if (DropDownListGroup.SelectedValue == "0") { //提示请选择用户组 GroupGuid = string.Empty; } WebBean bean = WebBean.GetInstance(); bool? ban = null; switch (DropDownListBan.SelectedValue) { case "1": ban = false; break; case "2": ban = true; break; default: break; } DataSet dataSet = bean.SelectGroupUsersData(GroupGuid, TextBoxAccount.Text.Trim(), TextBoxUserName.Text.Trim(), ban, RadioButtonIsTrue.Checked); //提示消息"权限组信息保存成功!" Repeater1.DataSource = dataSet; Repeater1.DataBind(); }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonSave_Click(object sender, EventArgs e) { try { WebBean bean = WebBean.GetInstance(); var model = new UrlDataModel { GUID = "add".Equals(AddOrUpdate) ? Guid.NewGuid().ToString() : UrlGuid, ParentGUID = null, Url = TextBoxUrl.Text.Trim(), UrlCode = TextBoxUrlCode.Text.Trim(), UrlParams = TextBoxParams.Text.Trim(), UrlName = TextBoxUrlName.Text.Trim(), UserAuthentication = DropDownListAuthentication.SelectedValue == "0", Show = DropDownListShow.SelectedValue == "0" }; if ("add".Equals(AddOrUpdate)) { bean.AddUrl(model); } else { bean.UpdateUrl(model); } Show(this.Page, "保存成功!"); } catch (Exception ex) { Show(this.Page, "保存失败!"); WriteLog.WriteExceptionLog(ex.ToString()); } }
/// <summary> /// 初始化页面 /// </summary> public void InitPage() { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUserGroupList("", TextBoxUserGroupName.Text.Trim()); Repeater1.DataSource = dataSet; Repeater1.DataBind(); }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonSave_Click(object sender, EventArgs e) { var selectedValue = string.Empty; foreach (RepeaterItem item in Repeater1.Items) { if (((RadioButton)item.FindControl("RadioButtonSelect")).Checked) { selectedValue = ((HiddenField)item.FindControl("HiddenFieldGUID")).Value.Trim(); break; } } if (Request.QueryString["urlGuid"] == null) { return; } var urlGuid = Request.QueryString["urlGuid"]; if (urlGuid != selectedValue.Trim()) { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.Select_Url_Data(urlGuid, string.Empty); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } UrlDataModel model = new UrlDataModel(); foreach (DataRow row in dataSet.Tables[0].Rows) { model = new UrlDataModel { GUID = row["Url_GUID"].ToString(), ParentGUID = selectedValue, Url = row["Url"].ToString(), UrlCode = row["UrlCode"].ToString(), UrlParams = row["UrlParams"].ToString(), UrlName = row["UrlName"].ToString(), UrlIndex = int.Parse(row["UrlIndex"].ToString()), UserAuthentication = (Boolean)row["UserAuthentication"], Show = (Boolean)row["Show"] }; } try { bean.UpdateUrl(model); } catch (Exception) { throw; } if (!Page.ClientScript.IsStartupScriptRegistered("close")) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "close", "<script language='javascript'>top.$.close('select');</script>"); } } }
/// <summary> /// 父页面是否存在子页面 /// </summary> /// <param name="parentGuid"></param> /// <returns></returns> private bool IsHasChild(string parentGuid) { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.Select_Url_Data(parentGuid: parentGuid); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return(false); } return(true); }
/// <summary> /// 初始化权限数据列表 /// </summary> private void InitUrlDataList() { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUrlAndUserGroupLink(GroupGuid, string.Empty, ParentUrlGuid, DropDownListStatus.SelectedValue); Repeater1.DataSource = dataSet; Repeater1.DataBind(); //if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) return; //BindTreeView(dataSet.Tables[0], TreeView1.Nodes[0]); }
/// <summary> /// 数据绑定到列表 /// </summary> private void DataBind() { WebBean bean = WebBean.GetInstance(); var model = new UrlDataModel { GUID = string.Empty, Url = TextBoxUrl.Text.Trim(), UrlName = TextBoxUrlName.Text.Trim() }; DataSet dataSet = bean.SelectUrlData(model); Repeater1.DataSource = dataSet; Repeater1.DataBind(); }
/// <summary> /// 初始化权限组信息 /// </summary> private void InitUserGroupInfo() { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUserGroupList(String.Empty, string.Empty); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in dataSet.Tables[0].Rows) { DropDownListGroupName.Items.Add(new ListItem(row["UserGroupName"].ToString(), row["GUID"].ToString())); } if (!string.IsNullOrEmpty(GroupGuid)) { DropDownListGroupName.Items.FindByValue(GroupGuid).Selected = true; } }
/// <summary> /// 根据子页面地址获取父页面地址 /// </summary> /// <param name="childUrlGuid"></param> /// <returns></returns> private string GetParentUrlGuid(string childUrlGuid) { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.Select_Url_Data(childUrlGuid, string.Empty); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return(string.Empty); } foreach (DataRow row in dataSet.Tables[0].Rows) { if (String.IsNullOrEmpty(row["ParentGUID"].ToString())) { return(null); } return(row["ParentGUID"].ToString()); } return(string.Empty); }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(TextBoxAccount.Text.Trim()) || String.IsNullOrEmpty(TextBoxUserName.Text.Trim())) { return; } if (RadioButtonListBan.SelectedItem == null) { return; } UserDataModel userDataModel = new UserDataModel { GUID = String.IsNullOrEmpty(UserGuid)?Guid.NewGuid().ToString():UserGuid, Account = TextBoxAccount.Text.Trim(), UserName = TextBoxUserName.Text.Trim(), Password = "******", Ban = RadioButtonListBan.SelectedItem.Value == "0" }; try { WebBean bean = WebBean.GetInstance(); bean.AddOrUpdateUser(userDataModel, string.IsNullOrEmpty(UserGuid)?"add":"update"); //如果用户组信息 bean.AddUserToUserGroup(UserGuid, string.Empty, false); foreach (ListItem item in CheckBoxListUserGroups.Items) { if (item.Selected) { bean.AddUserToUserGroup(userDataModel.GUID, item.Value, true); } } //if (CheckBoxListUserGroups.SelectedItem != null && DropDownListUserGroup.SelectedValue != "0") //{ // bean.AddUserToUserGroup(userDataModel.GUID, DropDownListUserGroup.SelectedValue, true); //} } catch (Exception ex) { WriteLog.WriteExceptionLog(ex.ToString()); } }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(TextBoxProirotyLevel.Text.Trim())) { Show(Page, "请输入优先级"); return; } int proirotyLevel; if (!int.TryParse(TextBoxProirotyLevel.Text.Trim(), out proirotyLevel)) { Show(Page, "优先级输入不正确,请输入整数"); return; } string type = "0"; switch (DropDownListStatus.SelectedValue) { case "-1": type = "-1"; break; case "0": type = "1"; break; default: type = "0"; break; } try { WebBean bean = WebBean.GetInstance(); bean.SavePermission(UrlGuid, GroupGuid, proirotyLevel, type); Show(Page, "保存成功!"); } catch (Exception ex) { Show(Page, "保存失败!"); WriteLog.WriteExceptionLog(ex.ToString()); } }
private void InitUserInfo() { if (String.IsNullOrEmpty(UserGuid)) { return; } WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.Select_User_Data(UserGuid); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in dataSet.Tables[0].Rows) { TextBoxAccount.Text = row["Account"].ToString(); TextBoxUserName.Text = row["UserName"].ToString(); RadioButtonListBan.Items.FindByValue("0").Selected = Convert.ToBoolean(row["Ban"].ToString()); } }
/// <summary> /// 数据绑定到列表 /// </summary> private void DataBind() { WebBean bean = WebBean.GetInstance(); bool?authentication = null; switch (DropDownListAuthentication.SelectedValue) { case "1": authentication = true; break; case "2": authentication = false; break; } bool?show = null; switch (DropDownListShow.SelectedValue) { case "1": show = true; break; case "2": show = false; break; } UrlDataModel model = new UrlDataModel { GUID = string.Empty, Url = TextBoxUrl.Text.Trim(), UrlName = TextBoxUrlName.Text.Trim(), UserAuthentication = authentication, Show = show }; DataSet dataSet = bean.SelectUrlData(model); Repeater1.DataSource = dataSet; Repeater1.DataBind(); }
/// <summary> /// 初始化页面 /// </summary> /// <param name="UserGroupGuid"></param> private void InitPage(string UserGroupGuid) { //如果传入的参数为空,则是插入调用 if (String.IsNullOrEmpty(UserGroupGuid)) { AddOrUpdate = "add"; return; } AddOrUpdate = "update"; WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUserGroupList(UserGroupGuid, string.Empty); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in dataSet.Tables[0].Rows) { TextBoxUserGroupName.Text = row["UserGroupName"].ToString(); } }
/// <summary> /// 行点击事件 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName != "delete") { return; } try { if (e.CommandArgument == null) { return; } string guid = e.CommandArgument.ToString(); WebBean bean = WebBean.GetInstance(); bean.DeleteUrl(" where GUID='" + guid + "'"); DataBind(); } catch (Exception ex) { } }
/// <summary> /// 行点击事件 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { WebBean bean = WebBean.GetInstance(); if (e.CommandName == "action") { List <String> args = e.CommandArgument.ToString().Split(',').ToList(); if (args.Count <= 0) { return; } bean.ChangeUserState(args[0], Convert.ToBoolean(args[1])); DataBind(); } if (e.CommandName == "delete") { string arg = e.CommandArgument.ToString().Trim(); bean.AddUserToUserGroup(arg, string.Empty, false); bean.DeleteUserData(arg); DataBind(); } }
/// <summary> /// 导入按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonImport_Click(object sender, EventArgs e) { WebBean bean = WebBean.GetInstance(); try { if (RadioButtonCover.Checked) { bean.DeleteAllUrl(); } DivContent = new StringBuilder(); SqlValues = new StringBuilder(); CreateDirectoryFiles(TextBoxImportDirectory.Text.Trim()); bean.ImportUrl(SqlValues.ToString()); //tempdiv.InnerText = divContent.ToString(); Show(Page, "导入成功!"); } catch (Exception exception) { WriteLog.WriteExceptionLog(exception.ToString()); Show(Page, "导入失败!"); } }
/// <summary> /// 保存或修改权限组信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(TextBoxUserGroupName.Text.Trim())) { //提示错误消息"权限组名称不能为空" return; } try { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.SaveUserGroupData("add".Equals(AddOrUpdate) ? Guid.NewGuid().ToString() : UserGroupGuid, TextBoxUserGroupName.Text.Trim(), AddOrUpdate); //提示消息"权限组信息保存成功!" TextBoxUserGroupName.Text = String.Empty; return; } catch (Exception ex) { //提示错误消息"权限组保存失败!" //写错误日志 WriteLog.WriteExceptionLog(ex.ToString()); return; } }
/// <summary> /// 初始化页面 /// </summary> /// <param name="urlGuid"></param> private void InitPage(string urlGuid) { //如果传入的参数为空,则是插入调用 if (String.IsNullOrEmpty(urlGuid)) { AddOrUpdate = "add"; TextBoxUrl.ReadOnly = false; ClearTextBox(); } else { AddOrUpdate = "update"; UrlDataModel model = new UrlDataModel { GUID = urlGuid, UrlName = string.Empty, UserAuthentication = null, Show = null }; WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.SelectUrlData(model); if (dataSet == null || dataSet.Tables.Count <= 0 || dataSet.Tables[0].Rows.Count <= 0) { return; } foreach (DataRow row in dataSet.Tables[0].Rows) { TextBoxUrlName.Text = row["UrlName"].ToString(); TextBoxUrlCode.Text = row["UrlCode"].ToString(); TextBoxUrl.Text = row["Url"].ToString(); TextBoxParams.Text = row["UrlParams"].ToString(); DropDownListAuthentication.Items.FindByValue(Convert.ToBoolean(row["UserAuthentication"].ToString()) ? "0" : "1").Selected = true; DropDownListShow.Items.FindByValue(Convert.ToBoolean(row["Show"].ToString()) ? "0" : "1").Selected = true; } } }
/// <summary> /// 获取索引最大值 /// </summary> /// <returns></returns> private int GetMaxIndex() { WebBean bean = WebBean.GetInstance(); return(bean.GetMaxUrlIndex() + 1); }