protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ListItem item = new ListItem(); item.Text = "所有铁路系统"; item.Value = "0"; ddlRailSystem.Items.Add(item); string strSql = "select * from Rail_System"; OracleAccess db = new OracleAccess(); DataSet ds = db.RunSqlDataSet(strSql); foreach (DataRow dr in ds.Tables[0].Rows) { item = new ListItem(); item.Text = dr["Rail_System_Name"].ToString(); item.Value = dr["Rail_System_ID"].ToString(); ddlRailSystem.Items.Add(item); } if (!string.IsNullOrEmpty(Request.QueryString.Get("id"))) { SystemRoleBLL objBll = new SystemRoleBLL(); SystemRole role = objBll.GetRole(Convert.ToInt32(Request.QueryString.Get("id"))); txtRoleNameInsert.Text = role.RoleName; txtDescriptionInsert.Text = role.Description; txtMemoInsert.Text = role.Memo; chIsAdminInsert.Checked = role.IsAdmin; ddlRailSystem.SelectedValue = role.RailSystemID.ToString(); } } }
protected void InsertButton_Click(object sender, EventArgs e) { SystemRoleBLL objBll = new SystemRoleBLL(); if (string.IsNullOrEmpty(Request.QueryString.Get("id"))) { SystemRole role = new SystemRole(); role.IsAdmin = chIsAdminInsert.Checked; role.RailSystemID = Convert.ToInt32(ddlRailSystem.SelectedValue); role.RoleName = txtRoleNameInsert.Text; role.Description = txtDescriptionInsert.Text; role.Memo = txtMemoInsert.Text; objBll.AddRole(role); } else { SystemRole role = objBll.GetRole(Convert.ToInt32(Request.QueryString.Get("id"))); role.IsAdmin = chIsAdminInsert.Checked; role.RailSystemID = Convert.ToInt32(ddlRailSystem.SelectedValue); role.RoleName = txtRoleNameInsert.Text; role.Description = txtDescriptionInsert.Text; role.Memo = txtMemoInsert.Text; objBll.UpdateRole(role); } Response.Write("<script>window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>"); }
public static int GetRailSystemId() { int railSystemId = 0; if (PrjPub.IsServerCenter) { SystemRoleBLL roleBll = new SystemRoleBLL(); SystemRole role = roleBll.GetRole(PrjPub.CurrentLoginUser.RoleID); railSystemId = role.RailSystemID; } return(railSystemId); }
private void BindGrid() { ds = UserRoleBLL.GetAllUserRoles(); storeDepGrid.DataSource = ds; storeDepGrid.DataBind(); DropDownList depList = (DropDownList)storeDepGrid.FooterRow.FindControl("ddlAddRoleName"); depList.DataSource = SystemRoleBLL.GetAllSystemRoles(); depList.DataBind(); depList.DataTextField = "RoleName"; depList.DataValueField = "RoleId"; depList.DataBind(); }
private void DeleteData(int nRoleID) { SystemUserBLL objBll = new SystemUserBLL(); IList <SystemUser> objList = objBll.GetUsersByRoleID(nRoleID); if (objList.Count > 0) { SessionSet.PageMessage = "该角色已被引用,不能删除!"; return; } SystemRoleBLL systemRoleBLL = new SystemRoleBLL(); systemRoleBLL.DeleteRole(nRoleID); }
protected void storeDepGrid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) > 0) { try { DropDownList depList = (DropDownList)e.Row.FindControl("ddlRoleName"); depList.DataSource = SystemRoleBLL.GetAllSystemRoles(); depList.DataBind(); depList.DataTextField = "RoleName"; depList.DataValueField = "RoleId"; depList.DataBind(); // depList.Items.FindByValue((e.Row.FindControl("lblDep_Id") as Label).Text).Selected = true; DataRowView dr = e.Row.DataItem as DataRowView; depList.SelectedValue = (string)e.Row.DataItem; // you can use e.Row.DataItem to get the value } catch (Exception exo) { } } } }
private void BindOrganizationTree() { OrganizationBLL organizationBLL = new OrganizationBLL(); IList <RailExam.Model.Organization> organizationList = new List <RailExam.Model.Organization>(); int railSystemID = 0; if (PrjPub.IsServerCenter) { SystemRoleBLL roleBll = new SystemRoleBLL(); SystemRole role = roleBll.GetRole(PrjPub.CurrentLoginUser.RoleID); railSystemID = role.RailSystemID; } if (PrjPub.IsServerCenter && (PrjPub.CurrentLoginUser.SuitRange == 1 || railSystemID != 0)) { SystemRoleBLL roleBll = new SystemRoleBLL(); SystemRole role = roleBll.GetRole(PrjPub.CurrentLoginUser.RoleID); organizationList = organizationBLL.GetOrganizations(); string strOwnIDs = string.Empty; if (railSystemID != 0) { IList <RailExam.Model.Organization> organizationList1 = organizationBLL.GetOrganizations(PrjPub.CurrentLoginUser.StationOrgID); foreach (RailExam.Model.Organization organization in organizationList1) { strOwnIDs += strOwnIDs == string.Empty ? organization.OrganizationId.ToString() : "," + organization.OrganizationId; } } if (organizationList.Count > 0) { TreeViewNode tvn = null; tvn = new TreeViewNode(); //tvn.ID = "0"; //tvn.Value = "0"; //tvn.Text = PrjPub.GetRailNameBao(); //tvn.ToolTip = PrjPub.GetRailNameBao(); //tvOrganization.Nodes.Add(tvn); foreach (RailExam.Model.Organization organization in organizationList) { if ((organization.IdPath + "/").IndexOf("/1/") >= 0 && organization.LevelNum != 1 && railSystemID != 0 && railSystemID != organization.RailSystemID) { continue; } if (organization.LevelNum != 1 && strOwnIDs != string.Empty && (organization.IdPath + "/").IndexOf("/1/") < 0 && ("," + strOwnIDs + ",").IndexOf("," + organization.OrganizationId + ",") < 0) { continue; } tvn = new TreeViewNode(); tvn.ID = organization.OrganizationId.ToString(); tvn.Value = organization.OrganizationId.ToString(); tvn.Text = organization.ShortName; tvn.ToolTip = organization.FullName; try { if (organization.ParentId == 0) { tvn.Expanded = true; tvOrganization.Nodes.Add(tvn); } else { tvOrganization.FindNodeById(organization.ParentId.ToString()).Nodes.Add(tvn); } } catch { tvOrganization.Nodes.Clear(); SessionSet.PageMessage = "数据错误!"; return; } } } //Pub.BuildComponentArtTreeView(tvOrganization, (IList)organizationList, "OrganizationId", // "ParentId", "ShortName", "FullName", "OrganizationId", null, null, null); } else { string strOrgID; if (PrjPub.IsServerCenter) { strOrgID = PrjPub.CurrentLoginUser.StationOrgID.ToString(); } else { strOrgID = ConfigurationManager.AppSettings["StationID"].ToString(); } int stationID = organizationBLL.GetStationOrgID(Convert.ToInt32(strOrgID)); organizationList = organizationBLL.GetOrganizations(stationID); if (organizationList.Count > 0) { TreeViewNode tvn = null; tvn = new TreeViewNode(); tvn.ID = "0"; tvn.Value = "0"; tvn.Text = PrjPub.GetRailNameBao(); tvn.ToolTip = PrjPub.GetRailNameBao(); tvOrganization.Nodes.Add(tvn); foreach (RailExam.Model.Organization organization in organizationList) { tvn = new TreeViewNode(); tvn.ID = organization.OrganizationId.ToString(); tvn.Value = organization.OrganizationId.ToString(); tvn.Text = organization.ShortName; tvn.ToolTip = organization.FullName; if (organization.LevelNum == 2) { tvn.Expanded = true; } try { if (organization.LevelNum == 2) { tvOrganization.FindNodeById("0").Nodes.Add(tvn); } else { tvOrganization.FindNodeById(organization.ParentId.ToString()).Nodes.Add(tvn); } } catch { tvOrganization.Nodes.Clear(); SessionSet.PageMessage = "数据错误!"; return; } } } } tvOrganization.DataBind(); if (tvOrganization.Nodes.Count > 0) { tvOrganization.Nodes[0].Expanded = true; } }