// Export protected void btnoutput_click (Object sender, eventargs e) {// role initialroles (); datatable dt = dbclass. getdatatable (string. format (@ "select * from {0} order by Sn DESC", view (where); stringwriter Sw = new stringwriter (); // The 4s store cannot see the relevant fields such as the Headquarters price if (umrolenames. contains ("4 s") {Sw = get4sstr (DT);} else {Sw = getadminstr (DT);} SW. close (); response. addheader ("content-disposition", "attachment; filename =" + datetime. now. tostring ("yyyymmddhhmmss") + ". CSV "); response. contenttype = "application/MS-excel"; response. contentencoding = system. text. encoding. getencoding ("gb2312"); response. write (SW); response. end ();}
// 4S Shop stitching protected stringwriter get4sstr (datatable DT) {stringwriter Sw = new stringwriter (); Sw. writeline (@ "purchase order number, region, 4S Shop Name, brand, part code, part name, model code, quantity, 4S cost price, Headquarters Purchase unit price, Headquarters Purchase total, 4s stores save money, suppliers, required arrival date, actual arrival date, 4S purchase discount "); foreach (datarow DR in DT. rows) {SW. writeline (Dr ["Sn"]. tostring () + "," + Dr ["firstarea"]. tostring () + "," + Dr ["shopname"]. tostring () + "," + Dr ["shopbrand"]. tostring () + "," + "'" + Dr ["PNO"]. tostring () + "," + Dr ["pname"]. tostring () + "," + Dr ["pcarnumber"]. tostring () + "," + Dr ["buynumber"]. tostring () + "," + Dr ["PSRP"]. tostring () + "," + Dr ["adminprice"]. tostring () + "," + Dr ["sum4sprice"]. tostring () + "," + Dr ["thriftprofit4s"]. tostring () + "," + Dr ["ooffer"]. tostring () + "," + Dr ["ojiaohuodate"]. tostring () + "," + Dr ["realreachdate"]. tostring () + "," + Dr ["discount4s"]. tostring ();} return SW ;}