Ejemplo n.º 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            CapitalGain rpt = new CapitalGain();

            rpt.Site = this.Site;
            return(rpt);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ClosingStock Cs;

            Cs   = new ClosingStock();
            conn = Cs.GetConnection();
            try
            {
                conn.Open();

                OleDbDataAdapter da;
                string           strSQL;

                if (cboHolder.Text == "All")
                {
                    strSQL = "select stocksold.ScriptCode,stocksold.Holder,scriptmaster.ScriptName,DateOfSale,Qty,Price,Qty*price as Amount,(select top 1 price from stockpurchase where trnid=stocksold.purchasetrnid) as PurchaseRate,(select top 1 dateofpurchase from stockpurchase where trnid=stocksold.purchasetrnid) as PurDate ,(select InflationIndex from InflationIndex where enddate>=(select  dateofpurchase from stockpurchase where trnid=stocksold.purchasetrnid) and startdate <=(select top 1 dateofpurchase from stockpurchase where trnid=stocksold.purchasetrnid)) as PurIndex,(select InflationIndex from InflationIndex where enddate>=dateofsale and startdate <=dateofsale) as SaleIndex,(select financialyear from InflationIndex where enddate>=dateofsale and startdate <=dateofsale )as FinancialYear, Purchaserate*qty as PurAmount from stocksold,scriptmaster where stocksold.scriptcode=scriptmaster.scriptcode and dateofsale>=#" + dtStart.Value.ToShortDateString() + "# and dateofsale<=#" + DtEnd.Value.ToShortDateString() + "#";
                }
                else
                {
                    strSQL = "select stocksold.ScriptCode,StockSold.Holder,scriptmaster.ScriptName,DateOfSale,Qty,Price,Qty*price as Amount,(select top 1 price from stockpurchase where trnid=stocksold.purchasetrnid) as PurchaseRate,(select top 1 dateofpurchase from stockpurchase where trnid=stocksold.purchasetrnid) as PurDate ,(select InflationIndex from InflationIndex where enddate>=(select  dateofpurchase from stockpurchase where trnid=stocksold.purchasetrnid) and startdate <=(select top 1 dateofpurchase from stockpurchase where trnid=stocksold.purchasetrnid)) as PurIndex,(select InflationIndex from InflationIndex where enddate>=dateofsale and startdate <=dateofsale) as SaleIndex,(select financialyear from InflationIndex where enddate>=dateofsale and startdate <=dateofsale) as FinancialYear, Purchaserate*qty as PurAmount from stocksold,scriptmaster where stocksold.scriptcode=scriptmaster.scriptcode and dateofsale>=#" + dtStart.Value.ToShortDateString() + "# and dateofsale<=#" + DtEnd.Value.ToShortDateString() + "# and holder='" + cboHolder.Text + "'";
                }

                da = new OleDbDataAdapter(strSQL, conn);

                DataSet ds;

                ds = new DataSet();

                da.Fill(ds, "Temp");

                dataGridView1.DataSource = ds.Tables[0];
                CapitalGain cr = new CapitalGain();
                cr.SetDataSource(ds.Tables[0]);
                cr.Refresh();
                crystalReportViewer1.ReportSource      = cr;
                crystalReportViewer1.ShowRefreshButton = true;

                crystalReportViewer1.DisplayToolbar = true;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

            finally
            {
            }
        }