zoukankan      html  css  js  c++  java
  • Syteline System Authorizations二次开发

    前段时间写了一些SQL语句或存储过程,可以参考此篇:http://www.cnblogs.com/insus/articles/1899336.html 原本只是为了自己方便工作,但是用户永远满足不了,他们也有跟自己需求一样,只有写成一个类别,并在asp.net界面显示出来。Authorizations.cs 代码片断:

    代码
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for Authorizations
    /// </summary>
    namespace Insus.NET
    {
        
    public class Authorizations
        {
            BusinessBase objBusinessBase 
    = new BusinessBase();

            
    public Authorizations()
            {
                
    //
                
    // TODO: Add constructor logic here
                
    //
            }

            
    //Get all group
            public DataTable GetGroupNames()
            {
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetGroupNames").Tables[0];
            }

            
    //Get all user
            public DataTable GetUserNames()
            {
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetUserNames").Tables[0];
            }

            
    // Get user by user id
            public DataTable GetUserNamesByUserId(string userId)
            {
                Parameter[] parameter 
    = { 
                                            
    new Parameter ("@UserId",SqlDbType.Decimal,9,ConvertData.ToDecimal(userId))
                                        };
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetUserNamesByUserId", parameter).Tables[0];
            }

            
    //Get user  by group id
            public DataTable GetUserNamesByGroupId(string groupId)
            {
                Parameter[] parameter 
    = { 
                                            
    new Parameter ("@GroupId",SqlDbType.Decimal,9,ConvertData.ToDecimal(groupId))
                                        };
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetUserNamesByGroup", parameter).Tables[0];
            }

            
    //Get group by user id
            public DataTable GetGroupNamesByUser(string userId)
            {
                Parameter[] parameter 
    = { 
                                            
    new Parameter ("@UserId",SqlDbType.Decimal,9,ConvertData.ToDecimal(userId))
                                        };
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetGroupNamesByUser", parameter).Tables[0];
            }

            
    //Get group by group id
            public DataTable GetGroupNamesByGroupId(string groupId)
            {
                Parameter[] parameter 
    = { 
                                            
    new Parameter ("@GroupId",SqlDbType.Decimal,9,ConvertData.ToDecimal(groupId))
                                        };
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetGroupNamesByGroup", parameter).Tables[0];
            }

            
    //Get user account authorization
            public DataTable GetAccountAuthorizationsByUser(string userId)
            {
                Parameter[] parameter 
    = { 
                                            
    new Parameter ("@UserId",SqlDbType.Decimal,9,ConvertData.ToDecimal(userId))
                                        };
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetAccountAuthorizationsByUser", parameter).Tables[0];
            }

            
    //Get group account authorization
            public DataTable GetAccountAuthorizationsByGroup(string groupId)
            {
                Parameter[] parameter 
    = { 
                                            
    new Parameter ("@GroupId",SqlDbType.Decimal,9,ConvertData.ToDecimal(groupId))
                                        };
                
    return objBusinessBase.GetDataToDataSet("usp_SyteLine_GetAccountAuthorizationsByGroup", parameter).Tables[0];
            }
        }
    }

      

    Users.aspx代码片断:

    代码
    <table border="0" cellpadding="0" cellspacing="3" width="100%">
        
    <tr>
            
    <td width="270" valign="top">
                
    <asp:GridView ID="GvUsers" runat="server" SkinID="gridviewSkin" DataKeyNames="UserId"
                    OnRowCreated
    ="GvUsers_RowCreated">
                    
    <AlternatingRowStyle BackColor="White" />
                    
    <RowStyle BackColor="WhiteSmoke" />
                    
    <Columns>
                        
    <asp:TemplateField HeaderText="User Id">
                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" />
                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                            
    <ItemTemplate>
                                
    <%Eval("username"%>
                            
    </ItemTemplate>
                        
    </asp:TemplateField>
                        
    <asp:TemplateField HeaderText="User Description">
                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" />
                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                            
    <ItemTemplate>
                                
    <%Eval("userDesc")%>
                            
    </ItemTemplate>
                        
    </asp:TemplateField>
                        
    <asp:TemplateField HeaderText="Details">
                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Width="30px" />
                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" Width="30px" HorizontalAlign="Center" />
                            
    <ItemTemplate>
                                
    <asp:ImageButton ID="ImageButtonDetails" runat="server" ImageAlign="Absmiddle" CausesValidation="false"
                                    ImageUrl
    ="~/System/Image/details.gif" />
                            
    </ItemTemplate>
                        
    </asp:TemplateField>
                    
    </Columns>
                
    </asp:GridView>
            
    </td>
            
    <td width="10">
            
    </td>
            
    <td valign="top">
                
    <fieldset id="fd_User_label" runat="server">
                    
    <div style="height: 5px;">
                    
    </div>
                    
    <asp:Label ID="lbShowUserId" runat="server" ForeColor="#003399"></asp:Label>
                    
    <div style="height: 5px;">
                    
    </div>
                
    </fieldset>
                
    <table border="0" cellpadding="0" cellspacing="3">
                    
    <tr>
                        
    <td valign="top">
                            
    <fieldset id="fd_group" runat="server">
                                
    <legend>Groups</legend>
                                
    <asp:GridView ID="GvGroups" runat="server" SkinID="gridviewSkin" DataKeyNames="GroupId">
                                    
    <AlternatingRowStyle BackColor="White" />
                                    
    <RowStyle BackColor="WhiteSmoke" />
                                    
    <Columns>
                                        
    <asp:TemplateField HeaderText="Group Name">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("GroupName")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Group Description">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("GroupDesc")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                    
    </Columns>
                                
    </asp:GridView>
                            
    </fieldset>
                        
    </td>
                        
    <td valign="top">
                            
    <fieldset id="fd_Authorizations" runat="server">
                                
    <legend>User Authorizations</legend>
                                
    <asp:GridView ID="GvAuthorizations" runat="server" SkinID="gridviewSkin">
                                    
    <AlternatingRowStyle BackColor="White" />
                                    
    <RowStyle BackColor="WhiteSmoke" />
                                    
    <Columns>
                                        
    <asp:TemplateField HeaderText="Object Name">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("ObjectName1")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Delete Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("DeletePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Edit Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("EditPrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Execute Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("ExecutePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Insert Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("InsertPrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Read Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("ReadPrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Bulk Update">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("BulkUpdatePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Update Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("UpdatePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                    
    </Columns>
                                
    </asp:GridView>
                            
    </fieldset>
                        
    </td>
                    
    </tr>
                
    </table>
            
    </td>
        
    </tr>
    </table>

       

    users.aspx.cs代码片断:

    代码
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Insus.NET;

    public partial class System_SyteLine_Authorizations_Users : BasePage
    {
        Authorizations objAuthorizations 
    = new Authorizations();

        
    protected void Page_Load(object sender, EventArgs e)
        {
           
    if (!IsPostBack)
            {
                Data_Binding();
            }

            
    this.SystemPageSubject1.SetSubject = "Users";
        }

        
    private void Data_Binding()
        {
            
    this.GvUsers.DataSource = objAuthorizations.GetUserNames();
            
    this.GvUsers.DataBind();
        }

        
    protected void GvUsers_RowCreated(object sender, GridViewRowEventArgs e)
        {
            InsusBase.GridView_RowCreated(GvUsers, e, 
    "Peachpuff");

            
    if (e.Row.RowType == DataControlRowType.DataRow)
            {
                
    if (e.Row.FindControl("ImageButtonDetails"!= null)
                {
                    ImageButton ImageButtonDetails 
    = (ImageButton)e.Row.FindControl("ImageButtonDetails");
                    ImageButtonDetails.Click 
    += new ImageClickEventHandler(ImageButtonDetails_Click);
                }
            }
        }

        
    private void ImageButtonDetails_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imageButton 
    = (ImageButton)sender;
            GridViewRow gvr 
    = (GridViewRow)imageButton.Parent.Parent;
            
    string primaryKey = GvUsers.DataKeys[gvr.RowIndex].Value.ToString();
           
            DataRow dataRow 
    = objAuthorizations.GetUserNamesByUserId(primaryKey).Rows[0];
            
    this.lbShowUserId.Text = "User Id: " + dataRow["username"].ToString() + "(" + dataRow["userDesc"].ToString() + ")";

            
    this.GvGroups.DataSource = objAuthorizations.GetGroupNamesByUser(primaryKey);
            
    this.GvGroups.DataBind();

            
    this.GvAuthorizations.DataSource = objAuthorizations.GetAccountAuthorizationsByUser(primaryKey);
            
    this.GvAuthorizations.DataBind();
        }
    }

     
    Groups.aspx代码片断: 

    代码
    <table border="0" cellpadding="0" cellspacing="3" width="100%">
        
    <tr>
            
    <td width="270" valign="top">
                
    <asp:GridView ID="GvGroups" runat="server" SkinID="gridviewSkin" DataKeyNames="GroupId"
                    OnRowCreated
    ="GvGroups_RowCreated">
                    
    <AlternatingRowStyle BackColor="White" />
                    
    <RowStyle BackColor="WhiteSmoke" />
                    
    <Columns>
                        
    <asp:TemplateField HeaderText="Group Name">
                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" />
                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                            
    <ItemTemplate>
                                
    <%Eval("GroupName")%>
                            
    </ItemTemplate>
                        
    </asp:TemplateField>
                        
    <asp:TemplateField HeaderText="Details">
                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Width="30px" />
                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" Width="30px" HorizontalAlign="Center" />
                            
    <ItemTemplate>
                                
    <asp:ImageButton ID="ImageButtonDetails" runat="server" ImageAlign="Absmiddle" CausesValidation="false"
                                    ImageUrl
    ="~/System/Image/details.gif" />
                            
    </ItemTemplate>
                        
    </asp:TemplateField>
                    
    </Columns>
                
    </asp:GridView>
            
    </td>
            
    <td width="10">
            
    </td>
            
    <td valign="top">
                
    <fieldset id="fd_Group_label" runat="server">
                    
    <div style="height: 5px;">
                    
    </div>
                    
    <asp:Label ID="lbGroupName" runat="server" ForeColor="#003399"></asp:Label>
                    
    <div style="height: 5px;">
                    
    </div>
                
    </fieldset>
                
    <table border="0" cellpadding="0" cellspacing="3">
                    
    <tr>
                        
    <td valign="top">
                            
    <fieldset id="fd_group" runat="server">
                                
    <legend>Users</legend>
                                
    <asp:GridView ID="GvUsers" runat="server" SkinID="gridviewSkin" Width="270">
                                    
    <AlternatingRowStyle BackColor="White" />
                                    
    <RowStyle BackColor="WhiteSmoke" />
                                    
    <Columns>
                                        
    <asp:TemplateField HeaderText="User Id">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("username"%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="User Description">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("userDesc")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                    
    </Columns>
                                
    </asp:GridView>
                            
    </fieldset>
                        
    </td>
                        
    <td valign="top">
                            
    <fieldset id="fd_Authorizations" runat="server">
                                
    <legend>Group Authorizations</legend>
                                
    <asp:GridView ID="GvAuthorizations" runat="server" SkinID="gridviewSkin">
                                    
    <AlternatingRowStyle BackColor="White" />
                                    
    <RowStyle BackColor="WhiteSmoke" />
                                    
    <Columns>                                
                                        
    <asp:TemplateField HeaderText="Object Name">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("ObjectName1")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Delete Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("DeletePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Edit Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("EditPrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Execute Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("ExecutePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Insert Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("InsertPrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Read Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("ReadPrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Update Privilege">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("UpdatePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                        
    <asp:TemplateField HeaderText="Bulk Update">
                                            
    <HeaderStyle BorderColor="#c0c0c0" BorderWidth="1" Font-Bold="false" />
                                            
    <ItemStyle BorderColor="#c0c0c0" BorderWidth="1" />
                                            
    <ItemTemplate>
                                                
    <%Eval("BulkUpdatePrivilege")%>
                                            
    </ItemTemplate>
                                        
    </asp:TemplateField>
                                    
    </Columns>
                                
    </asp:GridView>
                            
    </fieldset>
                        
    </td>
                    
    </tr>
                
    </table>
            
    </td>
        
    </tr>
    </table>

     Groups.aspx.cs代码片断: 

    代码
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Insus.NET;

    public partial class System_SyteLine_Authorizations_Groups : BasePage
    {
        Authorizations objAuthorizations 
    = new Authorizations();

        
    protected void Page_Load(object sender, EventArgs e)
        {
            InsusBase.SystemPath 
    = Request.RawUrl;
            InsusBase.SystemLoginAuthorizationed();
            
            
    if (!IsPostBack)
            {
                Data_Binding();
            }

            
    this.SystemPageSubject1.SetSubject = "Groups";
        }

        
    private void Data_Binding()
        {
            
    this.GvGroups.DataSource = objAuthorizations.GetGroupNames();
            
    this.GvGroups.DataBind();
        }

        
    protected void GvGroups_RowCreated(object sender, GridViewRowEventArgs e)
        {
            InsusBase.GridView_RowCreated(GvGroups, e, 
    "Peachpuff");

            
    if (e.Row.RowType == DataControlRowType.DataRow)
            {
                
    if (e.Row.FindControl("ImageButtonDetails"!= null)
                {
                    ImageButton ImageButtonDetails 
    = (ImageButton)e.Row.FindControl("ImageButtonDetails");
                    ImageButtonDetails.Click 
    += new ImageClickEventHandler(ImageButtonDetails_Click);
                }
            }
        }

        
    private void ImageButtonDetails_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imageButton 
    = (ImageButton)sender;
            GridViewRow gvr 
    = (GridViewRow)imageButton.Parent.Parent;
            
    string primaryKey = GvGroups.DataKeys[gvr.RowIndex].Value.ToString();

            DataRow dataRow 
    = objAuthorizations.GetGroupNamesByGroupId(primaryKey).Rows[0];

            
    string message = string.Empty;
            
    if (dataRow["GroupDesc"].ToString().Length == 0)
            {
                message 
    += dataRow["GroupName"].ToString();
            }
            
    else
            {
                message 
    += dataRow["GroupName"].ToString() + "(" + dataRow["GroupDesc"].ToString() + ")";
            }

            
    this.lbGroupName.Text = "Group Name: " + message;

            
    this.GvUsers.DataSource = objAuthorizations.GetUserNamesByGroupId(primaryKey);
            
    this.GvUsers.DataBind();

            
    this.GvAuthorizations.DataSource = objAuthorizations.GetAccountAuthorizationsByGroup(primaryKey);
            
    this.GvAuthorizations.DataBind();
        }
    }

     
    下图是Groups界面截图:


     以上代码片码,仅供参考,您无法直接拷贝运行。如有什么问题,可以留言与以博客园联系方式联系Insus.NET。

  • 相关阅读:
    android
    需求分析
    请简述使用MediaRecorder实现录音的步骤
    AudioManager的详细内容
    ios 开发failed to chmod
    崩溃block
    图片不能切割成功 调了五个小时!!!!
    collectionView itemW宽度计算不对
    只用头文件
    ping 10.13.5.233
  • 原文地址:https://www.cnblogs.com/insus/p/1911700.html
Copyright © 2011-2022 走看看