public DataTable GetList(string strWhere) { string sqlStr = "select dwmc , count(dwmc) as total,sum(case when jw_bzh='毕业' then 1 else 0 end) as biye , sum(case when jw_bzh='结业' then 1 else 0 end) as jieye from jwc_GraduationAudit ,jxdw where jw_xy=dwbh "; if (strWhere.Length > 0) { sqlStr +=" and " + strWhere; } sqlStr += " group by dwmc"; DataTable dt = null; try { dt = SqlHelper.GetDt(SqlHelper.ConnectionStringLocalTransaction, sqlStr); } catch(Exception e) { throw new Exception("Query Failed"); } return dt; } public DataTable GetData(string strWhere) { StringBuilder strSql = new StringBuilder(); DataTable dt = null; SqlConnection cn = new SqlConnection(SqlHelper .ConnectionStringLocalTransaction); cn.Open(); SqlTransaction trans = cn.BeginTransaction(IsolationLevel.ReadCommitted); try { strSql.Append("create table #bycjhz(xh varchar (10) not null,xm varchar (12),xb varchar (2),pycc varchar (20),bh varchar (10), kcbh varchar (10),shxf float,jw_fyh varchar(2),jw_zyh varchar(10)) "); strSql.Append(" insert into #bycjhz"); strSql.Append(" select xh,xm,xb,pycc,bh,kcbh,shxf,jw_fyh,jw_zyh from V_xscjhz"); if (strWhere.Trim().Length > 0) { strSql.Append(" where "+strWhere +" "); } strSql.Append(" select A.xh,xm,xb,pycc,jw_fyh,jw_zyh ,bxk,qxryxxk,xdxxk,qxggk from "); strSql.Append(" (select xh, sum(case jw_kcxzbh when 'X' then shxf end) as bxk,"); strSql.Append(" sum(case jw_kcxzbh when 'O' then shxf end) as qxryxxk,"); strSql.Append(" sum(case jw_kcxzbh when 'M' then shxf end) as xdxxk,"); strSql.Append(" sum(case jw_kcxzbh when 'Q' then shxf end) as qxggk"); strSql.Append(" from #bycjhz ,kcjbxx where #bycjhz.kcbh=kcjbxx.kcbh group by #bycjhz.xh) as A ,"); strSql.Append(" (select distinct xh,xm,xb,pycc,jw_fyh,jw_zyh from #bycjhz ) as B"); strSql.Append(" where A.xh=B.xh"); try { dt = SqlHelper.GetDt(SqlHelper.ConnectionStringLocalTransaction, strSql.ToString()); } catch (Exception e) { throw new Exception("Query Failed"); } trans.Commit(); } catch (Exception e) { trans.Rollback(); throw new ApplicationException(e.Message); } finally { cn.Close(); } return dt; }