1、插件中添加按钮
添加一个按钮的主要代码 #region 添加按钮:出口发票打印 //实例化按钮 IUFButton btnMergeInvoicePrint = new UFWebButtonAdapter(); btnMergeInvoicePrint.Text = "出口发票打印"; btnMergeInvoicePrint.ID = "btnMergeInvoicePrint"; btnMergeInvoicePrint.AutoPostBack = true; //加入Card容器 IUFCard card = (IUFCard)Part.GetUFControlByName(Part.TopLevelContainer, "Card0"); card.Controls.Add(btnMergeInvoicePrint); CommonFunction.Layout(card, btnMergeInvoicePrint, 8, 0); //设置“出口发票打印”按钮事件 btnMergeInvoicePrint.Click += new EventHandler(btnMergeInvoicePrint_Click); #endregion
2、在按钮事件中调用打印模板进行打印
调用打印模板的主要代码 IExportSettings settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject(); settings.PrintTemplateCatalogType = "UFIDA.U9.SM.KENT.JR.ShipBListInvoicePrint"; //打印模板分类ID:打印模板实体key settings.DefaultPrintTemplateID = "66f834e2-0e79-471a-8f97-33c8477bda5e"; //打印模板ID settings.PrintData = GetMergeInvoiceData(); //打印数据DataSet settings.ShowPrintStyleWhenDataIsNull = true; //当数据为空时打印表样 settings.TitleVisible = true; //显示列头表 UIActionEventArgs ex = new UIActionEventArgs(); ex.Tag = settings; ExportServiceFactory.DoPrintCommand(sender,(BaseAction)shipBListPart.Action,ex); //打印Do