public DataSet Getdata(DateTime start, bool se, string oper)
{
string where = string.Empty;
string sqlstr = string.Empty;
SqlParameter[] paras;
sqlstr = @"SELECT "
+ "mMonth 月份,isnull(e1,0) 北,isnull(i1,0) 外
+ "FROM "
+ "(SELECT 1 AS 'mMonth' "
+ " UNION SELECT 2 AS 'mMonth' "
+ "UNION SELECT 3 AS 'mMonth' "
+ " UNION SELECT 4 AS 'mMonth' "
+ "UNION SELECT 5 AS 'mMonth' "
+ " UNION SELECT 6 AS 'mMonth' "
+ " UNION SELECT 7 AS 'mMonth' "
+ " UNION SELECT 8 AS 'mMonth' "
+ "UNION SELECT 9 AS 'mMonth' "
+ " UNION SELECT 10 AS 'mMonth' "
+ "UNION SELECT 11 AS 'mMonth' "
+ " UNION SELECT 12 AS 'mMonth') m "
+ "left JOIN "
+ "( "
+ "SELECT Month(C.[RECEIVE_TIME]) as 月份, "
+ "Count(CASE WHEN C.COMPLAINT_TYPE=325 and P.[CARD_NET_ID]=1301 THEN C.ID ELSE NULL END) e1, "
+ "Count(CASE WHEN C.COMPLAINT_TYPE=325 and P.[CARD_NET_ID]<>1301 THEN C.ID ELSE NULL END) i1, "
+ "Count(C.ID) heji "
+ "FROM [COMPLAINTS] as C inner join [INFO] as P on C.[PRECINCT_INFO_ID]=P.ID "
+ "where YEAR(C.[TIME])=@START "
+ "GROUP BY Month(C.[TIME]) "
+ ") b "
+ "on m.mMonth=b.月份 order by m.mMonth asc";
paras = new SqlParameter[]
{
new SqlParameter("@START",SqlDbType.Int),
};
paras[0].Value = start.Year;
DataSet ds = new DataSet();
DataTable dtt = SqlHelper.ExecuteSqlDataSet(sqlstr, paras, "t").Tables[0];
String[] totalRow = new String[10];
for (int i = 1; i < dtt.Columns.Count; i++)
{
// 赋值
totalRow[i] = dtt.Compute("SUM(" + dtt.Columns[i].ColumnName + ")", "true").ToString();
}
DataTable dt = UpdateDataTable(dtt);
if (int.Parse(totalRow[9]) > 0)
{
float e = float.Parse(totalRow[9]);
float scale1 = (float.Parse(totalRow[1]) / e) * 100;
dt.Rows.Add("合计", totalRow[1]);
dt.Rows.Add("占比", scale1.ToString("0.00") + "%");
//dt.Rows.Add("", a + b, c + d, f + g, "", "", "");
}
else
{
dt.Rows.Add("合计", totalRow[1]);
dt.Rows.Add("占比", 0);
//dt.Rows.Add("", a + b, c + d, f + g, "", "", "");
}
ds.Tables.Add(dt);
return ds;
}