bug
lu
6 天以前 98e93a53c3407b9785eba27faec13fe7afc1255b
DevApp/Gs.DevApp/UserControl/UcBtnPrint.cs
@@ -1,5 +1,4 @@
using Gs.DevApp.DevFrm.Rpt;
using Gs.DevApp.DevFrm.Sys;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
@@ -12,90 +11,74 @@
        public UcBtnPrint()
        {
            InitializeComponent();
            btnReport.Click += BtnReport_ItemClick;
            btnDesign.Click += BtnDesign_ItemClick;
            this.btnPrint.Click += (s, e) =>
            {
                if (btnPrintClick != null)
                    btnPrintClick(this, e);
                else
                    return;
                if (rptParameter == "return false")
                    return;
                if (string.IsNullOrEmpty(rptParameter))
                {
                    MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!");
                    return;
                }
                var _bl = false;
                _bl = _ckRptService();
                if (_bl)
                {
                    try
                    {
                        using (Form frm = new RptPreview(guidKey, rptParameter))
                        {
                            frm.ShowDialog();
                        }
                    }
                    catch (Exception)
                    {
                    }
                    return;
                }
                MsgHelper.ShowError("没有设计模板,请先设计模板!");
            };
            this.btnAll.Click += (s, e) =>
            {
                if (btnAllClick != null)
                    btnAllClick(this, e);
                else
                    return;
            };
        }
        /// <summary>
        ///     关键字,一般是主键
        /// </summary>
        public string guidKey { get; set; }
        /// <summary>
        /// 批量操作时的关键字:托板码
        /// </summary>
        public string allClickKey { get; set; }
        /// <summary>
        ///     报表,在数据库中要唯一,如:存储过程名{入参1名|入参值,入参2名|入参值}
        /// </summary>
        public string rptParameter { get; set; }
        /// <summary>
        /// 打印
        /// </summary>
        public event EventHandler btnPrintClick;
        /// <summary>
        /// 设置报表
        /// 批量操作
        /// </summary>
        public event EventHandler btnDesignClick;
        public event EventHandler btnAllClick;
        /// <summary>
        /// 报表
        /// </summary>
        public event EventHandler btnReportClick;
        private void BtnReport_ItemClick(object sender, EventArgs e)
        {
            if (btnReportClick != null)
                btnReportClick(this, e);
            else
                return;
            if (rptParameter == "return false")
                return;
            if (string.IsNullOrEmpty(rptParameter))
            {
                MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!");
                return;
            }
            var _bl = false;
            _bl = _ckRptService();
            if (_bl)
            {
                try
                {
                    using (Form frm = new RptPreview(guidKey, rptParameter))
                    {
                        frm.ShowDialog();
                    }
                }
                catch (Exception)
                {
                }
                return;
            }
            MsgHelper.ShowError("没有设计模板,请先设计模板!");
        }
        private void BtnDesign_ItemClick(object sender, EventArgs e)
        {
            if (btnDesignClick != null)
                btnDesignClick(this, e);
            else
                return;
            if (string.IsNullOrEmpty(rptParameter))
            {
                MsgHelper.ShowError("没有指定报表参数,请联系技术开发人员!");
                return;
            }
            var _bl = false;
            _bl = _ckRptService();
            //如果已经有模板了,直接打开设置模板
            if (_bl)
            {
                var frm = new EasyRptDesign(guidKey, rptParameter);
                frm.ShowDialog();
                return;
            }
            //否则向导设计模板
            var rptWizard = new ShowRptWizard(guidKey, rptParameter);
            rptWizard.ShowDialog();
        }
        private bool _ckRptService()
        {
            try
@@ -120,5 +103,12 @@
            return false;
        }
        public void SetPlButton( bool blPiLiang) {
            if (blPiLiang == true)
                this.layoutControlItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            else
                this.layoutControlItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
        }
    }
}