report.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:6k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using Microsoft.Reporting.WebForms;
- 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 CrystalDecisions.CrystalReports.Engine;
- public partial class web_pos_report : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- /* protected void Button1_Click(object sender, EventArgs e)
- {
- string year = DropDownList1.SelectedItem.ToString();
- string month = DropDownList2.SelectedItem.ToString();
- string date = "";
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- date = year + "-" + month;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet DataSet2 = new DataSet();
- DataTable DataTable1 = new DataTable();
- DataTable1.Columns.Add("date", typeof(string));
- DataTable1.Columns.Add("shop", typeof(string));
- DataTable1.Columns.Add("money", typeof(double));
- SqlCommand sqlcom = new SqlCommand("select NO,name from POS_SHOP", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom1 = new SqlCommand("select DATE,QTY*UNITPRICE as money from CTI where SUBSTRING(DATE,0,8)='" + date + "' and shop='" + dr["NO"].ToString() + "'", conn1);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- DataRow row = DataTable1.NewRow();
- row["shop"] = dr["name"].ToString();
- row["date"] = dr1["DATE"].ToString();
- row["money"] = Convert.ToInt32(dr1["money"]);
- DataTable1.Rows.Add(row);
- }
- }
- dr1.Close();
- conn1.Close();
- }
- }
- DataSet2.Tables.Add(DataTable1);
- dr.Close();
- conn.Close();
- CrystalReportSource1.ReportDocument.Load(Server.MapPath("~/web/pos/CrystalReport.rpt"));
- CrystalReportSource1.ReportDocument.SetDataSource(DataSet2);
- CrystalReportSource1.DataBind();
- CrystalReportViewer1.ReportSource = CrystalReportSource1;
- CrystalReportViewer1.DataBind();
- CrystalReportViewer1.Visible = true;
- }*/
- protected void Button1_Click(object sender, EventArgs e)
- {
- string year = DropDownList1.SelectedItem.ToString();
- string month = DropDownList2.SelectedItem.ToString();
- string date = "";
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- date = year + "-" + month;
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataSet4 ds = new DataSet4();
- SqlCommand sqlcom = new SqlCommand("select NO,name from POS_SHOP", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom1 = new SqlCommand("select distinct DATE from CTI where SUBSTRING(DATE,0,8)='" + date + "' order by DATE", conn1);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- DataRow row = ds.CTI.NewRow();
- row["shop"] = dr["name"].ToString();
- row["date"] = dr1["DATE"].ToString();
- SqlConnection conn2 = dbConnection.getConnection();
- conn2.Open();
- SqlCommand sqlcom2 = new SqlCommand("select sum(QTY*UNITPRICE) as money from CTI where DATE='" + dr1["DATE"] + "' and shop='" + dr["NO"].ToString() + "'", conn2);
- SqlDataReader dr2 = sqlcom2.ExecuteReader();
- if (dr2.HasRows)
- {
- while (dr2.Read())
- {
- if (!dr2["money"].ToString().Equals(""))
- {
- row["QTY*UNITPRICE"] = Convert.ToInt32(dr2["money"]);
- }
- else
- {
- row["QTY*UNITPRICE"] = 0;
- }
- }
- }
- ds.CTI.Rows.Add(row);
- dr2.Close();
- conn2.Close();
- }
- }
- dr1.Close();
- conn1.Close();
- }
- }
- dr.Close();
- conn.Close();
- CrystalReportSource1.ReportDocument.Load(Server.MapPath("~/web/pos/CrystalReport.rpt"));
- CrystalReportSource1.ReportDocument.SetDataSource(ds);
- CrystalReportSource1.DataBind();
- CrystalReportViewer1.ReportSource = CrystalReportSource1;
- CrystalReportViewer1.DataBind();
- CrystalReportViewer1.Visible = true;
- }
- }