public override byte[] GetData(string url)
        {
            XtraReport report;

            if (url == "brokenReportLayout")
            {
                report = XtraReport.FromFile(brokenReportLayoutPath);
            }
            else if (url == "fileNotFound")
            {
                report = XtraReport.FromFile(url);
            }
            else if (url == "reportWithCustomException")
            {
                report = new XtraReport1();
            }
            else if (url == "reportWithException")
            {
                report = new XtraReport2();
            }
            else if (url == "ValidReport")
            {
                report = new XtraReport3();
            }
            else
            {
                throw new KeyNotFoundException();
            }
            using (var ms = new MemoryStream()) {
                report.SaveLayoutToXml(ms);
                return(ms.ToArray());
            }
        }
Exemple #2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string          id   = Convert.ToString(cmb.SelectedValue);
            XtraReport2     rpt  = new XtraReport2(id);
            ReportPrintTool tool = new ReportPrintTool(rpt);

            rpt.ShowPreviewDialog();
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    con.ConnectionString = connectionString;//System.Configuration.ConfigurationManager.ConnectionStrings["LogicalData.mdf"].ConnectionString;
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection  = con;
                    cmd.CommandText = "PcdUserConsult";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Identificacion", SqlDbType.VarChar);
                    cmd.Parameters["@Identificacion"].Value = "m-0001";
                    try
                    {
                        con.Open();

                        XtraReport2    report  = new XtraReport2();
                        SqlDataAdapter adapter = new SqlDataAdapter();
                        adapter.SelectCommand = cmd;
                        DataSet ds = new DataSet();
                        adapter.Fill(ds);
                        report.DataSource = ds;

                        //ASPxWebDocumentViewer1.wr

                        /*XtraReport report = new XtraReport();
                         * report.DataSource = ds;
                         * ASPxWebDocumentViewer1. = report;*/

                        ASPxWebDocumentViewer1.ReportSourceId = report.XmlDataPath;
                        ASPxWebDocumentViewer1.OpenReport(report);
                        report.CreateDocument();
                        //ASPxWebDocumentViewer1.ReportSourceId
                    } catch (Exception ex)
                    {
                    }
                    finally
                    {
                        con.Close();
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.IsCallback && this.hf.Value != string.Empty)
     {
         if (hf.Value == "1")
         {
             XtraReport1 r = new XtraReport1();
             this.DocumentViewer1.Report = r;
             this.DocumentViewer1.DataBind();
             Page.Session["2"] = null;
         }
         else if (hf.Value == "2")
         {
             XtraReport2 r = new XtraReport2();
             this.DocumentViewer1.Report = r;
             this.DocumentViewer1.DataBind();
             Page.Session["1"] = null;
         }
     }
 }
