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

📄 sraaaaaa.a

📁 人事管理系统
💻 A
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MODEL;
using DBManage;
using IDAL;

namespace SQLServerDAL
{
     public class RoleRightService:IRoleRightService
    {
        #region IBaseService<RoleRight> 成员


        private static List<RoleRight> GetModelsFromDataSet(DataSet ds)
        {
            List<RoleRight> ls = new List<RoleRight>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                RoleRight model = new RoleRight();
                model.RoleRightId = Convert.ToInt32(row[0]);
                model.RoleId = Convert.ToInt32(row[1]);
                model.NodeId = Convert.ToInt32(row[2]);
                ls.Add(model);
            }
            return ls;
        }

        public int AddModel(RoleRight model)
        {
            string sql = string.Format("insert into RoleRight values('{0}','{1}')",
                model.RoleId ,
                model.NodeId);
            return DBOperate.UpdateModel(sql);
        }

        public int DeleteModelById(int id)
        {
            string where = " RoleRightid=" + id;
            return DeleteModelByWhere(where);
        }

        public int DeleteModelByWhere(string where)
        {
            string sql = string.Format("delete RoleRight");
            if (!string.IsNullOrEmpty(where))
            {
                sql = sql + " where " + where;
            }
            return DBOperate.UpdateModel(sql);
        }

        public int UpdateModel(RoleRight model)
        {
            string something = string.Format(" RoleId='{0}',NodeId='{1}' ",
                 model.RoleId,
                model.NodeId);
            string where = string.Format(" RoleRightid={0} ", model.RoleRightId);
            return UpdateSomethingByWhere(something, where);
        }

        public int UpdateSomethingByWhere(string something, string where)
        {
            string sql = "update RoleRight set " + something;
            if (!string.IsNullOrEmpty(where))
            {
                sql = sql + " where " + where;
            }
            return DBOperate.UpdateModel(sql);
        }

        public List<RoleRight> GetAllModels()
        {
            DataSet ds = DBOperate.GetModels("RoleRight", "");
            return GetModelsFromDataSet(ds);
        }

        public RoleRight GetModelById(int id)
        {
            DataSet ds = DBOperate.GetModels("RoleRight", "RoleRightid=" + id);
            return GetModelsFromDataSet(ds)[0];
        }

        public List<RoleRight> GetModelByForeignKey(int ForeignKeyID)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public List<RoleRight> GetModels(string strWhere)
        {
            DataSet ds = DBOperate.GetModels("RoleRight", strWhere);
            return GetModelsFromDataSet(ds);
        }

        public List<RoleRight> GetModels(int pageIndex, int pageSize, string orderColumnsName, string strWhere)
        {
            DataSet ds = DBOperate.GetModels("RoleRight", pageIndex, pageSize, orderColumnsName, strWhere);
            return GetModelsFromDataSet(ds);
        }

        public List<RoleRight> GetModels(int pageIndex, int pageSize, string orderColumnsName)
        {
            return GetModels(pageIndex, pageSize, orderColumnsName, "");
        }

        public List<RoleRight> GetModels(int pageIndex, string orderColumnsName)
        {
            return GetModels(pageIndex, 10, orderColumnsName, "");
        }

        public List<RoleRight> GetModels(int pageIndex, int pageSize)
        {
            return GetModels(pageIndex, pageSize, "RoleRightid", "");
        }

        public List<RoleRight> GetModels(int pageIndex)
        {
            return GetModels(pageIndex, 10, "RoleRightid", "");
        }

        #endregion
    }
}

⌨️ 快捷键说明

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