1 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Stimulsoft.Report;
using Stimulsoft.Report.Components;
using Stimulsoft.Report.Print;
using Stimulsoft.Report.Export;
using System.IO;
using System.Net.Mail;
using System.Text;
using System.Net; public class applicationStart
{
public static bool isshowlogo = false;
public static string orderid = "";
public static DataTable dthead;
public static DataTable dtmessage;
} public partial class StimulReport : System.Web.UI.Page
{
double left = , right = , top = , bottom = ; protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
try
{
string aa = Request.QueryString["printno"];
if (aa == null || aa == "")
throw new Exception();
applicationStart.orderid = aa;
}
catch
{
return;
}
try
{
applicationStart.isshowlogo = Convert.ToBoolean(Request.QueryString["isshowlogo"]); }
catch
{
}
GetSource();
}
ShowReport(applicationStart.isshowlogo);
} private void ShowReport(bool isshowlogo)
{
if (applicationStart.isshowlogo)
{
this.Button2.Text = "HideLogo";
}
else
{
this.Button2.Text = "ShowLogo";
} string filepath = Server.MapPath("~/Report_1.mrt");
StiReport stireport = new StiReport();
stireport.Load(filepath); stireport.RegData("datasource", applicationStart.dtmessage);
//设置报表内控件状态
StiFooterBand fb = stireport.Pages[].Components["FooterBand1"] as StiFooterBand;
StiText st = fb.Components["Text47"] as StiText;
st.Enabled = applicationStart.dthead.Rows[]["looksampletype"].ToString() == "" ? false : true; StiPageHeaderBand head = stireport.Pages[].Components["PageHeaderBand1"] as StiPageHeaderBand;
StiImage imglogo1 = head.Components["Image1"] as StiImage;
imglogo1.Enabled = applicationStart.isshowlogo; StiPageFooterBand footer = stireport.Pages[].Components["PageFooterBand1"] as StiPageFooterBand;
StiImage imglogo2 = footer.Components["Image2"] as StiImage;
imglogo2.Enabled = applicationStart.isshowlogo; //设置页边距
stireport.Pages[].Margins = new StiMargins(left, right, top, bottom); stireport.Compile();
//设置报表内的参数值
stireport["code"] = applicationStart.dthead.Rows[]["code"].ToString();
stireport["orderno"] = applicationStart.dthead.Rows[]["orderno"].ToString();
stireport["price"] = applicationStart.dthead.Rows[]["price"].ToString();
stireport["discountprice"] = applicationStart.dthead.Rows[]["discountprice"].ToString();
stireport["tobefinishstr"] = applicationStart.dthead.Rows[]["tobefinishstr"].ToString();
stireport["createdate"] = applicationStart.dthead.Rows[]["createdate"].ToString();
stireport["contact"] = applicationStart.dthead.Rows[]["contact"].ToString();
stireport["companyname"] = applicationStart.dthead.Rows[]["companyname"].ToString();
stireport["tel"] = applicationStart.dthead.Rows[]["tel"].ToString();
stireport["fax"] = applicationStart.dthead.Rows[]["fax"].ToString();
stireport["mobile"] = applicationStart.dthead.Rows[]["mobile"].ToString();
stireport["address"] = applicationStart.dthead.Rows[]["address"].ToString();
stireport["email"] = applicationStart.dthead.Rows[]["email"].ToString();
stireport["deliverytypeenname"] = applicationStart.dthead.Rows[]["deliverytypeenname"].ToString();
stireport["name"] = applicationStart.dthead.Rows[]["name"].ToString();
stireport["customermemo"] = applicationStart.dthead.Rows[]["customermemo"].ToString();
stireport["looksampletypestr"] = applicationStart.dthead.Rows[]["looksampletypestr"].ToString(); viewer1.Report = stireport;
} private void GetSource()
{
string headsql = "select orderno, tobefinishdate, so.price,so.discountprice, tobefinishstr,so.deliverydate,createdate ,so.contact,so.companyname,so.tel,so.fax,so.mobile,so.address,so.looksampletype, " +
"so.orderid, so.email,so.code, sales.username as salename ,openso.username as openname ,base_delivery_type.deliverytypeenname,base_delivery_type.shiptypename,user_position.positionname," + "name,so.discountoffflag,so.customermemo from so ,user as sales,user as openso ,base_delivery_type,user_position ,customer,customer_discount " +
"where so.userid=sales.userid and so.opuserid=openso.userid and base_delivery_type.deliverytypeid=so.deliverytypeid " +
"and so.positionid=user_position.positionid and customer.discountid=customer_discount.discountid " +
"and so.customerid=customer.customerid and so.orderid=" + applicationStart.orderid; string messagesql = "SELECT *from (" +
"select jobno,product.productname,enproductname,so_detail.printnum,sampleflag,socontent as jobcontent , printprice , " +
"sodetailid as sortno,so.customermemo as memo " +
"From so_detail ,so,product where so_detail.deleteflag=0 and so.orderid=so_detail.orderid and " +
"product.productid=so_detail.productid and so.orderid= " + applicationStart.orderid +
" union all " +
"select '' as jobno , 'Delivery' as productname ,'Delivery' as enproductname , ' ' as printnum ,' ' as sampleflag , '' as jobcontent ,price ," +
"'1' as sortno ,address as memo from so_delivery where orderid= " + applicationStart.orderid +
" union all " +
"select '' as jobno , 'PostProcess' as productname ,'PostProcess' as enproductname, outsidenum as printnum ,' ' as sampleflag , postprocessname, costamount " +
", so_detail.sodetailid as sortno ,concat(memo,memostr) as memo From so_detail_outside,so ,so_detail where so.orderid=so_detail.orderid and so_detail.deleteflag=0 " +
"and so_detail.sodetailid=so_detail_outside.sodetailid and so.orderid= " + applicationStart.orderid +
" union all " +
"select '' as jobno , 'OtherItem' as productname ,'OtherItem' as enproductname , ' ' as printnum ,' ' as sampleflag , pricenamecn, so_detail_price.price " +
", so_detail.sodetailid as sortno ,'' as memo From so_detail_price,so ,so_detail where so.orderid=so_detail.orderid and so_detail.deleteflag=0 " +
"and so_detail.sodetailid=so_detail_price.sodetailid and so.orderid= " + applicationStart.orderid +
" union all " +
"select '' as jobno , offername as productname ," +
"'Discountinfo' as enproductname , ' ' as printnum ,' ' as sampleflag , offer_so_history.offermemo as discountmemo, -offer_so_history.discountprice as price , " +
"'0' as sortno , offer_so_history.offername as memo From offer_so_history,so where so.orderid=offer_so_history.orderid and so.deleteflag=0 " +
"and so.orderid=" + applicationStart.orderid + " ) as itemlist order by sortno desc";
DataModule dm = DataModule.GetDataModule();
applicationStart.dthead = dm.QuerySql(headsql);
applicationStart.dtmessage = dm.QuerySql(messagesql);
DataTable dt = applicationStart.dtmessage; applicationStart.dthead.Columns.Add(new DataColumn("looksampletypestr", typeof(string)));
applicationStart.dthead.Columns.Add(new DataColumn("isshowdiscountprice", typeof(string)));
if (applicationStart.dthead.Rows.Count > )
{
if (applicationStart.dthead.Rows[][].ToString() == applicationStart.dthead.Rows[][].ToString())
{
applicationStart.dthead.Rows[]["isshowdiscountprice"] = ;//false
}
else
{
applicationStart.dthead.Rows[]["isshowdiscountprice"] = ;//true
}
} foreach (DataRow dr in applicationStart.dthead.Rows)
{
if (dr["looksampletype"].ToString() == "")
{
dr["looksampletypestr"] = "不打稿";
}
else if (dr["looksampletype"].ToString() == "")
{
dr["looksampletypestr"] = "打稿";
}
else
{
dr["looksampletypestr"] = "";
}
}
} protected void Button1_Click(object sender, EventArgs e)
{
SendEmail(this.DropDownList1.SelectedValue, this.viewer1.Report, "aaa@163.com", this.TextBox1.Text, "Report[" + this.DropDownList1.SelectedValue + "]" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "", "smtp.163.com", , "aaa@163.com", "");
} private void GetFormat(string filetype, ref StiExportFormat sf, ref string filename)
{
switch (filetype)
{
case "pdf": sf = StiExportFormat.Pdf; filename = "report.pdf"; break;
case "jpeg": sf = StiExportFormat.ImageJpeg; filename = "report.jpeg"; break;
case "gif": sf = StiExportFormat.ImageGif; filename = "report.gif"; break;
case "excel": sf = StiExportFormat.Excel; filename = "report.xls"; break;
case "word2007": sf = StiExportFormat.Word2007; filename = "report.docx"; break;
}
} public void SendEmail(string filetype, StiReport report, string fromaddress, string toaddress, string subject, string messageBody, string host, int port, string username, string password)
{
using (MemoryStream ms = new MemoryStream())
{
string filename = "";
StiExportFormat sef = StiExportFormat.Pdf;
GetFormat(filetype, ref sef, ref filename);
report.ExportDocument(sef, ms);
ms.Seek(, SeekOrigin.Begin); //使用自己的邮件发送机制
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(ms, filename); MailMessage item = new MailMessage(fromaddress, toaddress);
item.Subject = subject;
item.Body = messageBody;
item.Attachments.Add(attachment); SmtpClient smtp = new SmtpClient(host, port);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(username, password);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(item);
ms.Close();
}
ClientScript.RegisterStartupScript(GetType(), "", "<script>showmessage();</script>");
}
protected void Button2_Click(object sender, EventArgs e)
{
applicationStart.isshowlogo = !applicationStart.isshowlogo;
ShowReport(applicationStart.isshowlogo);
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="StimulReport.aspx.cs" Inherits="StimulReport" %>

<%@ Register Assembly="Stimulsoft.Report.Web, Version=2013.3.1800.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a"
Namespace="Stimulsoft.Report.Web" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 498px;
}
</style>
<script language="javascript" type="text/javascript">
function showmessage() {
document.getElementById("divmessage").style.display = "block";
setTimeout("document.getElementById('divmessage').style.display ='none';", 2000);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table style="width: 100%">
<tr>
<td class="style1">
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
Text="ShowLogo" />
Email:<asp:TextBox ID="TextBox1" runat="server">huang_198906@163.com</asp:TextBox>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Selected="True">pdf</asp:ListItem>
<asp:ListItem>jpeg</asp:ListItem>
<asp:ListItem>gif</asp:ListItem>
<asp:ListItem>excel</asp:ListItem>
<asp:ListItem>word2007</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Email" />
</td>
<td>
<div id="divmessage" style="width: 69px; background-color: #BDB8FA; display: none">
發送成功
</div>
</td>
</tr>
</table>
<cc1:StiWebViewer ID="viewer1" runat="server" ShowBookmarksButton="False" ShowParametersButton="False" />
<cc1:StiWebReport ID="report1" runat="server" />
</form>
</body>
</html>

Stimulsoft.Report.net报表简单实用的更多相关文章

  1. stimulsoft report工具—— 简单的多表连接打印报表例子

    一.用报表工具打印多个表格信息(包括学生表.教师表.班级表) 1.准备打印的数据(用sqlserver) 1)班级表

  2. stimulsoft Report报表使用笔记

    1.使用设计器设计mrt报表模板,或者从其他文件复制修改 2.删除business object 数据源 3.使用代码添加数据源 ParcelChangeItem change = new Parce ...

  3. Stimulsoft.Report.web viewer控件添加按钮

    当你购买了带源码的时候,你可以对源码进行修改以达到自己想要的效果,比较这里讲到的,向viewer控件工具栏添加按钮. 通过源码目录可以看出我们需要修改的有两部分代码 红色方块圈中的部分,[StiWeb ...

  4. Visual Studio 2010 RDLC 报表简单使用

    原文:Visual Studio 2010 RDLC 报表简单使用 RDLC(Report Definition Language Client-side Processing)是Visual Stu ...

  5. jQuery + Stimulsoft.Report 选择gridview多行打印

    jQuery + Stimulsoft.Report 报表空间打印多个ID split函数,多行ID 1. 获取选择多行ID(前台) //按钮-打印 function PrinterWorkQuali ...

  6. jQuery的几种简单实用效果

    许久未分享博客,或许已生疏. 闲来无事, 分享几个jQuery简单实用的效果案例 不喜勿喷... 1.页面常用的返回顶部 <!DOCTYPE html> <html lang=&qu ...

  7. PowerDesigner导出Report通用报表

    PowerDesigner导出Report通用报表 通用模板下载地址:http://pan.baidu.com/s/1c0NDphm

  8. 经验分享:10个简单实用的 jQuery 代码片段

    尽管各种 JavaScirpt 框架和库层出不穷,jQuery 仍然是 Web 前端开发中最常用的工具库.今天,向大家分享我觉得在网站开发中10个简单实用的 jQuery 代码片段. 您可能感兴趣的相 ...

  9. 简单实用的PHP防注入类实例

    这篇文章主要介绍了简单实用的PHP防注入类实例,以两个简单的防注入类为例介绍了PHP防注入的原理与技巧,对网站安全建设来说非常具有实用价值,需要的朋友可以参考下   本文实例讲述了简单实用的PHP防注 ...

随机推荐

  1. A + B Again 2057 有符号的64进位的运算

    Problem Description There must be many A + B problems in our HDOJ , now a new one is coming.Give you ...

  2. 在ASP.net中的UpdatePanel,弹窗失败解决办法

    原文:在ASP.net中的UpdatePanel,弹窗失败解决办法 最开始我用: Response.Write("<script>alert('和哈呵呵呵呵呵呵!')</s ...

  3. cocos2dx 3.1.1移植安卓apk (lua交叉编译器项目 mac环境)

    cocos2dx 3.1.1   lua项目安卓交叉编译 mac环境 本文基于ant,sdk,ndk,adt等软件和环境已经事前设置好 1\新建项目 在mac的终端下输入命令: cocos new t ...

  4. VisualStudio 自动排版等 快捷键

    VisualStudio2010自动排版快捷键:全部代码排版:1. ctrl+E,D 按住ctrl,相继按下E.D                          2. ctrl+K,F 按住ctr ...

  5. 解决Unity3d 4.3 动画系统带来的烦恼

    近期有非常多同学问我关于unity3d 4.3更新之后动画系统和曾经不一样了,并且之前用的非常熟练的创建动画和修修改画非常多操作都不好用了,那么在这里和大家分享一下三杀的个人经验,方便大家使用unit ...

  6. XCL-Charts圈图

    我不知道是不是叫图,无论如何,所以叫它. 图形是今天我Circliful这个jQuery 插件上看到的. 认为非常好看. 就想把它实现出来,由于之前画过环形图.且我如今的图表基类基本已成型,所以非常快 ...

  7. Robot Framework + appium 启动手机浏览器的两个方法(1)

    一.Open Browser启动 使用Selenium2Library的Open Browser方法,例子如下: browser=手机浏览器类型,如chrome 二.Open Application启 ...

  8. 深入struts2(三)---工作机制和运行流程图

    1     工作原理 1.1     体系架构 图2.1 struts2.0体系架构图 1.2     工作机制 针对上节体系架构图,以下分步说明运行流程 Ø  client初始化一个指向Servle ...

  9. HDU 1385 Minimum Transport Cost 最短路径题解

    本题就是使用Floyd算法求全部路径的最短路径,并且须要保存路径,并且更进一步须要依照字典顺序输出结果. 还是有一定难度的. Floyd有一种非常巧妙的记录数据的方法,大多都是使用这种方法记录数据的. ...

  10. MVC验证04-自定义验证规则、日期范围验证

    原文:MVC验证04-自定义验证规则.日期范围验证 本文体验范围验证.与本文相关的包括: MVC验证01-基础.远程验证   MVC验证02-自定义验证规则.邮件验证   MVC验证03-自定义验证规 ...