⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.cs

📁 这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FilLDropDownList();//填冲DropDownList控件
            
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("server=(local);uid=sa;pwd=;database=db_06");
        con.Open();
        SqlCommand com = new SqlCommand();
        com.Connection = con;
        com.CommandText = "ProWorke";
        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.Add("@monthMonye", SqlDbType.SmallDateTime).Value = DropDownList1.SelectedValue.ToString(); ;
        SqlDataAdapter da = new SqlDataAdapter(com);
        DataSet ds = new DataSet();
        da.Fill(ds, "tb_worke");
        con.Close();
        ReportDocument studentsReport = new ReportDocument();//定义ReportDocument类对象
        studentsReport.Load(Server.MapPath("CrystalReport.rpt"));//加载报表
        studentsReport.SetDataSource(ds);//加载数据源
        this.CrystalReportViewer1.ReportSource = studentsReport;//为CrystalReportViewer控件指定报表
    }

    public void FilLDropDownList()//填冲DropDownList控件
    {
        SqlConnection con = new SqlConnection("server=(local);uid=sa;pwd=;database=db_06");
        con.Open();
        string strSql = "select distinct 月份 from tb_worke";
        SqlCommand com = new SqlCommand(strSql, con);
        SqlDataReader dr = com.ExecuteReader();
        while (dr.Read())
        {
            DateTime dat = Convert.ToDateTime(dr[0].ToString());
            DropDownList1.Items.Add(dat.ToShortDateString());
        }
        dr.Close();
        con.Close();
    }
        
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -