b/s架构的水晶报表,有人做过这类似的例子吗?
只要实现分组排序,打印预览就可以

解决方案 »

  1.   

    架构文件<?xml version="1.0" encoding="utf-8" ?> 
    <xs:schema id="RepairContact" 
        targetNamespace="http://tempuri.org/RepairContact.xsd"
        elementFormDefault="qualified"
        xmlns="http://tempuri.org/RepairContact.xsd"
        xmlns:mstns="http://tempuri.org/RepairContact.xsd"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="document">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="RepairSearch">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="接车员" type="xs:string" />
    <xs:element name="接车台次" type="xs:int" />
    <xs:element name="备件收入" type="xs:decimal" />
    <xs:element name="工时收入" type="xs:decimal" />
    <xs:element name="维修收入" type="xs:decimal" />
    <xs:element name="实收金额" type="xs:decimal" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
      

  2.   

    页面:RepairContact.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RepairContact.aspx.cs" Inherits="Report_Repair_RepairContact" %><%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
        Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
    <!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>
    </head>
    <body>
        <form id="form1" runat="server">
            <div style="text-align: center">
                <table border="0" cellpadding="0" cellspacing="0" style="margin-top: 20px; width: 760px;">
                    <tr>
                        <td style="width: 86px">
                            &nbsp;结算日期:</td>
                        <td style="width: 122px">
                            从&nbsp;
                            <asp:TextBox ID="txtStartQuerytime" runat="server" Width="94px"></asp:TextBox>
                        </td>
                        <td>
                            到&nbsp;
                            <asp:TextBox ID="txtEndQuerytime" runat="server" Width="94px"></asp:TextBox>
                        </td>
                        <td valign="middle">
                            <asp:Button ID="btnSearch" runat="server" Text="查询" Height="21px" OnClick="btnSearch_Click" />
                        </td>
                    </tr>
                </table>
                <br />
                <CR:CrystalReportViewer ID="crvContact" runat="server" ReportSourceID="crsContact" AutoDataBind="false"
                    DisplayGroupTree="False" EnableDatabaseLogonPrompt="False" HasCrystalLogo="False"
                    PrintMode="ActiveX" />
                <CR:CrystalReportSource ID="crsContact" runat="server" Report-FileName="RptFile/RepairContact.rpt">
                    <Report FileName="RptFile\RepairContact.rpt">
                    </Report>
                </CR:CrystalReportSource>
            </div>
        </form>    <script language="javascript" type="text/javascript" src="../../Javascripts/My97DatePicker/WdatePicker.js"></script></body>
    </html>
      

  3.   

    后台文件:Report_Repair_RepairContact.cs
    #region 命名空间
    using System;
    using System.Data;using BitAuto.Common;
    using BitAuto.Model.Report.Repair;
    using BitAuto.BLL.Report.Repair;
    #endregionpublic partial class Report_Repair_RepairContact : System.Web.UI.Page
    {
        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack)
            {
                try
                {
                    //绑定水晶报表
                    CrystalReportHelper.HoldCRVZomm(this.crvContact);
                    CrystalReportHelper.BindReport(this.crsContact, this.crvContact);
                }
                catch
                {
                    //设置数据并绑定报表
                    CrystalReportHelper.BindDataSource(this.crsContact, this.GetData());
                    CrystalReportHelper.BindReport(this.crsContact, this.crvContact);
                }
            }
            else
            {
                //为文本框增加日历功能,消除直接标记onfocus属性警告
                this.txtStartQuerytime.Attributes.Add("onfocus", "WdatePicker({skin:'blue',dateFmt:'yyyy-MM-dd',isShowWeek:true})");
                this.txtEndQuerytime.Attributes.Add("onfocus", "WdatePicker({skin:'blue',dateFmt:'yyyy-MM-dd',isShowWeek:true})");
            }
        }    protected void btnSearch_Click(object sender, EventArgs e)
        {
            //设置数据并绑定报表
            CrystalReportHelper.BindDataSource(crsContact, this.GetData());
            CrystalReportHelper.BindReport(crsContact, crvContact);
        }
        #endregion    #region 私有方法
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns>根据条件返回DataTable</returns>
        private DataTable GetData()
        {
            //建立搜索实体类,按照实体类的内容来搜索
            ContactModel model = new ContactModel(
                this.txtStartQuerytime.Text,        //查询起始时间
                this.txtEndQuerytime.Text           //查询结束时间
                );
            //调用BLL实现逻辑
            return BLRep_Contact.GetRepairList(model);
        }
        #endregion
    }
      

  4.   

    Model层
    namespace Model.Report.Repair
    {
        public partial class ContactModel
        {
            public ContactModel(string startTime, string endTime)
            {
                this.startTime = startTime;
                this.endTime = endTime;
            }        private string startTime;        public string StartTime
            {
                get { return startTime; }
                set { startTime = value; }
            }
            private string endTime;        public string EndTime
            {
                get { return endTime; }
                set { endTime = value; }
            }
        }
    }DAL层
    using System.Data;using DBUtility;
    using System.Data.SqlClient;namespace DAL.Report.Repair
    {
        public partial class DARep_RepairContact
        {
            #region 构造函数
            private DARep_RepairContact()
            {
            }
            #endregion        #region "常量声明"
            private const string UP_REPCONTACT = "UP_Report_RepairContact";        private const string PARA_WHERE = "@strWhere";        private const string CONTACTTABLENAME = "Contact";
            #endregion        #region  "成员方法"
            public static DataTable GetRepairList(string strWhere)
            {
                IDataParameter[] paramWhere = new IDataParameter[] { new SqlParameter(PARA_WHERE, strWhere) as IDataParameter };
                return SqlHelper.RunProcedure(UP_REPCONTACT, paramWhere, CONTACTTABLENAME).Tables[CONTACTTABLENAME];
            }
            #endregion
        }
    }BLL层
    #region 命名空间
    using System;
    using System.Data;using Common;
    using Model.Report.Repair;
    using DAL.Report.Repair;
    #endregionnamespace BLL.Report.Repair
    {
        public partial class BLRep_Contact
        {
            #region 构造函数
            private BLRep_Contact()
            {
            }
            #endregion        #region 私有常量
            private const string FINDATE = "[RO_FinDate]";
            #endregion        #region  "成员方法"
            internal static DataTable GetRepairList(string strWhere)
            {
                return DARep_RepairContact.GetRepairList(strWhere);
            }        public static DataTable GetRepairList(ContactModel model)
            {
                string strWhere = string.Empty;            strWhere += SqlWhereBuilder.GetSqlString(FINDATE, model.StartTime, BitAuto.Common.PublicEnum.WhereType.MoreThan);
                strWhere += SqlWhereBuilder.GetSqlString(FINDATE, model.EndTime, BitAuto.Common.PublicEnum.WhereType.LessThan);
                SqlWhereBuilder.SqlTrimAND(ref strWhere);            return GetRepairList(strWhere);
            }
            #endregion
        }
    }
      

  5.   

    请问CrystalReportHelper是什么组件,自己写的类吗?
      

  6.   

    帮助类:CrystalReportHelper#region 命名空间
    using System;
    using System.Data;using CrystalDecisions.Web;
    #endregion/// <summary>
    /// 水晶报表帮助类
    /// </summary>
    public class CrystalReportHelper
    {
        #region 构造方法
        private CrystalReportHelper()
        {
        }
        #endregion    #region 共有方法
        /// <summary>
        /// 将水晶报表和数据源绑定
        /// </summary>
        /// <param name="crs">数据源</param>
        /// <param name="crv">报表</param>
        public static void BindReport(CrystalReportSource crs, CrystalReportViewer crv)
        {
            crs.DataBind();
            crv.DataBind();
        }    /// <summary>
        /// 将水晶报表数据源与数据对象绑定
        /// </summary>
        /// <param name="crs">数据源</param>
        /// <param name="dt">数据对象</param>
        public static void BindDataSource(CrystalReportSource crs, DataTable dt)
        {
            crs.ReportDocument.SetDataSource(dt);
        }    /// <summary>
        /// 页面回传后保持水晶报表缩放比例
        /// </summary>
        /// <param name="crv">保持缩放比例的水晶报表</param>
        public static void HoldCRVZomm(CrystalReportViewer crv)
        {
            System.Web.HttpRequest Request = System.Web.HttpContext.Current.Request;
            //获得回传的比例
            if (Request.Form[crv.Controls[2].Controls[15].UniqueID] != null)
            {
                //手动设置比例大小
                crv.PageZoomFactor = Int32.Parse(Request.Form[crv.Controls[2].Controls[15].UniqueID]);
            }
        }
        #endregion
    }
      

  7.   

    //SqlHelper和SqlWhereBuilder就不贴了
      

  8.   

    微软webcast上有一个水晶报表的使用基础视频,邵志东主讲的,你搜索一下就能找到了