using System; using System.Data; using System.Configuration; using System.Collections; using System.Text; using System.Collections.Generic; 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 i_salesDAL; using i_salesModels; using i_salesBLL; using MySql.Data.MySqlClient; using System.IO; public partial class CEO_ComToTotal : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { year.Text = "X"; month.Text = "X"; day.Text = "X"; } } //搜索统计信息 protected void btnsearch_Click(object sender, EventArgs e) { //得到下拉列表年份 int year = int.Parse(this.ddlyear.SelectedItem.Value); //得到下拉列表月份 int mouth = int.Parse(this.ddlmouth.SelectedItem.Value); //得到日期 int day = int.Parse(this.ddlday.SelectedItem.Value); //组装日期 string date = "" + year + "-" + mouth + "-"+day+""; //查找v数目,v_company string sqlCon1 = "select count(*) from v_company where TIME like '" + date + "'"; int vNum = DBHelper.GetScalar(sqlCon1); //得到A+客户 string sqlCon2 = "select count(*) from sales_company where TIME like '" + date + "' and STATE in(3,4,5,6)"; int aNum = DBHelper.GetScalar(sqlCon2); //得到B客户 string sqlCon3 = "select count(*) from sales_company where TIME like '" + date + "' and STATE=8"; int bNum = DBHelper.GetScalar(sqlCon3); //得到C客户 string sqlCon4 = "select count(*) from sales_company where TIME like '" + date + "' and STATE=9"; int cNum = DBHelper.GetScalar(sqlCon4); //得到D客户 string sqlCon5 = "select count(*) from d_company where TIME like '" + date + "'"; int dNum = DBHelper.GetScalar(sqlCon5); int va = vNum - aNum; int ab = aNum - bNum; int bc = bNum - cNum; int cd = cNum - dNum; int ad = aNum - dNum; 修改对应的txt文件 StreamWriter sw = File.CreateText(Server.MapPath(@"./pie2/va") + @"/va.txt"); sw.WriteLine("NO;" + va + ";"); sw.WriteLine("OK;" + aNum + ";true"); sw.Flush(); sw.Close(); StreamWriter sw1 = File.CreateText(Server.MapPath(@"./pie2/ab") + @"/ab.txt"); sw1.WriteLine("NO;" + ab + ";"); sw1.WriteLine("OK;" + bNum + ";true"); sw1.Flush(); sw1.Close(); StreamWriter sw2 = File.CreateText(Server.MapPath(@"./pie2/bc") + @"/bc.txt"); sw2.WriteLine("NO;" + bc + ";"); sw2.WriteLine("OK;" + cNum + ";true"); sw2.Flush(); sw2.Close(); StreamWriter sw3 = File.CreateText(Server.MapPath(@"./pie2/cd") + @"/cd.txt"); sw3.WriteLine("NO;" + cd + ";"); sw3.WriteLine("OK;" + dNum + ";true"); sw3.Flush(); sw3.Close(); StreamWriter sw4 = File.CreateText(Server.MapPath(@"./pie2/ad") + @"/ad.txt"); sw4.WriteLine("NO;" + ad + ";"); sw4.WriteLine("OK;" + dNum + ";true"); sw4.Flush(); sw4.Close(); //talbe show this.year.Text = year.ToString(); this.month.Text = mouth.ToString(); this.day.Text = day.ToString(); double va2 = Convert.ToDouble(aNum) / vNum; this.lbl1.Text = va2.ToString("0.##%"); double ab2 = Convert.ToDouble(bNum) / aNum; this.lbl2.Text = ab2.ToString("0.##%"); double bc2 = Convert.ToDouble(cNum) / bNum; this.lbl3.Text = bc2.ToString("0.##%"); double cd2 = Convert.ToDouble(dNum) / cNum; this.lbl4.Text = cd2.ToString("0.##%"); double ad2 = Convert.ToDouble(dNum) / aNum; this.lbl5.Text = ad2.ToString("0.##%"); } } 文本文件 a.txt: NO;119; OK;84;true