/// <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> 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="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 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> public void InitPage() { WebBean bean = WebBean.GetInstance(); DataSet dataSet = bean.GetUserGroupList("", TextBoxUserGroupName.Text.Trim()); Repeater1.DataSource = dataSet; Repeater1.DataBind(); }
/// <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(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()); } }
/// <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, 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="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> /// <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; } }