Exemple #5
0
        void bttnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cboPeriods.Text))
            {
                Common.setEmptyField("Station Name", Program.ApplicationName);
                cboPeriods.Focus(); return;
            }
            else
            {
                System.Data.DataSet ds = new System.Data.DataSet();

                string quy = string.Format("SELECT  IssueDate, IssueFrom, IssueTo, UploadStatus, IssueQty, StationCode FROM Receipt.tblIssueReceipt where StationCode='{0}' AND CONVERT(VARCHAR, CONVERT(DATETIME, IssueDate), 101) BETWEEN '{1}' AND '{2}' ", cboPeriods.SelectedValue, dateTimePicker1.Value.Date.ToString("dd-MM-yyyy"), dateTimePicker2.Value.Date.ToString("dd-MM-yyyy"));

                using (SqlDataAdapter ada = new SqlDataAdapter((string)quy, Logic.ConnectionString))
                {
                    ada.Fill(ds, "table");
                }

                if (ds.Tables[0].Rows.Count > 0)
                {
                    XtraReport2 report = new XtraReport2()
                    {
                        DataSource = ds, DataMember = "table"
                    };

                    report.xrLabel8.Text  = cboPeriods.Text;
                    report.xrLabel18.Text = string.Format("{0} State Government", Program.StateName);
                    report.xrLabel19.Text = string.Format("Receipts Issued to {0}  between {1} and {2}", cboPeriods.Text, dateTimePicker1.Value.Date.ToString("dd/MM/yyyy"), dateTimePicker2.Value.Date.ToString("dd/MM/yyyy"));

                    report.ShowPreviewDialog();
                }
                else
                {
                    Common.setMessageBox("No Records for this Station to Preview", "Station Issue Report ", 1);
                } return;
            }
        }
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        string resourceFileName = "XtraReport1.resx";

        this.Detail        = new DevExpress.XtraReports.UI.DetailBand();
        this.xrLabel3      = new DevExpress.XtraReports.UI.XRLabel();
        this.xrPictureBox1 = new DevExpress.XtraReports.UI.XRPictureBox();
        this.xrLabel2      = new DevExpress.XtraReports.UI.XRLabel();
        this.TopMargin     = new DevExpress.XtraReports.UI.TopMarginBand();
        this.BottomMargin  = new DevExpress.XtraReports.UI.BottomMarginBand();
        this.xrLabel1      = new DevExpress.XtraReports.UI.XRLabel();
        this.ReportHeader  = new DevExpress.XtraReports.UI.ReportHeaderBand();
        this.northwind1    = new Northwind();
        this.CatID         = new DevExpress.XtraReports.Parameters.Parameter();
        this.xrSubreport1  = new DevExpress.XtraReports.UI.XRSubreport();
        this.xtraReport21  = new XtraReport2();
        ((System.ComponentModel.ISupportInitialize)(this.northwind1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.xtraReport21)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
        //
        // Detail
        //
        this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
            this.xrSubreport1,
            this.xrLabel3,
            this.xrPictureBox1,
            this.xrLabel2
        });
        this.Detail.HeightF       = 132F;
        this.Detail.Name          = "Detail";
        this.Detail.Padding       = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
        this.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        //
        // xrLabel3
        //
        this.xrLabel3.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
            new DevExpress.XtraReports.UI.XRBinding("Text", null, "spCategory.Description")
        });
        this.xrLabel3.LocationFloat = new DevExpress.Utils.PointFloat(10.00001F, 49.95832F);
        this.xrLabel3.Name          = "xrLabel3";
        this.xrLabel3.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
        this.xrLabel3.SizeF         = new System.Drawing.SizeF(348.9583F, 23F);
        this.xrLabel3.Text          = "xrLabel3";
        //
        // xrPictureBox1
        //
        this.xrPictureBox1.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
            new DevExpress.XtraReports.UI.XRBinding("Image", null, "spCategory.Picture")
        });
        this.xrPictureBox1.LocationFloat = new DevExpress.Utils.PointFloat(427.0833F, 10.00001F);
        this.xrPictureBox1.Name          = "xrPictureBox1";
        this.xrPictureBox1.SizeF         = new System.Drawing.SizeF(212.9167F, 62.95834F);
        this.xrPictureBox1.Sizing        = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
        //
        // xrLabel2
        //
        this.xrLabel2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
            new DevExpress.XtraReports.UI.XRBinding("Text", null, "spCategory.CategoryName")
        });
        this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(10.00001F, 10.00001F);
        this.xrLabel2.Name          = "xrLabel2";
        this.xrLabel2.Padding       = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
        this.xrLabel2.SizeF         = new System.Drawing.SizeF(100F, 23F);
        this.xrLabel2.Text          = "xrLabel2";
        //
        // TopMargin
        //
        this.TopMargin.HeightF       = 100F;
        this.TopMargin.Name          = "TopMargin";
        this.TopMargin.Padding       = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
        this.TopMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        //
        // BottomMargin
        //
        this.BottomMargin.HeightF       = 100F;
        this.BottomMargin.Name          = "BottomMargin";
        this.BottomMargin.Padding       = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
        this.BottomMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
        //
        // xrLabel1
        //
        this.xrLabel1.Font                  = new System.Drawing.Font("Times New Roman", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        this.xrLabel1.LocationFloat         = new DevExpress.Utils.PointFloat(275F, 0F);
        this.xrLabel1.Name                  = "xrLabel1";
        this.xrLabel1.Padding               = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
        this.xrLabel1.SizeF                 = new System.Drawing.SizeF(128.125F, 35.5F);
        this.xrLabel1.StylePriority.UseFont = false;
        this.xrLabel1.Text                  = "Categories";
        //
        // ReportHeader
        //
        this.ReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
            this.xrLabel1
        });
        this.ReportHeader.HeightF = 35.5F;
        this.ReportHeader.Name    = "ReportHeader";
        //
        // northwind1
        //
        this.northwind1.DataSetName             = "Northwind";
        this.northwind1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
        //
        // CatID
        //
        this.CatID.Name          = "CatID";
        this.CatID.ParameterType = DevExpress.XtraReports.Parameters.ParameterType.Int32;
        this.CatID.Value         = 0;
        //
        // xrSubreport1
        //
        this.xrSubreport1.LocationFloat = new DevExpress.Utils.PointFloat(0F, 95.58334F);
        this.xrSubreport1.Name          = "xrSubreport1";
        this.xrSubreport1.ReportSource  = this.xtraReport21;
        this.xrSubreport1.SizeF         = new System.Drawing.SizeF(100F, 23F);
        this.xrSubreport1.BeforePrint  += new System.Drawing.Printing.PrintEventHandler(this.xrSubreport1_BeforePrint);
        //
        // XtraReport1
        //
        this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
            this.Detail,
            this.TopMargin,
            this.BottomMargin,
            this.ReportHeader
        });
        this.DataMember = "spCategory";
        this.DataSource = this.northwind1;
        this.Parameters.AddRange(new DevExpress.XtraReports.Parameters.Parameter[] {
            this.CatID
        });
        this.Version      = "9.3";
        this.BeforePrint += new System.Drawing.Printing.PrintEventHandler(this.XtraReport1_BeforePrint);
        ((System.ComponentModel.ISupportInitialize)(this.northwind1)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.xtraReport21)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
    }
