pos_baobiao.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:10k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using Microsoft.Reporting.WebForms;
- using System.Data;
- using System.Data.SqlClient;
- 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 DataTable = System.Data.DataTable;
- public partial class web_pos_pos_baobiao : System.Web.UI.Page
- {
- DataTable dt = new DataTable("dataname");
- string last_date = "";
- string last_time = "";
- string last_d = "";
- string last_t = "";
- double sum_1 = 0;
- double sum_2 = 0;
- double sum = 0;
- int num_1 = 0;
- int num_2 = 0;
- protected void Page_Load(object sender, EventArgs e)
- {
- dt.Columns.Add("date", typeof(string));
- dt.Columns.Add("shop_id", typeof(string));
- dt.Columns.Add("shop_name", typeof(string));
- dt.Columns.Add("total_money", typeof(double));
- dt.Columns.Add("cancel_money", typeof(double));
- dt.Columns.Add("cancel_num", typeof(Int32));
- dt.Columns.Add("back_money", typeof(double));
- dt.Columns.Add("back_num", typeof(Int32));
- dt.Columns.Add("cancel_total", typeof(string));
- ReportViewer1.Visible = false;
- }
- public void bind()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- DataRow row = dt.NewRow();
- SqlCommand sqlcom = new SqlCommand("select distinct shop as shop from SPECREC order by shop", conn);
- SqlDataReader dr = sqlcom.ExecuteReader();
- if (dr.HasRows)
- {
- while (dr.Read())
- {
- SqlConnection conn1 = dbConnection.getConnection();
- conn1.Open();
- SqlCommand sqlcom2 = new SqlCommand("select distinct DATE as DATE from SPECREC where DATE between'" + b_date.Text.Trim().ToString() + "' and '" + e_date.Text.Trim().ToString() + "' order by DATE", conn1);
- SqlDataReader dr2 = sqlcom2.ExecuteReader();
- if (dr2.HasRows)
- {
- while (dr2.Read())
- {
- sum_1 = 0;
- sum_2 = 0;
- num_1 = 0;
- num_2 = 0;
- sum = 0;
- row = dt.NewRow();
- last_d = "";
- last_date = "";
- last_t = "";
- last_time = "";
- row["shop_id"] = dr["shop"].ToString();
- row["date"] = dr2["DATE"].ToString();
- SqlConnection conn2 = dbConnection.getConnection();
- conn2.Open();
- SqlCommand sqlcom5 = new SqlCommand("select sum(QTY*UNITPRICE) as sum from CTI where shop='" + dr["shop"].ToString() + "' and DATE='" + dr2["DATE"].ToString() + "'", conn2);
- sqlcom5.CommandTimeout = 432000;
- SqlDataReader dr5 = sqlcom5.ExecuteReader();
- if (dr5.HasRows)
- {
- while (dr5.Read())
- {
- if (dr5["sum"].ToString().Equals(""))
- {
- }
- else
- {
- row["total_money"] = Round(Convert.ToDouble(dr5["sum"]), 2);
- sum = Round(Convert.ToDouble(dr5["sum"]), 2);
- }
- }
- }
- dr5.Close();
- SqlCommand sqlcom4 = new SqlCommand("select name from POS_SHOP where NO='" + dr["shop"].ToString() + "'", conn2);
- SqlDataReader dr4 = sqlcom4.ExecuteReader();
- if (dr4.HasRows)
- {
- while (dr4.Read())
- {
- row["shop_name"] = dr4["name"].ToString();
- }
- }
- dr4.Close();
- SqlCommand sqlcom1 = new SqlCommand("select QTY,UNITPRICE,TDATE,TTIME from SPECREC where shop='" + dr["shop"].ToString() + "' and TDATE ='" + dr2["DATE"].ToString() + "' and REMARK='V' AND MANAGER='' ORDER BY TIME", conn2);
- SqlDataReader dr1 = sqlcom1.ExecuteReader();
- if (dr1.HasRows)
- {
- while (dr1.Read())
- {
- sum_1 = sum_1 + Convert.ToDouble(dr1["UNITPRICE"])*Convert.ToInt32(dr1["QTY"]);
- if (dr1["TDATE"].ToString().Equals(last_date) && dr1["TTIME"].ToString().Equals(last_time))
- {
- }
- else
- {
- num_1 = num_1 + 1;
- }
- last_date = dr1["TDATE"].ToString();
- last_time = dr1["TTIME"].ToString();
- }
- }
- dr1.Close();
- row["cancel_num"] = num_1;
- row["cancel_money"] = sum_1;
- SqlCommand sqlcom3 = new SqlCommand("select QTY,UNITPRICE,TDATE,TTIME from SPECREC where shop='" + dr["shop"].ToString() + "' and TDATE ='" + dr2["DATE"].ToString() + "' and REMARK='R' ORDER BY TIME", conn2);
- SqlDataReader dr3 = sqlcom3.ExecuteReader();
- if (dr3.HasRows)
- {
- while (dr3.Read())
- {
- sum_2 = sum_2 + Convert.ToDouble(dr3["UNITPRICE"]) * Convert.ToInt32(dr3["QTY"]);
- if (dr3["TDATE"].ToString().Equals(last_d) && dr3["TTIME"].ToString().Equals(last_t))
- {
- }
- else
- {
- num_2 = num_2 + 1;
- }
- last_d = dr3["TDATE"].ToString();
- last_t = dr3["TTIME"].ToString();
- }
- }
- dr3.Close();
- conn2.Close();
- row["back_num"] = num_2;
- row["back_money"] = sum_2;
- row["cancel_total"] = Round(100 * sum_1 / sum, 2).ToString() + "%";
- dt.Rows.Add(row);
- }
- }
- dr2.Close();
- conn1.Close();
- }
- }
- dr.Close();
- conn.Close();
- ReportDataSource rds = new ReportDataSource("DataSet3_DataTable1", dt);
- ReportViewer1.LocalReport.DataSources.Clear();
- ReportViewer1.LocalReport.DataSources.Add(rds);
- ReportViewer1.LocalReport.Refresh();
- }
- protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
- {
- if (Begindate.Visible == true)
- {
- Begindate.Visible = false;
- Begindate.Focus();
- }
- else
- {
- Begindate.Visible = true;
- Begindate.Focus();
- }
- }
- protected void Begindate_SelectionChanged(object sender, EventArgs e)
- {
- Begindate.Visible = false;
- string year = Begindate.SelectedDate.Year.ToString();
- string month = Begindate.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Begindate.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- b_date.Text = year + "-" + month + "-" + day;
- b_date.Focus();
- }
- protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
- {
- if (Enddate.Visible == true)
- {
- Enddate.Visible = false;
- Enddate.Focus();
- }
- else
- {
- Enddate.Visible = true;
- Enddate.Focus();
- }
- }
- protected void Enddate_SelectionChanged(object sender, EventArgs e)
- {
- Enddate.Visible = false;
- string year = Enddate.SelectedDate.Year.ToString();
- string month = Enddate.SelectedDate.Month.ToString();
- if (month.Length == 1)
- {
- month = "0" + month;
- }
- string day = Enddate.SelectedDate.Day.ToString();
- if (day.Length == 1)
- {
- day = "0" + day;
- }
- e_date.Text = year + "-" + month + "-" + day;
- e_date.Focus();
- }
- protected void ShowMessageBox(string strMessage)
- {
- Response.Write(string.Format("<script>alert('{0}')</script>", strMessage));
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- if (b_date.Text.Trim().Equals("") || e_date.Text.Trim().Equals(""))
- {
- ShowMessageBox("请选择日期");
- }
- else
- {
- ReportViewer1.Visible = true;
- bind();
- }
- }
- public double Round(double v, int x)
- {
- bool flat = false;
- if (v < 0)
- {
- flat = true;
- v = -v;
- }
- int ivalue = 1;
- for (int i = 1; i <= x; i++)
- {
- ivalue = 10 * ivalue;
- }
- double num = Math.Round(v * ivalue + 0.5, 0);
- v = num / ivalue;
- if (flat)
- {
- v = -v;
- }
- return v;
- }
- }