111,128
社区成员
发帖
与我相关
我的任务
分享
难道是因为datagridview里面有空值么?别的表没有空值所以能显示
那我该怎么把?是在datagridview附上0还是怎么办?
select idinventoryclass = case AA_Inventory.idinventoryclass
when '46788662-AFB2-4C84-84F7-A50E00F9B74E' then
'镜片'
when '378C3E42-DEDA-4A5B-A324-A50E00FF1D3E' then
'镜架'
when 'C48B0657-3372-4ED0-A4F1-A50E00FA36ED' then
'花镜'
else
'其它'
end,
abc= case when sum(RE_Retail_b.quantity) is null then 0
else round(sum(RE_Retail_b.quantity),2)
end,
dsf= case when sum(RE_Retail_b.retailamount) is null then 0
else round(sum(RE_Retail_b.retailamount),2)
end
from RE_Retail_b
left join AA_Inventory on RE_Retail_b.idinventory = AA_Inventory.id
where (idinventoryclass = '46788662-AFB2-4C84-84F7-A50E00F9B74E' or
idinventoryclass = '378C3E42-DEDA-4A5B-A324-A50E00FF1D3E' or
idinventoryclass = 'C48B0657-3372-4ED0-A4F1-A50E00FA36ED' or
idinventoryclass = '85EB34A4-6949-4AB7-B8B0-A50E00FA3F97')
group by AA_Inventory.idinventoryclass
试试吧
数据0的必须要有,然后小数点后面没用的0怎么去掉..[/quote]
private void Form4_Load(object sender, EventArgs e)
{
sql = "select idinventoryclass = case AA_Inventory.idinventoryclass when '46788662-AFB2-4C84-84F7-A50E00F9B74E' then '镜片' when '378C3E42-DEDA-4A5B-A324-A50E00FF1D3E' then '镜架' when 'C48B0657-3372-4ED0-A4F1-A50E00FA36ED' then '花镜' else '其它' end,SUM(RE_Retail_b.quantity)as abc,SUM(RE_Retail_b.retailamount) as dsf from RE_Retail_b left join AA_Inventory on RE_Retail_b.idinventory = AA_Inventory.id where (idinventoryclass = '46788662-AFB2-4C84-84F7-A50E00F9B74E'or idinventoryclass ='378C3E42-DEDA-4A5B-A324-A50E00FF1D3E'or idinventoryclass = 'C48B0657-3372-4ED0-A4F1-A50E00FA36ED' or idinventoryclass = '85EB34A4-6949-4AB7-B8B0-A50E00FA3F97') group by AA_Inventory.idinventoryclass";
DataSet ds = DBHelper.getset(sql);
this.dataGridView1.DataSource = ds.Tables[0];
List<string> xData = new List<string>() { };
List<double> yData = new List<double>() { };
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
xData.Add(ds.Tables[0].Rows[i]["idinventoryclass"].ToString());
yData.Add(Convert.ToDouble(ds.Tables[0].Rows[i]["dsf"].ToString()));
}
chart1.Series[0]["PieLabelStyle"] = "Outside";
chart1.Series[0]["PieLineColor"] = "Black";
chart1.Series[0].Points.DataBindXY(xData, yData);
}private void Form4_Load(object sender, EventArgs e)
{
sql = "select idinventoryclass = case AA_Inventory.idinventoryclass when '46788662-AFB2-4C84-84F7-A50E00F9B74E' then '镜片' when '378C3E42-DEDA-4A5B-A324-A50E00FF1D3E' then '镜架' when 'C48B0657-3372-4ED0-A4F1-A50E00FA36ED' then '花镜' else '其它' end,SUM(RE_Retail_b.quantity)as abc,SUM(RE_Retail_b.retailamount) as dsf from RE_Retail_b left join AA_Inventory on RE_Retail_b.idinventory = AA_Inventory.id where (idinventoryclass = '46788662-AFB2-4C84-84F7-A50E00F9B74E'or idinventoryclass ='378C3E42-DEDA-4A5B-A324-A50E00FF1D3E'or idinventoryclass = 'C48B0657-3372-4ED0-A4F1-A50E00FA36ED' or idinventoryclass = '85EB34A4-6949-4AB7-B8B0-A50E00FA3F97') group by AA_Inventory.idinventoryclass";
DataSet ds = DBHelper.getset(sql);
this.dataGridView1.DataSource = ds.Tables[0];
List<string> xData = new List<string>() { };
List<double> yData = new List<double>() { };
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
xData.Add(ds.Tables[0].Rows[i]["idinventoryclass"].ToString());
yData.Add(Convert.ToDouble(ds.Tables[0].Rows[i]["dsf"].ToString()));
}
chart1.Series[0]["PieLabelStyle"] = "Outside";
chart1.Series[0]["PieLineColor"] = "Black";
chart1.Series[0].Points.DataBindXY(xData, yData);
}