www.pudn.com > DevPrintReport.rar > XtraReport1.cs, change:2011-03-16,size:6161b


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using DevExpress.XtraReports.UI; 
using System.Data; 
using System.Drawing.Printing; 
 
namespace TZL_Print 
{ 
    public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport 
    { 
        public XtraReport1() 
        { 
            InitializeComponent(); 
 
            //this.PaperKind = System.Drawing.Printing.PaperKind.Custom; 
            //this.PageHeight = 1169 / 2; 
            //this.PageWidth = 827; 
            //this.PaperName = "A4HALF"; 
            //PaperSize ps = new PaperSize("A4HALF", 827, 1169 / 2); 
        } 
        DataSet DataS_打印 = new DataSet(); 
        string uc_类名 = ""; 
        public XtraReport1(ref DataSet ds, string uc_name, int ptype) 
            : this() 
        { 
            DataS_打印 = ds; 
            uc_类名 = uc_name; 
            _ptype = ptype; 
            try 
            { 
                Data_TPrint = DataS_打印.Tables[DataS_打印.Tables.Count - 1]; 
            } 
            catch { } 
            SetDataBinding(DataS_打印.Tables[0]); 
            xt单据名称.Text = uc_类名; 
            //this.RequestParameters = false; 
            if (_ptype == 0) 
            { 
                xRptMX1 = new XRptMX(ref Data_TPrint, uc_类名); 
                this.xrSubreport1.ReportSource = this.xRptMX1; 
                //this.xRptMX1.DataSource = Data_TPrint; 
                //this.xRptMX1.PrintingSystem = this.PrintingSystem; 
                this.xRptMX1.CreateDocument(); 
            } 
            else 
            { 
                xRptgvMX1 = new XRptGVMX(ref Data_TPrint, uc_类名); 
                this.xrSubreport1.ReportSource = this.xRptgvMX1; 
                this.xRptgvMX1.CreateDocument(); 
                //this.xRptgvMX1.DataSource = Data_TPrint; 
                //this.xRptgvMX1.PrintingSystem = this.PrintingSystem; 
            } 
            //xrSubreport1.ReportSource.CreateDocument(); 
        } 
        int _ptype = 0; 
 
        public bool CreateReport(ref DataSet ds, string uc_name, int ptype) 
        { 
            try 
            { 
                DataS_打印 = ds; 
                uc_类名 = uc_name; 
                _ptype = ptype; 
                try 
                { 
                    Data_TPrint = DataS_打印.Tables[DataS_打印.Tables.Count - 1]; 
                } 
                catch { } 
                SetDataBinding(DataS_打印.Tables[0]); 
                xt单据名称.Text = uc_类名; 
                //this.RequestParameters = false; 
                if (_ptype == 0) 
                { 
                    xRptMX1 = new XRptMX(ref Data_TPrint, uc_类名); 
                    this.xrSubreport1.ReportSource = this.xRptMX1; 
                    //this.xRptMX1.DataSource = Data_TPrint; 
                    //this.xRptMX1.PrintingSystem = this.PrintingSystem; 
                    this.xRptMX1.CreateDocument(); 
                } 
                else 
                { 
                    xRptgvMX1 = new XRptGVMX(ref Data_TPrint, uc_类名); 
                    this.xrSubreport1.ReportSource = this.xRptgvMX1; 
                    this.xRptgvMX1.CreateDocument(); 
                    //this.xRptgvMX1.DataSource = Data_TPrint; 
                    //this.xRptgvMX1.PrintingSystem = this.PrintingSystem; 
                } 
                //xrSubreport1.ReportSource.CreateDocument(); 
                return true; 
            } 
            catch { return false; } 
        } 
        void SetDataBinding(DataTable dt) 
        { 
            try 
            { 
                try 
                { xt单据编号.DataBindings.Add("Text", dt, dt.Columns[0].Caption); } 
                catch { } 
                try 
                { xt单据类型.DataBindings.Add("Text", dt, dt.Columns[1].Caption); } 
                catch { } 
                try 
                { xt供应商.DataBindings.Add("Text", dt, dt.Columns[2].Caption); } 
                catch { } 
                try 
                { xt仓库.DataBindings.Add("Text", dt, dt.Columns[3].Caption); } 
                catch { } 
                try 
                { xt制单人.DataBindings.Add("Text", dt, dt.Columns[4].Caption); } 
                catch { } 
                try 
                { xt审核人.DataBindings.Add("Text", dt, dt.Columns[5].Caption); } 
                catch { } 
                try 
                { xt经手人.DataBindings.Add("Text", dt, dt.Columns[6].Caption); } 
                catch { } 
                try 
                { xt备注说明.DataBindings.Add("Text", dt, dt.Columns[7].Caption); } 
                catch { } 
                try 
                { xt制单日期.DataBindings.Add("Text", dt, "制单日期"); } 
                catch { } 
                try 
                { xt审核日期.DataBindings.Add("Text", dt, "审核日期"); } 
                catch { } 
                if (dt.Columns.Count > 9) 
                { 
                    if (dt.Rows[0][9].ToString().Contains("太子龙")) 
                    { 
                        try 
                        { 
                            xrLabel1.Text = dt.Rows[0][9].ToString(); 
                        } 
                        catch 
                        { 
                            xrLabel1.Text = "浙江太子龙服饰股份有限公司"; 
                        } 
                    } 
                    else 
                        xrLabel1.Text = "浙江太子龙实业发展有限公司"; 
                } 
            } 
            catch { } 
        } 
 
 
 
        DataTable Data_TPrint = new DataTable(); 
        public XtraReport1(ref DataTable dt, string uc_name) 
            : this() 
        { 
            this.DataSource = dt; 
            Data_TPrint = dt; 
            uc_类名 = uc_name; 
        } 
        private void XtraReport1_DesignerLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) 
        { 
            //xrSubreport1.ReportSource.DataSource = Data_TPrint; 
            xrSubreport1.ReportSource.CreateDocument(); 
            //xrPivotGrid1.DataSource = Data_TPrint; 
        } 
 
    } 
}