using System; using System.Data; using System.Data.OracleClient; using System.Text; using WX.CRM.Common; namespace WX.CRM.DAL.QH { public class QH_CUSTOMER_SALEUSER_DAL { public DataTable GetList(ref Pager pager, string userAccount, decimal? innerUserId, decimal bindType) { OracleConnection conn = new OracleConnection(OracleHelper.AYCRMConn); if (conn.State == ConnectionState.Closed) conn.Open(); try { StringBuilder sql = new StringBuilder(); sql.AppendLine("select qhc.useraccount,qhcs.pkid,qhcs.inneruserid,qhcs.eid,qhcs.gid,qhcs.ctime from qh_Customer qhc"); sql.AppendLine("left join qh_customer_saleuser qhcs on qhc.useraccount = qhcs.useraccount where 1 = 1"); if (!string.IsNullOrEmpty(userAccount)) { sql.AppendLine("and qhc.useraccount='" + userAccount + "'"); } if (innerUserId.HasValue) { sql.AppendLine("and qhcs.inneruserid=" + innerUserId.Value); } switch (Convert.ToInt32(bindType)) { case 0: sql.AppendLine("and qhcs.pkid is null"); break; case 1: sql.AppendLine("and qhcs.pkid is not null"); break; case 2: break; } sql.AppendLine("order by qhcs.ctime desc"); string str = "select * from (select a.*,rownum row_num from (" + sql.ToString() + ") a) TB where TB.row_num between " + ((pager.page - 1) * pager.rows + 1) + " and " + ((pager.page - 1) * pager.rows + pager.rows); string strsql = "select count(a.useraccount) from (" + sql.ToString() + ") a"; DataSet ds = OracleHelper.DataQueray(CommandType.Text, str); pager.totalRows = Convert.ToInt32(OracleHelper.ExecuteScalar(CommandType.Text, strsql)); return ds.Tables[0]; } catch (Exception) { throw; } finally { if (conn.State == ConnectionState.Open) conn.Close(); } } } }