| | |
| | | using DevExpress.XtraEditors; |
| | | using Gs.DevApp.DevFrm.Rpt; |
| | | using Gs.DevApp.DevFrm.Sys; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Gs.DevApp.UserControl |
| | |
| | | public UcBtnPrint() |
| | | { |
| | | InitializeComponent(); |
| | | btnReport.Click += BtnReport_ItemClick; |
| | | btnDesign.Click += BtnDesign_ItemClick; |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 关键字,一般是主键 |
| | | /// </summary> |
| | | public string guidKey { get; set; } |
| | | /// <summary> |
| | | /// 报表,在数据库中要唯一,如:存储过程名{入参1名|入参值,入参2名|入参值} |
| | | /// </summary> |
| | | public string rptParameter { get; set; } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置报表 |
| | | /// </summary> |
| | | public event EventHandler btnDesignClick; |
| | | |
| | | /// <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 |
| | | { |
| | | var _obj = new |
| | | { |
| | | guid = guidKey, |
| | | rptParameter, |
| | | isDesign = 1 |
| | | }; |
| | | var strJson = UtilityHelper.HttpPost("", "Report/GetRptData", |
| | | JsonConvert.SerializeObject(_obj)); |
| | | var _rtn = UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) return true; |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgHelper.Warning("提示:" + ex.Message); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | } |