protected void btnDown_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverOldDbDataContext ctx = new LandRoverOldDbDataContext())
            {
                var list = from u in ctx.shouce
                           where u.times >= dfrom && u.times < dto
                           select u;

                var data = list.ToList();
                if (data.Count == 0)
                    return;

                StringBuilder sb = new StringBuilder("id,sex,username,date,sheng,city,address,youbian,email,dianhua,shouji,shouceida,shouceidb,shouceid1,shouceid2,shouceid3,shouceid4,shouceid5,contactme,times,gcsj,gcys,phcx,phcx1,phcx2,phcx3,phcx4,phcx5,td");
                Regex quote = new Regex("\"");
                foreach (var obj in data)
                {
                    sb.AppendLine();
                    sb.AppendFormat("{0},", obj.id);
                    sb.AppendFormat("{0},", obj.sex);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.username));
                    sb.AppendFormat("{0},", obj.date);
                    sb.AppendFormat("{0},", obj.sheng);
                    sb.AppendFormat("{0},", obj.city);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.address));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.youbian));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.email));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.dianhua));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.shouji));
                    sb.AppendFormat("{0},", obj.shouceida);
                    sb.AppendFormat("{0},", obj.shouceidb);
                    sb.AppendFormat("{0},", obj.shouceid1);
                    sb.AppendFormat("{0},", obj.shouceid2);
                    sb.AppendFormat("{0},", obj.shouceid3);
                    sb.AppendFormat("{0},", obj.shouceid4);
                    sb.AppendFormat("{0},", obj.shouceid5);
                    sb.AppendFormat("{0},", obj.contactme);
                    sb.AppendFormat("{0},", obj.times);
                    sb.AppendFormat("{0},", obj.gcsj);
                    sb.AppendFormat("{0},", obj.gcys);
                    sb.AppendFormat("{0},", obj.phcx);
                    sb.AppendFormat("{0},", obj.phcx1);
                    sb.AppendFormat("{0},", obj.phcx2);
                    sb.AppendFormat("{0},", obj.phcx3);
                    sb.AppendFormat("{0},", obj.phcx4);
                    sb.AppendFormat("{0},", obj.phcx5);
                    sb.AppendFormat("{0},", obj.td);
                }
                string path = Helper.ExportAsCsvFile(sb);
                Response.Redirect(path);
            }
        }
Exemple #2
0
        protected void btnDown_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverOldDbDataContext ctx = new LandRoverOldDbDataContext())
            {
                var list = from u in ctx.shijia1
                           where u.times >= dfrom && u.times < dto
                           select u;

                var data = list.ToList();
                if (data.Count == 0)
                    return;

                StringBuilder sb = new StringBuilder("id,sex,username,date,sheng,city,address,youbian,email,dianhua,shouji,chexing,sjsj,jxssf,jxscs,jxs,lxfs,times,gcsj,gcys,phcx,phcx1,phcx2,phcx3,phcx4,owner,boughtdate,carbrand,carmodel,brochure");
                foreach (var obj in data)
                {
                    sb.AppendLine();
                    sb.AppendFormat("{0},", obj.id);
                    sb.AppendFormat("{0},", obj.sex);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.username));
                    sb.AppendFormat("{0},", obj.date);
                    sb.AppendFormat("{0},", obj.sheng);
                    sb.AppendFormat("{0},", obj.city);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.address));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.youbian));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.email));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.dianhua));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.shouji));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.chexing));
                    sb.AppendFormat("{0},", obj.sjsj);
                    sb.AppendFormat("{0},", obj.jxssf);
                    sb.AppendFormat("{0},", obj.jxscs);
                    sb.AppendFormat("{0},", obj.jxs);
                    sb.AppendFormat("{0},", obj.lxfs);
                    sb.AppendFormat("{0},", obj.times);
                    sb.AppendFormat("{0},", obj.gcsj);
                    sb.AppendFormat("{0},", obj.gcys);
                    sb.AppendFormat("{0},", obj.phcx);
                    sb.AppendFormat("{0},", obj.phcx1);
                    sb.AppendFormat("{0},", obj.phcx2);
                    sb.AppendFormat("{0},", obj.phcx3);
                    sb.AppendFormat("{0},", obj.phcx4);
                    sb.AppendFormat("{0},", obj.owner);
                    sb.AppendFormat("{0},", obj.boughtdate);
                    sb.AppendFormat("{0},", obj.carbrand);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.carmodel));
                    sb.AppendFormat("{0},", obj.brochure);
                }
                string path = Helper.ExportAsCsvFile(sb);
                Response.Redirect(path);
            }
        }
Exemple #3
0
        protected void btnDown_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverOldDbDataContext ctx = new LandRoverOldDbDataContext())
            {
                var list = from u in ctx.users
                           where u.times >= dfrom && u.times < dto
                           select new
                           {
                               ID = u.id,
                               Name = u.username,
                               Email = u.email,
                               Phone = u.phone,
                               Sub = u.enews,
                               Model = u.carStyle,
                               Time = u.times,
                               Source = u.receive
                           };

                var data = list.ToList();
                if (data.Count == 0)
                    return;

                StringBuilder sb = new StringBuilder("id,username,email,phone,enews,carStyle,times,receive");
                Regex quote = new Regex("\"");
                foreach (var obj in data)
                {
                    sb.AppendLine();
                    sb.AppendFormat("{0},", obj.ID);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.Name));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.Email));
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.Phone));
                    sb.AppendFormat("{0},", obj.Sub);
                    sb.AppendFormat("\"{0}\",", Helper.FormatForCSV(obj.Model));
                    sb.AppendFormat("{0},", obj.Time);
                    sb.AppendFormat("{0},", obj.Source);
                }
                string path = Helper.ExportAsCsvFile(sb);
                Response.Redirect(path);
            }
        }
Exemple #4
0
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            DateTime dfrom = DateTime.Parse(tbDateFrom.Text);
            DateTime dto = DateTime.Parse(tbDateTo.Text).AddDays(1);

            using (LandRoverOldDbDataContext ctx = new LandRoverOldDbDataContext())
            {
                var list = from u in ctx.users
                           where u.times >= dfrom && u.times < dto && u.receive == "effect2011"
                           select new
                           {
                               ID = u.id,
                               Name = u.username,
                               Email = u.email,
                               Phone = u.phone,
                               Sub = u.enews,
                               Time = u.times,
                               Source = u.receive
                           };
                dataList.DataSource = list.ToList();
                dataList.DataBind();
            }
        }