string[] CustomerCode_,CustomerName_,Years_; //存放客户代码,客户名称,和年份的数组
double[] CustomerAllPrice_; //存放每个客户每年的销售额 double cuAllPrice = 0; //初始所有客户销售额,选中客户销售额
string sqls = "SELECT SUM(AllPrice) AS AllPrice, YEAR(SYSUD) AS Y, customer_code, customer_name FROM product_analysis_month_tubing3 GROUP BY YEAR(SYSUD), customer_code, customer_name";
DataSet sets = WebData1.dataSet(sqls); for (int i = 0; i < sets.Tables[0].Rows.Count; i++)
{
cuAllPrice += double.Parse(sets.Tables[0].Rows[i]["AllPrice"].ToString());
if (cu == sets.Tables[0].Rows[i]["customer_code"].ToString())
{
CustomerCode_[i] = sets.Tables[0].Rows[i]["customer_code"].ToString();
CustomerName_[i] = sets.Tables[0].Rows[i]["customer_name"].ToString();//使用了未赋值的局部变量
Years_[i] = sets.Tables[0].Rows[i]["Y"].ToString();
CustomerAllPrice_[i] = double.Parse(sets.Tables[0].Rows[i]["AllPrice"].ToString());
}
}高人指点一下,谢谢
double[] CustomerAllPrice_; //存放每个客户每年的销售额 double cuAllPrice = 0; //初始所有客户销售额,选中客户销售额
string sqls = "SELECT SUM(AllPrice) AS AllPrice, YEAR(SYSUD) AS Y, customer_code, customer_name FROM product_analysis_month_tubing3 GROUP BY YEAR(SYSUD), customer_code, customer_name";
DataSet sets = WebData1.dataSet(sqls); for (int i = 0; i < sets.Tables[0].Rows.Count; i++)
{
cuAllPrice += double.Parse(sets.Tables[0].Rows[i]["AllPrice"].ToString());
if (cu == sets.Tables[0].Rows[i]["customer_code"].ToString())
{
CustomerCode_[i] = sets.Tables[0].Rows[i]["customer_code"].ToString();
CustomerName_[i] = sets.Tables[0].Rows[i]["customer_name"].ToString();//使用了未赋值的局部变量
Years_[i] = sets.Tables[0].Rows[i]["Y"].ToString();
CustomerAllPrice_[i] = double.Parse(sets.Tables[0].Rows[i]["AllPrice"].ToString());
}
}高人指点一下,谢谢
解决方案 »
- 如何在循环中给DataGridView添加行?!
- directshow和线程的问题
- 最近要做一个地税的涉及到CA证书的项目,希望大家提供点这方面的资料?
- 怎么解决DataGridView的InvalidOperationException?
- 快来呀,来者有分
- vs2005中,双击选中,点击go to definition,结果转到了[from metadata]叶面了?谢谢!
- 如何在vs2005里调整代码编辑区的显示format?
- 如何将datagridview的列名显示成自定义的combobox
- 如何实现C#winform中右击combobox下拉选项中的某一项弹出右键菜单?
- 向高手咨询Dotfuscator!!!!
- 获取当前时间,代码没有错,为什么不是动态滴?
- 如何让TextBox不自动刷新?
其他数组都这样申明
CustomerName_[i] = sets.Tables[0].Rows[i]["customer_name"].ToString();//使用了未赋值的局部变量
是不是customer_name并没有值
{
pubilc string CustomerCode_;
public string CustomerName_;
public string Years_; public Customer_(string customerCode, string ustomerName, string years)
{
CustomerCode_ = customerCode;
CustomerName_ = ustomerName;
Years_ = years;
}
}ArrayList Customer_List = new ArrayList();for (int i = 0; i < sets.Tables[0].Rows.Count; i++)
{
cuAllPrice += double.Parse(sets.Tables[0].Rows[i]["AllPrice"].ToString());
if (cu == sets.Tables[0].Rows[i]["customer_code"].ToString())
{
Customer_List.Add(new Customer_(sets.Tables[0].Rows[i]["customer_code"].ToString(), sets.Tables[0].Rows[i]["customer_name"].ToString(), sets.Tables[0].Rows[i]["Y"].ToString()));
CustomerAllPrice_[i] = double.Parse(sets.Tables[0].Rows[i]["AllPrice"].ToString());
}
}可以使用linq做查询