Exemple #7
0
        public override void UpdateChargeGrid(Object _chargeObjects)
        {
            CalculateChargeClass calculateChargeClass =
                (_chargeObjects as Dictionary <string, object>)["第二阶段"] as CalculateChargeClass;

            base.UpdateChargeGrid(calculateChargeClass);
            if (calculateChargeClass != null)
            {
                DataRow row = _chargeTable_1.NewRow();
                row[0] = calculateChargeClass.MID;
                row[1] = "有功(总)";
                row[2] = calculateChargeClass.endEnergy.ToString("#0.00");
                row[3] = calculateChargeClass.startEnergy.ToString("#0.00");
                row[4] = "30";
                row[5] = calculateChargeClass.totalPower.ToString("#0.00");
                _chargeTable_1.Rows.Add(row);

                row    = _chargeTable_1.NewRow();
                row[0] = calculateChargeClass.MID;
                row[1] = "有功(尖峰)";
                row[2] = calculateChargeClass.spikeEnergy.ToString("#0.00");
                row[4] = "30";
                row[5] = calculateChargeClass.spikePower.ToString("#0.00");
                _chargeTable_1.Rows.Add(row);

                row    = _chargeTable_1.NewRow();
                row[0] = calculateChargeClass.MID;
                row[1] = "有功(峰)";
                row[2] = calculateChargeClass.peakEnergy.ToString("#0.00");
                row[4] = "30";
                row[5] = calculateChargeClass.peakPower.ToString("#0.00");
                _chargeTable_1.Rows.Add(row);

                row    = _chargeTable_1.NewRow();
                row[0] = calculateChargeClass.MID;
                row[1] = "有功(谷)";
                row[2] = calculateChargeClass.valleyEnergy.ToString("#0.00");;
                row[4] = "30";
                row[5] = calculateChargeClass.valleyPower.ToString("#0.00");
                _chargeTable_1.Rows.Add(row);

                row    = _chargeTable_1.NewRow();
                row[0] = calculateChargeClass.MID;
                row[1] = "无功(QI象限)";
                row[2] = "";
                row[4] = "30";
                row[5] = calculateChargeClass.ReactiveQI.ToString("#0.00");
                _chargeTable_1.Rows.Add(row);

                DataRow row1 = _chargeTable_2.NewRow();
                row1[0] = calculateChargeClass.activeCopperLoss.ToString("#0.00");
                row1[1] = calculateChargeClass.activeCoreLoss.ToString("#0.00");
                row1[2] = calculateChargeClass.activeAll.ToString("#0.00");
                row1[3] = calculateChargeClass.reactiveCopperLoss.ToString("#0.00");
                row1[4] = calculateChargeClass.reactiveCoreLoss.ToString("#0.00");
                row1[5] = calculateChargeClass.reactiveAll.ToString("#0.00");
                row1[6] = calculateChargeClass.peakPower.ToString("#0.00");
                row1[7] = calculateChargeClass.valleyPower.ToString("#0.00");
                row1[8] = calculateChargeClass.spikePower.ToString("#0.00");
                _chargeTable_2.Rows.Add(row1);

                DataRow row2 = _chargeTable_3.NewRow();
                row2[0] = 0;
                row2[1] = 0;
                row2[2] = 0;
                row2[3] = 0;
                row2[4] = 0;
                row2[5] = 0;
                row2[6] = 0;
                row2[7] = 0;
                row2[8] = 0;
                _chargeTable_3.Rows.Add(row2);
                DataRow row3  = _chargeTable_4.NewRow();
                Double  total = 0;
                row3[0] = "尖 一般工商";
                row3[1] = calculateChargeClass.spikePower.ToString("#0.00");
                row3[2] = 0;
                row3[3] = "kW.h";
                row3[4] =
                    ((_chargeObjects as Dictionary <string, object>)["电量参数"] as List <ElectricityParameter>)[0].PriceSpike;
                row3[5] = (Convert.ToDouble(row3[4].ToString()) * Convert.ToDouble(row3[1].ToString())).ToString("#0.00");
                total  += Convert.ToDouble(row3[5]);
                _chargeTable_4.Rows.Add(row3);
                row3    = _chargeTable_4.NewRow();
                row3[0] = "峰 一般工商";
                row3[1] = calculateChargeClass.peakPower.ToString("#0.00");
                row3[2] = 0;
                row3[3] = "kW.h";
                row3[4] =
                    ((_chargeObjects as Dictionary <string, object>)["电量参数"] as List <ElectricityParameter>)[0].PricePeak;
                row3[5] = (Convert.ToDouble(row3[4].ToString()) * Convert.ToDouble(row3[1].ToString())).ToString("#0.00");
                total  += Convert.ToDouble(row3[5]);
                _chargeTable_4.Rows.Add(row3);
                row3    = _chargeTable_4.NewRow();
                row3[0] = "谷 一般工商";
                row3[1] = calculateChargeClass.valleyPower.ToString("#0.00");
                row3[2] = 0;
                row3[3] = "kW.h";
                row3[4] =
                    ((_chargeObjects as Dictionary <string, object>)["电量参数"] as List <ElectricityParameter>)[0]
                    .PriceValley;
                row3[5] = (Convert.ToDouble(row3[4].ToString()) * Convert.ToDouble(row3[1].ToString())).ToString("#0.00");
                total  += Convert.ToDouble(row3[5]);
                _chargeTable_4.Rows.Add(row3);
                row3    = _chargeTable_4.NewRow();
                row3[0] = "合计";
                row3[1] = "";
                row3[2] = "";
                row3[3] = "";
                row3[4] = "";
                row3[5] = total.ToString("#0.00");
                _chargeTable_4.Rows.Add(row3);


                gridCharge_1.DataSource = _chargeTable_1;
                gridCharge_2.DataSource = _chargeTable_2;
                gridCharge_3.DataSource = _chargeTable_3;
                gridCharge_4.DataSource = _chargeTable_4;


                XtraReport2 report = new XtraReport2();
                report.ExportOptions.PrintPreview.DefaultFileName = "国网浙江慈溪市供电公司非居民用户电费复核单据 (二次抄表)" +
                                                                    DateTime.Now.ToString("D");

                documentViewer.DocumentSource = report;
                report.SetReportDataSource(_chargeTable_1, _chargeTable_2, _chargeTable_3, _chargeTable_4);
            }
        }