UserData1.cs 213 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325
  1. using System;
  2. using System.Data;
  3. using System.Data.OleDb;
  4. using System.Configuration;
  5. using System.Data.Sql;
  6. using System.Data.SqlClient;
  7. using System.Web;
  8. using System.Web.Security;
  9. using System.Security.Cryptography;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. using System.Web.UI.WebControls.WebParts;
  13. using System.Web.UI.HtmlControls;
  14. using System.IO;
  15. using System.Text;
  16. using System.Globalization;
  17. using System.Threading; //
  18. using System.Collections;
  19. namespace LYS
  20. {
  21. /// <summary>
  22. ///UserData1 的摘要说明
  23. /// </summary>
  24. public class UserData1
  25. {
  26. MyFiles myf = new MyFiles();
  27. //private string connectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
  28. private string connectionString = "Data Source=192.168.0.66;Initial Catalog=Ddxt;Persist Security Info=True;User ID=sa;Password=1;Pooling=True;Max Pool Size=10000;";
  29. public void ConnDB()
  30. {
  31. SqlConnection objConn = new SqlConnection();
  32. // objConn.ConnectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
  33. objConn.ConnectionString = "Data Source=192.168.0.66;Initial Catalog=Ddxt;Persist Security Info=True;User ID=sa;Password=1;Pooling=True;Max Pool Size=10000;";
  34. objConn.Open();
  35. }
  36. public string ConnString()
  37. {
  38. string connstr = connectionString;
  39. return connstr;
  40. }
  41. /// <summary>
  42. /// 根据SQL语句指定条件记录值绑定到input type="text" id="sDemp" list="sDemplist" 对应list ,by 版权所有:广东松山职业技术学院计算机系 刘友生(QQ:290578102,Tel:15089879808)
  43. /// </summary>
  44. /// <param name="myDropDownList"></param>
  45. /// <param name="BindFileName"></param>
  46. /// <param name="DispFileName"></param>
  47. /// <param name="TableName"></param>
  48. /// <param name="scondition"></param>
  49. public StringBuilder HTML5SQLBindRecValueToDDL(string BindFileName, string sSQL)
  50. {//将字段BindFileName绑定到myDropDownList
  51. StringBuilder sb = new StringBuilder();
  52. //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
  53. string SQL = sSQL;
  54. SqlConnection dtConn = new SqlConnection(connectionString);
  55. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, dtConn); ;
  56. DataSet dtSet = new DataSet();
  57. dtCmd.Fill(dtSet);
  58. DataTableReader objreader = dtSet.CreateDataReader();
  59. while (objreader.Read())
  60. {
  61. sb.Append(" <option value=\"" + objreader[BindFileName].ToString() + "\" />");
  62. }
  63. return sb;
  64. }
  65. /// <summary>
  66. /// 替换指定位置字符
  67. /// </summary>
  68. /// <param name="OleStr">原字符</param>
  69. /// <param name="ReplaceStr">替换字符</param>
  70. /// <param name="Replacelocation">起始位置</param>
  71. /// <returns></returns>
  72. public string ReplaceStr(string OleStr, string ReplaceStr, int Replacelocation)
  73. {
  74. string str1 = OleStr.Substring(0, Replacelocation - 1); //ab
  75. string str2 = OleStr.Substring(Replacelocation + ReplaceStr.Length - 1); //d
  76. return str1 + ReplaceStr + str2;
  77. }
  78. //执行SQL语句:
  79. public void RunCreateSQL(String SQL)
  80. {
  81. SqlConnection DBConn;
  82. SqlCommand DBUpdate = new SqlCommand();
  83. // SqlConnection DBConn;
  84. // SqlCommand DBUpdate = new SqlCommand();
  85. DBConn = new SqlConnection(connectionString);
  86. DBUpdate.CommandText = SQL;
  87. DBUpdate.Connection = DBConn;
  88. DBUpdate.Connection.Open();
  89. DBUpdate.ExecuteNonQuery();
  90. }
  91. /// <summary>
  92. /// 连接eXCEL数据库
  93. /// </summary>
  94. /// <param name="pathDir">上传Excel文件存放目录</param>
  95. /// <param name="filename">EXCEL文件名</param>
  96. /// <returns></returns>
  97. public string ConnExcelString(string pathDir, string filename)
  98. {
  99. string conn = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =" + HttpContext.Current.Server.MapPath(pathDir) + "//" + filename + ";Extended Properties=Excel 8.0";
  100. return conn;
  101. }
  102. /// <summary>
  103. /// 获得EXCEL数据库中的表名
  104. public void GetExcelTable(string conn, DropDownList DropDownList1)
  105. {
  106. OleDbConnection connect = new OleDbConnection(conn);
  107. connect.Open();
  108. DataTable schemaTable = connect.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
  109. for (int i = 0; i <= schemaTable.Rows.Count - 1; i++)
  110. {
  111. if (schemaTable.Rows[i].ItemArray[3].ToString() == "TABLE")
  112. { DropDownList1.Items.Add(schemaTable.Rows[i].ItemArray[2].ToString()); }
  113. }
  114. }
  115. public DataTable getExcelds(string conn, string Sql)
  116. {
  117. OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, conn);
  118. DataSet ds = new DataSet();
  119. mycommand.Fill(ds, "tablename");
  120. DataTable myTable = ds.Tables["tablename"];
  121. return myTable;
  122. }
  123. /// <summary>
  124. /// 从EXCEL文件中导入数据到SQL Server文件 并根据两个关键字段查询是否有重复
  125. /// </summary>
  126. /// <param name="excelFile"></param>
  127. /// <param name="sheetName"></param>
  128. /// <param name="connectionString"></param>
  129. public void ExcelToSQLKey(string tablename, string conn, DataTable myTable, string keyFieldName1, string keyFieldName2, Literal L1)
  130. {
  131. //DataTable myTable = getds(conn, Sql,tablename);
  132. // SqlConnection thisconnection1 = new SqlConnection(connectionString);
  133. SqlConnection thisconnection1 = new SqlConnection(connectionString);
  134. thisconnection1.Open();
  135. int count = myTable.Rows.Count;
  136. int s = 0; int rr = 0;
  137. string msg = "";
  138. string Strrec = "";
  139. for (int i = 0; i < count; i++)
  140. {
  141. Strrec = "有重复记录:";
  142. string strSql1 = "insert into " + tablename + "("; //插入到SQL数据库的语句
  143. string strSql2 = "Select * from " + tablename + " where "; //检查是不断中有重复数据的SQL语句
  144. foreach (System.Data.DataColumn c in myTable.Columns)
  145. {
  146. strSql1 += c.ColumnName + ",";
  147. }
  148. strSql1 = strSql1.Substring(0, strSql1.Length - 1) + ") values ('";
  149. for (int j = 0; j < myTable.Columns.Count; j++)
  150. {
  151. strSql1 += myTable.Rows[i][j].ToString() + "','";
  152. if (myTable.Columns[j].ToString() == keyFieldName1)
  153. {
  154. strSql2 += keyFieldName1 + "='" + myTable.Rows[i][j].ToString() + "' ";
  155. Strrec += keyFieldName1+ "='" + myTable.Rows[i][j].ToString();
  156. }
  157. if (myTable.Columns[j].ToString() == keyFieldName2)
  158. {
  159. strSql2 += " and " + keyFieldName2 + "='" + myTable.Rows[i][j].ToString() + "' ";
  160. Strrec += ";" + keyFieldName2 + "='" + myTable.Rows[i][j].ToString() + "<br>";
  161. }
  162. }
  163. //HttpContext.Current.Response.Write(strSql2+"<br>");
  164. // HttpContext.Current.Response.Write(Strrec + "<br>");
  165. msg = Strrec;
  166. if (CheckRecord(strSql2) == true)
  167. {
  168. //HttpContext.Current.Response.Write(Strrec + "<br>");
  169. HttpContext.Current.Response.Write("<script> alert('" + msg + "') </script>");
  170. // HttpContext.Current.Response.Write("<script>alert('有重复记录')</script>");
  171. // openWin(strSql2);
  172. rr = rr + 1;
  173. L1.Text = L1.Text + "<br>" + msg;
  174. }
  175. else
  176. {
  177. s = s + 1;
  178. strSql1 = strSql1.Substring(0, strSql1.Length - 2) + ")";
  179. SqlCommand mycommand2 = new SqlCommand(strSql1, thisconnection1);
  180. mycommand2.ExecuteNonQuery();
  181. }
  182. }
  183. thisconnection1.Close();
  184. //HttpContext.Current.Response.Write("<script> alert('导入完成,共导入" + s.ToString() + "条记录') </script>");
  185. L1.Text = L1.Text + "<font color=\"red\" size=3> 共导入" + s.ToString() + "条记录!另外有" + rr.ToString() + "条记录未导入</font>";
  186. // openWin("导入完成,共导入" + s.ToString() + "条记录" + msg);
  187. }
  188. //以行显示,每一行下划线显示 第一行交替显示
  189. public StringBuilder DispOleDbLineDataJTExcel(string SQL, string Excelconnstr)
  190. {
  191. StringBuilder sb = new StringBuilder();
  192. OleDbConnection dtConn = new OleDbConnection(Excelconnstr);
  193. OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn);
  194. DataSet dtSet = new DataSet();
  195. dtCmd.Fill(dtSet);
  196. DataTableReader objreader = dtSet.CreateDataReader();
  197. int i = 0, j = 0;
  198. sb.Append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"dataTable\">");
  199. sb.Append("\n <tr class=\"dataTableHeader\">");
  200. for (i = 0; i <= objreader.FieldCount - 1; i++)
  201. {
  202. sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9;font-size: 12px; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  203. }
  204. sb.Append("\n </tr>");
  205. while (objreader.Read())
  206. {
  207. j = j + 1;
  208. if (j % 2 == 0)
  209. { sb.Append("\n <tr class=\"odd_row\">"); }
  210. else
  211. { sb.Append("\n <tr class=\"even_row\" style=\"background-image: url('images/list_line2-1.gif')\">"); }
  212. for (i = 0; i <= objreader.FieldCount - 1; i++)
  213. {
  214. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5;font-size: 12px; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  215. }
  216. sb.Append("\n </tr>");
  217. }
  218. sb.Append("</table>");
  219. return sb;
  220. }
  221. /// <summary>
  222. /// 以行显示,每一行下划线显示 显示统计结果(总数)
  223. /// </summary>
  224. /// <param name="SQL"></param>
  225. /// <returns></returns>
  226. public StringBuilder DispLineCount(string SQL)
  227. { //调用
  228. //DateTime startTime = Convert.ToDateTime("2017-9-1");
  229. //DateTime endTime = Convert.ToDateTime("2017-9-11");
  230. //string sql = "select count(*) as 总计 from TKJL where 听课日期 >= #2017-9-1# and 听课日期 <=#2017-9-10#"; //OK
  231. StringBuilder sb = new StringBuilder();
  232. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  233. string sql = SQL;
  234. SqlConnection dtConn = new SqlConnection(connectionString);
  235. SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
  236. DataSet dtSet = new DataSet();
  237. dtCmd.Fill(dtSet);
  238. DataTableReader objreader = dtSet.CreateDataReader();
  239. int i = 0, j = 0;
  240. sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
  241. sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  242. for (i = 0; i <= objreader.FieldCount - 1; i++)
  243. {
  244. sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  245. }
  246. sb.Append("\n </tr>");
  247. while (objreader.Read())
  248. {
  249. j = j + 1;
  250. sb.Append("\n <tr class=\"list_bline1\">");
  251. for (i = 0; i <= objreader.FieldCount - 1; i++)
  252. {
  253. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  254. }
  255. sb.Append("\n </tr>");
  256. }
  257. sb.Append("</table>");
  258. return sb;
  259. }
  260. /// <summary>
  261. /// 以行显示,每一行下划线显示 显示统计结果(总数)
  262. /// </summary>
  263. /// <param name="SQL"></param>
  264. /// <returns></returns>
  265. public string DispLineCountNum(string SQL)
  266. { //调用
  267. //DateTime startTime = Convert.ToDateTime("2017-9-1");
  268. //DateTime endTime = Convert.ToDateTime("2017-9-11");
  269. //string sql = "select count(*) as 总计 from TKJL where 听课日期 >= #2017-9-1# and 听课日期 <=#2017-9-10#"; //OK
  270. StringBuilder sb = new StringBuilder();
  271. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  272. string sql = SQL;
  273. SqlConnection dtConn = new SqlConnection(connectionString);
  274. SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
  275. DataSet dtSet = new DataSet();
  276. dtCmd.Fill(dtSet);
  277. string cNum = "";
  278. DataTableReader objreader = dtSet.CreateDataReader();
  279. int i = 0, j = 0;
  280. while (objreader.Read())
  281. {
  282. j = j + 1;
  283. for (i = 0; i <= objreader.FieldCount - 1; i++)
  284. {
  285. cNum = objreader.GetValue(i).ToString();
  286. // sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  287. }
  288. }
  289. return cNum;
  290. }
  291. /// <summary>
  292. /// 动态生成添加表单
  293. /// </summary>
  294. /// <param name="SQLStr"></param>
  295. /// <returns></returns>
  296. public StringBuilder BuildAddRecordFormOK(string SQLStr)
  297. {
  298. StringBuilder sb = new StringBuilder();
  299. sb.Append("<ul>");
  300. //连接并打开数据库
  301. SqlConnection objConn = new SqlConnection();
  302. objConn.ConnectionString = connectionString;
  303. objConn.Open();
  304. //创建DataReader对象(COMMAND)
  305. SqlCommand objcmd = new SqlCommand();
  306. objcmd.Connection = objConn;
  307. objcmd.CommandText = SQLStr;
  308. SqlDataReader objreader = objcmd.ExecuteReader();
  309. //读取并显示数据库
  310. objreader.Read();
  311. String TypeN, dispC;
  312. int FieldNum = objreader.FieldCount;
  313. for (int i = 1; i <= FieldNum - 1; i++)
  314. {
  315. sb.Append("<li>");
  316. sb.Append("<label>" + objreader.GetName(i) + "</label>");
  317. sb.Append(" <input type=\"hidden\" name=\"MyLabel" + i.ToString() + "\" id=\"MyLabel" + i.ToString() + "\" value=\"" + objreader.GetName(i) + "\" />");
  318. string FV = objreader.GetValue(i).ToString();
  319. TypeN = objreader.GetFieldType(i).Name;
  320. switch (TypeN)
  321. {
  322. case "String":
  323. dispC = "输文字";
  324. break;
  325. case "DateTime":
  326. dispC = Convert.ToString(DateTime.Now);
  327. break;
  328. case "Boolean":
  329. dispC = "true false";
  330. break;
  331. default:
  332. dispC = "输数值";
  333. break;
  334. }
  335. if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  336. {
  337. sb.Append("<textarea name=\"MyText" + Convert.ToString(i) + "\" id=\"MyText" + Convert.ToString(i) + "\" placeholder=\"输入数据\">" + dispC + " </textarea>");
  338. }
  339. else
  340. { sb.Append("<input type=\"text\" name=\"MyText" + Convert.ToString(i) + "\" id=\"MyText" + Convert.ToString(i) + "\" placeholder=\"" + dispC + "\" required=\"required\" autofocus=\"autofocus\" />"); }
  341. sb.Append("</li>");
  342. }
  343. sb.Append("</ul>");
  344. objreader.Close();
  345. objConn.Close();
  346. return sb;
  347. }
  348. /// <summary>
  349. /// 从动态生成的表单中读取数据并添加到数据库
  350. /// </summary>
  351. /// <param name="parasql"></param>
  352. /// <param name="tablename"></param>
  353. public void AddRecordToDB(string parasql, string tablename)
  354. {
  355. SqlConnection objConn = new SqlConnection(connectionString);
  356. objConn.Open();
  357. SqlDataAdapter objcmd = new SqlDataAdapter();
  358. objcmd.SelectCommand = new SqlCommand("select * from " + tablename, objConn);
  359. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  360. DataSet ds = new DataSet();
  361. objcmd.Fill(ds, tablename);
  362. objConn.Close();
  363. DataTable dt = ds.Tables[tablename];
  364. DataRow dtrow = dt.NewRow();
  365. dtrow[0] = DBNull.Value;
  366. int k = 0;
  367. for (int i = 1; i < HttpContext.Current.Request.Form.Count; i++)
  368. {
  369. string name = HttpContext.Current.Request.Form.GetKey(i);
  370. if (name.IndexOf("Text") > 0)
  371. {
  372. k = k + 1;
  373. // Response.Write(k.ToString() + ":" + HttpContext.Current.Request.Form[i] + "<br>");
  374. dtrow[k] = HttpContext.Current.Request.Form[i];
  375. }
  376. }
  377. dt.Rows.Add(dtrow);
  378. objcmd.Update(ds, tablename);
  379. }
  380. //根据菜单内容动态生成老师或学生主菜单
  381. public StringBuilder main1(string SQL1)
  382. {
  383. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  384. sb.Append("\n <LINK rel=stylesheet type=text/css href=\"../css/style1.css\" media=screen>");
  385. sb.Append("\n <SCRIPT type=text/javascript src=\"../js/js/jquery.min.js\"></SCRIPT>");
  386. sb.Append("\n <SCRIPT type=text/javascript src=\"../js/js/lavalamp.min.js\"></SCRIPT>");
  387. sb.Append("\n <SCRIPT type=text/javascript src=\"../js/js/xixi.js\"></SCRIPT>");
  388. sb.Append("\n <SCRIPT type=text/javascript>");
  389. sb.Append("\n $(function () { $(\".lavaLamp\").lavaLamp({ fx: \"backout\", speed: 700 }) });");
  390. sb.Append("\n </SCRIPT>");
  391. sb.Append("\n <DIV id=wrapper>");
  392. sb.Append("\n <UL class=lavaLamp>");
  393. //SqlConnection objConn = new SqlConnection(connectionString);
  394. SqlConnection dtConn = new SqlConnection(connectionString);
  395. //OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, dtConn);
  396. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, dtConn);
  397. DataSet dtSet1 = new DataSet();
  398. dtCmd1.Fill(dtSet1);
  399. DataTableReader objreader1 = dtSet1.CreateDataReader();
  400. int i = 0;
  401. sb.Append("\n <li class=\"onelink\"><a href='#'>主页</a></li>");
  402. while (objreader1.Read())
  403. {
  404. i = i + 1;
  405. sb.Append("\n <li><a href='" + objreader1["URL"] + "' rel='dropmenu" + i.ToString() + "'>" + objreader1["ClassName"] + "</a></li>");
  406. }
  407. sb.Append("\n </UL>");
  408. sb.Append("\n </DIV>");
  409. return sb;
  410. }
  411. //将上传文件转换为日期格式
  412. public string FilenameToDateFilename(string oldfilename)
  413. {
  414. string UpfileExtension = System.IO.Path.GetExtension(oldfilename); ;
  415. string Newfilename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + UpfileExtension;
  416. return Newfilename;
  417. }
  418. //根据ID从数据库获得指定字段的值
  419. public string GetFieldValue(int FieldsOrderNo, int id, string Tablename)
  420. {
  421. string SQL = "Select * from " + Tablename + " where id=" + id;
  422. SqlConnection objConn = new SqlConnection(connectionString);
  423. //OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn); ;
  424. //SqlConnection dtConn = new SqlConnection();
  425. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  426. DataSet dtSet = new DataSet();
  427. dtCmd.Fill(dtSet);
  428. DataTableReader objreader = dtSet.CreateDataReader();
  429. // int i = 0;
  430. string getValue = "";
  431. while (objreader.Read())
  432. {
  433. getValue = objreader.GetValue(FieldsOrderNo).ToString();
  434. }
  435. return getValue;
  436. }
  437. //根据ID,字段名从数据库获得指定字段的值
  438. public string GetFieldValueFromFieldName(string FieldName, int id, string Tablename)
  439. {
  440. string SQL = "Select * from " + Tablename + " where id=" + id;
  441. SqlConnection objConn = new SqlConnection(connectionString);
  442. //OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn); ;
  443. //SqlConnection dtConn = new SqlConnection();
  444. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  445. DataSet dtSet = new DataSet();
  446. dtCmd.Fill(dtSet);
  447. DataTableReader objreader = dtSet.CreateDataReader();
  448. //int i = 0;
  449. string getValue = "";
  450. while (objreader.Read())
  451. {
  452. getValue = objreader[FieldName].ToString();
  453. }
  454. return getValue;
  455. }
  456. //从数据库获得指定关键字段(字符)的值
  457. public string GetKeyFieldValue(int FieldsOrderNo, string KeyFieldName, string KeyFieldValue, string Tablename)
  458. {
  459. string SQL = "Select * from " + Tablename + " where " + KeyFieldName + "='" + KeyFieldValue + "'";
  460. SqlConnection objConn = new SqlConnection(connectionString);
  461. //OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn);
  462. //SqlConnection dtConn = new SqlConnection();
  463. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  464. DataSet dtSet = new DataSet();
  465. dtCmd.Fill(dtSet);
  466. DataTableReader objreader = dtSet.CreateDataReader();
  467. string getValue = "";
  468. while (objreader.Read())
  469. {
  470. getValue = objreader.GetValue(FieldsOrderNo).ToString();
  471. }
  472. return getValue;
  473. }
  474. //确定上传文件的路径
  475. public string UpFilePath(string demp, Int32 CourseID, string BJ, string XH, string XM, string ChsOrEng)
  476. //dempukuy,系部 BJ班级+XH学号+XM姓名 ChsOrEng中文还是英文文件夹存储
  477. {
  478. System.DateTime currentTime = System.DateTime.Now;
  479. int strYear = Convert.ToInt32(currentTime.Year.ToString());
  480. int strMonth = Convert.ToInt32(currentTime.Month.ToString());
  481. string SavePath = "";
  482. if (strMonth >= 2 && strMonth <= 7)
  483. { SavePath = strYear.ToString() + "S" + ")"; }
  484. else
  485. { SavePath = strYear.ToString() + "X"; }
  486. if (ChsOrEng == "Chs")
  487. {
  488. //以中文文件夹
  489. string KCM = GetFieldValue(2, CourseID, "Course");
  490. SavePath = demp + "\\" + SavePath + "\\" + KCM + "\\" + BJ + "\\" + XH + XM + "\\";
  491. }
  492. else
  493. {
  494. //以英文文件夹XM XH BJ存数据库,文件名转换为以日期为文件名
  495. //HttpPostedFile postedfile = fileupload.PostedFile; (参数:System.Web.UI.WebControls.FileUpload fileupload)
  496. //string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
  497. //string UpfileExtension = System.IO.Path.GetExtension(postedfile.FileName);
  498. //string Newfilename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + UpfileExtension;
  499. //if (OldFilenameOrNewFileName == true) { UpFilename = Newfilename; }
  500. demp = GetKeyFieldValue(1, "FieldNameChinese", demp, "FieldCHs_Eng");
  501. SavePath = demp + "\\" + SavePath + "\\" + CourseID + "\\" + XH + "\\";
  502. }
  503. return SavePath;
  504. //上传文件查看UpfilesPathandToDB
  505. }
  506. //显示指定表的所有数据
  507. public void DispTableData(string TableName)
  508. {
  509. //<configuration>
  510. // <connectionStrings>
  511. // <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MYDBSQL.mdf;User Instance=true"
  512. // providerName="System.Data.SqlClient" />
  513. // <add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
  514. // providerName="System.Data.SqlClient" />
  515. // </connectionStrings>
  516. SqlConnection objConn = new SqlConnection();
  517. //objConn.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
  518. objConn.ConnectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
  519. objConn.Open();
  520. //**创建DATEREADER对象(COMMAND)**//
  521. SqlCommand objCmd = new SqlCommand();
  522. //OleDbCommand objCmd=new OleDbCommand();
  523. objCmd.Connection = objConn;
  524. objCmd.CommandText = "Select * from " + TableName;
  525. SqlDataReader objreader = objCmd.ExecuteReader();
  526. // OleDbDataReader objreader=objCmd.ExecuteReader() ;
  527. //读取并显示数据库
  528. int i;
  529. HttpContext.Current.Response.Write("<Table border='1'><tr align='center'>");
  530. for (i = 0; i <= objreader.FieldCount - 1; i++)
  531. {
  532. HttpContext.Current.Response.Write("<td>" + objreader.GetName(i) + "</TD>");
  533. }
  534. HttpContext.Current.Response.Write("</tr>");
  535. while (objreader.Read())
  536. {
  537. HttpContext.Current.Response.Write("<tr>");
  538. for (i = 0; i <= objreader.FieldCount - 1; i++)
  539. {
  540. HttpContext.Current.Response.Write("<td>" + objreader.GetValue(i) + "</TD>");
  541. }
  542. HttpContext.Current.Response.Write("</tr>");
  543. }
  544. HttpContext.Current.Response.Write("</table>");
  545. objreader.Close();
  546. objConn.Close();
  547. }
  548. //获得当前学期
  549. public string getCurrentXQ()
  550. {
  551. // string strDay = "";
  552. System.DateTime currentTime = System.DateTime.Now;
  553. int strYear = Convert.ToInt32(currentTime.Year.ToString());
  554. int strMonth = Convert.ToInt32(currentTime.Month.ToString());
  555. string xq = "";
  556. if (strMonth >= 2 && strMonth <= 7)
  557. { xq = (strYear - 1).ToString() + "~" + strYear.ToString() + "学年第二学期" + "(" + strYear.ToString() + "年春学期" + ")"; }
  558. else
  559. { xq = strYear.ToString() + "~" + (strYear + 1).ToString() + "学年第一学期" + "(" + strYear.ToString() + "年秋学期" + ")"; }
  560. return xq;
  561. }
  562. /// <summary>
  563. /// 获得当前日期的月日
  564. /// </summary>
  565. /// <param name="userData"></param>
  566. /// <returns></returns>
  567. public string getMonthDay()
  568. {
  569. System.DateTime currentTime = System.DateTime.Now;
  570. int strMonth = Convert.ToInt32(currentTime.Month.ToString());
  571. int strDay = Convert.ToInt32(currentTime.Day.ToString());
  572. return (strMonth + strDay).ToString();
  573. }
  574. /// <summary>
  575. /// //获取用户许可字符
  576. /// </summary>
  577. /// <param name="userData"></param>
  578. /// <returns></returns>
  579. public Boolean getUserChr(string userData)
  580. {//获取用户著作权,是否包含LYS,是否超过指定日期
  581. //获取是否有使用权限(通过指定指定特定字符,如第19个字符是否是L,第49个字符是否是Y,第77个字符是否是S,),获取使用12-82为日期
  582. //比较时间大小
  583. //DateTime dat1 = DateTime.Parse("2003-12-30");
  584. // DateTime dat2 = DateTime.Parse(DateTime.Now.ToShortDateString());
  585. // Response.Write("比较日期大小=" + dat1.CompareTo(dat2));// dat2.CompareTo(dat1)) 返回1,dat1.CompareTo(dat2))返回-1
  586. Boolean checkUY = false;
  587. DateTime dat1;
  588. string userPer = "";
  589. string Y1 = "0", Y2 = "0", Y3 = "0", Y4 = "0", M1 = "0", M2 = "0", D1 = "0", D2 = "0";
  590. userPer = userData.Substring(18, 1) + userData.Substring(48, 1) + userData.Substring(76, 1);
  591. //当前时间
  592. DateTime dat2 = DateTime.Parse(DateTime.Now.ToShortDateString());
  593. if (userData.Length < 90)
  594. { return false; }
  595. Y1 = userData.Substring(12, 1);
  596. Y2 = userData.Substring(22, 1);
  597. Y3 = userData.Substring(32, 1);
  598. Y4 = userData.Substring(42, 1);
  599. M1 = userData.Substring(52, 1);
  600. M2 = userData.Substring(62, 1);
  601. D1 = userData.Substring(72, 1);
  602. D2 = userData.Substring(82, 1);
  603. dat1 = DateTime.Parse(Y1 + Y2 + Y3 + Y4 + "-" + M1 + M2 + "-" + D1 + D2 + " 0:00:00");
  604. //HttpContext.Current.Response.Write(dat1);
  605. //HttpContext.Current.Response.Write("userPer" + userPer);
  606. // if (dat2.CompareTo(dat1) > 0 && userPer == "LYS")
  607. if (dat1 > dat2 && userPer == "LYS")
  608. {
  609. checkUY = true;
  610. }
  611. return checkUY;
  612. }
  613. //SQL语句中英文字段名自动转换为中文
  614. public string EnglishSQLToChineseSQL(string C_ETable, string EnglishFiledNameSQL)
  615. { //C_ETable英文字段与中文字段对照表(FieldCHs_Eng) EnglishFiledNameSQL英文字段名的SQL语句
  616. //Response.Write(myud.EnglishSQLToChineseSQL("FieldCHs_Eng", "Select ID,courseID,courseName,courseTrem,courseMemo from course").ToString())
  617. string sql = "select * from " + C_ETable;
  618. // string Chs_SQL = "";
  619. // SqlConnection objConn = new SqlConnection(connectionString);
  620. // SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, dtConn);
  621. SqlConnection dtConn = new SqlConnection();
  622. SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
  623. DataSet dtSet = new DataSet();
  624. dtCmd.Fill(dtSet);
  625. DataTableReader objreader = dtSet.CreateDataReader();
  626. while (objreader.Read())
  627. {
  628. if (EnglishFiledNameSQL.IndexOf(objreader["FieldName"].ToString()) >= 0)
  629. {
  630. EnglishFiledNameSQL = EnglishFiledNameSQL.Replace(objreader["FieldName"].ToString(), objreader["FieldName"].ToString() + " as " + objreader["FieldNameChinese"].ToString());
  631. }
  632. }
  633. return EnglishFiledNameSQL;
  634. }
  635. //获得当前学期前后五个学期,用for (int i=1;i<=5;i++)
  636. public string getfiveXQ()
  637. {
  638. // string strDay = "";
  639. System.DateTime currentTime = System.DateTime.Now;
  640. int strYear = Convert.ToInt32(currentTime.Year.ToString());
  641. int strMonth = Convert.ToInt32(currentTime.Month.ToString());
  642. string xq = "";
  643. if (strMonth >= 2 && strMonth <= 7)
  644. { xq = (strYear - 1).ToString() + "~" + strYear.ToString() + "学年第二学期" + "(" + strYear.ToString() + "年春学期" + ")"; }
  645. else
  646. { xq = strYear.ToString() + "~" + (strYear + 1).ToString() + "学年第一学期" + "(" + strYear.ToString() + "年秋学期" + ")"; }
  647. return xq;
  648. }
  649. //jQuery+CSS清新蓝色水平二级菜单
  650. public StringBuilder main50(string SQL1, string targetWindowName)
  651. {
  652. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  653. sb.Append("\n <link rel=\"stylesheet\" type=\"text/css\" href=\"images/50/CSS/header.css\" />");
  654. sb.Append("\n <script language=\"javascript\" type=\"text/javascript\" src=\"images/50/js/jquery-1.3.2.min.js\"></script>");
  655. sb.Append("\n <script language=\"javascript\" type=\"text/javascript\">");
  656. sb.Append("\n $(document).ready(function(){");
  657. sb.Append("\n $(\".mainNav a\").mouseover(function(){");
  658. sb.Append("\n $(\".mainNav a\").attr(\"class\",\"\");");
  659. sb.Append("\n $(\"#\"+this.id).attr(\"class\",\"actived\");");
  660. sb.Append("\n var currentMenuNo = parseInt(this.id.substring(1));");
  661. sb.Append("\n $(\".secondNav div\").each(function(){");
  662. sb.Append("\n $(this).hide();");
  663. sb.Append("\n $(\"#subNav\"+currentMenuNo).show();");
  664. sb.Append("\n });");
  665. sb.Append("\n });");
  666. sb.Append("\n });");
  667. sb.Append("\n </script>");
  668. sb.Append("\n <div class=\"header\">");
  669. sb.Append("\n <div class=\"padder\">");
  670. sb.Append("\n <div class=\"nav\">");
  671. sb.Append("\n <div class=\"navLaftBg\">");
  672. sb.Append("\n <div class=\"navRightBg\">");
  673. sb.Append("\n <div class=\"mainNav\">");
  674. //SqlConnection objConn = new SqlConnection(connectionString);
  675. //OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, dtConn);
  676. SqlConnection dtConn = new SqlConnection();
  677. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, dtConn);
  678. DataSet dtSet1 = new DataSet();
  679. dtCmd1.Fill(dtSet1);
  680. DataTableReader objreader1 = dtSet1.CreateDataReader();
  681. int i = 0;
  682. Int16[] getContent = new Int16[15];
  683. while (objreader1.Read())
  684. {
  685. i = i + 1;
  686. sb.Append("\n <a href=\"" + objreader1["URL"].ToString() + "\" id=\"n" + i.ToString() + "\" class=\"actived\">" + objreader1["ClassName"].ToString() + "</a>");
  687. getContent[i] = Convert.ToInt16(objreader1["id"].ToString());
  688. }
  689. sb.Append("\n ");
  690. sb.Append("\n </div>");
  691. sb.Append("\n </div>");
  692. sb.Append("\n </div>");
  693. sb.Append("\n </div>");
  694. sb.Append("\n <div class=\"secondNav\">");
  695. for (int k = 1; k <= i; k++)
  696. {
  697. sb.Append("\n <div id=\"subNav" + k.ToString() + "\" class=\"subNav" + k.ToString() + "\">");
  698. sb.Append("\n ");
  699. //OleDbConnection dtConn2 = new OleDbConnection(connectionString);
  700. SqlConnection dtConn2 = new SqlConnection(connectionString);
  701. // OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from TreeGJK where followid=" + getContent[k].ToString() + " Order by id asc,followid Asc", dtConn2);
  702. SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from TreeGJK where followid=" + getContent[k].ToString() + " Order by id asc,followid Asc", dtConn2);
  703. DataSet dtSet2 = new DataSet();
  704. dtCmd2.Fill(dtSet2);
  705. DataTableReader objreader2 = dtSet2.CreateDataReader();
  706. while (objreader2.Read())
  707. {
  708. sb.Append("\n <a href=\"" + objreader2["URL"] + "\">" + objreader2["ClassName"].ToString() + "</a>");
  709. }
  710. sb.Append("\n </div>");
  711. dtConn2.Close();
  712. }
  713. sb.Append("\n </div>");
  714. sb.Append("\n </div>");
  715. sb.Append("\n </div>");
  716. return sb;
  717. }
  718. //将前后五个学期绑定到DropDownList
  719. public void BindFiveXQToDropDownList(DropDownList myDropDownList)
  720. {
  721. // string strDay = "";
  722. System.DateTime currentTime = System.DateTime.Now;
  723. int strYear = Convert.ToInt32(currentTime.Year.ToString());
  724. int strMonth = Convert.ToInt32(currentTime.Month.ToString());
  725. //string xq = "";
  726. System.Collections.ArrayList arrTableList = new System.Collections.ArrayList();
  727. for (int i = 1; i <= 4; i++)
  728. {
  729. arrTableList.Add((strYear - 1).ToString() + "~" + strYear.ToString() + "学年第二学期" + "(" + strYear.ToString() + "年春学期" + ")");
  730. arrTableList.Add(strYear.ToString() + "~" + (strYear + 1).ToString() + "学年第一学期" + "(" + strYear.ToString() + "年秋学期" + ")");
  731. strYear = strYear - 1;
  732. }
  733. arrTableList.Sort();
  734. myDropDownList.DataSource = arrTableList;
  735. myDropDownList.DataBind();
  736. myDropDownList.Visible = true;
  737. }
  738. //检查学生登录
  739. public Boolean check_Studlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
  740. {
  741. Boolean LoginAccess = false;
  742. //学生登录检查
  743. //OleDbConnection objConn = new OleDbConnection(connectionString);
  744. SqlConnection objConn = new SqlConnection(connectionString);
  745. string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
  746. //OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  747. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  748. myCommand.Connection.Open();
  749. // OleDbDataReader myReader = myCommand.ExecuteReader();
  750. SqlDataReader myReader = myCommand.ExecuteReader();
  751. if (myReader.Read())
  752. {
  753. HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
  754. LoginAccess = true;
  755. }
  756. else
  757. {
  758. HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
  759. LoginAccess = false;
  760. }
  761. myCommand.Connection.Close();
  762. return LoginAccess;
  763. }
  764. ////将数据写入Cookie文件中
  765. //public void WriteCookies(string CookiesName, string CookiesValue, int DayNum)
  766. //{ // DateTime.Now.AddDays(7); DayNum=7(一周),1=一天,30
  767. // HttpContext.Current.Response.Cookies[CookiesName].Value = CookiesValue;
  768. // HttpContext.Current.Response.Cookies[CookiesName].Expires = DateTime.Now.AddDays(DayNum);
  769. //}
  770. ////将读取Cookie文件中数据
  771. //public string ReadCookies(string CookiesName)
  772. //{
  773. // string cookieValue = HttpContext.Current.Request.Cookies[CookiesName].Value.ToString();
  774. // return cookieValue;
  775. //}
  776. //将读取Cookie文件中数据2018.3.11
  777. public string ReadCookies(string CookiesName)
  778. {
  779. string cookieValue = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[CookiesName].Value.ToString(), System.Text.Encoding.GetEncoding("gb2312"));
  780. return cookieValue;
  781. }
  782. //将数据写入Cookie文件中,2018.3.11改
  783. public void WriteCookies(string CookiesName, string CookiesValue, int DayNum)
  784. { // DateTime.Now.AddDays(7); DayNum=7(一周),1=一天,30
  785. HttpContext.Current.Response.Cookies[CookiesName].Value = HttpUtility.UrlEncode(CookiesValue, System.Text.Encoding.GetEncoding("gb2312")); ;
  786. HttpContext.Current.Response.Cookies[CookiesName].Expires = DateTime.Now.AddDays(DayNum);
  787. }
  788. //老师登录,督导系统用
  789. public Boolean check_userlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
  790. {
  791. WriteCookies("UserName", "", 1);
  792. WriteCookies("UserType", "", 1);
  793. WriteCookies("UserDemp", "",1);
  794. WriteCookies("WorkNumber", "", 1);
  795. Boolean LoginAccess = false;
  796. //一般教师登录检查
  797. // OleDbConnection objConn = new OleDbConnection(connectionString);
  798. SqlConnection objConn = new SqlConnection(connectionString);
  799. string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
  800. // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  801. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  802. myCommand.Connection.Open();
  803. // OleDbDataReader myReader = myCommand.ExecuteReader();
  804. SqlDataReader myReader = myCommand.ExecuteReader();
  805. if (myReader.Read())
  806. {
  807. HttpContext.Current.Session["UserName"] = myReader["用户名"].ToString();
  808. WriteCookies("UserName", myReader["用户名"].ToString(), 7);
  809. //HttpContext.Current.Session["密码"] = myReader.GetValue(5);
  810. HttpContext.Current.Session["UserType"] = myReader["类别"].ToString();
  811. WriteCookies("UserType", myReader["类别"].ToString(), 7);
  812. HttpContext.Current.Session["UserDemp"] = myReader["部门"].ToString();
  813. WriteCookies("UserDemp", myReader["部门"].ToString(), 7);
  814. //HttpContext.Current.Session["姓名"] = myReader.GetValue(2);
  815. HttpContext.Current.Session["WorkNumber"] = myReader["工号"].ToString();
  816. WriteCookies("WorkNumber", myReader["工号"].ToString(), 7);
  817. HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
  818. LoginAccess = true;
  819. }
  820. else
  821. {
  822. HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
  823. LoginAccess = false;
  824. }
  825. myCommand.Connection.Close();
  826. return LoginAccess;
  827. }
  828. //老师登录,DQP系统用
  829. public Boolean check_Teacherlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
  830. {
  831. WriteCookies("UserName", "", 7);
  832. WriteCookies("UserType", "", 7);
  833. WriteCookies("UserDemp", "", 7);
  834. Boolean LoginAccess = false;
  835. //一般教师登录检查
  836. //OleDbConnection objConn = new OleDbConnection(connectionString);
  837. SqlConnection objConn = new SqlConnection(connectionString);
  838. string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
  839. // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  840. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  841. myCommand.Connection.Open();
  842. // OleDbDataReader myReader = myCommand.ExecuteReader();
  843. SqlDataReader myReader = myCommand.ExecuteReader();
  844. if (myReader.Read())
  845. {
  846. HttpContext.Current.Session["UserName"] = myReader["Username"].ToString(); //用户名
  847. WriteCookies("UserName", myReader["Username"].ToString(), 7);
  848. HttpContext.Current.Session["Tea_name"] = myReader["Tea_name"].ToString();
  849. WriteCookies("Tea_name", myReader["Tea_name"].ToString(), 7);
  850. HttpContext.Current.Session["Dempent"] = myReader["Dempent"].ToString();//系部
  851. WriteCookies("Dempent", myReader["Dempent"].ToString(), 7);
  852. HttpContext.Current.Session["TeachR_Office"] = myReader["TeachR_Office"].ToString(); //教研室
  853. WriteCookies("TeachR_Office", myReader["TeachR_Office"].ToString(), 7);
  854. //HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
  855. HttpContext.Current.Response.Write("<script>alert('登录成功!')</script>");
  856. LoginAccess = true;
  857. }
  858. else
  859. {
  860. //HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
  861. HttpContext.Current.Response.Write("<script>alert('登录失败!你的用户名或者密码有误!')</script>");
  862. LoginAccess = false;
  863. }
  864. myCommand.Connection.Close();
  865. return LoginAccess;
  866. }
  867. //通用查询,根据字段名,字段值,返回另一个字段值
  868. public string QueryRecord(string QueryFieldName, string QueryFieldValue, string RetrnValueFieldName, string TableName)
  869. {
  870. // Boolean LoginAccess = false;
  871. //一般教师登录检查
  872. OleDbConnection objConn = new OleDbConnection(connectionString);
  873. string searchCmd = "select * from " + TableName + " where " + QueryFieldName + " = '" + QueryFieldValue + "'";
  874. OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  875. myCommand.Connection.Open();
  876. OleDbDataReader myReader = myCommand.ExecuteReader();
  877. if (myReader.Read())
  878. {
  879. return myReader[RetrnValueFieldName].ToString();
  880. }
  881. else
  882. {
  883. return "未查询到数据";
  884. }
  885. }
  886. //通用查询,根据字段名,字段值,返回另一个字段值
  887. public string QueryRecordMaxValue(string SQL, string RetrnValueFieldName, string TableName)
  888. {
  889. SqlConnection objConn = new SqlConnection(connectionString);
  890. string searchCmd = SQL;
  891. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  892. myCommand.Connection.Open();
  893. SqlDataReader myReader = myCommand.ExecuteReader();
  894. if (myReader.Read())
  895. {
  896. return myReader[RetrnValueFieldName].ToString();
  897. }
  898. else
  899. {
  900. return "未查询到数据";
  901. }
  902. }
  903. //根据用户类型动态生成不同的菜单导航系统
  904. public StringBuilder Prod_menu(string userType)
  905. {
  906. //userType:用户类型
  907. StringBuilder sb = new StringBuilder();
  908. switch (userType)
  909. {
  910. case "院管理员":
  911. {
  912. sb.Append("\n <div class=\"divs\" title=\"登记填写听课记录\"><a href=\"Default.aspx\"><img alt=\"\" src=\"images/address-book.png\" width=\"80\" height=\"80\" /><br /></a>填写听课记录</div>");
  913. sb.Append("\n <div class=\"divs\" title=\"登记填写听课记录时可自动选择评语\"><a href=\"Default.aspx?OP=auto\"><img alt=\"\" src=\"images/network-utility.png\" width=\"80\" height=\"80\" /></a><br />自动评语</div>");
  914. sb.Append("\n <div class=\"divs\" title=\"查看评价信息\"><a href=\"DisplayPJ.aspx?Type=xyadmin&OP=disppj\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /></a><br />查看评价信息</div>");
  915. // sb.Append("\n <div class=\"divs\" title=\"修改评价信息\"><a href=\"DisplayPJ.aspx?Type=dd&OP=modi\"><img alt=\"\" src=\"images/finder.png\" width=\"80\" height=\"80\" /><br /></a>修改评语</div>");
  916. sb.Append("\n <div class=\"divs\" title=\"打印预览评价数据\"><a href=\"Admin/printDISP.aspx?utype=xyadmin\"><img alt=\"\" src=\"images/activity-monitor.png\" width=\"80\" height=\"80\" /></a><br />打印预览</div>");
  917. sb.Append("\n <div class=\"divs\" title=\"登记填写专题会议、项目评审、试卷检查等其它项目\"><a href=\"AddOther.aspx\"><img alt=\"\" src=\"images/a311ec9.jpg\" width=\"80\" height=\"80\" /><br /></a>填写其它项目</div>");
  918. sb.Append("\n <div class=\"divs\" title=\"查看显示修改填写专题会议、项目评审、试卷检查等其它项目信息\"><a href=\"DisplayOth.aspx?Type=xyadmin&OP=dispother\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /><br /></a>查看其它项目</div>");
  919. sb.Append("\n <div class=\"divs\" title=\"修改专题会议、项目评审、试卷检查等其它项目信息\"><a href=\"DisplayOth.aspx?Type=xyadmin&OP=dispother\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"80\" height=\"80\" /><br /></a>修改其它项目</div>");
  920. sb.Append("\n <div class=\"divs\" title=\"专题会议、项目评审、试卷检查等其它项目信息图片、附件等上传\"><a href=\"DispUpList.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /><br /></a>附件上传</div>");
  921. sb.Append("\n <div class=\"divs\" title=\"导出数据为WORD或EXCEL\"><a href=\"Admin/BatchExport.aspx\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"80\" height=\"80\" /></a><br />导出数据</div>");
  922. sb.Append("\n <div class=\"divs\" title=\"添加系部督导专员、系部督导员、添加新教师 \"><a href=\"admin/AddAdmin.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />添加用户</div>");
  923. sb.Append("\n <div class=\"divs\" title=\"数据报表\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表</div>");
  924. sb.Append("\n <div class=\"divs\" title=\"修改本人登录密码\"><a href=\"ModiPassword.aspx\"><img alt=\"\" src=\"images/keychain-access.png\" width=\"80\" height=\"80\" /><br /></a>修改密码</div>");
  925. sb.Append("\n <div class=\"divs\" title=\"数据报表--部门工作量统计\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表(部门工作量)</div>");
  926. sb.Append("\n <div class=\"divs\" title=\"工作量统计\"><a href=\"TeacherCount.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />督导个人工作统计</div>");
  927. } break;
  928. case "系管理员":
  929. {
  930. sb.Append("\n <div class=\"divs\" title=\"登记填写听课记录\"><a href=\"Default.aspx\"><img alt=\"\" src=\"images/address-book.png\" width=\"80\" height=\"80\" /><br /></a>填写听课记录</div>");
  931. sb.Append("\n <div class=\"divs\" title=\"登记填写听课记录时可自动选择评语\"><a href=\"Default.aspx?OP=auto\"><img alt=\"\" src=\"images/network-utility.png\" width=\"80\" height=\"80\" /></a><br />自动评语</div>");
  932. sb.Append("\n <div class=\"divs\" title=\"查看评价信息\"><a href=\"DisplayPJ.aspx?Type=dd&OP=disppj\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /></a><br />查看评价信息</div>");
  933. sb.Append("\n <div class=\"divs\" title=\"修改评价信息\"><a href=\"DisplayPJ.aspx?Type=dd&OP=modi\"><img alt=\"\" src=\"images/finder.png\" width=\"80\" height=\"80\" /><br /></a>修改评语</div>");
  934. sb.Append("\n <div class=\"divs\" title=\"填写综合听课后几位督导的综合评价意见 \"><a href=\"Admin/DisplayZHPJ.aspx\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"80\" height=\"80\" /><br /></a>填写综合评价</div>");
  935. sb.Append("\n <div class=\"divs\" title=\"查看综合评价\"><a href=\"DisplayPJ.aspx?Type=dd&OP=dispzhpj\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"80\" height=\"80\" /><br /></a>查看综合评价</div>");
  936. sb.Append("\n <div class=\"divs\" title=\"登记填写专题会议、项目评审、试卷检查等其它项目\"><a href=\"AddOther.aspx\"><img alt=\"\" src=\"images/front-row.png\" width=\"80\" height=\"80\" /><br /></a>填写其它项目</div>");
  937. sb.Append("\n <div class=\"divs\" title=\"查看显示修改填写专题会议、项目评审、试卷检查等其它项目信息\"><a href=\"DisplayOth.aspx?Type=xbadmin&OP=dispother\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"80\" height=\"80\" /><br /></a>查看其它项目</div>");
  938. sb.Append("\n <div class=\"divs\" title=\"修改专题会议、项目评审、试卷检查等其它项目信息\"><a href=\"DisplayOth.aspx?Type=dd&OP=dispother\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /><br /></a>修改其它项目</div>");
  939. sb.Append("\n <div class=\"divs\" title=\"专题会议、项目评审、试卷检查等其它项目信息图片、附件等上传\"><a href=\"DispUpList.aspx\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /><br /></a>附件上传</div>");
  940. sb.Append("\n <div class=\"divs\" title=\"数据报表--部门工作量统计\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表(部门工作量)</div>");
  941. sb.Append("\n <div class=\"divs\" title=\"打印预览评价数据\"><a href=\"Admin/printDISP.aspx?utype=xbadmin\"><img alt=\"\" src=\"images/activity-monitor.png\" width=\"80\" height=\"80\" /></a><br />打印预览</div>");
  942. sb.Append("\n <div class=\"divs\" title=\"导出数据\"><a href=\"Admin/BatchExport.aspx\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"80\" height=\"80\" /></a><br />导出数据</div>");
  943. sb.Append("\n <div class=\"divs\" title=\"修改本人登录密码\"><a href=\"ModiPassword.aspx\"><img alt=\"\" src=\"images/keychain-access.png\" width=\"80\" height=\"80\" /><br /></a>修改密码</div>");
  944. sb.Append("\n <div class=\"divs\" title=\"添加用户\"><a href=\"admin/AddAdmin.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />添加用户</div>");
  945. sb.Append("\n <div class=\"divs\" title=\"督导个人工作量统计\"><a href=\"TeacherCount.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />督导个人工作量统计</div>");
  946. } break;
  947. case "督导员":
  948. {
  949. sb.Append("\n <div class=\"divs\" title=\"登记填写听课记录\"><a href=\"Default.aspx\"><img alt=\"\" src=\"images/address-book.png\" width=\"80\" height=\"80\" /><br /></a>填写听课记录</div>");
  950. sb.Append("\n <div class=\"divs\" title=\"登记填写听课记录时可自动选择评语\"><a href=\"Default.aspx?OP=auto\"><img alt=\"\" src=\"images/network-utility.png\" width=\"80\" height=\"80\" /></a><br />自动评语</div>");
  951. sb.Append("\n <div class=\"divs\" title=\"查看显示本人录入系统的评价信息\"><a href=\"DisplayPJ.aspx?Type=dd&OP=disppj\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /></a><br />查看评价信息</div>");
  952. sb.Append("\n <div class=\"divs\" title=\"修改评价信息\"><a href=\"DisplayPJ.aspx?Type=dd&OP=modi\"><img alt=\"\" src=\"images/finder.png\" width=\"80\" height=\"80\" /><br /></a>修改评语</div>");
  953. sb.Append("\n <div class=\"divs\" title=\"查看我的听课教师的综合评价意见\"><a href=\"DisplayPJ.aspx?Type=dd&OP=dispzhpj\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"80\" height=\"80\" /><br /></a>查看综合评价</div>");
  954. sb.Append("\n <div class=\"divs\" title=\"登记填写专题会议、项目评审、试卷检查等其它项目\"><a href=\"AddOther.aspx\"><img alt=\"\" src=\"images/front-row.png\" width=\"80\" height=\"80\" /><br /></a>填写其它项目</div>");
  955. sb.Append("\n <div class=\"divs\" title=\"查看显示修改填写专题会议、项目评审、试卷检查等其它项目信息\"><a href=\"DisplayOth.aspx?Type=dd&OP=dispother\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"80\" height=\"80\" /><br /></a>查看其它项目</div>");
  956. sb.Append("\n <div class=\"divs\" title=\"修改专题会议、项目评审、试卷检查等其它项目信息\"><a href=\"DisplayOth.aspx?Type=dd&OP=dispother\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /><br /></a>修改其它项目</div>");
  957. sb.Append("\n <div class=\"divs\" title=\"专题会议、项目评审、试卷检查等其它项目信息图片、附件等上传\"><a href=\"DispUpList.aspx\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /><br /></a>附件上传</div>");
  958. sb.Append("\n <div class=\"divs\" title=\"打印预览评价数据\"><a href=\"Admin/printDISP.aspx?utype=dd\"><img alt=\"\" src=\"images/activity-monitor.png\" width=\"80\" height=\"80\" /></a><br />打印预览</div>");
  959. sb.Append("\n <div class=\"divs\" title=\"修改本人登录密码\"><a href=\"ModiPassword.aspx\"><img alt=\"\" src=\"images/keychain-access.png\" width=\"80\" height=\"80\" /><br /></a>修改密码</div>");
  960. sb.Append("\n <div class=\"divs\" title=\"导出数据\"><a href=\"#\" onclick=\"javascript:alert('你没有权限进行此项操作!')\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"80\" height=\"80\" /></a><br />导出数据</div>");
  961. sb.Append("\n <div class=\"divs\" title=\"数据报表\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表</div>");
  962. sb.Append("\n <div class=\"divs\" title=\"督导个人工作量统计\"><a href=\"TeacherCount.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />督导个人工作量统计</div>");
  963. //sb.Append("\n <ul id=\"list\" class=\"image-grid\">");
  964. //sb.Append("\n <li class=\"util\" data-id=\"id-12\"><a href=\"LoginNew.aspx\"><img alt=\"\" src=\"images/sync.png\" width=\"128\" height=\"128\" /><strong>重新登录</strong></a><span>返回登录页面</span></li>");
  965. //sb.Append("\n <li class=\"util\" data-id=\"id-10\"><a href=\"ModiPassword.aspx\"><img alt=\"\" src=\"images/keychain-access.png\" width=\"128\" height=\"128\" /><strong>修改密码</strong></a><span>修改登录密码</span></li>");
  966. //sb.Append("\n <li class=\"util\" data-id=\"id-1\"><a href=\"Default.aspx\"><img alt=\"\" src=\"images/address-book.png\" width=\"128\" height=\"128\" /><strong>登记填写评价信息</strong></a><span>将听课信息录入到系统</span></li>");
  967. //sb.Append("\n <li class=\"util\" data-id=\"id-11\"><a href=\"Default.aspx?OP=auto\"><img alt=\"\" src=\"images/network-utility.png\" width=\"128\" height=\"128\" /><strong>自动评语功能</strong></a> <span>使用自动评语为你填写评语</span></li>");
  968. //sb.Append("\n <li class=\"app\" data-id=\"id-2\"><a href=\"DisplayPJ.aspx?Type=dd&OP=disppj\"><img alt=\"\" src=\"images/ichat.png\" width=\"128\" height=\"128\" /><strong>查看评价信息</strong></a><span>查看显示本人录入系统的评价信息</span></li>");
  969. //sb.Append("\n <li class=\"app\" data-id=\"id-8\"><a href=\"DisplayPJ.aspx?Type=dd&OP=dispzhpj\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"128\" height=\"128\" /><strong>查看综合评价结果</strong></a><span>查看我的听课教师的综合评价结果</span></li>");
  970. //sb.Append("\n <li class=\"app\" data-id=\"id-3\"><a href=\"DisplayPJ.aspx?Type=dd&OP=modi\"><img alt=\"\" src=\"images/finder.png\" width=\"128\" height=\"128\" /><strong>修改评语</strong></a><span>修改看本人录入系统的评价信息</span></li>");
  971. //sb.Append("\n <li class=\"app\" data-id=\"id-4\"><a href=\"Admin/printDISP.aspx?utype=xbdd\"><img alt=\"\" src=\"images/activity-monitor.png\" width=\"128\" height=\"128\" /><strong>打印预览评价数据</strong> </a><span>打印预览评价数据</span></li>");
  972. //sb.Append("\n <li class=\"app\" data-id=\"id-5\"><a href=\"#\" onclick=\"javascript:alert('你没有权限进行此项操作!')\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"128\" height=\"128\" /><strong>导出数据</strong></a> <span>导出为WORD报表格式</span></li>");
  973. //sb.Append("\n <li class=\"app\" data-id=\"id-13\"><a href=\"admin/BatchExport.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"128\" height=\"128\" /><strong>批量数据处理</strong></a><span>将数据批量导出</span></li>");
  974. //// sb.Append("\n <li class=\"app\" data-id=\"id-6\"><a href=\"admin/AddAdmin.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"128\" height=\"128\" /><strong>添加用户</strong></a><span>添加系部管理员、督导员和系部教师</span></li>");
  975. //sb.Append("\n <li class=\"app\" data-id=\"id-6\"><a href=\"#\"><img alt=\"\" src=\"images/ical.png\" width=\"128\" height=\"128\" /><strong>待定功能</strong></a><span>添加系部管理员、督导员和系部教师</span></li>");
  976. //sb.Append("\n <li class=\"app\" data-id=\"id-9\"><img alt=\"\" src=\"images/ituna.png\" width=\"128\" height=\"128\" /><strong>待定功能</strong><span>待定功能</span></li>");
  977. //sb.Append("\n </ul>");
  978. } break;
  979. case "教师":
  980. {
  981. //sb.Append("\n <ul id=\"list\" class=\"image-grid\">");
  982. //sb.Append("\n <li class=\"util\" data-id=\"id-12\"><a href=\"LoginNew.aspx\"><img alt=\"\" src=\"images/sync.png\" width=\"128\" height=\"128\" /><strong>重新登录</strong></a><span>返回登录页面</span></li>");
  983. //sb.Append("\n <li class=\"util\" data-id=\"id-10\"><a href=\"ModiPassword.aspx\"><img alt=\"\" src=\"images/keychain-access.png\" width=\"128\" height=\"128\" /><strong>修改密码</strong></a><span>修改登录密码</span></li>");
  984. //sb.Append("\n <li class=\"app\" data-id=\"id-8\"><a href=\"DisplayPJ.aspx?Type=Tea\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"128\" height=\"128\" /><strong>查看我的评价</strong><span>查看督导对我上课的评价!</span></li>");
  985. //sb.Append("\n <li class=\"app\" data-id=\"id-5\"><a href=\"importWord.aspx\"><img alt=\"\" src=\"images/google-pokemon.png\" width=\"128\" height=\"128\" /><strong>导出数据</strong></a> <span>导出为WORD报表格式</span></li>");
  986. //sb.Append("\n <li class=\"app\" data-id=\"id-9\"><img alt=\"\" src=\"images/ituna.png\" width=\"128\" height=\"128\" /><strong>待定功能</strong><span>待定功能</span></li>");
  987. //sb.Append("\n </ul>");
  988. sb.Append("\n <div class=\"divs\" title=\"查看我的综合评价意见\"><a href=\"DisplayPJ.aspx?Type=Tea&OP=dispzhpj\"><img alt=\"\" src=\"images/interface-builder.png\" width=\"80\" height=\"80\" /><br /></a>查看综合评价</div>");
  989. sb.Append("\n <div class=\"divs\" title=\"修改本人登录密码\"><a href=\"ModiPassword.aspx\"><img alt=\"\" src=\"images/keychain-access.png\" width=\"80\" height=\"80\" /><br /></a>修改密码</div>");
  990. sb.Append("\n <div class=\"divs\" title=\"待定功能\"><a href=\"#\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />待定功能</div>");
  991. sb.Append("\n <div class=\"divs\" title=\"待定功能\"><a href=\"#\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />待定功能</div>");
  992. } break;
  993. }
  994. return sb;
  995. }
  996. //将SQL表名绑定到DropDownList OK
  997. public void BindFieldNameToCheckBoxListSQL(string SelectTableName, CheckBoxList FieldNameList)
  998. {//SelectTableName 选择的表名
  999. //FieldNameList(CheckList的名称,用于显示字段名 FieldNameList
  1000. string selTableName = SelectTableName;
  1001. HttpContext.Current.Session.Add("TableName", selTableName);
  1002. //'创建 DataAdpter 对象案例
  1003. //OleDbConnection objConn = new OleDbConnection();
  1004. SqlConnection objConn = new SqlConnection(connectionString);
  1005. //OleDbDataAdapter objCmd = new OleDbDataAdapter("Select * From " + selTableName, connectionString);
  1006. SqlDataAdapter objCmd = new SqlDataAdapter("Select * From " + selTableName, connectionString);
  1007. //'创建 DataSet 对象案例
  1008. DataSet DS = new DataSet();
  1009. objCmd.Fill(DS, selTableName);
  1010. DataTable myTable = DS.Tables[selTableName];
  1011. ArrayList arrTableList = new ArrayList();
  1012. int i = 0;
  1013. for (i = 0; i <= myTable.Columns.Count - 1; i++)
  1014. {
  1015. arrTableList.Add(myTable.Columns[i].Caption);
  1016. }
  1017. FieldNameList.DataSource = arrTableList;
  1018. FieldNameList.DataBind();
  1019. objConn.Close();
  1020. }
  1021. //将字段名绑定到DropDownList
  1022. public void BindFieldNameToCheckBoxList(string SelectTableName, CheckBoxList FieldNameList)
  1023. {//SelectTableName 选择的表名
  1024. //FieldNameList(CheckList的名称,用于显示字段名 FieldNameList
  1025. string selTableName = SelectTableName;
  1026. HttpContext.Current.Session.Add("TableName", selTableName);
  1027. //'创建 DataAdpter 对象案例
  1028. //OleDbConnection objConn = new OleDbConnection();
  1029. SqlConnection objConn = new SqlConnection();
  1030. //OleDbDataAdapter objCmd = new OleDbDataAdapter("Select * From " + selTableName, connectionString);
  1031. SqlDataAdapter objCmd = new SqlDataAdapter("Select * From " + selTableName, connectionString);
  1032. //'创建 DataSet 对象案例
  1033. DataSet DS = new DataSet();
  1034. objCmd.Fill(DS, selTableName);
  1035. DataTable myTable = DS.Tables[selTableName];
  1036. ArrayList arrTableList = new ArrayList();
  1037. int i = 0;
  1038. for (i = 0; i <= myTable.Columns.Count - 1; i++)
  1039. {
  1040. arrTableList.Add(myTable.Columns[i].Caption);
  1041. }
  1042. FieldNameList.DataSource = arrTableList;
  1043. FieldNameList.DataBind();
  1044. objConn.Close();
  1045. }
  1046. ////将表名绑定到DropDownList
  1047. //public void BindTableNameToDropDownList(DropDownList myDropDownList)
  1048. //{
  1049. // int i = 0;
  1050. // //OleDbConnection objConn = new OleDbConnection();
  1051. // //objConn.ConnectionString = connectionString;
  1052. // //objConn.Open();
  1053. // SqlConnection objConn = new SqlConnection();
  1054. // objConn.ConnectionString = connectionString;
  1055. // objConn.Open();
  1056. // DataTable schemaTable = objConn.GetSchema(s SOleDbSchemaGuid.Tables, null);
  1057. // ArrayList arrTableList = new ArrayList();
  1058. // for (i = 1; i <= schemaTable.Rows.Count - 1; i++)
  1059. // {
  1060. // if (schemaTable.Rows[i].ItemArray[3].ToString() == "TABLE")
  1061. // { arrTableList.Add(schemaTable.Rows[i].ItemArray[2].ToString()); }
  1062. // }
  1063. // myDropDownList.DataSource = arrTableList;
  1064. // myDropDownList.DataBind();
  1065. // objConn.Close();
  1066. // myDropDownList.Visible = true;
  1067. //}
  1068. ////将表名绑定到ListBox
  1069. //public void BindTableNameToListBox(ListBox myDropDownList)
  1070. //{
  1071. //}
  1072. //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
  1073. //浏览更新数据(含上传和修改)
  1074. public StringBuilder UpdateMenuBrowse1(string SQL, string TableName, int mPageSize, string SaveFileDir, Boolean bRow)
  1075. {
  1076. SqlConnection conn = new SqlConnection(connectionString);
  1077. SqlCommand cmd = new SqlCommand("", conn);
  1078. int rowIndex = 1;
  1079. int pageId = 1;
  1080. int maxRow = 1;
  1081. int maxPage = 1;
  1082. int pageSize = mPageSize;
  1083. StringBuilder sb = new StringBuilder();
  1084. //确定当前页
  1085. if (HttpContext.Current.Request.QueryString["pageId"] == null)
  1086. {
  1087. pageId = 1;
  1088. }
  1089. else
  1090. {
  1091. pageId = int.Parse(HttpContext.Current.Request.QueryString["pageId"].Trim());
  1092. }
  1093. try
  1094. {
  1095. if (conn.State == ConnectionState.Closed)
  1096. {
  1097. conn.Open();
  1098. }
  1099. // cmd.CommandText = "select count(*) from " + TableName + QueryConditions;//"select count(*) from " + TableName;
  1100. cmd.CommandText = "select count(*) from " + TableName;
  1101. maxRow = (int)cmd.ExecuteScalar();
  1102. maxPage = (maxRow % pageSize > 0) ? (maxRow / pageSize + 1) : (maxRow / pageSize);
  1103. cmd.CommandText = SQL;// "select * from " + TableName + " order by id"; //+ QueryConditions;
  1104. SqlDataReader dr = cmd.ExecuteReader();
  1105. for (int i = 0; i < (pageId - 1) * pageSize; i++)
  1106. {
  1107. dr.Read();
  1108. rowIndex++;
  1109. }
  1110. int by = (pageId > 1) ? (pageId - 1) : 1;
  1111. int by1 = (pageId < maxPage) ? (pageId + 1) : maxPage;
  1112. sb.Append("记录总数为:" + maxRow.ToString() + ";当前页:" + pageId.ToString() + "/" + maxPage.ToString());
  1113. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=1'>第一页</a>]");
  1114. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by.ToString() + "'>上一页</a>]");
  1115. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by1.ToString() + "'>下一页</a>]");
  1116. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + maxPage.ToString() + "'>最后页</a>]");
  1117. sb.Append("<br />");
  1118. // sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  1119. sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  1120. if (bRow == true)
  1121. {
  1122. sb.Append("<tr bgcolor='#99ccff'>");
  1123. for (int j = 0; j <= dr.FieldCount - 1; j++)
  1124. {
  1125. //sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</th>");
  1126. sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</th>");
  1127. }
  1128. for (int i = rowIndex; i < (rowIndex + pageSize); i++)
  1129. {
  1130. if (dr.Read())
  1131. {
  1132. sb.Append("</tr><tr>");
  1133. for (int j = 0; j <= dr.FieldCount - 1; j++)
  1134. {
  1135. if (dr.GetName(j).ToString().Contains("附件"))
  1136. {
  1137. if (dr[j].ToString().Trim().Length > 0)
  1138. {
  1139. if (CheckImgType(dr[j].ToString().Trim()))
  1140. { sb.Append("<td><img src=\"Upfiles\\"+dr[j].ToString().Trim()+"\" width=\"120\" height=\"120\" /></td>"); }
  1141. else
  1142. {
  1143. sb.Append("<td>" + dr[j].ToString() + "</td>");
  1144. }
  1145. }
  1146. else
  1147. {
  1148. sb.Append("<td>[<a href =\"Uppic.aspx?KeyF=" + dr["ID"].ToString() + "&tn=" + TableName + "&FieldN=" + dr.GetName(j).ToString() + "&Dir=" + SaveFileDir + "\" target=\"_blank\">上传附件]</a></td>");
  1149. }
  1150. }
  1151. else
  1152. {
  1153. if (dr.GetName(j).ToString().Contains("督导内容"))
  1154. { sb.Append("<td>[<a href =\"#\" target=\"_blank\" title='" + dr[j].ToString() + "'>督导内容</a>]</td>"); }
  1155. else
  1156. {
  1157. sb.Append("<td>" + dr[j].ToString() + "</td>");
  1158. }
  1159. }
  1160. }
  1161. //sb.Append("<hr/>");
  1162. }
  1163. }
  1164. }
  1165. else
  1166. {
  1167. for (int i = rowIndex; i < (rowIndex + pageSize); i++)
  1168. {
  1169. if (dr.Read())
  1170. {
  1171. for (int j = 0; j <= dr.FieldCount - 1; j++)
  1172. {
  1173. sb.Append("<tr>");
  1174. sb.Append("<td>" + dr.GetName(j) + "</td>");
  1175. sb.Append("<td algin=left>" + dr[j].ToString().Replace("\r\n", "<br />") + "</td>");
  1176. //if (dr.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  1177. //{
  1178. // sb.Append("<td><asp:TextBox ID='TextBox1' Text='" + dr[j].ToString() + "' runat='server' Columns='60' Rows='12' TextMode='MultiLine'></asp:TextBox>&nbsp;</td>");
  1179. //}
  1180. //else
  1181. //{ sb.Append("<td><asp:TextBox ID='TextBox1' Text='"+ dr[j].ToString() +"' runat='server' Columns='60'></asp:TextBox>&nbsp;</td>"); }
  1182. sb.Append("</tr>");
  1183. }
  1184. }
  1185. }
  1186. }
  1187. sb.Append("</Table>");
  1188. }
  1189. catch (OleDbException e)
  1190. {
  1191. sb.Append(e.Message.ToString());
  1192. }
  1193. finally
  1194. {
  1195. if (conn.State == ConnectionState.Open)
  1196. {
  1197. conn.Close();
  1198. }
  1199. }
  1200. return sb;
  1201. }
  1202. public bool CheckImgType(string strImg)
  1203. {
  1204. if (strImg != null && strImg.ToString().Length > 0)
  1205. {
  1206. int i = strImg.LastIndexOf(".");
  1207. string StrType = strImg.Substring(i).ToLower();
  1208. if (StrType == ".jpg" || StrType == ".gif" || StrType == ".jpeg" || StrType == ".png")
  1209. {
  1210. return true;
  1211. }
  1212. else
  1213. {
  1214. return false;
  1215. }
  1216. }
  1217. else
  1218. {
  1219. return false;
  1220. }
  1221. }
  1222. //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
  1223. public StringBuilder DispLineDataModi(string SQL, string OPtype)
  1224. {
  1225. StringBuilder sb = new StringBuilder();
  1226. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1227. string sql = SQL;
  1228. SqlConnection dtConn = new SqlConnection(connectionString);
  1229. SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
  1230. DataSet dtSet = new DataSet();
  1231. dtCmd.Fill(dtSet);
  1232. DataTableReader objreader = dtSet.CreateDataReader();
  1233. int i = 0, j = 0;
  1234. sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
  1235. // sb.Append("\n <tr class=\"list_bline1\">");
  1236. sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1237. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1238. {
  1239. sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  1240. //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + "&nbsp;</td>");
  1241. }
  1242. // sb.Append(" <td>[预览显示操作]</td>");
  1243. if (OPtype.Trim().Length > 0)
  1244. {
  1245. sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>操作&nbsp;</b>");
  1246. }
  1247. sb.Append("\n </tr>");
  1248. while (objreader.Read())
  1249. {
  1250. j = j + 1;
  1251. sb.Append("\n <tr class=\"list_bline1\">");
  1252. //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1253. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1254. {
  1255. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  1256. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \"><a herf='Modify.aspx?ID=" + objreader["ID"].ToString + "'>[修改]</a>&nbsp;</td>");
  1257. }
  1258. switch (OPtype)
  1259. {
  1260. case "disp":
  1261. {
  1262. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"BrowseMenu.aspx?disp=disppj&ID=" + objreader["ID"].ToString() + "\">显示详细</a></td>");
  1263. } break;
  1264. case "del":
  1265. {
  1266. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"#\" target=\"_blank\" onclick=\"Delconfirm('" + objreader["ID"].ToString() + "')\" >删除</a></td>");
  1267. } break;
  1268. case "disppj":
  1269. {
  1270. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"BrowseMenu.aspx?disp=disppj&ID=" + objreader["ID"].ToString() + "\">显示详细</a></td>");
  1271. } break;
  1272. case "modi":
  1273. {
  1274. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"Modify.aspx?ID=" + objreader["ID"].ToString() + "\">修改数据</a></td>");
  1275. } break;
  1276. case "ModiAndDel":
  1277. {
  1278. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"../admin/ModifyRec.aspx?id=" + objreader["ID"].ToString() + "\">修改数据</a>&nbsp;&nbsp;<a href=\"#\" target=\"_blank\" onclick=\"Delconfirm('" + objreader["ID"].ToString() + "')\" >删除</a></td>");
  1279. } break;
  1280. case "dispzhpj":
  1281. {
  1282. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"BrowseMenu.aspx?disp=dispzhpj&ID=" + objreader["ID"].ToString() + "\">显示详细</a></td>");
  1283. } break;
  1284. case "dispzhpjAdd":
  1285. {
  1286. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"modiZHPJ.aspx?ID=" + objreader["ID"].ToString() + "\">填写综合评语</a></td>");
  1287. } break;
  1288. case "print":
  1289. {
  1290. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"../print.aspx?disp=dispzhpj&ID=" + objreader["ID"].ToString() + "\">打印</a></td>");
  1291. } break;
  1292. case "dispother":
  1293. {
  1294. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"ModifyOther.aspx?ID=" + objreader["ID"].ToString() + "\">显示详细</a></td>");
  1295. } break;
  1296. case "":
  1297. {
  1298. } break;
  1299. }
  1300. sb.Append("\n </tr>");
  1301. }
  1302. sb.Append("</table>");
  1303. return sb;
  1304. }
  1305. //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
  1306. public StringBuilder DispLineData(string SQL)
  1307. {
  1308. StringBuilder sb = new StringBuilder();
  1309. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1310. string sql = SQL;
  1311. SqlConnection objConn = new SqlConnection(connectionString);
  1312. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1313. DataSet dtSet = new DataSet();
  1314. dtCmd.Fill(dtSet);
  1315. DataTableReader objreader = dtSet.CreateDataReader();
  1316. int i = 0, j = 0;
  1317. sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
  1318. // sb.Append("\n <tr class=\"list_bline1\">");
  1319. sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1320. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1321. {
  1322. sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  1323. //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + "&nbsp;</td>");
  1324. }
  1325. // sb.Append(" <td>[预览显示操作]</td>");
  1326. sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>操作&nbsp;</b>");
  1327. sb.Append("\n </tr>");
  1328. while (objreader.Read())
  1329. {
  1330. j = j + 1;
  1331. sb.Append("\n <tr class=\"list_bline1\">");
  1332. //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1333. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1334. {
  1335. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  1336. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \"><a herf='Modify.aspx?ID=" + objreader["ID"].ToString + "'>[修改]</a>&nbsp;</td>");
  1337. }
  1338. // sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"Modify.aspx?ID=" + objreader["ID"].ToString() + "\">修改数据</a></td>");
  1339. sb.Append("\n </tr>");
  1340. }
  1341. sb.Append("</table>");
  1342. return sb;
  1343. }
  1344. //以行显示成绩
  1345. //以行显示成绩
  1346. public StringBuilder DispScorea(string SQL, string OriginalOrWeight)
  1347. {//OriginalOrWeight Original原始分Weight权重分
  1348. StringBuilder sb = new StringBuilder();
  1349. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1350. string sql = SQL;
  1351. SqlConnection objConn = new SqlConnection(connectionString);
  1352. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1353. DataSet dtSet = new DataSet();
  1354. dtCmd.Fill(dtSet);
  1355. DataTableReader objreader = dtSet.CreateDataReader();
  1356. int i = 0, j = 0;
  1357. sb.Append("\n <table width=\"98%\" cellspacing='0' cellpadding='0' align=\"center\" class=\"lh28 font_st\">");
  1358. sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1359. for (i = 0; i <= objreader.FieldCount - 1; i++)
  1360. {
  1361. // Response.Write(objreader.GetFieldType(i).Name);
  1362. sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF;border-bottom-width: 1px; border-bottom-style: dotted;border-left-color: #C1CCD5; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b></td>");
  1363. }
  1364. if (OriginalOrWeight != "Original")
  1365. {
  1366. sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>总成绩&nbsp;</b>");
  1367. }
  1368. sb.Append("\n </tr>");
  1369. while (objreader.Read())
  1370. {
  1371. j = j + 1;
  1372. Single T_Score = 0; Single s1 = 0;
  1373. sb.Append("\n <tr class=\"list_bline1\">");
  1374. for (i = 0; i <= objreader.FieldCount - 1; i++)
  1375. {
  1376. //if (objreader.GetName(i) == "TotalScore ") //如果字段名为TotalScore 计算总成绩
  1377. // {
  1378. // for (i = 0; i <= objreader.FieldCount - 1; i++)
  1379. if (objreader.GetName(i).Substring(0, 3).ToUpper() == "SOC")
  1380. {
  1381. if (!string.IsNullOrEmpty(objreader.GetValue(i).ToString()))
  1382. {
  1383. s1 = Convert.ToSingle(objreader.GetValue(i).ToString());
  1384. T_Score = T_Score + s1;
  1385. }
  1386. }
  1387. // }
  1388. sb.Append("\n <td align=\"center\" style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted;border-bottom-color: #C1CCD5;border-left-width: 1px;border-left-style: inset;border-left-color: #FFFFFE; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  1389. }
  1390. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\">&nbsp</td>");
  1391. if (OriginalOrWeight != "Original")
  1392. {
  1393. sb.Append("\n <td align=\"center\" style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted;border-bottom-color: #C1CCD5;border-left-width: 1px;border-left-style: inset;border-left-color: #FFFFFE; \">" + (int)T_Score + "&nbsp;</td>");
  1394. }
  1395. sb.Append("\n </tr>");
  1396. }
  1397. sb.Append("</table>");
  1398. return sb;
  1399. }
  1400. //学生成果显示及阅卷
  1401. public StringBuilder DispSOCLineData(string SQL)
  1402. {
  1403. StringBuilder sb = new StringBuilder();
  1404. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1405. string sql = SQL;
  1406. SqlConnection objConn = new SqlConnection(connectionString);
  1407. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1408. DataSet dtSet = new DataSet();
  1409. dtCmd.Fill(dtSet);
  1410. DataTableReader objreader = dtSet.CreateDataReader();
  1411. int i = 0, j = 0;
  1412. sb.Append("\n <table width=\"100%\" align=\"center\" >");
  1413. sb.Append("\n <tr>");
  1414. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1415. {
  1416. sb.Append(" <td align=\"center\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  1417. }
  1418. sb.Append(" <td align=\"center\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>下载&nbsp;</b></td><td align=\"center\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>评分&nbsp;</b></td>");
  1419. sb.Append("\n </tr>");
  1420. while (objreader.Read())
  1421. {
  1422. j = j + 1;
  1423. sb.Append("\n <tr>");
  1424. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1425. {
  1426. sb.Append("\n <td align=\"center\">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  1427. }
  1428. //sb.Append("\n <td>[下载成果查看]</td><td><a href=\"SOCYue.aspx?ID=" + objreader["ID"].ToString() + "\">");
  1429. //sb.Append("<input type=\"text\" name=\"TextA" + objreader["ID"].ToString() + "\" value=\"" + objreader["TeaScore"].ToString() + "\" style=\"height:28px;width:40px;\" id=\"TextA" + (i + 1) + "\" />保存成绩</a></td>");
  1430. sb.Append("\n <td align=\"center\">[下载成果查看]</td><td align=\"center\">");
  1431. //sb.Append("<input type=\"text\" name=\"TextA" + objreader["ID"].ToString() + "\" value=\"" + objreader["TeaScore"].ToString() + "\" style=\"height:28px;width:40px;\" id=\"TextA" + (i + 1) + "\" /><a href=\"#\" onclick=\"window.open('SaveSocScore.aspx?ID=ID','','width=300,height=400')\">保存成绩</a></td>");
  1432. sb.Append("<a href=\"#\" onclick=\"window.open('SaveSocScore.aspx?ID=" + objreader["ID"].ToString() + "','','width=300,height=450')\">评分</a></td>");
  1433. sb.Append("\n </tr>");
  1434. }
  1435. sb.Append("</table>");
  1436. return sb;
  1437. }
  1438. //以行显示,每一行下划线显示 显示学生的课程
  1439. public StringBuilder DispCourseLineData(string SQL, string DispFieldName)
  1440. {
  1441. StringBuilder sb = new StringBuilder();
  1442. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1443. string sql = SQL;
  1444. SqlConnection objConn = new SqlConnection(connectionString);
  1445. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1446. DataSet dtSet = new DataSet();
  1447. dtCmd.Fill(dtSet);
  1448. DataTableReader objreader = dtSet.CreateDataReader();
  1449. int j = 0;
  1450. // sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
  1451. while (objreader.Read())
  1452. {
  1453. j = j + 1;
  1454. // sb.Append("\n <tr class=\"list_bline1\">");
  1455. // sb.Append("\n <li><a href='CourseSocList.aspx'\"?StudentID=" + HttpContext.Current.Session["stud_number"].ToString() + "&courseID=" + objreader["ID"].ToString() + "\">" + objreader[DispFieldName].ToString() + "[查看]</a>&nbsp;</li>");
  1456. sb.Append("\n <li><a href=\"CourseSocList.aspx?StudentID=" + HttpContext.Current.Session["stud_number"].ToString() + "&courseID=" + objreader["ID"].ToString() + "\">" + objreader[DispFieldName].ToString() + "[查看]</a>&nbsp;</li>");
  1457. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"Modify.aspx?ID=" + objreader["ID"].ToString() + "\">修改数据</a></td>");
  1458. //sb.Append("\n </tr>");
  1459. }
  1460. //sb.Append("</table>");
  1461. return sb;
  1462. }
  1463. //课程设置
  1464. public StringBuilder DispCourseSetLineData(string SQL, string DispFieldName)
  1465. {
  1466. StringBuilder sb = new StringBuilder();
  1467. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1468. string sql = SQL;
  1469. SqlConnection objConn = new SqlConnection(connectionString);
  1470. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1471. DataSet dtSet = new DataSet();
  1472. dtCmd.Fill(dtSet);
  1473. DataTableReader objreader = dtSet.CreateDataReader();
  1474. int j = 0;
  1475. sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
  1476. while (objreader.Read())
  1477. {
  1478. j = j + 1;
  1479. sb.Append("\n <tr class=\"list_bline1\">");
  1480. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \"><li><a href=\"?ID=" + objreader["ID"].ToString() + "\">" + objreader[DispFieldName].ToString() + "[设置成果]</a>&nbsp;</li></td>");
  1481. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"Modify.aspx?ID=" + objreader["ID"].ToString() + "\">修改数据</a></td>");
  1482. sb.Append("\n </tr>");
  1483. }
  1484. sb.Append("</table>");
  1485. return sb;
  1486. }
  1487. //课程评分
  1488. public StringBuilder DispCoursePFLineData(string SQL, string DispFieldName)
  1489. {
  1490. StringBuilder sb = new StringBuilder();
  1491. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1492. string sql = SQL;
  1493. SqlConnection objConn = new SqlConnection(connectionString);
  1494. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1495. DataSet dtSet = new DataSet();
  1496. dtCmd.Fill(dtSet);
  1497. DataTableReader objreader = dtSet.CreateDataReader();
  1498. int j = 0;
  1499. sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
  1500. while (objreader.Read())
  1501. {
  1502. j = j + 1;
  1503. sb.Append("\n <tr class=\"list_bline1\">");
  1504. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \"><li><a href=\"?ID=" + objreader["ID"].ToString() + "\">" + objreader[DispFieldName].ToString() + "[评分]</a>&nbsp;</li></td>");
  1505. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"Modify.aspx?ID=" + objreader["ID"].ToString() + "\">修改数据</a></td>");
  1506. sb.Append("\n </tr>");
  1507. }
  1508. sb.Append("</table>");
  1509. return sb;
  1510. }
  1511. //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
  1512. public StringBuilder DispLineDataadmin(string SQL)
  1513. {
  1514. StringBuilder sb = new StringBuilder();
  1515. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1516. string sql = SQL;
  1517. SqlConnection objConn = new SqlConnection(connectionString);
  1518. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1519. DataSet dtSet = new DataSet();
  1520. dtCmd.Fill(dtSet);
  1521. DataTableReader objreader = dtSet.CreateDataReader();
  1522. int i = 0, j = 0;
  1523. sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
  1524. // sb.Append("\n <tr class=\"list_bline1\">");
  1525. sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1526. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1527. {
  1528. sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + "&nbsp;</b>");
  1529. //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + "&nbsp;</td>");
  1530. }
  1531. // sb.Append(" <td>[预览显示操作]</td>");
  1532. sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>操作&nbsp;</b>");
  1533. sb.Append("\n </tr>");
  1534. while (objreader.Read())
  1535. {
  1536. j = j + 1;
  1537. sb.Append("\n <tr class=\"list_bline1\">");
  1538. //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1539. for (i = 1; i <= objreader.FieldCount - 1; i++)
  1540. {
  1541. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  1542. //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \"><a herf='Modify.aspx?ID=" + objreader["ID"].ToString + "'>[修改]</a>&nbsp;</td>");
  1543. }
  1544. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"><a href=\"BrowseMenu.aspx?ID=" + objreader["ID"].ToString() + "\">详细...</a></td>");
  1545. sb.Append("\n </tr>");
  1546. }
  1547. sb.Append("</table>");
  1548. return sb;
  1549. }
  1550. //评价数据显示,以行显示,每一行下划线显示
  1551. public StringBuilder PJLineData(string SQL, string NB)
  1552. {
  1553. StringBuilder sb = new StringBuilder();
  1554. // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1555. string sql = SQL;
  1556. SqlConnection objConn = new SqlConnection(connectionString);
  1557. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1558. DataSet dtSet = new DataSet();
  1559. dtCmd.Fill(dtSet);
  1560. DataTableReader objreader = dtSet.CreateDataReader();
  1561. int i = 0, j = 0;
  1562. sb.Append("\n <table width=\"98%\" align=\"center\" class=\"lh28 font_st\">");
  1563. // sb.Append("\n <tr class=\"list_bline1\">");
  1564. sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1565. for (i = 0; i <= objreader.FieldCount - 1; i++)
  1566. {
  1567. sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\">" + objreader.GetName(i) + "&nbsp;</td>");
  1568. //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + "&nbsp;</td>");
  1569. }
  1570. sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\">[操作]</td>");
  1571. sb.Append("\n </tr>");
  1572. while (objreader.Read())
  1573. {
  1574. j = j + 1;
  1575. sb.Append("\n <tr class=\"list_bline1\">");
  1576. //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
  1577. for (i = 0; i <= objreader.FieldCount - 1; i++)
  1578. {
  1579. sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "</td>");
  1580. }
  1581. sb.Append("\n <td ><a href=\"PJ.aspx?id=" + objreader["id"].ToString() + "&NB=" + NB + "\">[评价]</a></td>");
  1582. sb.Append("\n </tr>");
  1583. }
  1584. sb.Append("</table>");
  1585. return sb;
  1586. }
  1587. //弹拉缩
  1588. public StringBuilder DisplayPOC(string SQL1)
  1589. {
  1590. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  1591. sb.Append("\n <script type=\"text/javascript\" src=\"../js/jquery.min.js\"></script>");
  1592. sb.Append("\n <link type=\"text/css\" rel=\"stylesheet\" href=\"../JS/T8.css\" />");
  1593. sb.Append("\n <script type=\"text/javascript\" src=\"../Js/showList.js\"></script>");
  1594. // sb.Append("\n <link href=\"js/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1595. sb.Append("\n <div>");
  1596. sb.Append("\n <div class=\"main content\" style=\"background-color:#ECF4FB;\"> ");
  1597. sb.Append(" \n <div class=\"left-sider\">");
  1598. sb.Append("\n <div class=\"operate\">");
  1599. sb.Append("\n <h3>专业预期学习成果 </h3>");
  1600. sb.Append("\n <ul id=\"J_navlist\">");
  1601. SqlConnection objConn = new SqlConnection(connectionString);
  1602. // OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, objConn);
  1603. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
  1604. DataSet dtSet1 = new DataSet();
  1605. dtCmd1.Fill(dtSet1);
  1606. DataTableReader objreader1 = dtSet1.CreateDataReader();
  1607. StringBuilder SB = new StringBuilder();
  1608. while (objreader1.Read())
  1609. {
  1610. sb.Append("\n <li >");
  1611. sb.Append(" \n <h4 ><b>" + objreader1.GetValue(3) + "</b></h4>");
  1612. sb.Append(" \n <div class=\"list-item none\" >");
  1613. // OleDbConnection dtConn2 = new OleDbConnection(connectionString);
  1614. SqlConnection objConn2 = new SqlConnection(connectionString);
  1615. //OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  1616. SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", objConn2);
  1617. DataSet dtSet2 = new DataSet();
  1618. dtCmd2.Fill(dtSet2);
  1619. DataTableReader objreader2 = dtSet2.CreateDataReader();
  1620. sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\" style=\"background-color:#F3F9FA;\">");
  1621. while (objreader2.Read())
  1622. {
  1623. sb.Append("\n <tr class=\"list_bline1\" align='left'>");
  1624. sb.Append("\n <td id='Tv" + objreader2["ID"] + "' style=\"height:30px;background-color:#F3F9FA; color:#0000FF;border-bottom-width: 1px;padding-left:30px; border-bottom-style: dotted;border-bottom-color: #C1CCD5; \">");
  1625. sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' id='MS" + objreader2["ID"] + "' name='MS" + objreader2["ID"] + "' value='" + objreader2["ClassName"] + "' onclick=\"checkbox('MS" + objreader2["ID"] + "','Tv" + objreader2["ID"] + "')\" />" + objreader2["ClassName"] + "");
  1626. sb.Append("\n</td><td style=\"font-size:12px;background-color:#F3F9FA; color:#476374 border-bottom-width: 1px;padding-left:26px; border-bottom-style: dotted;border-bottom-color: #C1CCD5; \">" + objreader2["intro"].ToString() + "</td></tr>");
  1627. }
  1628. sb.Append("</table>");
  1629. sb.Append(" \n </div>");
  1630. sb.Append(" \n </li>");
  1631. objConn2.Close();
  1632. }
  1633. objConn.Close();
  1634. sb.Append(" \n </ul>");
  1635. sb.Append("\n <script type=\"text/javascript\" language=\"javascript\">");
  1636. sb.Append("\n navList(12);");
  1637. sb.Append("\n </script>");
  1638. sb.Append("\n </div>");
  1639. sb.Append("\n </div>");
  1640. sb.Append("\n </div>");
  1641. sb.Append("\n </div>");
  1642. sb.Append("\n <div style=\"text-align:center;clear:both\"></div>");
  1643. return sb;
  1644. }
  1645. //弹拉缩
  1646. public StringBuilder main8(string SQL1)
  1647. {
  1648. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  1649. sb.Append("\n <script type=\"text/javascript\" src=\"js/jquery.min.js\"></script>");
  1650. sb.Append("\n <link type=\"text/css\" rel=\"stylesheet\" href=\"JS/T8.css\" />");
  1651. sb.Append("\n <script type=\"text/javascript\" src=\"Js/showList.js\"></script>");
  1652. // sb.Append("\n <link href=\"js/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
  1653. sb.Append("\n <div>");
  1654. sb.Append("\n <div class=\"main content\">");
  1655. sb.Append(" \n <div class=\"left-sider\">");
  1656. sb.Append("\n <div class=\"operate\">");
  1657. // sb.Append("\n <h3>主菜单 </h3>");
  1658. sb.Append("\n <ul id=\"J_navlist\">");
  1659. SqlConnection objConn = new SqlConnection(connectionString);
  1660. // OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, objConn);
  1661. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
  1662. DataSet dtSet1 = new DataSet();
  1663. dtCmd1.Fill(dtSet1);
  1664. DataTableReader objreader1 = dtSet1.CreateDataReader();
  1665. StringBuilder SB = new StringBuilder();
  1666. while (objreader1.Read())
  1667. {
  1668. sb.Append("\n <li >");
  1669. sb.Append(" \n <h4 ><b>" + objreader1.GetValue(3) + "</b></h4>");
  1670. sb.Append(" \n <div class=\"list-item none\">");
  1671. SqlConnection dtConn2 = new SqlConnection(connectionString);
  1672. // OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  1673. SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  1674. DataSet dtSet2 = new DataSet();
  1675. dtCmd2.Fill(dtSet2);
  1676. DataTableReader objreader2 = dtSet2.CreateDataReader();
  1677. sb.Append("\n <table width=\"98%\" align=\"center\" class=\"lh28 font_st\">");
  1678. while (objreader2.Read())
  1679. {
  1680. sb.Append("\n <tr class=\"list_bline1\">");
  1681. sb.Append("\n <td id='Tv" + objreader2["ID"] + "' style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted;border-bottom-color: #C1CCD5; \">");
  1682. sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' id='MS" + objreader2["ID"] + "' name='MS" + objreader2["ID"] + "' value='" + objreader2["ClassName"] + "' onclick=\"checkbox('MS" + objreader2["ID"] + "','Tv" + objreader2["ID"] + "')\" />" + objreader2["ClassName"] + "");
  1683. //sb.Append("<p ><input type='checkbox' checked='checked' id='MS" + objreader2["ID"] + "' name='MSA" + objreader2["ID"] + "' value='A' onclick=\"checkbox('MSA" + objreader2["ID"] + "','Tv" + objreader2["ID"] + "')\" />");
  1684. //sb.Append("<a href=\"#\" target=\"_self\">" + objreader2["ClassName"].ToString() + "</a></p>");
  1685. sb.Append("\n </td></tr>");
  1686. }
  1687. sb.Append("</table>");
  1688. sb.Append(" \n </div>");
  1689. sb.Append(" \n </li>");
  1690. dtConn2.Close();
  1691. }
  1692. objConn.Close();
  1693. sb.Append(" \n </ul>");
  1694. sb.Append("\n <script type=\"text/javascript\" language=\"javascript\">");
  1695. sb.Append("\n navList(12);");
  1696. sb.Append("\n </script>");
  1697. sb.Append("\n </div>");
  1698. sb.Append("\n </div>");
  1699. sb.Append("\n </div>");
  1700. sb.Append("\n </div>");
  1701. sb.Append("\n <div style=\"text-align:center;clear:both\"></div>");
  1702. return sb;
  1703. }
  1704. //显示预览功能,通过单击表格行,显示当前页SWF的内容
  1705. public StringBuilder ViewInCurrentSWF(string SQL, int ViewFiledNo)
  1706. {
  1707. StringBuilder sb = new StringBuilder();
  1708. sb.Append("\n <script>");
  1709. sb.Append("\n function kai(i)");
  1710. sb.Append("\n {");
  1711. sb.Append("\n var DT_win=document.getElementById(i);");
  1712. sb.Append("\n ");
  1713. sb.Append("\n DT_win.style.display=(DT_win.style.display==\"none\"?\"block\":\"none\");");
  1714. sb.Append("\n }");
  1715. sb.Append("\n </script>");
  1716. string sql = SQL;
  1717. SqlConnection objConn = new SqlConnection(connectionString);
  1718. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1719. DataSet dtSet = new DataSet();
  1720. dtCmd.Fill(dtSet);
  1721. DataTableReader objreader = dtSet.CreateDataReader();
  1722. int i = 0, j = 0;
  1723. sb.Append("\n <table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"#E7F5FE\" bgcolor=\"#FFFFFF\" >");
  1724. sb.Append("\n <tr height=\"32\">");
  1725. for (i = 2; i <= objreader.FieldCount - 1; i++)
  1726. {
  1727. if (i != ViewFiledNo)
  1728. {
  1729. sb.Append(" <td bgcolor=\"#A4DCF7\" style=\"border-bottom-style: dotted; border-bottom-width: 1px; height:30px;border-bottom-color: #ACCEFD; font-size:12px; width: ;\">" + objreader.GetName(i) + "&nbsp;</td>");
  1730. }
  1731. }
  1732. sb.Append(" <td style=\"border-bottom-style: dotted; border-bottom-width: 1px; height:30px;border-bottom-color: #ACCEFD; font-size:12px; width: ;\" bgcolor=\"#A4DCF7\" >[预览显示操作]</td>");
  1733. sb.Append("\n </tr>");
  1734. while (objreader.Read())
  1735. {
  1736. j = j + 1;
  1737. sb.Append("\n <tr height=\"30\" style=\"CURSOR: pointer\" onclick=javascript:kai(" + j.ToString() + ") >");
  1738. for (i = 2; i <= objreader.FieldCount - 1; i++)
  1739. {
  1740. if (i != ViewFiledNo)
  1741. {
  1742. sb.Append("\n <td style=\"border-bottom-style: dotted; border-bottom-width: 1px; height:30px;border-bottom-color: #ACCEFD; font-size:12px; width: ;\">" + objreader.GetValue(i).ToString() + "&nbsp;</td>");
  1743. }
  1744. }
  1745. sb.Append("\n <td style=\"border-bottom-style: dotted; border-bottom-width: 1px; height:30px;border-bottom-color: #ACCEFD; font-size:12px; width: ;\"><a herf=''>[单击预览/双击关闭]</a></td>");
  1746. sb.Append("\n </tr>");
  1747. sb.Append("\n <tr style=\"DISPLAY: none\" id=\"" + j.ToString() + "\" bgColor=\"#f0f8ff\"><td colspan=\"");
  1748. sb.Append("\n" + (objreader.FieldCount - 1).ToString() + "\">");
  1749. sb.Append("\n <UL><LI><table width=\"96%\" border=\"0\" style=\"border: 1px outset #5CACED\"> <tr><td align=\"center\" style=\"border-bottom-style: dotted; border-bottom-width: 1px; height:30px;border-bottom-color: #ACCEFD; font-size:12px; width: ;\"> <div align=\"center\"><span class=\"TitileFont\">" + objreader.GetValue(2) + "<hr></span></div>");
  1750. sb.Append("\n <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=98% height=\"" + 700 + "\">");
  1751. sb.Append("\n <param name=\"movie\" value=\"" + "UpFiles/" + objreader.GetValue(ViewFiledNo).ToString() + "\">");
  1752. sb.Append("\n <param name=\"quality\" value=\"high\">");
  1753. sb.Append("\n <embed src=\"" + "UpFiles/" + objreader.GetValue(ViewFiledNo).ToString() + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=98% height=\"" + 680 + "\"></embed>");
  1754. sb.Append("\n </object>");
  1755. //sb.Append(DispSWFFile(700,680,"文件名","UpFiles//"+objreader.GetValue(ViewFiledNo).ToString()+"").ToString() );
  1756. sb.Append("</LI></UL></td></tr></table></td>");
  1757. //sb.Append(" <td>[操作][<asp:Button ID=\"Button" + objreader.GetName(0) + "\" CommandName=\"" + objreader.GetName(0) + "\" CommandArgument=\"+Tablename+\" runat=\"server\" onclick=\"Button1_Click\" Text=\"预览\" />]</td>");这个可以用按钮事件来管理
  1758. }
  1759. sb.Append("</table>");
  1760. return sb;
  1761. }
  1762. //将课程名称显示为超链接
  1763. public StringBuilder ShowKCname(string tablename, string BindFieldName)
  1764. {
  1765. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  1766. string SQL = "select DISTINCT(" + BindFieldName + ") , intro from " + tablename + " where followid=0";
  1767. SqlConnection objConn = new SqlConnection(connectionString);
  1768. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  1769. DataSet dtSet = new DataSet();
  1770. dtCmd.Fill(dtSet);
  1771. DataTableReader objreader = dtSet.CreateDataReader();
  1772. string myurl = GetAddressUrl();
  1773. while (objreader.Read())
  1774. {
  1775. sb.Append("<a href=\"?intro=" + objreader["intro"] + "\">" + objreader[BindFieldName] + "</a>");
  1776. }
  1777. return sb;
  1778. }
  1779. //非常不错与数据库结合,并以选项卡形式,界面清新,可用于多个FLASH等多个页面同时显示
  1780. public StringBuilder main161(string URLFieldName, string SQL1)
  1781. {
  1782. //URLFieldName URL对应字段名
  1783. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  1784. sb.Append("\n <STYLE type=text/css>");
  1785. sb.Append("\n BODY { FONT-SIZE: 14px; FONT-FAMILY: \"宋体\"; }");
  1786. sb.Append("\n OL LI { MARGIN: 8px }");
  1787. sb.Append("\n #con { FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH: 700px;Height:680 }");
  1788. sb.Append("\n #tags { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 10px; WIDTH:700px; PADDING-TOP: 0px; HEIGHT: 23px }");
  1789. sb.Append("\n #tags LI { BACKGROUND: url(images/tagleft.gif) no-repeat left bottom; FLOAT: left; MARGIN-RIGHT: 1px; LIST-STYLE-TYPE: none; HEIGHT: 23px }");
  1790. sb.Append("\n #tags LI A { PADDING-RIGHT: 6px; PADDING-LEFT:6px; BACKGROUND: url(images/tagright.gif) no-repeat right bottom; FLOAT: left; PADDING-BOTTOM: 0px; COLOR: #999; LINE-HEIGHT: 23px; PADDING-TOP: 0px; HEIGHT: 23px; TEXT-DECORATION: none }");
  1791. sb.Append("\n #tags LI.emptyTag { BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px }");
  1792. sb.Append("\n #tags LI.selectTag { BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 25px }");
  1793. sb.Append("\n #tags LI.selectTag A { BACKGROUND-POSITION: right top; COLOR: #000; LINE-HEIGHT: 25px; HEIGHT: 25px }");
  1794. sb.Append("\n #tagContent { BORDER-RIGHT: #aecbd4 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #aecbd4 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #aecbd4 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #aecbd4 1px solid; BACKGROUND-COLOR: #fff }");
  1795. //sb.Append("\n .tagContent { PADDING-RIGHT: 10px; DISPLAY: none; PADDING-LEFT: 10px; BACKGROUND: url(images/bg.gif) repeat-x; PADDING-BOTTOM: 10px; WIDTH:728px; COLOR: #474747; PADDING-TOP: 10px; HEIGHT: 680px }");
  1796. sb.Append("\n .tagContent { PADDING-RIGHT: 5px; DISPLAY: none; PADDING-LEFT: 5px; BACKGROUND: url() repeat-x; PADDING-BOTTOM: 2px; WIDTH:696px; COLOR: #474747; PADDING-TOP: 2px; HEIGHT: 680px }");
  1797. sb.Append("\n #tagContent DIV.selectTag { DISPLAY: block }");
  1798. sb.Append("\n </STYLE>");
  1799. sb.Append("\n ");
  1800. sb.Append("\n <SCRIPT type=text/javascript>");
  1801. sb.Append("\n function selectTag(showContent,selfObj){");
  1802. sb.Append("\n // 操作标签");
  1803. sb.Append("\n var tag = document.getElementById(\"tags\").getElementsByTagName(\"li\");");
  1804. sb.Append("\n var taglength = tag.length;");
  1805. sb.Append("\n for(i=0; i<taglength; i++){");
  1806. sb.Append("\n tag[i].className = \"\";");
  1807. sb.Append("\n }");
  1808. sb.Append("\n selfObj.parentNode.className = \"selectTag\";");
  1809. sb.Append("\n // 操作内容");
  1810. sb.Append("\n for(i=0; j=document.getElementById(\"tagContent\"+i); i++){");
  1811. sb.Append("\n j.style.display = \"none\";");
  1812. sb.Append("\n }");
  1813. sb.Append("\n document.getElementById(showContent).style.display = \"block\";");
  1814. sb.Append("\n ");
  1815. sb.Append("\n ");
  1816. sb.Append("\n }");
  1817. sb.Append("\n </SCRIPT>");
  1818. sb.Append("\n ");
  1819. sb.Append("\n <DIV id=con>");
  1820. sb.Append("\n <UL id=tags>");
  1821. SqlConnection objConn = new SqlConnection(connectionString);
  1822. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
  1823. DataSet dtSet1 = new DataSet();
  1824. dtCmd1.Fill(dtSet1);
  1825. DataTableReader objreader1 = dtSet1.CreateDataReader();
  1826. string[] getContent = new string[12];
  1827. int s = 0; int i = 0;
  1828. while (objreader1.Read())
  1829. {
  1830. s = s + 1;
  1831. sb.Append("\n <LI><A onClick=\"selectTag('tagContent" + (s - 1).ToString() + "',this)\" href=\"javascript:void(0)\">当前练习内容:" + objreader1.GetValue(2) + "</A> </LI>");
  1832. getContent[s] = objreader1[URLFieldName].ToString();
  1833. }
  1834. sb.Append("\n </UL>");
  1835. sb.Append("\n <DIV id=tagContent>");
  1836. for (i = 1; i <= s; i++)
  1837. {
  1838. if (i == 1)
  1839. { sb.Append("\n <DIV class=\"tagContent selectTag\" id=tagContent" + (i - 1).ToString() + ">" + DispSWFFile(690, 660, "构件概述", "" + getContent[i].ToString().Trim() + "").ToString() + "</DIV>"); }
  1840. else
  1841. {
  1842. sb.Append("\n <DIV class=\"tagContent\" id=tagContent" + (i - 1).ToString() + ">" + DispSWFFile(690, 660, "构件概述", "" + getContent[i].ToString().Trim() + "").ToString() + "</DIV>");
  1843. }
  1844. }
  1845. sb.Append("\n </DIV>");
  1846. sb.Append("\n </DIV>");
  1847. return sb;
  1848. }
  1849. //显示SWF文件
  1850. public StringBuilder DispSWFFile(int swfWidth, int swfHeight, string sTitle, string swfFileName)
  1851. {
  1852. StringBuilder sb = new StringBuilder();
  1853. sb.Append("\n <table cellspacing=\"1\" cellpadding=\"2\" width=\"" + swfWidth + "\" height=\"" + swfHeight + "\" border=\"0\" class=\"a2\" align=\"center\">");
  1854. sb.Append("\n <tr height=20>");
  1855. sb.Append("\n <td colspan=\"3\" align=middle valign=\"middle\" class=a1><b>上机内容</b></td>");
  1856. sb.Append("\n </tr>");
  1857. sb.Append("\n ");
  1858. sb.Append("\n <tr height=25>");
  1859. sb.Append("\n <td colspan=\"3\" align=left class=a3>");
  1860. sb.Append("\n <object id=\"FlashID\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + swfWidth + "\" height=\"" + swfHeight + "\">");
  1861. sb.Append("\n <param name=\"movie\" value=\"UPfiles\\" + swfFileName + "\" />");
  1862. sb.Append("\n <param name=\"quality\" value=\"high\" />");
  1863. sb.Append("\n<param name=\"wmode\" value=\"opaque\" />");
  1864. sb.Append("\n<param name=\"swfversion\" value=\"6.0.65.0\" />");
  1865. sb.Append("\n <!-- 此 param 标签提示使用 Flash Player 6.0 r65 和更高版本的用户下载最新版本的 Flash Player。如果您不想让用户看到该提示,请将其删除。 -->");
  1866. sb.Append("\n <param name=\"expressinstall\" value=\"Scripts/expressInstall.swf\" />");
  1867. sb.Append("\n <!-- 下一个对象标签用于非 IE 浏览器。所以使用 IECC 将其从 IE 隐藏。 -->");
  1868. sb.Append("\n <!--[if !IE]>-->");
  1869. sb.Append("\n <object type=\"application/x-shockwave-flash\" data=\"Upfiles\\" + swfFileName + "\" width=\"" + swfWidth + "\" height=\"" + swfHeight + "\">");
  1870. sb.Append("\n <!--<![endif]-->");
  1871. sb.Append("\n <param name=\"quality\" value=\"high\" />");
  1872. sb.Append("\n <param name=\"wmode\" value=\"opaque\" />");
  1873. sb.Append("\n <param name=\"swfversion\" value=\"6.0.65.0\" />");
  1874. sb.Append("\n <param name=\"expressinstall\" value=\"Scripts/expressInstall.swf\" />");
  1875. sb.Append("\n <!-- 浏览器将以下替代内容显示给使用 Flash Player 6.0 和更低版本的用户。 -->");
  1876. sb.Append("\n <div>");
  1877. sb.Append("\n <h4>此页面上的内容需要较新版本的 Adobe Flash Player。</h4>");
  1878. sb.Append("\n <p><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"获取 Adobe Flash Player\" width=\"" + swfWidth + "\" height=\"33\" /></a></p>");
  1879. sb.Append("\n </div>");
  1880. sb.Append("\n <!--[if !IE]>-->");
  1881. sb.Append("\n </object>");
  1882. sb.Append("\n <!--<![endif]-->");
  1883. sb.Append("\n</object>");
  1884. sb.Append("\n<script type=\"text/javascript\">");
  1885. sb.Append("\nswfobject.registerObject(\"FlashID\");");
  1886. sb.Append("\n</script>");
  1887. sb.Append("\n <br></td></tr></table>");
  1888. return sb;
  1889. }
  1890. //一行一行读文本文件的内容
  1891. public string LineReadTxtFile(string Txt_filename)
  1892. {
  1893. StringBuilder sb = new StringBuilder();
  1894. if (!File.Exists(Txt_filename))
  1895. {
  1896. HttpContext.Current.Response.Write("<script>alert('文件" + Txt_filename + "不存在!')</script>");
  1897. }
  1898. else
  1899. {
  1900. StreamReader sr = new StreamReader(Txt_filename, Encoding.GetEncoding("gb2312"));
  1901. //StreamReader sr = File.OpenText(Txt_filename); //这行容易出现乱码,改为上一行即可
  1902. string input;
  1903. int s = 0;
  1904. while ((input = sr.ReadLine()) != null)
  1905. {
  1906. s = s + 1;
  1907. sb.Append(input + "\n");
  1908. //Response.Write(input + "<br>");
  1909. }
  1910. sr.Close();
  1911. }
  1912. return sb.ToString();
  1913. }
  1914. //访问记数:
  1915. public void AddNum(String TableName, String UpdateFieldName, int JS_FieldsOrderNo, int KeyID)
  1916. {
  1917. //OleDbConnection DBConn;
  1918. // OleDbCommand DBUpdate = new OleDbCommand();
  1919. SqlConnection DBConn;
  1920. SqlCommand DBUpdate = new SqlCommand();
  1921. DBConn = new SqlConnection(connectionString);
  1922. DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "=" + (Convert.ToInt32(GetFieldValue(JS_FieldsOrderNo, KeyID, TableName)) + 1) + " Where ID=" + KeyID;
  1923. DBUpdate.Connection = DBConn;
  1924. DBUpdate.Connection.Open();
  1925. DBUpdate.ExecuteNonQuery();
  1926. }
  1927. //浏览更新数据(含上传和修改)
  1928. public StringBuilder UpdateMenuBrowse(string CSSFilename, string TableName, int mPageSize, string SaveFileDir, Boolean bRow)
  1929. {
  1930. // OleDbConnection conn = new OleDbConnection(connectionString);
  1931. SqlConnection conn = new SqlConnection(connectionString);
  1932. //OleDbCommand cmd = new OleDbCommand("", conn);
  1933. SqlCommand cmd = new SqlCommand("", conn);
  1934. int rowIndex = 1;
  1935. int pageId = 1;
  1936. int maxRow = 1;
  1937. int maxPage = 1;
  1938. int pageSize = mPageSize;
  1939. StringBuilder sb = new StringBuilder();
  1940. //确定当前页
  1941. if (HttpContext.Current.Request.QueryString["pageId"] == null)
  1942. {
  1943. pageId = 1;
  1944. }
  1945. else
  1946. {
  1947. pageId = int.Parse(HttpContext.Current.Request.QueryString["pageId"].Trim());
  1948. }
  1949. try
  1950. {
  1951. if (conn.State == ConnectionState.Closed)
  1952. {
  1953. conn.Open();
  1954. }
  1955. // cmd.CommandText = "select count(*) from " + TableName + QueryConditions;//"select count(*) from " + TableName;
  1956. cmd.CommandText = "select count(*) from " + TableName;
  1957. maxRow = (int)cmd.ExecuteScalar();
  1958. maxPage = (maxRow % pageSize > 0) ? (maxRow / pageSize + 1) : (maxRow / pageSize);
  1959. cmd.CommandText = "select * from " + TableName + " order by id"; //+ QueryConditions;
  1960. //OleDbDataReader dr = cmd.ExecuteReader();
  1961. SqlDataReader dr = cmd.ExecuteReader();
  1962. for (int i = 0; i < (pageId - 1) * pageSize; i++)
  1963. {
  1964. dr.Read();
  1965. rowIndex++;
  1966. }
  1967. int by = (pageId > 1) ? (pageId - 1) : 1;
  1968. int by1 = (pageId < maxPage) ? (pageId + 1) : maxPage;
  1969. sb.Append("记录总数为:" + maxRow.ToString() + ";当前页:" + pageId.ToString() + "/" + maxPage.ToString());
  1970. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=1'>第一页</a>]");
  1971. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by.ToString() + "'>上一页</a>]");
  1972. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by1.ToString() + "'>下一页</a>]");
  1973. sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + maxPage.ToString() + "'>最后页</a>]");
  1974. sb.Append("<br />");
  1975. sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  1976. sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  1977. if (bRow == true)
  1978. {
  1979. sb.Append("<tr bgcolor='#99ccff'>");
  1980. for (int j = 0; j <= dr.FieldCount - 1; j++)
  1981. {
  1982. sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</th>");
  1983. }
  1984. for (int i = rowIndex; i < (rowIndex + pageSize); i++)
  1985. {
  1986. if (dr.Read())
  1987. {
  1988. sb.Append("</tr><tr>");
  1989. for (int j = 0; j <= dr.FieldCount - 1; j++)
  1990. {
  1991. if (j == 5 && dr[5].ToString().Length == 0)
  1992. { sb.Append("<td>[<a href =\"Uppic.aspx?KeyF=" + dr[0].ToString() + "&tn=" + TableName + "&FieldN=URL&Dir=" + SaveFileDir + "\" target=\"_blank\">上传文件]</a></td>"); }
  1993. else if (j == 9 && dr[9].ToString().Length == 0)
  1994. { sb.Append("<td>[<a href =\"UpdateFiledValue.aspx?KeyF=" + dr[0].ToString() + "&tn=" + TableName + "&FiledN=sContent\" target=\"_blank\">添加内容</a>]</td>"); }
  1995. else
  1996. {
  1997. sb.Append("<td>" + dr[j].ToString() + "</td>");
  1998. }
  1999. }
  2000. //sb.Append("<hr/>");
  2001. }
  2002. }
  2003. }
  2004. else
  2005. {
  2006. for (int i = rowIndex; i < (rowIndex + pageSize); i++)
  2007. {
  2008. if (dr.Read())
  2009. {
  2010. for (int j = 0; j <= dr.FieldCount - 1; j++)
  2011. {
  2012. sb.Append("<tr>");
  2013. sb.Append("<td>" + dr.GetName(j) + "</td>");
  2014. sb.Append("<td algin=left>" + dr[j].ToString().Replace("\r\n", "<br />") + "</td>");
  2015. //if (dr.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  2016. //{
  2017. // sb.Append("<td><asp:TextBox ID='TextBox1' Text='" + dr[j].ToString() + "' runat='server' Columns='60' Rows='12' TextMode='MultiLine'></asp:TextBox>&nbsp;</td>");
  2018. //}
  2019. //else
  2020. //{ sb.Append("<td><asp:TextBox ID='TextBox1' Text='"+ dr[j].ToString() +"' runat='server' Columns='60'></asp:TextBox>&nbsp;</td>"); }
  2021. sb.Append("</tr>");
  2022. }
  2023. }
  2024. }
  2025. }
  2026. sb.Append("</Table>");
  2027. }
  2028. catch (OleDbException e)
  2029. {
  2030. sb.Append(e.Message.ToString());
  2031. }
  2032. finally
  2033. {
  2034. if (conn.State == ConnectionState.Open)
  2035. {
  2036. conn.Close();
  2037. }
  2038. }
  2039. return sb;
  2040. }
  2041. /// <summary> 上传文件(所有类型,没有限制,以原文件名或者日期为文件名保存) </summary>
  2042. /// <param name="fileupload">WebControls.FileUpload 控件</param>
  2043. /// <param name="Fdir">保存的文件夹</param>
  2044. /// <param name="OldFilenameOrNewFileName">是以原文件名保存还是以日期为文件名保存</param>
  2045. //调用:
  2046. //Literal1.Text = myud.UpfilesPathandToDB(FileUpload1, "upfile", true, "TreeGJK","URL",23).ToString();
  2047. public string UpfilesPathandToDB(System.Web.UI.WebControls.FileUpload fileupload, string Fdir, Boolean OldFilenameOrNewFileName, string TableName, string SaveFieldName, Int32 KeyID)
  2048. {// OldFilenameOrNewFileName 为True 时,以日期为文件名,否则以原文件名
  2049. HttpPostedFile postedfile = fileupload.PostedFile;
  2050. //if (!Directory.Exists(Server.MapPath(".") + "PIC"))
  2051. //{ Directory.CreateDirectory(Server.MapPath(".") + "PIC"); }
  2052. StringBuilder strmsg = new StringBuilder();
  2053. string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
  2054. string UpfileExtension = System.IO.Path.GetExtension(postedfile.FileName);
  2055. string Newfilename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + UpfileExtension;
  2056. if (OldFilenameOrNewFileName == true) { UpFilename = Newfilename; }
  2057. if (postedfile.ContentLength > 0)
  2058. {
  2059. if (TableName.Length > 0 && KeyID > 0)
  2060. { UpdateStringFieldValue(TableName, SaveFieldName, UpFilename.ToString(), KeyID); }
  2061. if (Fdir == "")
  2062. { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + UpFilename); }
  2063. else
  2064. { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + Fdir + "\\" + UpFilename); }
  2065. strmsg.AppendFormat("【文件名:" + UpFilename.ToString() + "】");
  2066. strmsg.AppendFormat("<br>【文件大小:" + postedfile.ContentLength.ToString() + "】");
  2067. strmsg.AppendFormat("<br>【文件类型:" + postedfile.ContentType.ToString() + "】");
  2068. return strmsg.ToString();
  2069. }
  2070. else
  2071. { return "请选择欲上传文件"; }
  2072. }
  2073. //教师成果设置及显示
  2074. public StringBuilder showmenu(string SQL1, string tablename)
  2075. {
  2076. SqlConnection objConn = new SqlConnection(connectionString);
  2077. // OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, objConn);
  2078. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
  2079. DataSet dtSet1 = new DataSet();
  2080. dtCmd1.Fill(dtSet1);
  2081. DataTableReader objreader1 = dtSet1.CreateDataReader();
  2082. int i = 0;
  2083. StringBuilder SB = new StringBuilder();
  2084. SB.Append(" <table width='96%' border='1' align=\"center\" cellspacing='1' bordercolor=\"#C1E7FD\" bgcolor=\"#F4FCFF\">");
  2085. SB.Append("<tr bgcolor=\"#45B5F8\" ><td height='30' align=\"center\"><font color=\"#FF0000\" size=\"4\" face=\"黑体\"><a target=\"_blank\" href=\"SetMyCourse.aspx\">添加我的课程</a></font></td></tr>");
  2086. // SB.Append("<tr bgcolor=\"#E2F2FC\" ><td height='28' width='10%' align=\"center\">序号</td><td width='30%'>课程名称</td><td width='60%'>操作</td></tr>");
  2087. SB.Append(" <tr bgcolor=\"#E2F2FC\" ><td><p>");
  2088. while (objreader1.Read())
  2089. {
  2090. i = i + 1;
  2091. SB.Append(objreader1["courseName"].ToString());
  2092. SB.Append("<a target=\"_blank\" href=\"../SetSOC.aspx?followid=" + objreader1.GetValue(0) + "\">[设置本课程成果]</a>");
  2093. SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader1.GetValue(0) + "\">[删除本课程]</a>");
  2094. SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader1.GetValue(0) + "\">[修改课程]</a></p>");
  2095. //SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader1.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
  2096. OleDbConnection dtConn2 = new OleDbConnection(connectionString);
  2097. OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  2098. // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
  2099. DataSet dtSet2 = new DataSet();
  2100. dtCmd2.Fill(dtSet2);
  2101. DataTableReader objreader2 = dtSet2.CreateDataReader();
  2102. int k = 0;
  2103. while (objreader2.Read())
  2104. {
  2105. k = k + 1;
  2106. SB.Append("<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;成果" + k.ToString() + "." + objreader2["SOCPoint"].ToString() + "(" + objreader2["SOCscore"].ToString() + ")");
  2107. SB.Append("<a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[为本课程设置子成果]</a>");
  2108. SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[删除此项成果]</a>");
  2109. SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader2.GetValue(0) + "\">[修改此成果评分点]</a></p>");
  2110. // SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader2.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
  2111. }
  2112. // SB.Append("<hr>");
  2113. dtConn2.Close();
  2114. }
  2115. SB.Append("\n</td></tr> </table>");
  2116. objConn.Close();
  2117. return SB;
  2118. }
  2119. //学生根据成果上传
  2120. public StringBuilder showCGUpfile(string SQL1, string tablename, Int32 courseID)
  2121. {
  2122. SqlConnection objConn = new SqlConnection(connectionString);
  2123. // SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, dtConn);
  2124. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
  2125. DataSet dtSet1 = new DataSet();
  2126. dtCmd1.Fill(dtSet1);
  2127. DataTableReader objreader1 = dtSet1.CreateDataReader();
  2128. int i = 0;
  2129. StringBuilder SB = new StringBuilder();
  2130. SB.Append(" <table class=\"bordered\" align=\"center\">");
  2131. while (objreader1.Read())
  2132. {
  2133. i = i + 1;
  2134. SB.Append(" <tr><td colspan=6>");
  2135. SB.Append("\n <h2>课程名称:" + objreader1["courseName"].ToString() + "</h2></td></tr>");
  2136. SB.Append(" <tr><td>成果序号</td><td>成果名称</td><td>成果对应学分</td><td>成果权重</td><td>成果描述</td><td>操作</td>");
  2137. // SB.Append(" <tr bgcolor=\"#E2F2FC\"><td>");
  2138. SqlConnection dtConn2 = new SqlConnection(connectionString);
  2139. SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  2140. // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
  2141. DataSet dtSet2 = new DataSet();
  2142. dtCmd2.Fill(dtSet2);
  2143. DataTableReader objreader2 = dtSet2.CreateDataReader();
  2144. int k = 0;
  2145. while (objreader2.Read())
  2146. {
  2147. k = k + 1;
  2148. SB.Append("\n <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[成果" + k.ToString() + "]</td><td>" + objreader2["SOCPoint"].ToString() + "</td><td>(学分:" + objreader2["SOCscore"].ToString() + ")</td><td>" + objreader2["SOCweight"].ToString() + "</td><td>" + objreader2["SOCBeWrite"].ToString() + "</td>");
  2149. SB.Append("<td><a target=\"_blank\" href=\"Upfiles.aspx?CID=" + courseID + "&courseID=" + objreader2["ID"].ToString() + "\">[上传我的成果]</a><br></td></tr>");
  2150. }
  2151. //SB.Append("\n</td></tr>");
  2152. dtConn2.Close();
  2153. }
  2154. SB.Append("\n </table>");
  2155. objConn.Close();
  2156. return SB;
  2157. }
  2158. //显示教师的课程设置及成果设置
  2159. public StringBuilder showmenu1(string SQL1, string tablename)
  2160. {
  2161. SqlConnection objConn = new SqlConnection(connectionString);
  2162. SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
  2163. DataSet dtSet1 = new DataSet();
  2164. dtCmd1.Fill(dtSet1);
  2165. DataTableReader objreader1 = dtSet1.CreateDataReader();
  2166. int i = 0;
  2167. StringBuilder SB = new StringBuilder();
  2168. SB.Append(" <table width='96%' border='1' align=\"center\" cellspacing='1' bordercolor=\"#C1E7FD\" bgcolor=\"#F4FCFF\">");
  2169. SB.Append("<tr bgcolor=\"#45B5F8\" ><td height='30' colspan=\"3\" align=\"center\"><font color=\"#FF0000\" size=\"4\" face=\"黑体\"><a target=\"_blank\" href=\"SetMyCourse.aspx\">添加我的课程</a></font></td></tr>");
  2170. SB.Append("<tr bgcolor=\"#E2F2FC\" ><td height='28' width='10%' align=\"center\">序号</td><td width='30%'>课程名称</td><td width='60%'>操作</td></tr>");
  2171. while (objreader1.Read())
  2172. {
  2173. i = i + 1;
  2174. SB.Append(" <tr bgcolor=\"#E2F2FC\" >");
  2175. SB.Append("<td height='28' align=\"center\">" + i.ToString() + "</td><td>" + objreader1["courseName"].ToString() + "</td>");
  2176. SB.Append("<td><a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader1.GetValue(0) + "\">[添加子成果评分点]</a><br>");
  2177. SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader1.GetValue(0) + "\">[删除此成果评分点]</a><br>");
  2178. SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader1.GetValue(0) + "\">[修改此成果评分点]</a></td>");
  2179. //SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader1.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
  2180. // OleDbConnection dtConn2 = new OleDbConnection(connectionString);
  2181. SqlConnection dtConn2 = new SqlConnection(connectionString);
  2182. //OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  2183. SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  2184. // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
  2185. DataSet dtSet2 = new DataSet();
  2186. dtCmd2.Fill(dtSet2);
  2187. DataTableReader objreader2 = dtSet2.CreateDataReader();
  2188. int k = 0;
  2189. while (objreader2.Read())
  2190. {
  2191. k = k + 1;
  2192. SB.Append("<td height='28' align=\"center\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + k.ToString() + "</td><td>" + objreader2["courseName"].ToString() + "</td>");
  2193. SB.Append("<td><a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[添加子成果评分点]</a><br>");
  2194. SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[删除此成果评分点]</a><br>");
  2195. SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader2.GetValue(0) + "\">[修改此成果评分点]</a></td>");
  2196. // SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader2.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
  2197. // OleDbConnection dtConn3 = new OleDbConnection(connectionString);
  2198. SqlConnection dtConn3 = new SqlConnection(connectionString);
  2199. // OleDbDataAdapter dtCmd3 = new OleDbDataAdapter("select * from TreeGJK where followid=" + objreader2.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
  2200. SqlDataAdapter dtCmd3 = new SqlDataAdapter("select * from TreeGJK where followid=" + objreader2.GetValue(0) + " Order by id asc,followid Asc", dtConn3);
  2201. // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
  2202. DataSet dtSet3 = new DataSet();
  2203. dtCmd3.Fill(dtSet3);
  2204. DataTableReader objreader3 = dtSet3.CreateDataReader();
  2205. int m = 0;
  2206. while (objreader3.Read())
  2207. {
  2208. m = m + 1;
  2209. SB.Append("<td height='28' align=\"center\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + m.ToString() + "</td><td>" + objreader3["courseName"].ToString() + "</td>");
  2210. SB.Append("<td><a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader3.GetValue(0) + "\">[添加子成果评分点]</a><br>");
  2211. SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader3.GetValue(0) + "\">[删除此成果评分点]</a><br>");
  2212. SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader3.GetValue(0) + "\">[修改此成果评分点]</a><br></td>");
  2213. //SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader3.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
  2214. }
  2215. SB.Append("</tr>");
  2216. dtConn3.Close();
  2217. }
  2218. // SB.Append("<hr>");
  2219. dtConn2.Close();
  2220. }
  2221. SB.Append("\n </table>");
  2222. objConn.Close();
  2223. return SB;
  2224. }
  2225. //文章分享功能
  2226. public string Share(int width, int height)
  2227. {
  2228. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  2229. sb.Append("\n <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + width + "px; height: " + height + "px;\">");
  2230. sb.Append("\n <tr>");
  2231. sb.Append("\n <td valign=\"bottom\" align=\"right\" style=\"background-position: center center; background-attachment: fixed; background-repeat: repeat-y\" align=\"center\" >");
  2232. sb.Append("\n <DIV class=\"bshare-custom\">");
  2233. sb.Append("\n <A class=\"bshare-qzone\" title=\"分享到QQ空间\"></A>");
  2234. sb.Append("\n <A class=\"bshare-sinaminiblog\" title=\"分享到新浪微博\"></A>");
  2235. sb.Append("\n <A class=\"bshare-renren\" title=\"分享到人人网\"></A>");
  2236. sb.Append("\n <A class=\"bshare-qqmb\" title=\"分享到腾讯微博\"></A>");
  2237. sb.Append("\n <A class=\"bshare-neteasemb\" title=\"分享到网易微博\"></A>");
  2238. sb.Append("\n <A class=\"bshare-more bshare-more-icon more-style-addthis\" title=\"更多平台\">");
  2239. sb.Append("\n <SPAN class=\"BSHARE_COUNT bshare-share-count\">0</SPAN></DIV>");
  2240. sb.Append("\n <SCRIPT type=\"text/javascript\" charset=\"utf-8\" src=\"js/share/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh\"></SCRIPT>");
  2241. sb.Append("\n <SCRIPT type=text/javascript charset=utf-8 src=\"js/share/bshareC0.js\"></SCRIPT>");
  2242. sb.Append("\n </td><td valign=\"bottom\" align=\"left\">将该文章分享给朋友!</td>");
  2243. sb.Append("\n </tr>");
  2244. sb.Append("\n </table> ");
  2245. return sb.ToString();
  2246. }
  2247. //检查记录是否存在
  2248. public Boolean CheckRecord(string SQL)
  2249. {
  2250. Boolean LoginAccess = false;
  2251. SqlConnection objConn = new SqlConnection(connectionString);
  2252. string searchCmd = SQL;
  2253. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  2254. myCommand.Connection.Open();
  2255. SqlDataReader myReader = myCommand.ExecuteReader();
  2256. if (myReader.Read())
  2257. {
  2258. LoginAccess = true;
  2259. }
  2260. else
  2261. {
  2262. LoginAccess = false;
  2263. }
  2264. myCommand.Connection.Close();
  2265. return LoginAccess;
  2266. }
  2267. //填写上传文件信息
  2268. public void AddUpFilesInfoToDB1(string parasql, string tablename, int followid, string sTitle, string UseExam, string getBody, string isPass)
  2269. { //sTitle 标题 UseExam文件内容说明 getBody提供者 isPass是否推荐
  2270. // OleDbConnection objConn = new OleDbConnection(connectionString);
  2271. SqlConnection objConn = new SqlConnection(connectionString);
  2272. objConn.Open();
  2273. //检测是否为重复添加
  2274. if (CheckRecord("Select * from " + tablename + " where ClassName='" + sTitle + "'"))
  2275. {
  2276. HttpContext.Current.Response.Write("<script>alert('已经有相同的记录,请检查是否为同一个文件,如果不为同一个文件,请更改标题后再添加')</script>");
  2277. HttpContext.Current.Response.Write("<script>history.bakc();</script>");
  2278. }
  2279. else
  2280. {
  2281. string sql = parasql;
  2282. //OleDbDataAdapter objcmd = new OleDbDataAdapter();
  2283. SqlDataAdapter objcmd = new SqlDataAdapter();
  2284. objcmd.SelectCommand = new SqlCommand(sql, objConn);
  2285. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  2286. DataSet ds = new DataSet();
  2287. objcmd.Fill(ds, tablename);
  2288. objConn.Close();
  2289. DataTable dt = ds.Tables[tablename];
  2290. DataRow dtrow = dt.NewRow();
  2291. dtrow["followid"] = followid;
  2292. dtrow["SortNum"] = 1;
  2293. dtrow["ClassName"] = sTitle;
  2294. dtrow["UseExam"] = UseExam;
  2295. dtrow["intro"] = "";
  2296. dtrow["UpdateTime"] = DateTime.Today.ToShortDateString(); ;
  2297. dtrow["getBody"] = getBody;
  2298. dtrow["isPass"] = isPass;
  2299. dtrow["DownNums"] = 1;
  2300. dt.Rows.Add(dtrow);
  2301. objcmd.Update(ds, tablename);
  2302. }
  2303. }
  2304. public void BindFiledRecValueToDropDownList1(DropDownList myDropDownList, string BindFileName, string DispFileName, string TableName)
  2305. {//将字段BindFileName绑定到myDropDownList
  2306. //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
  2307. string SQL = "select " + BindFileName + "," + DispFileName + " from " + TableName;
  2308. SqlConnection objConn = new SqlConnection(connectionString);
  2309. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  2310. DataSet dtSet = new DataSet();
  2311. dtCmd.Fill(dtSet);
  2312. DataTableReader objreader = dtSet.CreateDataReader();
  2313. while (objreader.Read())
  2314. {
  2315. ListItem myit = new ListItem();
  2316. myit.Text = objreader.GetValue(0).ToString();
  2317. myit.Value = objreader.GetValue(1).ToString();
  2318. myDropDownList.Items.Add(myit);
  2319. //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
  2320. //myDropDownList.Items.Add(
  2321. }
  2322. }
  2323. //根据关键字查询后进行绑定
  2324. public void BindFiledRecValueKeyToDropDownList(DropDownList myDropDownList, string BindFileName, string DispFileName, string TableName, string keyword)
  2325. {//将字段BindFileName绑定到myDropDownList
  2326. //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
  2327. string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " LIKE '%" + keyword + "%'";
  2328. SqlConnection objConn = new SqlConnection(connectionString);
  2329. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  2330. DataSet dtSet = new DataSet();
  2331. dtCmd.Fill(dtSet);
  2332. DataTableReader objreader = dtSet.CreateDataReader();
  2333. while (objreader.Read())
  2334. {
  2335. ListItem myit = new ListItem();
  2336. myit.Text = objreader.GetValue(0).ToString();
  2337. myit.Value = objreader.GetValue(1).ToString();
  2338. myDropDownList.Items.Add(myit);
  2339. //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
  2340. //myDropDownList.Items.Add(
  2341. }
  2342. }
  2343. //根据关键字查询后进行绑定
  2344. public void BindFiledRecValueKetToDropDownList(DropDownList myDropDownList, string BindFileName, string TableName, string keyword)
  2345. {//将字段BindFileName绑定到myDropDownList
  2346. string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " LIKE '%" + keyword + "%' and " + BindFileName + " IS NOT NULL";
  2347. //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " IS NOT NULL";
  2348. //string SQL = "select " + BindFileName + "," + DispFileName + " from " + TableName;
  2349. SqlConnection objConn = new SqlConnection(connectionString);
  2350. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  2351. DataSet dtSet = new DataSet();
  2352. dtCmd.Fill(dtSet);
  2353. DataTableReader objreader = dtSet.CreateDataReader();
  2354. while (objreader.Read())
  2355. {
  2356. ListItem myit = new ListItem();
  2357. myit.Text = objreader.GetValue(0).ToString();
  2358. myit.Value = objreader.GetValue(0).ToString();
  2359. myDropDownList.Items.Add(myit);
  2360. //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
  2361. //myDropDownList.Items.Add(
  2362. }
  2363. objConn.Close();
  2364. }
  2365. public void BindFiledRecValueToDropDownList2(DropDownList myDropDownList, string BindFileName, string TableName)
  2366. {//将字段BindFileName绑定到myDropDownList
  2367. string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " IS NOT NULL";
  2368. //string SQL = "select " + BindFileName + "," + DispFileName + " from " + TableName;
  2369. SqlConnection objConn = new SqlConnection(connectionString);
  2370. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  2371. DataSet dtSet = new DataSet();
  2372. dtCmd.Fill(dtSet);
  2373. DataTableReader objreader = dtSet.CreateDataReader();
  2374. while (objreader.Read())
  2375. {
  2376. ListItem myit = new ListItem();
  2377. myit.Text = objreader.GetValue(0).ToString();
  2378. myit.Value = objreader.GetValue(0).ToString();
  2379. myDropDownList.Items.Add(myit);
  2380. //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
  2381. //myDropDownList.Items.Add(
  2382. }
  2383. objConn.Close();
  2384. }
  2385. //文章分享功能
  2386. public string Share1(int width, int height)
  2387. {
  2388. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  2389. sb.Append("\n <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + width + "px; height: " + height + "px;\">");
  2390. sb.Append("\n <tr>");
  2391. sb.Append("\n <td valign=\"bottom\" style=\"background-position: center center; background-attachment: fixed; background-repeat: repeat-y\" align=\"center\" >");
  2392. sb.Append("\n <DIV class=\"bshare-custom\">");
  2393. sb.Append("\n <A class=\"bshare-qzone\" title=\"分享到QQ空间\"></A>");
  2394. sb.Append("\n <A class=\"bshare-sinaminiblog\" title=\"分享到新浪微博\"></A>");
  2395. sb.Append("\n <A class=\"bshare-renren\" title=\"分享到人人网\"></A>");
  2396. sb.Append("\n <A class=\"bshare-qqmb\" title=\"分享到腾讯微博\"></A>");
  2397. sb.Append("\n <A class=\"bshare-neteasemb\" title=\"分享到网易微博\"></A>");
  2398. sb.Append("\n <A class=\"bshare-more bshare-more-icon more-style-addthis\" title=\"更多平台\">");
  2399. sb.Append("\n <SPAN class=\"BSHARE_COUNT bshare-share-count\">0</SPAN></DIV>");
  2400. sb.Append("\n <SCRIPT type=\"text/javascript\" charset=\"utf-8\" src=\"js/share/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh\"></SCRIPT>");
  2401. sb.Append("\n <SCRIPT type=text/javascript charset=utf-8 src=\"js/share/bshareC0.js\"></SCRIPT>");
  2402. sb.Append("\n 将该文章分享给朋友!<br> </td>");
  2403. sb.Append("\n </tr>");
  2404. sb.Append("\n </table> ");
  2405. return sb.ToString();
  2406. }
  2407. //限速下载
  2408. public bool ResponseFile(HttpRequest _Request, HttpResponse _Response, string _fileName, string _fullPath, long _speed)
  2409. {
  2410. try
  2411. {
  2412. FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  2413. BinaryReader br = new BinaryReader(myFile);
  2414. try
  2415. {
  2416. _Response.AddHeader("Accept-Ranges", "bytes");
  2417. _Response.Buffer = false;
  2418. long fileLength = myFile.Length;
  2419. long startBytes = 0;
  2420. int pack = 10240; //10K bytes
  2421. int sleep = (int)Math.Floor((double)(1000 * pack / _speed)) + 1;
  2422. if (_Request.Headers["Range"] != null)
  2423. {
  2424. _Response.StatusCode = 206;
  2425. string[] range = _Request.Headers["Range"].Split(new char[] { '=', '-' });
  2426. startBytes = Convert.ToInt64(range[1]);
  2427. }
  2428. _Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
  2429. if (startBytes != 0)
  2430. {
  2431. _Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength - 1, fileLength));
  2432. }
  2433. _Response.AddHeader("Connection", "Keep-Alive");
  2434. _Response.ContentType = "application/octet-stream";
  2435. _Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_fileName, System.Text.Encoding.UTF8));
  2436. br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
  2437. int maxCount = (int)Math.Floor((double)((fileLength - startBytes) / pack)) + 1;
  2438. for (int i = 0; i < maxCount; i++)
  2439. {
  2440. if (_Response.IsClientConnected)
  2441. {
  2442. _Response.BinaryWrite(br.ReadBytes(pack));
  2443. Thread.Sleep(sleep);
  2444. }
  2445. else
  2446. {
  2447. i = maxCount;
  2448. }
  2449. }
  2450. }
  2451. catch
  2452. {
  2453. return false;
  2454. }
  2455. finally
  2456. {
  2457. br.Close();
  2458. myFile.Close();
  2459. }
  2460. }
  2461. catch
  2462. {
  2463. return false;
  2464. }
  2465. return true;
  2466. }
  2467. //支持任意类型文件下载
  2468. public void FileDownLoadDel(string fullFilename)
  2469. {
  2470. System.IO.Stream iStream = null;
  2471. byte[] buffer = new Byte[10000];
  2472. int length;
  2473. long dataToRead;
  2474. string filepath = fullFilename;
  2475. filepath = HttpContext.Current.Server.MapPath(filepath);
  2476. string filename = System.IO.Path.GetFileName(filepath);
  2477. try
  2478. {
  2479. iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
  2480. System.IO.FileAccess.Read, System.IO.FileShare.Read);
  2481. dataToRead = iStream.Length;
  2482. HttpContext.Current.Response.ContentType = "application/octet-stream";
  2483. HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
  2484. while (dataToRead > 0)
  2485. {
  2486. if (HttpContext.Current.Response.IsClientConnected)
  2487. {
  2488. length = iStream.Read(buffer, 0, 10000);
  2489. HttpContext.Current.Response.OutputStream.Write(buffer, 0, length);
  2490. HttpContext.Current.Response.Flush();
  2491. buffer = new Byte[10000];
  2492. dataToRead = dataToRead - length;
  2493. }
  2494. else
  2495. {
  2496. dataToRead = -1;
  2497. HttpContext.Current.Response.Clear();
  2498. }
  2499. }
  2500. HttpContext.Current.Response.End(); //没有这句会将该页面刷新后的内容追加写入文件中。
  2501. }
  2502. catch (Exception ex)
  2503. {
  2504. HttpContext.Current.Response.Write("Error : " + ex.Message);
  2505. }
  2506. finally
  2507. {
  2508. if (iStream != null)
  2509. {
  2510. iStream.Close();
  2511. }
  2512. File.Delete(fullFilename);
  2513. }
  2514. }
  2515. //显示下载列表,下载链接用ID、表名、下载文件所保存的字段名FileNameFieldName,要显示列表的字段名1DispFiledName1 dispListType显示列表类型Down(下载),PLAY(播放),READ(阅读)
  2516. public StringBuilder DisplayDownList2(string SQL, string tablename, int LeftFiledNameNo, int FileNameFieldNo, string dispListType)
  2517. {//sql="select id,classname,url,date from tablename
  2518. //调用 Literal1.Text = myu.DisplayDownList1("select * from classVideo", "classVideo", 3, 8,5).ToString();
  2519. SqlConnection objConn = new SqlConnection(connectionString);
  2520. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  2521. DataSet dtSet = new DataSet();
  2522. dtCmd.Fill(dtSet);
  2523. DataTableReader objreader = dtSet.CreateDataReader();
  2524. //int i, j;
  2525. StringBuilder sb = new StringBuilder();
  2526. // DateTime dt = new DateTime();
  2527. int k = 0;
  2528. while (objreader.Read())
  2529. {
  2530. k = k + 1;
  2531. sb.Append("<table align=\"center\" style=\"border-bottom-style: dotted; border-bottom-width: 1px; height:32px;border-bottom-color: #ACCEFD; font-size:12px; width: 90%;\">");
  2532. sb.Append("<tr><td width=\"6%\"><img src=\"images/li.gif\" /></td>");
  2533. if (objreader.GetFieldType(LeftFiledNameNo).Name == "DateTime")
  2534. { sb.Append("<td width=\"58%\" align=\"left\" style=\"height:32px;color: #7BA9EE\">" + Convert.ToDateTime(objreader.GetValue(LeftFiledNameNo).ToString()).ToShortDateString().Trim() + "</td>"); }
  2535. else
  2536. { sb.Append("<td width=\"58%\" align=\"left\" >" + objreader.GetValue(LeftFiledNameNo).ToString() + "</td>"); }
  2537. sb.Append("<td align=\"center\" width=\"36%\" style=\"height:32px;color: #7BA9EE\">");
  2538. if (dispListType == "DOWN")
  2539. {
  2540. sb.Append(" <a href=\"Filedown.aspx?FFN=" + FileNameFieldNo.ToString() + "&tn=" + tablename + "&KeyF=" + objreader.GetValue(0).ToString() + "\" target=\"_blank\">[下载]</a>&nbsp;&nbsp;");
  2541. }
  2542. if (dispListType == "DOWN1")
  2543. {
  2544. sb.Append("<a href=\"Upfiles\\" + objreader["URL"] + "\" target=\"_blank\">[下载]</a></li>&nbsp;");
  2545. }
  2546. if (dispListType == "READ")
  2547. {
  2548. sb.Append("<a href=\"Upfiles\\" + objreader["URL"] + "\" target=\"_blank\">[运行效果]<img src=\"images/arr.jpg\" /></a>");
  2549. sb.Append("<a href=\"Filedown.aspx?FFN=5&tn=treeGJK&KeyF=" + objreader["id"].ToString() + "\" title=\"" + objreader["intro"].ToString() + "\" target=\"_blank\">[下载]<img src=\"images/down.jpg\" /></a>");
  2550. string extName = myf.GetExtension(objreader.GetValue(FileNameFieldNo).ToString());
  2551. //HttpContext.Current.Response.Write(extName + " ");
  2552. if (extName.Trim().ToUpper() == "SWF")
  2553. {
  2554. sb.Append(" <a target=\"_blank\" href=\"SWF.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[上机练一练]<img src=\"images/qipao.jpg\" /></a><td>");
  2555. }
  2556. if (extName.Trim().ToUpper() == "HTML" || extName.Trim().ToUpper() == "HTM")
  2557. {
  2558. sb.Append(" <a target=\"_blank\" href=\"SJNX.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[上机练一练]<img src=\"images/qipao.jpg\" /></a><td>");
  2559. }
  2560. if (extName.Trim().ToUpper() == "ASPX")
  2561. {
  2562. sb.Append(" <a target=\"_blank\" href=\"NetSJnx.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[上机练一练]<img src=\"images/qipao.jpg\" /></a><td>");
  2563. }
  2564. }
  2565. if (dispListType == "READ1")
  2566. {
  2567. sb.Append("<a href=\"Upfiles\\" + objreader["URL"] + "\" target=\"_blank\">[查看运行效果]<img src=\"images/arr.jpg\" />&nbsp;</a>&nbsp;");
  2568. sb.Append("<a href=\"Filedown.aspx?FFN=5&tn=treeGJK&KeyF=" + objreader["id"].ToString() + "\" title=\"" + objreader["intro"].ToString() + "\" target=\"_blank\">[下载]<img src=\"images/down.jpg\" />&nbsp;</a>&nbsp;");
  2569. sb.Append(" <a target=\"_blank\" href=\"ShowFileContent.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[查看源代码]<img src=\"images/qipao.jpg\" />&nbsp;</a><td>");
  2570. }
  2571. if (dispListType == "PLAY")
  2572. {
  2573. sb.Append(" <a href=\"RMPlay.aspx??FFN=" + FileNameFieldNo.ToString() + "&tn=" + tablename + "&KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[播放视频]\">[在线播放]</a><td>");
  2574. }
  2575. if (dispListType == "EDIT")
  2576. {
  2577. sb.Append(" <a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><td>");
  2578. }
  2579. sb.Append("</tr></table>");
  2580. }
  2581. return sb;
  2582. }
  2583. public StringBuilder ShowNewTitle(string sSQL, string DsipFieldName)
  2584. {//页标题,样式表,表名,显示新闻数,是否显示日期,标题字数,新闻类型审核通过字段,对齐方式 NewsNumber=0 显示所有
  2585. //公告类别:项目信息xmxx;学校信息xxxx;企业信息qyxx;项目安排信息xmzz,相关新闻sNew TitleFieldNo标题字段序号 sType:消息XX、构件GJ、其它OTHER
  2586. string SQL = sSQL;
  2587. SqlConnection objConn = new SqlConnection(connectionString);
  2588. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  2589. DataSet dtSet = new DataSet();
  2590. dtCmd.Fill(dtSet);
  2591. DataTableReader objreader = dtSet.CreateDataReader();
  2592. // int i = 0;
  2593. StringBuilder SB = new StringBuilder();
  2594. string TitltID = "";
  2595. while (objreader.Read())
  2596. {
  2597. TitltID = objreader.GetValue(0).ToString();
  2598. string TitleContent = objreader[DsipFieldName].ToString();
  2599. SB.Append("<li><a href=\"?id=" + TitltID + "\" Title=\"" + objreader[DsipFieldName].ToString() + "\">" + objreader[DsipFieldName].ToString() + "</a><span class=\"post-date\">" + "</span></li>");
  2600. }
  2601. return SB;
  2602. }
  2603. public int GetWeekOfYear(DateTime dt)
  2604. {
  2605. CultureInfo ci = CultureInfo.CurrentCulture;
  2606. System.Globalization.Calendar cal = ci.Calendar;
  2607. CalendarWeekRule cwr = ci.DateTimeFormat.CalendarWeekRule;
  2608. DayOfWeek dow = ci.DateTimeFormat.FirstDayOfWeek;
  2609. return cal.GetWeekOfYear(dt, cwr, dow);
  2610. }
  2611. public int CurrentWeek(string StartTime) {
  2612. string startTime = StartTime; //起始时间
  2613. int StartWeek, CurrentWeek = 0;
  2614. StartWeek = GetWeekOfYear(DateTime.Parse(startTime)); //起始周
  2615. CurrentWeek = GetWeekOfYear(DateTime.Now) + 1; //当前周
  2616. // string myweek = "第" + (CurrentWeek - StartWeek) + "周";
  2617. return CurrentWeek - StartWeek;
  2618. }
  2619. public Boolean check_QM(string tableName, string XHFieldName, string XHFieldValue, string ZJFieldName, string ZJFieldValue)
  2620. {
  2621. Boolean LoginAccess = false;
  2622. //一般教师登录检查
  2623. // OleDbConnection objConn = new OleDbConnection(connectionString);
  2624. SqlConnection objConn = new SqlConnection(connectionString);
  2625. string searchCmd = "select * from " + tableName + " where " + XHFieldName + " = '" + XHFieldValue + "' and " + ZJFieldName + "='" + ZJFieldValue + "'";
  2626. //OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  2627. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  2628. myCommand.Connection.Open();
  2629. // OleDbDataReader myReader = myCommand.ExecuteReader();
  2630. SqlDataReader myReader = myCommand.ExecuteReader();
  2631. if (myReader.Read())
  2632. {
  2633. HttpContext.Current.Session["DisplayMsg"] = "今天已经签名!";
  2634. LoginAccess = true;
  2635. }
  2636. else
  2637. {
  2638. HttpContext.Current.Session["DisplayMsg"] = "今天没有签名";
  2639. LoginAccess = false;
  2640. }
  2641. myCommand.Connection.Close();
  2642. return LoginAccess;
  2643. }
  2644. public Boolean check_TeacherLogin(string tableName, string m_teacherName, string m_userName, string m_Password)
  2645. {
  2646. Boolean LoginAccess = false;
  2647. //一般教师登录检查
  2648. // OleDbConnection objConn = new OleDbConnection(connectionString);
  2649. SqlConnection objConn = new SqlConnection(connectionString);
  2650. string searchCmd = "select * from " + tableName + " where 姓名='" + m_teacherName + "' and 用户名='" + m_userName + "' and 密码='" + m_Password + "'";
  2651. //string searchCmd = "select * from " + tableName + " where 用户名='" + m_userName + "' and 密码='" + m_Password + "'";
  2652. //HttpContext.Current.Response.Write(searchCmd);
  2653. //HttpContext.Current.Response.End();
  2654. // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  2655. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  2656. myCommand.Connection.Open();
  2657. // OleDbDataReader myReader = myCommand.ExecuteReader();
  2658. SqlDataReader myReader = myCommand.ExecuteReader();
  2659. if (myReader.Read())
  2660. {
  2661. HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
  2662. LoginAccess = true;
  2663. }
  2664. else
  2665. {
  2666. HttpContext.Current.Session["DisplayMsg"] = "登录失败";
  2667. LoginAccess = false;
  2668. }
  2669. myCommand.Connection.Close();
  2670. return LoginAccess;
  2671. }
  2672. public Boolean check_Adminlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
  2673. {
  2674. Boolean LoginAccess = false;
  2675. //管理员登录检查
  2676. // OleDbConnection objConn = new OleDbConnection(connectionString);
  2677. SqlConnection objConn = new SqlConnection(connectionString);
  2678. string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
  2679. // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
  2680. SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
  2681. myCommand.Connection.Open();
  2682. // OleDbDataReader myReader = myCommand.ExecuteReader();
  2683. SqlDataReader myReader = myCommand.ExecuteReader();
  2684. if (myReader.Read())
  2685. {
  2686. HttpContext.Current.Session["用户名"] = myReader.GetValue(4);
  2687. HttpContext.Current.Session["密码"] = myReader.GetValue(5);
  2688. HttpContext.Current.Session["类型"] = myReader.GetValue(6);
  2689. HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
  2690. }
  2691. else
  2692. {
  2693. HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
  2694. LoginAccess = false;
  2695. }
  2696. myCommand.Connection.Close();
  2697. return LoginAccess;
  2698. }
  2699. public void UpdateUserPassword(String TableName, String NewPassword, String UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
  2700. {
  2701. //OleDbConnection DBConn;
  2702. SqlConnection DBConn;
  2703. //OleDbCommand DBUpdate = new OleDbCommand();
  2704. SqlCommand DBUpdate = new SqlCommand();
  2705. DBConn = new SqlConnection(connectionString);
  2706. DBUpdate.CommandText = "Update " + TableName + " Set " + PasswordFieldName + "='" + NewPassword + "' Where " + UserNameFieldName + "='" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
  2707. DBUpdate.Connection = DBConn;
  2708. DBUpdate.Connection.Open();
  2709. DBUpdate.ExecuteNonQuery();
  2710. }
  2711. public void UpdateStringFieldValue(String TableName, String UpdateFieldName, String UpdateFieldValue, int IDvalue)
  2712. {
  2713. SqlConnection DBConn;
  2714. SqlCommand DBUpdate = new SqlCommand();
  2715. DBConn = new SqlConnection(connectionString);
  2716. DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "='" + UpdateFieldValue + "' Where ID=" + IDvalue;
  2717. DBUpdate.Connection = DBConn;
  2718. DBUpdate.Connection.Open();
  2719. DBUpdate.ExecuteNonQuery();
  2720. DBConn.Close();
  2721. }
  2722. public void UpdateDateFieldValue(String TableName, String UpdateFieldName, String UpdateFieldValue, int IDvalue)
  2723. {
  2724. SqlConnection DBConn;
  2725. SqlCommand DBUpdate = new SqlCommand();
  2726. DBConn = new SqlConnection(connectionString);
  2727. DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "='#" + UpdateFieldValue + "#' Where ID=" + IDvalue;
  2728. DBUpdate.Connection = DBConn;
  2729. DBUpdate.Connection.Open();
  2730. DBUpdate.ExecuteNonQuery();
  2731. DBConn.Close();
  2732. }
  2733. public void UpdateNumberFieldValue(String TableName, String UpdateFieldName, String UpdateFieldValue, int IDvalue)
  2734. {
  2735. SqlConnection DBConn;
  2736. SqlCommand DBUpdate = new SqlCommand();
  2737. DBConn = new SqlConnection(connectionString);
  2738. DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "=" + UpdateFieldValue + " Where ID=" + IDvalue;
  2739. DBUpdate.Connection = DBConn;
  2740. DBUpdate.Connection.Open();
  2741. DBUpdate.ExecuteNonQuery();
  2742. }
  2743. public StringBuilder RowDisplayData1(string CSSFilename, string SQL, string PageTitleStr)
  2744. {
  2745. int sum;
  2746. SqlConnection objConn = new SqlConnection(connectionString);
  2747. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  2748. DataSet dtSet = new DataSet();
  2749. dtCmd.Fill(dtSet);
  2750. DataTableReader objreader = dtSet.CreateDataReader();
  2751. int i;
  2752. StringBuilder sb = new StringBuilder();
  2753. sb.Append("<div align=center style='font-size: 12px; color: slateblue'><center ><h4>" + PageTitleStr + "</h4></center>");
  2754. sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  2755. sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  2756. sb.Append("<tr bgcolor='#99ccff'>");
  2757. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2758. {
  2759. sb.Append("<th nowrap=nowrap>" + objreader.GetName(i) + "</Th>");
  2760. }
  2761. sb.Append("<th nowrap=nowrap>缺课统计</Th>");
  2762. sb.Append("</tr>");
  2763. while (objreader.Read())
  2764. {
  2765. sb.Append("<tr>");
  2766. sum = 0;
  2767. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2768. {
  2769. // Response.Write("<td nowrap='nowrap'>" + objreader.GetValue(i) + "</TD>");
  2770. if (objreader.GetValue(i).ToString().Length == 0)
  2771. { sum = sum + 1; }
  2772. sb.Append("<td align=center>" + objreader.GetValue(i) + "</TD>");
  2773. }
  2774. sb.Append("<td align=center>" + sum.ToString() + "</TD>");
  2775. sb.Append("</tr>");
  2776. }
  2777. sb.Append("</table></div>");
  2778. return sb;
  2779. }
  2780. public void RowDisplayData(string CSSFilename, Boolean isDisplayTitile, string AddDispTitle, string AddDispContent, string SQL, string PageTitleStr)
  2781. {
  2782. // OleDbConnection dtConn = new OleDbConnection(connectionString);
  2783. SqlConnection objConn = new SqlConnection(connectionString);
  2784. // OleDbDataAdapter dtCmd= new OleDbDataAdapter(SQL, objConn);
  2785. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  2786. DataSet dtSet = new DataSet();
  2787. dtCmd.Fill(dtSet);
  2788. DataTableReader objreader = dtSet.CreateDataReader();
  2789. int i;
  2790. System.Web.HttpContext.Current.Response.Write("<div align=center style='font-size: 12px; color: slateblue'><center ><h4>" + PageTitleStr + "</h4></center>");
  2791. System.Web.HttpContext.Current.Response.Write("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  2792. System.Web.HttpContext.Current.Response.Write("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  2793. System.Web.HttpContext.Current.Response.Write("<tr bgcolor='#99ccff'>");
  2794. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2795. {
  2796. System.Web.HttpContext.Current.Response.Write("<th nowrap=nowrap>" + objreader.GetName(i) + "</Th>");
  2797. }
  2798. if (isDisplayTitile)
  2799. { System.Web.HttpContext.Current.Response.Write(AddDispTitle); }
  2800. System.Web.HttpContext.Current.Response.Write("</tr>");
  2801. while (objreader.Read())
  2802. {
  2803. System.Web.HttpContext.Current.Response.Write("<tr>");
  2804. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2805. {
  2806. // Response.Write("<td nowrap='nowrap'>" + objreader.GetValue(i) + "</TD>");
  2807. System.Web.HttpContext.Current.Response.Write("<td align=center>" + objreader.GetValue(i) + "</TD>");
  2808. }
  2809. if (isDisplayTitile)
  2810. {
  2811. System.Web.HttpContext.Current.Response.Write(AddDispContent);
  2812. }
  2813. System.Web.HttpContext.Current.Response.Write("</tr>");
  2814. }
  2815. System.Web.HttpContext.Current.Response.Write("</table></div>");
  2816. }
  2817. public StringBuilder dispTableData(string CSSFilename, string SQL, string PageTitleStr)
  2818. {
  2819. SqlConnection objConn = new SqlConnection(connectionString);
  2820. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  2821. DataSet dtSet = new DataSet();
  2822. DataTableReader objreader = dtSet.CreateDataReader();
  2823. int i;
  2824. while (objreader.Read())
  2825. {
  2826. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2827. {
  2828. HttpContext.Current.Session.Add(objreader.GetName(i), objreader.GetValue(i));
  2829. }
  2830. }
  2831. StringBuilder SB = new StringBuilder();
  2832. SB.Append("<div align=center style='font-size: 12px; color: slateblue'><center ><h4>" + PageTitleStr + "</h4></center>");
  2833. SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  2834. SB.Append("<table width='640' height='712' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#D0EBFD' bgcolor='#EFF7FE' >");
  2835. SB.Append("<tr>");
  2836. SB.Append("<td width='104' height='30' valign='middle'>姓  名</td>");
  2837. SB.Append("<td width='120' valign='middle'>" + HttpContext.Current.Session["姓名"] + "&nbsp;</td>");
  2838. SB.Append("<td width='77' valign='middle'>性  别 </td>");
  2839. SB.Append("<td width='84' valign='middle'>" + HttpContext.Current.Session["性别"] + "&nbsp;</td>");
  2840. if (HttpContext.Current.Session["个人照片"].ToString().Length == 0)
  2841. { SB.Append("<td width='121' rowspan='7' align='center' valign='middle'><a href='UpFileAndToDB.aspx?Dir=PICFiles&amp;FF=jhcasdkjdkwie4i23i43&amp;KeyF=" + HttpContext.Current.Session["ID"] + "' target='_blank'>还没有照片<br />上传照片</a></td>"); }
  2842. else
  2843. { SB.Append("<td rowspan='7' align='center' valign='middle' nowrap='nowrap'>&nbsp<img src='PICFiles/" + HttpContext.Current.Session["个人照片"].ToString() + "' width='120' height='160' /></td>"); }
  2844. SB.Append("</tr>");
  2845. SB.Append("<tr valign='middle'>");
  2846. SB.Append("<td width='104' height='34'><p align='center'>出生年月 </p></td>");
  2847. if (HttpContext.Current.Session["出生年月"].ToString().Length > 0)
  2848. { SB.Append("<td width='120'><p align='center'>&nbsp;" + Convert.ToDateTime(HttpContext.Current.Session["出生年月"]).ToLongDateString() + "</p></td>"); }
  2849. else
  2850. { SB.Append("<td width='120'><p align='center'>&nbsp;" + HttpContext.Current.Session["出生年月"] + "</p></td>"); }
  2851. SB.Append("<td width='77'><p align='center'>籍贯 </p></td>");
  2852. SB.Append("<td width='84'><p align='center'>&nbsp;" + HttpContext.Current.Session["籍贯"] + "</p></td>");
  2853. SB.Append("</tr>");
  2854. SB.Append("<tr valign='middle'>");
  2855. SB.Append("<td width='104' height='27'><p align='center'>政治面貌</p></td>");
  2856. SB.Append("<td width='120'><p align='center'>&nbsp;" + HttpContext.Current.Session["政治面貌"] + "</p></td>");
  2857. SB.Append("<td width='77'><p align='center'>学  位 </p></td>");
  2858. SB.Append("<td width='84' align='center'>" + HttpContext.Current.Session["学位"] + "&nbsp;</td>");
  2859. SB.Append("</tr>");
  2860. SB.Append("<tr valign='middle'>");
  2861. SB.Append("<td width='104' height='23'><p align='center'>学历</p></td>");
  2862. SB.Append("<td width='120'><p align='center'>" + HttpContext.Current.Session["学历"] + "&nbsp;</p></td>");
  2863. SB.Append("<td width='77'><p align='center'>联系电话 </p></td>");
  2864. SB.Append("<td width='84' align='center'>&nbsp;" + HttpContext.Current.Session["联系电话"] + "&nbsp;</td>");
  2865. SB.Append("</tr>");
  2866. SB.Append("<tr valign='middle'>");
  2867. SB.Append("<td width='104' height='27'><p align='center'>专业</p></td>");
  2868. SB.Append("<td align='center'>" + HttpContext.Current.Session["专业"] + "&nbsp;</td>");
  2869. SB.Append("<td align='center'>毕业时间 </td>");
  2870. if (HttpContext.Current.Session["毕业时间"].ToString().Length > 0)
  2871. { SB.Append("<td align='center'>" + Convert.ToDateTime(HttpContext.Current.Session["毕业时间"]).ToLongDateString() + "&nbsp;</td>"); }
  2872. else
  2873. { SB.Append("<td align='center'>" + HttpContext.Current.Session["毕业时间"] + "&nbsp;</td>"); }
  2874. SB.Append("</tr>");
  2875. SB.Append("<tr valign='middle'>");
  2876. SB.Append("<td width='104' height='31'><p align='center'>毕业院校 </p></td>");
  2877. SB.Append("<td colspan='3'><p align='center'>" + HttpContext.Current.Session["毕业院校"] + "&nbsp;</p></td>");
  2878. SB.Append("</tr>");
  2879. SB.Append("<tr valign='middle'>");
  2880. SB.Append("<td width='104' height='32'><p align='center'>专业技术资格 </p></td>");
  2881. SB.Append("<td colspan='3'><p align='center'>&nbsp;</p></td>");
  2882. SB.Append("</tr>");
  2883. SB.Append("<tr valign='middle'>");
  2884. SB.Append("<td width='104'><p align='center'>身份证号 </p></td>");
  2885. SB.Append("<td height='32'><p align='center'>" + HttpContext.Current.Session["身份证号"] + "&nbsp;</p></td>");
  2886. SB.Append("<td>双师素质:" + HttpContext.Current.Session["双师素质"] + "&nbsp;</td>");
  2887. SB.Append("<td>专任教师:" + HttpContext.Current.Session["专任教师"] + "&nbsp;</td>");
  2888. SB.Append("<td>教师资格:" + HttpContext.Current.Session["教师资格"] + "&nbsp;</td>");
  2889. SB.Append("</tr>");
  2890. SB.Append("<tr valign='middle'>");
  2891. SB.Append("<td width='104' height='35' nowrap='nowrap'><p align='center'>通讯地址 </p></td>");
  2892. SB.Append("<td colspan='4'><p align='center'>" + HttpContext.Current.Session["通讯地址"] + "&nbsp;</p></td>");
  2893. SB.Append("</tr>");
  2894. SB.Append("<tr>");
  2895. SB.Append("<td width='104' valign='top'><p align='center'>工</p>");
  2896. SB.Append("<p align='center'>作</p>");
  2897. SB.Append("<p align='center'>经</p>");
  2898. SB.Append("<p align='center'>历 </p></td>");
  2899. SB.Append("<td height='441' colspan='4' valign='top'><p align='left'><strong>工作简历(含在行业、企业的工作经历和当时从事工作的专业领域及所负责任) </strong></a></p> " + HttpContext.Current.Session["个人简历"] + "</td>");
  2900. SB.Append("</tr>");
  2901. SB.Append("</tr>");
  2902. SB.Append("</table></div>");
  2903. return SB;
  2904. }
  2905. public StringBuilder dispCharData(string CSSFilename, Boolean isDisplayTitile, string AddDispTitle, string AddDispContent, string SQL, string PageTitleStr, Boolean DispDataProcessing, int ProcessingType)
  2906. {
  2907. //ProcessingType 1,2,3,4 详细,添加,修改,删除
  2908. string Procchar = "";
  2909. string ProgFilename = "";
  2910. switch (ProcessingType)
  2911. {
  2912. case 1: { Procchar = "详细"; ProgFilename = "DisplayJBXX.aspx"; } break;
  2913. case 2: { Procchar = "添加"; ProgFilename = "AddData.aspx"; } break;
  2914. case 3: { Procchar = "修改"; ProgFilename = "UpdateData.aspx"; } break;
  2915. case 4: { Procchar = "删除"; ProgFilename = "DeleteData.aspx"; } break;
  2916. case 5: { Procchar = "批改作业"; ProgFilename = "UpdateData.aspx"; } break;
  2917. }
  2918. SqlConnection objConn = new SqlConnection(connectionString);
  2919. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  2920. DataSet dtSet = new DataSet();
  2921. dtCmd.Fill(dtSet);
  2922. DataTableReader objreader = dtSet.CreateDataReader();
  2923. int i;
  2924. StringBuilder SB = new StringBuilder();
  2925. SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  2926. SB.Append("<div align=center style='font-size: 12px; color: #063E7B'><center ><h4>" + PageTitleStr + "</h4></center>");
  2927. SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  2928. SB.Append("<tr bgcolor='#DCECF5'>");
  2929. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2930. {
  2931. SB.Append("<th nowrap='nowrap'>" + objreader.GetName(i) + "</Th>");
  2932. }
  2933. if (DispDataProcessing)
  2934. { SB.Append("<th nowrap='nowrap'>数据处理</Th>"); }
  2935. if (isDisplayTitile)
  2936. { SB.Append(AddDispTitle); }
  2937. SB.Append("</tr>");
  2938. while (objreader.Read())
  2939. {
  2940. SB.Append("<tr>");
  2941. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2942. {
  2943. // Response.Write("<td nowrap='nowrap'>" + objreader.GetValue(i) + "</TD>");
  2944. SB.Append("<td align=center>" + objreader.GetValue(i) + "</TD>");
  2945. }
  2946. if (DispDataProcessing)
  2947. { SB.Append("<td align=center><a href='" + ProgFilename + "?KeyF=" + objreader.GetValue(0).ToString() + "&ProcessingType=" + ProcessingType + "' target=_blank>" + Procchar + "</a></TD>"); }
  2948. if (isDisplayTitile)
  2949. {
  2950. SB.Append(AddDispContent);
  2951. }
  2952. SB.Append("</tr>");
  2953. }
  2954. SB.Append("</table></div>");
  2955. return SB;
  2956. }
  2957. public StringBuilder dispCharZY(string CSSFilename, Boolean isDisplayTitile, string AddDispTitle, string AddDispContent, string SQL)
  2958. {
  2959. SqlConnection objConn = new SqlConnection(connectionString);
  2960. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
  2961. DataSet dtSet = new DataSet();
  2962. dtCmd.Fill(dtSet);
  2963. DataTableReader objreader = dtSet.CreateDataReader();
  2964. int i;
  2965. StringBuilder SB = new StringBuilder();
  2966. SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  2967. SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  2968. SB.Append("<tr bgcolor='#DCECF5'>");
  2969. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2970. {
  2971. SB.Append("<th nowrap='nowrap'>" + objreader.GetName(i) + "</Th>");
  2972. }
  2973. SB.Append("</tr>");
  2974. while (objreader.Read())
  2975. {
  2976. SB.Append("<tr>");
  2977. for (i = 0; i <= objreader.FieldCount - 1; i++)
  2978. {
  2979. if (objreader.GetName(i) == "文件名")
  2980. {
  2981. SB.Append("<td align=center>" + objreader.GetValue(i) + "&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;<a href='UPFilesZY/" + objreader.GetValue(3).ToString() + objreader.GetValue(1).ToString() + objreader.GetValue(2).ToString() + "\\" + objreader.GetValue(i) + "'title='" + objreader.GetValue(i) + "' target=_blank>单击查阅作业</a>]");
  2982. SB.Append("&nbsp;[<a href='UpdateWJZYFS.aspx?KeyF=" + objreader.GetValue(0).ToString() + "' target=_blank>给分数</a>]</TD>");
  2983. }
  2984. else
  2985. {
  2986. SB.Append("<td align=center>" + objreader.GetValue(i) + "</TD>");
  2987. }
  2988. }
  2989. SB.Append("</tr>");
  2990. }
  2991. SB.Append("</table></div>");
  2992. return SB;
  2993. }
  2994. public string GetAddressUrl()
  2995. {
  2996. string GetUrl = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + HttpContext.Current.Request.ServerVariables["URL"];
  2997. if (HttpContext.Current.Request.ServerVariables["QUERY_STRING"] != "")
  2998. { GetUrl = GetUrl + "?" + HttpContext.Current.Request.ServerVariables["QUERY_STRING"]; }
  2999. return GetUrl;
  3000. }
  3001. public string GetSpace(int StringLanght, string getChr)
  3002. {
  3003. int i;
  3004. String TempStr = getChr;
  3005. if (getChr.Length < StringLanght)
  3006. {
  3007. for (i = 1; i <= (StringLanght - getChr.Length); i++)
  3008. { TempStr += "&nbsp;&nbsp;&nbsp;&nbsp;"; }
  3009. }
  3010. return TempStr;
  3011. }
  3012. public Panel BuildModifyForm(Panel PanelcontrolName, string SQLStr, int FieldMaxLenght)
  3013. {
  3014. //定义变量和控件数组
  3015. Panel mypanel = new Panel();
  3016. int i, FieldNum;
  3017. TextBox[] MyText = new TextBox[30];
  3018. Label[] MyLabel = new Label[30];
  3019. //连接并打开数据库
  3020. // OleDbConnection objConn = new OleDbConnection();
  3021. SqlConnection objConn = new SqlConnection();
  3022. StringBuilder sQueryStringValues = new StringBuilder();
  3023. objConn.ConnectionString = connectionString;
  3024. objConn.Open();
  3025. //创建DataReader对象(COMMAND)
  3026. // OleDbCommand objcmd = new OleDbCommand();
  3027. SqlCommand objcmd = new SqlCommand();
  3028. objcmd.Connection = objConn;
  3029. objcmd.CommandText = SQLStr;
  3030. // OleDbDataReader objreader = objcmd.ExecuteReader();
  3031. SqlDataReader objreader = objcmd.ExecuteReader();
  3032. //读取并显示数据库
  3033. objreader.Read();
  3034. String TypeN, dispC;
  3035. FieldNum = objreader.FieldCount;
  3036. for (i = 1; i <= FieldNum - 1; i++)
  3037. {
  3038. string FV = objreader.GetValue(i).ToString();
  3039. //objreader.GetDataTypeName
  3040. TypeN = objreader.GetFieldType(i).Name;
  3041. switch (TypeN)
  3042. {
  3043. case "String":
  3044. dispC = "输文字";
  3045. break;
  3046. case "DateTime":
  3047. dispC = Convert.ToString(DateTime.Now);
  3048. break;
  3049. case "Boolean":
  3050. dispC = "1 or 0[是为1,否为0]";
  3051. break;
  3052. default:
  3053. dispC = "12";
  3054. break;
  3055. }
  3056. if (FV.Trim().Length == 0) { FV = dispC; }
  3057. MyLabel[i] = new Label();
  3058. MyLabel[i].ID = "MyLabel" + Convert.ToString(i);
  3059. MyLabel[i].Text = "<BR>";
  3060. MyLabel[i].Text = MyLabel[i].Text + GetSpace(FieldMaxLenght, objreader.GetName(i));
  3061. mypanel.Controls.Add(MyLabel[i]);
  3062. MyText[i] = new TextBox();
  3063. MyText[i].ID = "MyText" + Convert.ToString(i);
  3064. MyText[i].Text = FV;
  3065. MyText[i].Columns = 72;
  3066. if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  3067. {
  3068. MyText[i].TextMode = TextBoxMode.MultiLine;
  3069. MyText[i].Rows = 4;
  3070. MyText[i].Columns = 48;
  3071. }
  3072. mypanel.Controls.Add(MyText[i]);
  3073. }
  3074. MyLabel[i + 1] = new Label();
  3075. MyLabel[i + 1].ID = "AAA";
  3076. MyLabel[i + 1].Text = "<br><br> ";
  3077. mypanel.Controls.Add(MyLabel[i + 1]);
  3078. objreader.Close();
  3079. objConn.Close();
  3080. PanelcontrolName.Controls.Add(mypanel);
  3081. return PanelcontrolName;
  3082. }
  3083. //根据数据库,动态生成表格表单
  3084. public string BuildModifyFormTable(string SQLStr)
  3085. {
  3086. //定义变量和控件数组
  3087. Panel mypanel = new Panel();
  3088. int i, FieldNum;
  3089. TextBox[] MyText = new TextBox[30];
  3090. Label[] MyLabel = new Label[30];
  3091. //连接并打开数据库
  3092. //OleDbConnection objConn = new OleDbConnection();
  3093. SqlConnection objConn = new SqlConnection();
  3094. StringBuilder sb = new StringBuilder();
  3095. objConn.ConnectionString = connectionString;
  3096. objConn.Open();
  3097. //创建DataReader对象(COMMAND)
  3098. SqlCommand objcmd = new SqlCommand();
  3099. objcmd.Connection = objConn;
  3100. objcmd.CommandText = SQLStr;
  3101. SqlDataReader objreader = objcmd.ExecuteReader();
  3102. //读取并显示数据库
  3103. objreader.Read();
  3104. FieldNum = objreader.FieldCount;
  3105. sb.Append("<table width='96%' border='1' align=\"center\" cellspacing='0' bordercolor=\"#C1E7FD\" bgcolor=\"#F4FCFF\">");
  3106. for (i = 1; i <= FieldNum - 1; i++)
  3107. {
  3108. string FV = objreader.GetValue(i).ToString();
  3109. //objreader.GetDataTypeName
  3110. sb.Append("<tr bgcolor=\"#E2F2FC\">");
  3111. sb.Append("<td height='30' width=\"200\" align='center' valign='middle'>" + objreader.GetName(i) + ":</td>");
  3112. if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  3113. {
  3114. sb.Append(" <td width=\"396\" CssClass=\"Input3\" align='left' valign='middle'><textarea id='Text" + i.ToString() + "' name='Text" + i.ToString() + "' cols=\"72\" rows=\"6\">" + FV + "</textarea></td>");
  3115. }
  3116. else
  3117. { sb.Append(" <td width=\"396\" align='left' CssClass=\"Input3\" valign='middle'> <input id='Text" + i.ToString() + "' name='Text" + i.ToString() + "' type=\"text\" style=\"width: 390px;height:30px;\" value=\"" + FV + "\" runat=\"server\" CssClass=\"Input3\"></td>"); }
  3118. sb.Append("</tr>");
  3119. }
  3120. sb.Append("</table>");
  3121. objreader.Close();
  3122. objConn.Close();
  3123. return sb.ToString();
  3124. }
  3125. public void BuildModifyFormTableToDB(string parasql, string tablename)
  3126. {
  3127. //OleDbDataAdapter objcmd = ExecuteDataAdapter(parasql, CommandType.Text, null);
  3128. SqlDataAdapter objcmd = ExecuteDataAdapter(parasql, CommandType.Text, null);
  3129. // OleDbCommandBuilder objtable = new OleDbCommandBuilder(objcmd);
  3130. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  3131. DataSet ds = new DataSet();
  3132. //string tablename = "table";
  3133. objcmd.Fill(ds, tablename);
  3134. DataTable dt = ds.Tables[tablename];
  3135. int i, k = 0;
  3136. for (i = 1; i < HttpContext.Current.Request.Form.Count - 1; i++)
  3137. {
  3138. string name = HttpContext.Current.Request.Form.GetKey(i);
  3139. if (name.IndexOf("Text") > 0)
  3140. {
  3141. k = k + 1;
  3142. dt.Rows[0][k] = HttpContext.Current.Request.Form[i];
  3143. }
  3144. }
  3145. objcmd.Update(ds, tablename);
  3146. }
  3147. public void ModifyToDB(string parasql, string tablename)
  3148. {
  3149. SqlDataAdapter objcmd = ExecuteDataAdapter(parasql, CommandType.Text, null);
  3150. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  3151. DataSet ds = new DataSet();
  3152. //string tablename = "table";
  3153. objcmd.Fill(ds, tablename);
  3154. DataTable dt = ds.Tables[tablename];
  3155. int i, k = 0;
  3156. for (i = 1; i < HttpContext.Current.Request.Form.Count - 2; i++)
  3157. {
  3158. string name = HttpContext.Current.Request.Form.GetKey(i);
  3159. if (name.IndexOf("Text") > 0)
  3160. {
  3161. k = k + 1;
  3162. dt.Rows[0][k] = HttpContext.Current.Request.Form[i];
  3163. }
  3164. }
  3165. objcmd.Update(ds, tablename);
  3166. }
  3167. public SqlDataAdapter ExecuteDataAdapter(string sql, CommandType commandType, SqlParameter[] parameters)
  3168. {
  3169. DataTable data = new DataTable();//实例化DataTable,用于装载查询结果集
  3170. SqlDataAdapter adapter;
  3171. SqlConnection connection = new SqlConnection(connectionString);
  3172. using (SqlCommand command = new SqlCommand(sql, connection))
  3173. {
  3174. command.CommandType = commandType;//设置command的CommandType为指定的CommandType
  3175. //如果同时传入了参数,则添加这些参数
  3176. if (parameters != null)
  3177. {
  3178. foreach (SqlParameter parameter in parameters)
  3179. {
  3180. command.Parameters.Add(parameter);
  3181. }
  3182. }
  3183. //通过包含查询SQL的SqlCommand实例来实例化SqlDataAdapter
  3184. adapter = new SqlDataAdapter(command);
  3185. //adapter.Fill(data);//填充DataTable
  3186. }
  3187. adapter.SelectCommand = new SqlCommand(sql, connection);
  3188. return adapter;
  3189. }
  3190. public void deleteRecord(string Tablename, int RecordID)
  3191. {
  3192. SqlConnection DBConn = new SqlConnection(connectionString);
  3193. SqlCommand DBDelete = new SqlCommand();
  3194. //OleDbDataAdapter DBCommand = new OleDbDataAdapter(SelectSQL, DBConn);
  3195. DataSet DS = new DataSet();
  3196. //使用 Connection 对象打开数据连接
  3197. DBDelete.CommandText = "Delete From " + Tablename + " Where ID=" + RecordID;
  3198. DBDelete.Connection = DBConn;
  3199. DBDelete.Connection.Open();
  3200. DBDelete.ExecuteNonQuery();
  3201. }
  3202. public Panel DynamicBuildForm(Panel PanelcontrolName, string SQLStr, int FieldMaxLenght)
  3203. {
  3204. //定义变量和控件数组
  3205. Panel mypanel = new Panel();
  3206. int i, FieldNum;
  3207. TextBox[] MyText = new TextBox[30];
  3208. Label[] MyLabel = new Label[30];
  3209. //连接并打开数据库
  3210. //OleDbConnection objConn = new OleDbConnection();
  3211. SqlConnection objConn = new SqlConnection();
  3212. StringBuilder sQueryStringValues = new StringBuilder();
  3213. objConn.ConnectionString = connectionString;
  3214. objConn.Open();
  3215. //创建DataReader对象(COMMAND)
  3216. //OleDbCommand objcmd = new OleDbCommand();
  3217. SqlCommand objcmd = new SqlCommand();
  3218. objcmd.Connection = objConn;
  3219. objcmd.CommandText = SQLStr;
  3220. SqlDataReader objreader = objcmd.ExecuteReader();
  3221. //读取并显示数据库
  3222. String TypeN, dispC;
  3223. FieldNum = objreader.FieldCount;
  3224. for (i = 1; i <= FieldNum - 1; i++)
  3225. {
  3226. //objreader.GetDataTypeName
  3227. TypeN = objreader.GetFieldType(i).Name;
  3228. switch (TypeN)
  3229. {
  3230. case "String":
  3231. dispC = "输文字";
  3232. break;
  3233. case "DateTime":
  3234. dispC = Convert.ToString(DateTime.Now);
  3235. break;
  3236. case "Boolean":
  3237. dispC = "1 or 0[是为1,否为0]";
  3238. break;
  3239. default:
  3240. dispC = "12";
  3241. break;
  3242. }
  3243. MyLabel[i] = new Label();
  3244. MyLabel[i].ID = "MyLabel" + Convert.ToString(i);
  3245. MyLabel[i].Text = "<BR>";
  3246. MyLabel[i].Text = MyLabel[i].Text + GetSpace(FieldMaxLenght, objreader.GetName(i));
  3247. mypanel.Controls.Add(MyLabel[i]);
  3248. MyText[i] = new TextBox();
  3249. MyText[i].ID = "MyText" + Convert.ToString(i);
  3250. MyText[i].Text = dispC;
  3251. MyText[i].Columns = 68;
  3252. if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  3253. {
  3254. MyText[i].TextMode = TextBoxMode.MultiLine;
  3255. MyText[i].Rows = 4;
  3256. MyText[i].Columns = 45;
  3257. }
  3258. mypanel.Controls.Add(MyText[i]);
  3259. }
  3260. MyLabel[i + 1] = new Label();
  3261. MyLabel[i + 1].ID = "AAA";
  3262. MyLabel[i + 1].Text = "<br><br> ";
  3263. mypanel.Controls.Add(MyLabel[i + 1]);
  3264. objreader.Close();
  3265. objConn.Close();
  3266. PanelcontrolName.Controls.Add(mypanel);
  3267. return PanelcontrolName;
  3268. }
  3269. public void InsertDataToDB(String TableName, string sql)
  3270. {
  3271. //'连接并打开数据库
  3272. SqlConnection objConn = new SqlConnection();
  3273. objConn.ConnectionString = connectionString;
  3274. objConn.Open();
  3275. SqlDataAdapter objCmd = new SqlDataAdapter();
  3276. objCmd.SelectCommand = new SqlCommand(sql, objConn);
  3277. //创建CommandBuilder对象
  3278. SqlCommandBuilder objCB = new SqlCommandBuilder(objCmd);
  3279. //创建DataSet对象并填充数据
  3280. DataSet Ds = new DataSet();
  3281. objCmd.Fill(Ds, TableName);
  3282. objConn.Close();
  3283. DataTable myTable = Ds.Tables[TableName];
  3284. //插入数据行
  3285. DataRow myRow = myTable.NewRow();
  3286. myRow[0] = DBNull.Value;
  3287. int i, k = 0;
  3288. for (i = 1; i <= HttpContext.Current.Request.Form.Count - 1; i++)
  3289. {
  3290. if (HttpContext.Current.Request.Form.GetKey(i).Substring(0, 6) == "MyText")
  3291. {
  3292. k = k + 1;
  3293. myRow[k] = HttpContext.Current.Request.Form[i];
  3294. }
  3295. }
  3296. myRow[k + 1] = HttpContext.Current.Request.ServerVariables["Remote_addr"];
  3297. myTable.Rows.Add(myRow);
  3298. objCmd.Update(myTable.Select(null, null, DataViewRowState.Added));
  3299. //lblMessage.Text = "注册成功!";
  3300. }
  3301. public void AddDataToDB(string parasql, string tablename)
  3302. {
  3303. SqlConnection objConn = new SqlConnection(connectionString);
  3304. objConn.Open();
  3305. string sql = parasql;
  3306. SqlDataAdapter objcmd = new SqlDataAdapter();
  3307. objcmd.SelectCommand = new SqlCommand(sql, objConn);
  3308. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  3309. DataSet ds = new DataSet();
  3310. objcmd.Fill(ds, tablename);
  3311. objConn.Close();
  3312. DataTable dt = ds.Tables[tablename];
  3313. DataRow dtrow = dt.NewRow();
  3314. dtrow[0] = DBNull.Value;
  3315. int i, k = 0;
  3316. for (i = 1; i < HttpContext.Current.Request.Form.Count - 2; i++)
  3317. {
  3318. string name = HttpContext.Current.Request.Form.GetKey(i);
  3319. if (name.IndexOf("Text") > 0)
  3320. {
  3321. k = k + 1;
  3322. dtrow[k] = HttpContext.Current.Request.Form[i];
  3323. //if (dt.Columns[k + 1].ColumnName == "IP")
  3324. // { dtrow[k+1] = HttpContext.Current.Request.ServerVariables["Remote_addr"]; }
  3325. }
  3326. }
  3327. dt.Rows.Add(dtrow);
  3328. objcmd.Update(ds, tablename);
  3329. }
  3330. public void AddUpFIlesInfoToDB(string parasql, string tablename, string XH, string XM, string BC, string ZJ, string upFileName, string TeacherName)
  3331. {
  3332. // OleDbConnection objConn = new OleDbConnection(connectionString);
  3333. SqlConnection objConn = new SqlConnection(connectionString);
  3334. objConn.Open();
  3335. string sql = parasql;
  3336. SqlDataAdapter objcmd = new SqlDataAdapter();
  3337. objcmd.SelectCommand = new SqlCommand(sql, objConn);
  3338. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  3339. DataSet ds = new DataSet();
  3340. objcmd.Fill(ds, tablename);
  3341. objConn.Close();
  3342. DataTable dt = ds.Tables[tablename];
  3343. DataRow dtrow = dt.NewRow();
  3344. dtrow[0] = DBNull.Value;
  3345. dtrow[1] = XH;
  3346. dtrow[2] = XM;
  3347. dtrow[3] = BC;
  3348. dtrow[4] = ZJ;
  3349. dtrow[5] = upFileName;
  3350. dtrow[6] = DateTime.Today;
  3351. dtrow[7] = HttpContext.Current.Request.ServerVariables["Remote_addr"];
  3352. dtrow[8] = TeacherName;
  3353. dt.Rows.Add(dtrow);
  3354. objcmd.Update(ds, tablename);
  3355. }
  3356. public void AddUsersToDB(string parasql, string tablename, string UserName, string Password, string Usertype, string dempment)
  3357. {
  3358. // OleDbConnection objConn = new OleDbConnection(connectionString);
  3359. SqlConnection objConn = new SqlConnection(connectionString);
  3360. objConn.Open();
  3361. string sql = parasql;
  3362. SqlDataAdapter objcmd = new SqlDataAdapter();
  3363. objcmd.SelectCommand = new SqlCommand(sql, objConn);
  3364. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  3365. DataSet ds = new DataSet();
  3366. objcmd.Fill(ds, tablename);
  3367. objConn.Close();
  3368. DataTable dt = ds.Tables[tablename];
  3369. DataRow dtrow = dt.NewRow();
  3370. dtrow[0] = DBNull.Value;
  3371. dtrow[1] = UserName;
  3372. dtrow[2] = Password;
  3373. dtrow[3] = Usertype;
  3374. dtrow[4] = dempment;
  3375. dt.Rows.Add(dtrow);
  3376. objcmd.Update(ds, tablename);
  3377. HttpContext.Current.Response.Write("<script>alert('添加成功!')</script>");
  3378. }
  3379. //将课程信息添加到数据库
  3380. public void AddCourseInfoToDB(string parasql, string tablename, string courseID, string courseName, string courseTrem, string courseTro, string mcourseClass, string courseTeacher, int courseStartWeek, int courseEndWeek, Single coursecredit, string courseMemo)
  3381. {
  3382. SqlConnection objConn = new SqlConnection(connectionString);
  3383. objConn.Open();
  3384. string sql = parasql;
  3385. SqlDataAdapter objcmd = new SqlDataAdapter();
  3386. objcmd.SelectCommand = new SqlCommand(sql, objConn);
  3387. SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
  3388. DataSet ds = new DataSet();
  3389. objcmd.Fill(ds, tablename);
  3390. objConn.Close();
  3391. DataTable dt = ds.Tables[tablename];
  3392. DataRow dtrow = dt.NewRow();
  3393. dtrow[0] = DBNull.Value;
  3394. dtrow[1] = courseID;
  3395. dtrow[2] = courseName;
  3396. dtrow[3] = courseTrem;
  3397. dtrow[4] = courseTro;
  3398. dtrow[5] = mcourseClass;
  3399. dtrow[6] = courseTeacher;
  3400. dtrow[7] = courseStartWeek;
  3401. dtrow[8] = courseEndWeek;
  3402. dtrow[9] = coursecredit;
  3403. dtrow[10] = courseMemo;
  3404. dt.Rows.Add(dtrow);
  3405. objcmd.Update(ds, tablename);
  3406. HttpContext.Current.Response.Write("<script>alert('添加成功!')</script>");
  3407. }
  3408. public string UpfilesToPath(HttpPostedFile postedfile, string filepath, string filename, long length)
  3409. {
  3410. //此方法的主要功能是提取上传文件名并保存到所指路径;返回相关的文件信息,如:文件大小及文件保存路径
  3411. string name = System.IO.Path.GetFileName(filename);
  3412. postedfile.SaveAs(filepath + "\\" + name);
  3413. StringBuilder strmsg = new StringBuilder();
  3414. if (length == 0)
  3415. {
  3416. return "请选择欲上传文件";
  3417. }
  3418. strmsg.AppendFormat("文件上传成功!<br>");
  3419. strmsg.AppendFormat("上传文件大小为:{0} kb<br>", length);
  3420. strmsg.AppendFormat("文件存储位置为:{0} <br>", filepath + "\\" + name);
  3421. return strmsg.ToString();
  3422. //public void b1_Click(object sender, EventArgs e)
  3423. //{//UpfilesToPath实例
  3424. // file f1 = new file();
  3425. // HttpPostedFile postedfile = this.myFile.PostedFile;//获得客户端上载的文件
  3426. // string filepath = Server.MapPath("upload");//设置保存路径
  3427. // string filename = postedfile.FileName;//获得上载文件的原始路径及文件名
  3428. // long length = myFile.PostedFile.ContentLength;//获得上传文件的大小
  3429. // Label2.Text = f1.insert(postedfile, filepath, filename, length);//调用file类中的insert方法,以实现文件上传及信息输出
  3430. //}
  3431. }
  3432. public string Upfiles(HttpPostedFile postedfile, string Fdir)
  3433. {
  3434. //if (!Directory.Exists(Server.MapPath(".") + "PIC"))
  3435. //{ Directory.CreateDirectory(Server.MapPath(".") + "PIC"); }
  3436. StringBuilder strmsg = new StringBuilder();
  3437. string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
  3438. if (postedfile.ContentLength > 0)
  3439. {
  3440. if (Fdir == "")
  3441. { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + UpFilename); }
  3442. else
  3443. { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + Fdir + "\\" + UpFilename); }
  3444. strmsg.AppendFormat("【文件名:" + UpFilename.ToString() + "】");
  3445. strmsg.AppendFormat("<br>【文件大小:" + postedfile.ContentLength.ToString() + "】");
  3446. strmsg.AppendFormat("<br>【文件类型:" + postedfile.ContentType.ToString() + "】");
  3447. return strmsg.ToString();
  3448. }
  3449. else
  3450. { return "请选择欲上传文件"; }
  3451. }
  3452. public string UpfilesAndSaveToDB(HttpPostedFile postedfile, string Fdir, string TableName, string SaveFileFieldName, Int32 IDvalue)
  3453. {
  3454. //if (!Directory.Exists(Server.MapPath(".") + "PIC"))
  3455. //{ Directory.CreateDirectory(Server.MapPath(".") + "PIC"); }
  3456. StringBuilder strmsg = new StringBuilder();
  3457. string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
  3458. if (postedfile.ContentLength > 0)
  3459. {
  3460. UpdateStringFieldValue(TableName, SaveFileFieldName, UpFilename.ToString(), IDvalue);
  3461. if (Fdir == "")
  3462. { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + UpFilename); }
  3463. else
  3464. { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + Fdir + "\\" + UpFilename); }
  3465. strmsg.AppendFormat("【文件名:" + UpFilename.ToString() + "】");
  3466. strmsg.AppendFormat("<br>【文件大小:" + postedfile.ContentLength.ToString() + "】");
  3467. strmsg.AppendFormat("<br>【文件类型:" + postedfile.ContentType.ToString() + "】");
  3468. return strmsg.ToString();
  3469. }
  3470. else
  3471. { return "请选择欲上传文件"; }
  3472. }
  3473. public StringBuilder F_Link(string CSSFilename, int LinkTextFieldsOrderNo, int LinkUrlFieldsOrderNo, string SQL, bool dispTitle, string PageTitleStr, int LinNumber, string aling)
  3474. {//aling=left| center| right
  3475. SqlConnection dtConn = new SqlConnection(connectionString);
  3476. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, dtConn); ;
  3477. DataSet dtSet = new DataSet();
  3478. dtCmd.Fill(dtSet);
  3479. DataTableReader objreader = dtSet.CreateDataReader();
  3480. int i = 0;
  3481. StringBuilder SB = new StringBuilder();
  3482. SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  3483. SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  3484. if (dispTitle == true) { SB.Append("<tr bgcolor='#99ccff'><th nowrap='nowrap'>" + PageTitleStr + "</Th></tr>"); }
  3485. while (objreader.Read())
  3486. {
  3487. if (i < LinNumber)
  3488. {
  3489. SB.Append("<tr>");
  3490. SB.Append("<td align=" + aling + "><a href='" + objreader.GetValue(LinkUrlFieldsOrderNo) + "'>" + objreader.GetValue(LinkTextFieldsOrderNo) + "</a></TD>");
  3491. SB.Append("</tr>");
  3492. }
  3493. }
  3494. SB.Append("</table>");
  3495. return SB;
  3496. }
  3497. public StringBuilder DispNB(string CSSFilename, string FieldName, string SQL, int LinNumber, string aling)
  3498. {//显示类别列表
  3499. SqlConnection objConn = new SqlConnection(connectionString);
  3500. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  3501. DataSet dtSet = new DataSet();
  3502. dtCmd.Fill(dtSet);
  3503. DataTableReader objreader = dtSet.CreateDataReader();
  3504. int i = 0;
  3505. StringBuilder SB = new StringBuilder();
  3506. SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  3507. SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
  3508. while (objreader.Read())
  3509. {
  3510. if (i < LinNumber)
  3511. {
  3512. SB.Append("<tr>");
  3513. SB.Append("<td align=" + aling + "><a href='#'>" + objreader[FieldName].ToString() + "</a></TD>");
  3514. SB.Append("</tr>");
  3515. }
  3516. }
  3517. SB.Append("</table>");
  3518. return SB;
  3519. }
  3520. public string EncryptDes(string EncryptStr)
  3521. {//标准DES对称加密的函数
  3522. string skey = "liuys123";
  3523. DESCryptoServiceProvider des = new DESCryptoServiceProvider();
  3524. byte[] inputByteArray;
  3525. inputByteArray = Encoding.Default.GetBytes(EncryptStr);
  3526. des.Key = ASCIIEncoding.ASCII.GetBytes(skey);
  3527. des.IV = ASCIIEncoding.ASCII.GetBytes(skey);
  3528. MemoryStream ms = new MemoryStream();
  3529. CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
  3530. StreamWriter sw = new StreamWriter(cs);
  3531. sw.Write(EncryptStr);
  3532. sw.Flush();
  3533. cs.FlushFinalBlock();
  3534. ms.Flush();
  3535. return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
  3536. }
  3537. public string DecryptDes(string DecryptStr)
  3538. {//标准DES对称解密的函数
  3539. string skey = "liuys123";
  3540. DESCryptoServiceProvider des = new DESCryptoServiceProvider();
  3541. des.Key = ASCIIEncoding.ASCII.GetBytes(skey);
  3542. des.IV = ASCIIEncoding.ASCII.GetBytes(skey);
  3543. byte[] buffer = Convert.FromBase64String(DecryptStr);
  3544. MemoryStream ms = new MemoryStream(buffer);
  3545. CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);
  3546. StreamReader sr = new StreamReader(cs);
  3547. return sr.ReadToEnd().ToString();
  3548. }
  3549. //public void RegAdmin(string username, string password, string userType)
  3550. //{
  3551. // SqlConnection objConn = new SqlConnection();
  3552. // objConn.ConnectionString = connectionString;
  3553. // objConn.Open();
  3554. // SqlCommand objCmd = new SqlCommand();
  3555. // objCmd.Connection = objConn;
  3556. // objCmd.Parameters.Add("@用户名", OleDbType.Char).Value = username;
  3557. // objCmd.Parameters.Add("@密码", OleDbType.Char).Value = EncryptDes(password);
  3558. // objCmd.Parameters.Add("@类型", OleDbType.Char).Value = userType;
  3559. // objCmd.CommandText = "Insert Into AdminUser(用户名, 密码,类型) Values(?, ?,?)";
  3560. // objCmd.ExecuteNonQuery();
  3561. // objConn.Close();
  3562. //}
  3563. public DataSet CreateDataSet(string strSQL, string TableName)
  3564. {
  3565. // string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~\\App_Data\\ZY.MDB");
  3566. SqlDataAdapter objCmd = new SqlDataAdapter(strSQL, connectionString);
  3567. //OleDbDataAdapter objCmd = new OleDbDataAdapter(strSQL, connectionString);
  3568. DataSet DS = new DataSet();
  3569. objCmd.Fill(DS, TableName);
  3570. return DS;
  3571. }
  3572. public void BindListToGridView(GridView mygridView, string tablename, string strSQL)
  3573. {
  3574. mygridView.DataSource = CreateDataSet(strSQL, tablename);
  3575. mygridView.DataBind();
  3576. }
  3577. public void BindFiledToDropDownList1(DropDownList myDropDownList, string sql, string tablename)
  3578. {
  3579. DataSet DS = CreateDataSet(sql, tablename);
  3580. DataView DV = new DataView(DS.Tables[tablename]);
  3581. // GridView1.DataSource = DV;
  3582. for (int i = 1; i < DV.Table.Columns.Count; i++)
  3583. {
  3584. //if (DV.Table.Columns[i].DataType.ToString() == "System.String") //将字符数据绑定到DropDownList
  3585. //{ //SQL语句中如果使用AS,如 Name as 姓名可能使查询出现问题,
  3586. //ListItem aa=new ListItem; aa.Text="" :aa.Value=""
  3587. myDropDownList.Items.Add(DV.Table.Columns[i].ToString());
  3588. //}
  3589. }
  3590. }
  3591. public void BindFiledToDropDownList(DropDownList myDropDownList, string sql, string tablename)
  3592. {
  3593. DataSet DS = CreateDataSet(sql, tablename);
  3594. DataView DV = new DataView(DS.Tables[tablename]);
  3595. // GridView1.DataSource = DV;
  3596. for (int i = 1; i < DV.Table.Columns.Count; i++)
  3597. {
  3598. if (DV.Table.Columns[i].DataType.ToString() == "System.String") //将字符数据绑定到DropDownList
  3599. { //SQL语句中如果使用AS,如 Name as 姓名可能使查询出现问题,
  3600. //ListItem aa=new ListItem; aa.Text="" :aa.Value=""
  3601. myDropDownList.Items.Add(DV.Table.Columns[i].ToString());
  3602. }
  3603. }
  3604. }
  3605. public void BindFiledRecValueToDropDownList(DropDownList myDropDownList, string BindFileName, string TableName)
  3606. {//将字段BindFileName绑定到myDropDownList
  3607. string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
  3608. SqlConnection objConn = new SqlConnection(connectionString);
  3609. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  3610. DataSet dtSet = new DataSet();
  3611. dtCmd.Fill(dtSet);
  3612. DataTableReader objreader = dtSet.CreateDataReader();
  3613. while (objreader.Read())
  3614. {
  3615. myDropDownList.Items.Add(objreader.GetValue(0).ToString());
  3616. }
  3617. }
  3618. public void BindFiledDataToDropDownList(DropDownList myDropDownList, string tablename, string BindFieldName, int BindFieldNameNo)
  3619. {
  3620. string SQL = "select DISTINCT(" + BindFieldName + ") from " + tablename;
  3621. SqlConnection objConn = new SqlConnection(connectionString);
  3622. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  3623. DataSet dtSet = new DataSet();
  3624. dtCmd.Fill(dtSet);
  3625. DataTableReader objreader = dtSet.CreateDataReader();
  3626. while (objreader.Read())
  3627. {
  3628. myDropDownList.Items.Add(objreader.GetValue(BindFieldNameNo).ToString());
  3629. }
  3630. return;
  3631. }
  3632. /// <summary>
  3633. /// 动态更新一个字段的值为身份证后6位
  3634. /// </summary>
  3635. /// <param name="SQL"></param>
  3636. /// <returns></returns>
  3637. public void UpdateAllFiledValue(string SQL, string UpdateFileNmae, string FromFiledName, string TableName)
  3638. { //调用
  3639. string sql = SQL;
  3640. SqlConnection dtConn = new SqlConnection(connectionString);
  3641. SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
  3642. DataSet dtSet = new DataSet();
  3643. dtCmd.Fill(dtSet);
  3644. DataTableReader objreader = dtSet.CreateDataReader();
  3645. while (objreader.Read())
  3646. {
  3647. int ln = objreader[FromFiledName].ToString().Length;
  3648. if (ln > 0)
  3649. {
  3650. string UV = objreader[FromFiledName].ToString().Substring(ln - 6, 6);
  3651. UpdateStringFieldValue(TableName, UpdateFileNmae, UV, Convert.ToInt32(objreader["ID"].ToString()));
  3652. }
  3653. }
  3654. }
  3655. public StringBuilder ShowLineNavigation(string SQL, string CSSFilename, string tablename, Int32 TitleFiledNo, Int32 UrlFieldNo, string aling, string targetWindowName, string PicOrWord, Int32 PicWidth, Int32 PicHeight)
  3656. {
  3657. if (targetWindowName.Length == 0) { targetWindowName = "_blank"; }
  3658. SqlConnection objConn = new SqlConnection(connectionString);
  3659. SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
  3660. DataSet dtSet = new DataSet();
  3661. dtCmd.Fill(dtSet);
  3662. DataTableReader objreader = dtSet.CreateDataReader();
  3663. // int i = 0;
  3664. StringBuilder SB = new StringBuilder();
  3665. SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  3666. SB.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'><tr>");
  3667. while (objreader.Read())
  3668. {
  3669. if (PicOrWord == "Word")
  3670. {
  3671. SB.Append("<td align=" + aling + "><a title='" + objreader.GetValue(TitleFiledNo) + "' href='" + objreader.GetValue(UrlFieldNo) + "' target='" + targetWindowName + "'>" + objreader.GetValue(TitleFiledNo) + "</a></td>");
  3672. }
  3673. else
  3674. {
  3675. SB.Append("<td align=" + aling + "><a title='" + objreader.GetValue(TitleFiledNo) + "' href='" + objreader.GetValue(UrlFieldNo) + "' target='" + targetWindowName + "'><img src='PICFiles/" + objreader.GetValue(6).ToString() + "' width='" + PicWidth + "' height='" + PicHeight + "' border='0' /></a></td>");
  3676. }
  3677. }
  3678. SB.Append("</tr></table>");
  3679. return SB;
  3680. }
  3681. public StringBuilder DataReaderPage(string CSSFilename, string TableName, int mPageSize, string PageFilename, Boolean bRow, string QueryConditions)
  3682. {
  3683. //if (QueryConditions.Length == 0)
  3684. //{
  3685. // HttpContext.Current.Session["countSQL"] = "select count(*) from " + TableName + QueryConditions;
  3686. // HttpContext.Current.Session["QuerySQL"] = "select * from " + TableName + QueryConditions;
  3687. //}
  3688. //if (HttpContext.Current.Session["countSQL"] ==null)
  3689. //{ HttpContext.Current.Session["countSQL"] = "select count(*) from " + TableName; }
  3690. //if (HttpContext.Current.Session["QuerySQL"]==null)
  3691. //{ HttpContext.Current.Session["QuerySQL"] = "select * from " + TableName; }
  3692. // OleDbConnection conn = new OleDbConnection(connectionString);
  3693. SqlConnection conn = new SqlConnection(connectionString);
  3694. SqlCommand cmd = new SqlCommand("", conn);
  3695. int rowIndex = 1;
  3696. int pageId = 1;
  3697. int maxRow = 1;
  3698. int maxPage = 1;
  3699. int pageSize = mPageSize;
  3700. StringBuilder sb = new StringBuilder();
  3701. //确定当前页
  3702. if (HttpContext.Current.Request.QueryString["pageId"] == null)
  3703. {
  3704. pageId = 1;
  3705. }
  3706. else
  3707. {
  3708. pageId = int.Parse(HttpContext.Current.Request.QueryString["pageId"].Trim());
  3709. }
  3710. try
  3711. {
  3712. if (conn.State == ConnectionState.Closed)
  3713. {
  3714. conn.Open();
  3715. }
  3716. cmd.CommandText = "select count(*) from " + TableName + QueryConditions;//"select count(*) from " + TableName;
  3717. maxRow = (int)cmd.ExecuteScalar();
  3718. maxPage = (maxRow % pageSize > 0) ? (maxRow / pageSize + 1) : (maxRow / pageSize);
  3719. cmd.CommandText = "select * from " + TableName + QueryConditions;
  3720. SqlDataReader dr = cmd.ExecuteReader();
  3721. for (int i = 0; i < (pageId - 1) * pageSize; i++)
  3722. {
  3723. dr.Read();
  3724. rowIndex++;
  3725. }
  3726. int by = (pageId > 1) ? (pageId - 1) : 1;
  3727. int by1 = (pageId < maxPage) ? (pageId + 1) : maxPage;
  3728. sb.Append("记录总数为:" + maxRow.ToString() + ";当前页:" + pageId.ToString() + "/" + maxPage.ToString());
  3729. sb.Append("[<a href='" + PageFilename + "?pageId=1'>第一页</a>]");
  3730. sb.Append("[<a href='" + PageFilename + "?pageId=" + by.ToString() + "'>上一页</a>]");
  3731. sb.Append("[<a href='" + PageFilename + "?pageId=" + by1.ToString() + "'>下一页</a>]");
  3732. sb.Append("[<a href='" + PageFilename + "?pageId=" + maxPage.ToString() + "'>最后页</a>]");
  3733. sb.Append("<br />");
  3734. sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
  3735. sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'><tr>");
  3736. if (bRow == true)
  3737. {
  3738. sb.Append("<tr bgcolor='#99ccff'>");
  3739. for (int j = 0; j <= dr.FieldCount - 1; j++)
  3740. {
  3741. sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</Th>");
  3742. }
  3743. for (int i = rowIndex; i < (rowIndex + pageSize); i++)
  3744. {
  3745. if (dr.Read())
  3746. {
  3747. sb.Append("</tr><tr>");
  3748. for (int j = 0; j <= dr.FieldCount - 1; j++)
  3749. {
  3750. sb.Append("<td>" + dr[j].ToString() + "</td>");
  3751. }
  3752. //sb.Append("<hr/>");
  3753. }
  3754. }
  3755. }
  3756. else
  3757. {
  3758. for (int i = rowIndex; i < (rowIndex + pageSize); i++)
  3759. {
  3760. if (dr.Read())
  3761. {
  3762. for (int j = 0; j <= dr.FieldCount - 1; j++)
  3763. {
  3764. sb.Append("<tr>");
  3765. sb.Append("<td>" + dr.GetName(j) + "</td>");
  3766. sb.Append("<td algin=left>" + dr[j].ToString().Replace("\r\n", "<br />") + "</td>");
  3767. //if (dr.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
  3768. //{
  3769. // sb.Append("<td><asp:TextBox ID='TextBox1' Text='" + dr[j].ToString() + "' runat='server' Columns='60' Rows='12' TextMode='MultiLine'></asp:TextBox>&nbsp;</td>");
  3770. //}
  3771. //else
  3772. //{ sb.Append("<td><asp:TextBox ID='TextBox1' Text='"+ dr[j].ToString() +"' runat='server' Columns='60'></asp:TextBox>&nbsp;</td>"); }
  3773. sb.Append("</tr>");
  3774. }
  3775. }
  3776. }
  3777. }
  3778. sb.Append("</Table>");
  3779. }
  3780. catch (OleDbException e)
  3781. {
  3782. sb.Append(e.Message.ToString());
  3783. }
  3784. finally
  3785. {
  3786. if (conn.State == ConnectionState.Open)
  3787. {
  3788. conn.Close();
  3789. }
  3790. }
  3791. return sb;
  3792. }
  3793. }
  3794. }