public frmSalesReportView(int month, string mon)
        {
            try
            {
                InitializeComponent();
                int salesmonth = month;
                con.Open();
                SqlDataAdapter SDA = new SqlDataAdapter("select sum(amounttobepaid) from Orderbill where month(date)=" + salesmonth + "", con);
                DataTable      dt  = new DataTable();
                SDA.Fill(dt);
                float amount = float.Parse(dt.Rows[0][0].ToString());

                DataSet1   ds  = new DataSet1();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "select o.orderid ,c.customername,o.date,o.amounttobepaid,'" + mon + "' as month ," + amount + "as total from Orderbill o inner join Customer c on c.CustomerID=o.CustomerID where month(date)=" + salesmonth + "";
                cmd.ExecuteNonQuery();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds.DataTable3);
                salesViewReport myr = new salesViewReport();
                myr.SetDataSource(ds);
                crystalReportViewer1.ReportSource = myr;
            }catch (FormatException fex)
            {
                MessageBox.Show("No Sales on this month");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            salesViewReport rpt = new salesViewReport();

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