protected override void OnLoad(EventArgs e) { base.OnLoad(e); mToolStripReportArgs = new ToolStripReportArgs(); OnInitToolStripControl(mToolStripReportArgs); }
protected override void OnInitToolStripControl(ToolStripReportArgs args) { args.LBToolStrip = skinToolStrip1; args.ReportTypeID = 3;//客户管理 base.OnInitToolStripControl(args); }
protected virtual void OnInitToolStripControl(ToolStripReportArgs args) { mToolStrip = args.LBToolStrip; if (args.LBToolStrip != null && args.ReportTypeID > 0) { if (!args.LBToolStrip.Items.ContainsKey("btnReportEdit")) { LBToolStripReportViewButton btnEditReport = new LB.Controls.LBToolStripReportViewButton(); btnEditReport.Image = Properties.Resources.btnConfig; btnEditReport.ImageTransparentColor = System.Drawing.Color.Magenta; btnEditReport.LBPermissionCode = ""; btnEditReport.Name = "btnReportEdit"; btnEditReport.ReportTypeID = args.ReportTypeID; btnEditReport.Size = new System.Drawing.Size(60, 37); btnEditReport.Text = "报表设计"; btnEditReport.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; btnEditReport.ToolStripType = LB.Controls.Helper.enToolStripType.EditReportButton; btnEditReport.Click += BtnEditReport_Click; args.LBToolStrip.Items.Add(btnEditReport); } DataTable dtReportTemp = ReportHelper.GetReportTemplateRowByType(args.ReportTypeID); if (args.LBToolStrip.Items.ContainsKey("btnReportViewSingle")) { args.LBToolStrip.Items.RemoveByKey("btnReportViewSingle"); } if (args.LBToolStrip.Items.ContainsKey("btnReportViewMulit")) { args.LBToolStrip.Items.RemoveByKey("btnReportViewMulit"); } if (args.LBToolStrip.Items.ContainsKey("btnReportPrintSingle")) { args.LBToolStrip.Items.RemoveByKey("btnReportPrintSingle"); } if (args.LBToolStrip.Items.ContainsKey("btnReportPrintMutli")) { args.LBToolStrip.Items.RemoveByKey("btnReportPrintMutli"); } if (dtReportTemp.Rows.Count == 1) { if (!args.LBToolStrip.Items.ContainsKey("btnReportViewSingle")) { string strReportTemplateID = dtReportTemp.Rows[0]["ReportTemplateID"].ToString(); LBToolStripReportViewButton btnReportViewSingle = new LB.Controls.LBToolStripReportViewButton(); btnReportViewSingle.Image = Properties.Resources.btnPreview; btnReportViewSingle.ImageTransparentColor = System.Drawing.Color.Magenta; btnReportViewSingle.LBPermissionCode = ""; btnReportViewSingle.Name = "btnReportViewSingle"; btnReportViewSingle.ReportTypeID = args.ReportTypeID; btnReportViewSingle.Tag = dtReportTemp.Rows[0]; btnReportViewSingle.Size = new System.Drawing.Size(60, 37); btnReportViewSingle.Text = "报表预览"; btnReportViewSingle.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; btnReportViewSingle.ToolStripType = LB.Controls.Helper.enToolStripType.EditReportButton; btnReportViewSingle.Click += BtnReportViewSingle_Click; args.LBToolStrip.Items.Add(btnReportViewSingle); } if (!args.LBToolStrip.Items.ContainsKey("btnReportPrintSingle")) { string strReportTemplateID = dtReportTemp.Rows[0]["ReportTemplateID"].ToString(); LBToolStripReportViewButton btnReportPrintSingle = new LB.Controls.LBToolStripReportViewButton(); btnReportPrintSingle.Image = Properties.Resources.btnPrint; btnReportPrintSingle.ImageTransparentColor = System.Drawing.Color.Magenta; btnReportPrintSingle.LBPermissionCode = ""; btnReportPrintSingle.Name = "btnReportPrintSingle"; btnReportPrintSingle.ReportTypeID = args.ReportTypeID; btnReportPrintSingle.Tag = dtReportTemp.Rows[0]; btnReportPrintSingle.Size = new System.Drawing.Size(60, 37); btnReportPrintSingle.Text = "报表打印"; btnReportPrintSingle.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; btnReportPrintSingle.ToolStripType = LB.Controls.Helper.enToolStripType.EditReportButton; btnReportPrintSingle.Click += BtnReportPrintSingle_Click;; args.LBToolStrip.Items.Add(btnReportPrintSingle); } } if (dtReportTemp.Rows.Count > 1) { //添加预览按钮 if (!args.LBToolStrip.Items.ContainsKey("btnReportViewMutli")) { LBToolStripDropDownReportViewButton btnReportViewSingle = new LB.Controls.LBToolStripDropDownReportViewButton(); btnReportViewSingle.Image = Properties.Resources.btnPreview; btnReportViewSingle.ImageTransparentColor = System.Drawing.Color.Magenta; btnReportViewSingle.LBPermissionCode = ""; btnReportViewSingle.Name = "btnReportViewMutli"; btnReportViewSingle.ReportTypeID = args.ReportTypeID; btnReportViewSingle.Size = new System.Drawing.Size(60, 37); btnReportViewSingle.Text = "报表预览"; btnReportViewSingle.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; btnReportViewSingle.Click += BtnReportViewSingle_Click; args.LBToolStrip.Items.Add(btnReportViewSingle); foreach (DataRow drReport in dtReportTemp.Rows) { string strReportTemplateID = drReport["ReportTemplateID"].ToString(); string strReportTemplateName = drReport["ReportTemplateName"].ToString().TrimEnd(); System.Windows.Forms.ToolStripMenuItem toolstripItem = new ToolStripMenuItem(); toolstripItem.Tag = drReport; toolstripItem.Name = "btnReportMunuItem" + strReportTemplateID; toolstripItem.Text = strReportTemplateName; toolstripItem.Click += BtnReportView_Click; btnReportViewSingle.DropDownItems.Add(toolstripItem); } } //添加直接打印按钮 if (!args.LBToolStrip.Items.ContainsKey("btnReportPrintMutli")) { LBToolStripDropDownReportViewButton btnReportPrintMutli = new LB.Controls.LBToolStripDropDownReportViewButton(); btnReportPrintMutli.Image = Properties.Resources.btnPrint; btnReportPrintMutli.ImageTransparentColor = System.Drawing.Color.Magenta; btnReportPrintMutli.LBPermissionCode = ""; btnReportPrintMutli.Name = "btnReportPrintMutli"; btnReportPrintMutli.ReportTypeID = args.ReportTypeID; btnReportPrintMutli.Size = new System.Drawing.Size(60, 37); btnReportPrintMutli.Text = "报表预览"; btnReportPrintMutli.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; //btnReportPrintMutli.Click += BtnReportViewSingle_Click; args.LBToolStrip.Items.Add(btnReportPrintMutli); foreach (DataRow drReport in dtReportTemp.Rows) { string strReportTemplateID = drReport["ReportTemplateID"].ToString(); string strReportTemplateName = drReport["ReportTemplateName"].ToString().TrimEnd(); System.Windows.Forms.ToolStripMenuItem toolstripItem = new ToolStripMenuItem(); toolstripItem.Tag = drReport; toolstripItem.Name = "btnReportPrintMunuItem" + strReportTemplateID; toolstripItem.Text = strReportTemplateName; toolstripItem.Click += BtnReportPrintSingle_Click; btnReportPrintMutli.DropDownItems.Add(toolstripItem); } } } } }