⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usersrolecontroller.cs

📁 图书管理系统
💻 CS
字号:
using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Library.Data
{
    /// <summary>
    /// Controller class for users_roles
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class UsersRoleController
    {
        // Preload our schema..
        UsersRole thisSchemaLoad = new UsersRole();
        private string userName = string.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}

					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}

				}

				return userName;
            }

        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public UsersRoleCollection FetchAll()
        {
            UsersRoleCollection coll = new UsersRoleCollection();
            Query qry = new Query(UsersRole.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public UsersRoleCollection FetchByID(object Id)
        {
            UsersRoleCollection coll = new UsersRoleCollection().Where("id", Id).Load();
            return coll;
        }

		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public UsersRoleCollection FetchByQuery(Query qry)
        {
            UsersRoleCollection coll = new UsersRoleCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (UsersRole.Delete(Id) == 1);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (UsersRole.Destroy(Id) == 1);
        }

        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(int UserId,int RoleId)
	    {
		    UsersRole item = new UsersRole();
		    
            item.UserId = UserId;
            
            item.RoleId = RoleId;
            
	    
		    item.Save(UserName);
	    }

    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int Id,int UserId,int RoleId)
	    {
		    UsersRole item = new UsersRole();
		    
				item.Id = Id;
				
				item.UserId = UserId;
				
				item.RoleId = RoleId;
				
		    item.MarkOld();
		    item.Save(UserName);
	    }

    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -