当前位置: 首页 > news >正文

基于DBDataAccess类的具体数据访问类,这些代码大部分都可以自动生成。

None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.Data.SqlClient;
None.gif
None.gif
using  SEM.DataEntity;
None.gif
using  COM.Makinfo.DataAccess;
None.gif
namespace  SEM.DataAccess.SysManage.RightManage
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// DASysUser 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class DASysUser:DBAccess
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private DataTable dataSysUser;
InBlock.gif
InBlock.gif        
public DASysUser()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
read#region read
InBlock.gif    
InBlock.gif        
public DataTable ReadAllData(string strIsUsed,string strusername,string strusercode,string strareacode)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
//Generate where condition string.
InBlock.gif
            string strWhereCo = "";
InBlock.gif            
InBlock.gif            
if(null != strIsUsed && strIsUsed != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " and UserIsUse = '" + strIsUsed +"'";
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
if(null != strusername && strusername != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " and UserName like '%" + strusername +"%'";
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
if(null != strusercode && strusercode != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " and UserCode like '%" + strusercode.ToLower()  +"%'";
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
if(null != strareacode && strareacode != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " and AreaCode = '" + strareacode +"'";            
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif
InBlock.gif            
string sql    = " SELECT * from SysUser ";
InBlock.gif
InBlock.gif            
if(strWhereCo != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
= strWhereCo.Substring(4);
InBlock.gif                sql 
= sql + " Where " + strWhereCo;
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 通过部门编码获取所有的用户,注意结构 必须是,aa,aaa,这种数据结构才行,否则数据会出错。
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="depcode"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif    
InBlock.gif        
//由于数据库设计的改变,这个方法有所改变,现在变成了从SysUserPost取数
InBlock.gif
         public DataTable GetAllUserByDepCode(string depcode)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif        
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
string sql    = " SELECT * from SysUser  where  usercode in (select distinct usercode from SysUserDept where Depguid  = '" + depcode +"')";
InBlock.gif
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;
InBlock.gif        
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 读取人口职位关联表中的数据。
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="postcode"></param>
InBlock.gif        
/// <param name="deptcode"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public DataTable ReadDataByUserPost(string strAreaCode,string strDepGuid,string  strPostGuid)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
string sql    = " SELECT * from SysUser  where  usercode in "+
InBlock.gif                
"(select distinct usercode from SysUserPost "+
InBlock.gif                
" where areaCode='"+ strAreaCode+"' and DepGuid  = '" + strDepGuid +"' and postGuid='"  + strPostGuid + "')";
InBlock.gif
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 读取人口角色关联表中的数据。
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="strAreaCode"></param>
InBlock.gif        
/// <param name="strRoleGuid"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public DataTable ReadDataByUserRole(string strAreaCode,string strRoleGuid)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
string sql    = " SELECT * from SysUser  where  usercode in "+
InBlock.gif                
"(select distinct usercode from SysUserRole "+
InBlock.gif                
" where areaCode='"+ strAreaCode+"' and RoleGuid  = '" + strRoleGuid + "')";
InBlock.gif
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
InBlock.gif        
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="aryIDs"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public DataTable ReadDataByIDs(string[] aryIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
//Generate where condition string.
InBlock.gif
            string strWhereCo = "";
InBlock.gif            
foreach(string strValue in aryIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " or UserCode = '" + strValue.ToLower() +"'";
ExpandedSubBlockEnd.gif            }

InBlock.gif            strWhereCo 
= strWhereCo.Substring(4);
InBlock.gif        
InBlock.gif            
string sql    = " SELECT * from SysUser "+
InBlock.gif                
" Where " + strWhereCo;
InBlock.gif            
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
///  根据GUID(数组)查询人员信息(Daizh)
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="aryGUIDs"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public DataTable ReadDataByGUIDs(string[] aryGUIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
//Generate where condition string.
InBlock.gif
            string strWhereCo = "";
InBlock.gif            
foreach(string strValue in aryGUIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " or UserGuid = '" + strValue.ToLower() +"'";
ExpandedSubBlockEnd.gif            }

InBlock.gif            strWhereCo 
= strWhereCo.Substring(4);
InBlock.gif        
InBlock.gif            
string sql    = " SELECT * from SysUser "+
InBlock.gif                
" Where " + strWhereCo;
InBlock.gif            
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 根据GUID查询人员信息(Daizh)
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="aryIDs"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public DataTable ReadDataByGuid(string strGuid)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();    
InBlock.gif            
string sql    = "SELECT * from SysUser Where UserGuid = '"+ strGuid + "'";            
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif            
return dataSysUser;
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 根据Code查询人员信息(Daizh)
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="aryIDs"></param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public DataTable ReadUserNameByCode(string strCode)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();    
InBlock.gif            
string strSQLCommand    = "SELECT * FROM SysUser Where UserCode = '" + strCode + "'";
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,strSQLCommand);
InBlock.gif            
return dataSysUser;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 得取地区数组和部门数组的所有用户  (Fenglx)
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="strDept">部门数组</param>
InBlock.gif        
/// <param name="strDept">部门数组</param>
ExpandedSubBlockEnd.gif        
/// <returns>用户</returns>

ExpandedSubBlockStart.gifContractedSubBlock.gif        public DataTable ReadDataArrayUserCode(string[] strArea,string[] strDept) dot.gif{
InBlock.gif            
this.dataSysUser = OsdSysUser.NewDataTable();
InBlock.gif
InBlock.gif            
string strAreaCode = "",strDeptCode = "";
InBlock.gif            
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for (int i=0 ; i < strArea.Length ; i++dot.gif{
InBlock.gif                strAreaCode 
+= ",'" + strArea[i] + "'";
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for (int i=0 ; i < strDept.Length ; i++dot.gif{
InBlock.gif                strDeptCode 
+= ",'" + strDept[i] + "'";
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            strAreaCode 
= strAreaCode.Substring(1);
InBlock.gif            strDeptCode 
= strDeptCode.Substring(1);
InBlock.gif        
InBlock.gif
//            string sql = " SELECT DISTINCT SysUser.UserName, SysUser.UserGuid" +
InBlock.gif
//                         " FROM SysUserDept INNER JOIN SysUser ON SysUserDept.AreaCode = SysUser.AreaCode AND SysUserDept.UserCode = SysUser.UserCode" +
InBlock.gif
//                         " WHERE SysUserDept.AreaCode IN (" + strAreaCode + ") AND SysUserDept.DepGuid IN (" + strDeptCode + ")";
InBlock.gif
            string sql = " SELECT DISTINCT SysUser.UserName, SysUser.UserGuid" +
InBlock.gif                
" FROM SysUserDept INNER JOIN SysUser ON SysUserDept.UserCode = SysUser.UserCode" +
InBlock.gif                
" WHERE SysUserDept.AreaCode IN (" + strAreaCode + ") AND SysUserDept.DepGuid IN (" + strDeptCode + ")";
InBlock.gif            
InBlock.gif            
this.InitDataSetTableBySQL(ref dataSysUser,sql);
InBlock.gif
InBlock.gif            
return dataSysUser;    
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif        
#endregion
 read
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
create#region create
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Create  new income type info.
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="defineData"></param>

InBlock.gif        public void Create(DataTable dataSysUser)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            IDbCommand[] insert 
= this.GetInsertCommand(dataSysUser);
InBlock.gif            
InBlock.gif            
//Excute command list.
InBlock.gif
            this.ExcuteCmdList(insert);
InBlock.gif            
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion
 create
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
update#region update
InBlock.gif        
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Create income type info.
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="dataSysUser"></param>

InBlock.gif        public void Update(DataTable dataSysUser)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string[] strUpdateColumns = OsdSysUser.Columns;
ExpandedSubBlockStart.gifContractedSubBlock.gif            
string[] strPKColumns = dot.gif{OsdSysUser.Col_UserGuid};
InBlock.gif        
InBlock.gif            IDbCommand[] update 
= this.GetUpdateCommand(dataSysUser,OsdSysUser.Columns,strPKColumns);
InBlock.gif
InBlock.gif            
//Excute command list.
InBlock.gif
            this.ExcuteCmdList(update);
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 修改密码
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="dataSysUser"></param>

InBlock.gif        public void UpdatePass(DataTable dataSysUser)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
string[] strUpdateColumns = dot.gif{OsdSysUser.Col_UserCode,OsdSysUser.Col_UserPass};
ExpandedSubBlockStart.gifContractedSubBlock.gif            
string[] strPKColumns = dot.gif{OsdSysUser.Col_UserCode};
InBlock.gif        
InBlock.gif            IDbCommand[] update 
= this.GetUpdateCommand(dataSysUser,strUpdateColumns,strPKColumns);
InBlock.gif
InBlock.gif            
//Excute command list.
InBlock.gif
            this.ExcuteCmdList(update);
InBlock.gif            
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion
 update
InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
delete#region delete
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="aryIDs"></param>

InBlock.gif        public void DeleteDataByIDs(string[] aryIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            IDbCommand delete 
= InstanceComm;
InBlock.gif            
//Generate where condition string.
InBlock.gif
            string strWhereCo = "";
InBlock.gif            
foreach(string strValue in aryIDs)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                strWhereCo 
+= " or UserCode ='" + strValue.ToLower()  +"";
ExpandedSubBlockEnd.gif            }

InBlock.gif            strWhereCo 
= strWhereCo.Substring(4);
InBlock.gif            
InBlock.gif            
if(strWhereCo == "")
InBlock.gif                
return;
InBlock.gif
InBlock.gif            delete.CommandText 
= 
InBlock.gif                
" update SysUser set UserIsUse ='F' "+
InBlock.gif                
" Where " + strWhereCo;
InBlock.gif            
InBlock.gif            
//Excute command list.
ExpandedSubBlockStart.gifContractedSubBlock.gif
            this.ExcuteCmdList(new IDbCommand[]dot.gif{delete});
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion
 delete
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

转载于:https://www.cnblogs.com/richardhu/archive/2006/07/25/459632.html

相关文章:

  • 通俗易懂系列 | 设计模式(八):建造者模式
  • O血型的性格
  • entity
  • 01-python学习之路
  • 企业网站服务器负载均衡技术
  • 玩转报表排名之组内排名
  • 觉得MemberShip的灵活性太低了,不知各位有什么招弥补呢?
  • Primitives vs Objects
  • 微软专家:Linux不会对Windows构成威胁---怀疑中~
  • [BZOJ 4598][Sdoi2016]模式字符串
  • 网管日志-06.08.15
  • react性能优化
  • Oracle临时表空间为何暴涨?
  • 对一个日期型对象怎么加一年,或加一个月
  • VS中使用git
  • JS 中的深拷贝与浅拷贝
  • 【面试系列】之二:关于js原型
  • 30天自制操作系统-2
  • Angular js 常用指令ng-if、ng-class、ng-option、ng-value、ng-click是如何使用的?
  • angular2开源库收集
  • eclipse的离线汉化
  • gitlab-ci配置详解(一)
  • Java多态
  • k8s如何管理Pod
  • Linux CTF 逆向入门
  • nginx 配置多 域名 + 多 https
  • 阿里云购买磁盘后挂载
  • 创建一个Struts2项目maven 方式
  • 基于Android乐音识别(2)
  • ------- 计算机网络基础
  • 技术:超级实用的电脑小技巧
  • 嵌入式文件系统
  • 一个SAP顾问在美国的这些年
  • 阿里云服务器购买完整流程
  • 新年再起“裁员潮”,“钢铁侠”马斯克要一举裁掉SpaceX 600余名员工 ...
  • ​​​​​​​Installing ROS on the Raspberry Pi
  • ​卜东波研究员:高观点下的少儿计算思维
  • #Linux(帮助手册)
  • #每日一题合集#牛客JZ23-JZ33
  • $.ajax中的eval及dataType
  • (10)Linux冯诺依曼结构操作系统的再次理解
  • (13)[Xamarin.Android] 不同分辨率下的图片使用概论
  • (17)Hive ——MR任务的map与reduce个数由什么决定?
  • (23)Linux的软硬连接
  • (function(){})()的分步解析
  • (Repost) Getting Genode with TrustZone on the i.MX
  • (区间dp) (经典例题) 石子合并
  • (四) 虚拟摄像头vivi体验
  • (转)用.Net的File控件上传文件的解决方案
  • .gitignore文件设置了忽略但不生效
  • .htaccess配置常用技巧
  • .Net - 类的介绍
  • .NET Core 和 .NET Framework 中的 MEF2
  • .NET 将混合了多个不同平台(Windows Mac Linux)的文件 目录的路径格式化成同一个平台下的路径
  • .NET 中的轻量级线程安全