123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.Common;
- using CB.Common;
- using CB.Entity;
- using CB.Interface.Infrastructure;
- namespace CB.Data.SqlServer
- {
- public class SysGroupManage : Repository<SysGroupInfo>, ISysGroupService
- {
- public SysGroupManage(string interfaceId)
- : base(interfaceId)
- {
- }
- public override bool Save(SysGroupInfo entity)
- {
- DbParameter[] pars =
- {
- DbHelper.MakeInParam(InterfaceId,"@statement",(DbType)SqlDbType.NVarChar,200,"INSERT INTO [SYS_SysGroup] ([GroupName],[Status]) VALUES (@GroupName,@Status)"),
- DbHelper.MakeInParam(InterfaceId,"@params",(DbType)SqlDbType.NVarChar,100,"@GroupName nchar(20),@Status bit"),
- DbHelper.MakeInParam(InterfaceId,"@GroupName",(DbType)SqlDbType.NChar,20,entity.GroupName),
- DbHelper.MakeInParam(InterfaceId,"@Status",(DbType)SqlDbType.Bit,1,entity.Status)
- };
- return DbHelper.ExecuteNonQuery(InterfaceId,CommandType.StoredProcedure, "dbo.sp_executesql", pars) > 0 ? true : false;
- }
- public override bool Update(SysGroupInfo entity)
- {
- DbParameter[] pars =
- {
- DbHelper.MakeInParam(InterfaceId,"@statement",(DbType)SqlDbType.NVarChar,200,"UPDATE [SYS_SysGroup] SET [GroupName]=@GroupName,[Status]=@Status WHERE [GroupId]=@gid"),
- DbHelper.MakeInParam(InterfaceId,"@params",(DbType)SqlDbType.NVarChar,100,"@GroupName nchar(20),@Status bit,@gid int"),
- DbHelper.MakeInParam(InterfaceId,"@GroupName",(DbType)SqlDbType.NChar,20,entity.GroupName),
- DbHelper.MakeInParam(InterfaceId,"@Status",(DbType)SqlDbType.Bit,1,entity.Status),
- DbHelper.MakeInParam(InterfaceId,"@gid",(DbType)SqlDbType.Int,4,entity.GroupId)
- };
- return DbHelper.ExecuteNonQuery(InterfaceId,CommandType.StoredProcedure, "dbo.sp_executesql", pars) > 0 ? true : false;
- }
- public override bool Delete(int Id)
- {
- DbParameter[] pars =
- {
- DbHelper.MakeInParam(InterfaceId,"@statement",(DbType)SqlDbType.NVarChar,200,"DELETE FROM [SYS_SysGroup] WHERE [GroupId]=@gid"),
- DbHelper.MakeInParam(InterfaceId,"@params",(DbType)SqlDbType.NVarChar,10,"@gid int"),
- DbHelper.MakeInParam(InterfaceId,"@gid",(DbType)SqlDbType.Int,4,Id)
- };
- return DbHelper.ExecuteNonQuery(InterfaceId,CommandType.StoredProcedure, "dbo.sp_executesql", pars) > 0 ? true : false;
- }
- public override SysGroupInfo Get<TKey>(TKey key)
- {
- throw new NotImplementedException();
- }
- public override IList<SysGroupInfo> ToList()
- {
- DbParameter[] pars =
- {
- DbHelper.MakeInParam(InterfaceId,"@statement",(DbType)SqlDbType.NVarChar,100,"SELECT [GroupId],[GroupName],[Status] FROM [SYS_SysGroup]")
- };
- IList<SysGroupInfo> list = new List<SysGroupInfo>();
- using (IDataReader reader = DbHelper.ExecuteReader(InterfaceId,CommandType.StoredProcedure, "dbo.sp_executesql", pars))
- {
- while (reader.Read())
- {
- list.Add(LoadEntity(reader));
- }
- reader.Dispose();
- }
- return list;
- }
- public override IList<SysGroupInfo> ToList(SysGroupInfo entity)
- {
- throw new NotImplementedException();
- }
- public override IList<SysGroupInfo> ToPaging(SysGroupInfo entity, int pageSize, int pageIndex, out int recordCount)
- {
- throw new NotImplementedException();
- }
- protected override SysGroupInfo LoadEntity(IDataReader reader)
- {
- return new SysGroupInfo
- {
- GroupId = TypeConverter.ObjectToInt(reader["GroupId"]),
- GroupName = reader["GroupName"].ToString().Trim(),
- Status = TypeConverter.ObjectToBool(reader["Status"], false)
- };
- }
- protected override SysGroupInfo LoadEntity(DataRow dr)
- {
- return new SysGroupInfo
- {
- GroupId = TypeConverter.ObjectToInt(dr["GroupId"]),
- GroupName = dr["GroupName"].ToString().Trim(),
- Status = TypeConverter.ObjectToBool(dr["Status"], false)
- };
- }
- }
- }
|