private void saleanalyse_Load(object sender, EventArgs e) { color.load(); dataBaseConnection();//连接数据库 //获取product表数据 DataTable product = new DataTable(); product = this.getProduct(); //调用getProduct方法 //获取saleproduct表数据 DataTable saleproduct = new DataTable(); saleproduct = this.getSaleproduct(); //调用getSaleproduct方法 //创建对象数组 saleProduct[] sale = new saleProduct[product.Rows.Count]; for (int i = 0; i < product.Rows.Count; i++) { sale[i] = new saleProduct(); } //调用analyse()方法,统计出各个同名称产品销售的数量 analyse(product, saleproduct, sale); //调用createImage()方法,根据同类名称产品销售的数量绘制饼状图 createImage(ref sale); //关闭数据库连接 conn.Close(); }
private void toolStripButton2_Click(object sender, EventArgs e) { //获取product表数据 DataTable product = new DataTable(); product = this.getProduct(); //调用getProduct方法 //获取saleproduct表数据 DataTable saleproduct = new DataTable(); saleproduct = this.getioutproduct(); //调用getSaleproduct方法 //创建对象数组 saleProduct[] sale = new saleProduct[product.Rows.Count]; for (int i = 0; i < product.Rows.Count; i++) { sale[i] = new saleProduct(); } //调用analyse()方法,统计出各个同名称产品销售的数量 analyse(product, saleproduct, sale); //调用createImage()方法,根据同类名称产品销售的数量绘制饼状图 createImage(ref sale, 2); //关闭数据库连接 conn.Close(); }