示例#1
0
        public void btReportDate_Click(object sender, EventArgs e)
        {
            string sql = "SELECT        TOP " + TextBox1.Text + @" dbo.tb_FoodAndDrink.foodID, dbo.tb_FoodAndDrink.foodName, SUM(dbo.tb_SellDetail.foodAmount) AS SumTotal, dbo.tb_Unit.UnitName
FROM            dbo.tb_FoodAndDrink INNER JOIN
dbo.tb_SellDetail ON dbo.tb_FoodAndDrink.foodID = dbo.tb_SellDetail.foodID INNER JOIN
dbo.tb_Unit ON dbo.tb_FoodAndDrink.UnitID = dbo.tb_Unit.UnitID
WHERE        (dbo.tb_SellDetail.SellID IN
(SELECT        SellID
FROM            dbo.tb_Selling AS Sell
WHERE        (Year(dateCome) = '" + System.Convert.ToString(cbYear.SelectedItem) + @"')))
GROUP BY dbo.tb_FoodAndDrink.foodID, dbo.tb_FoodAndDrink.foodName, dbo.tb_Unit.UnitName
ORDER BY SumTotal DESC";

            DSReport     dsr = new DSReport();
            BestSellYear rpt = new BestSellYear();
            var          da  = new SqlDataAdapter(sql, ConstVar.connect.DatabaseConnection(ConstVar.constr));

            da.Fill(dsr, "DSBestSellByYear");
            if (dsr.Tables["DSBestSellByYear"].Rows.Count == 0)
            {
                MessageBox.Show("ບໍ່ມີຂໍ້ມູນ");
            }
            else
            {
                rpt.SetDataSource(dsr);
                rpt.SetParameterValue("top", TextBox1.Text);
                rpt.SetParameterValue("year", cbYear.SelectedItem);
                frm_MainReportChoosing.Default.CrystalReportViewer1.ReportSource = rpt;
                frm_MainReportChoosing.Default.Show(this);
            }
        }
示例#2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            BestSellYear rpt = new BestSellYear();

            rpt.Site = this.Site;
            return(rpt);
        }