12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325 |
- using System;
- using System.Data;
- using System.Data.OleDb;
- using System.Configuration;
- using System.Data.Sql;
- using System.Data.SqlClient;
- using System.Web;
- using System.Web.Security;
- using System.Security.Cryptography;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.IO;
- using System.Text;
- using System.Globalization;
- using System.Threading; //
- using System.Collections;
- namespace LYS
- {
- /// <summary>
- ///UserData1 的摘要说明
- /// </summary>
- public class UserData1
- {
- MyFiles myf = new MyFiles();
- //private string connectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
- 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;";
-
- public void ConnDB()
- {
- SqlConnection objConn = new SqlConnection();
- // objConn.ConnectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
- 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;";
- objConn.Open();
- }
- public string ConnString()
- {
- string connstr = connectionString;
- return connstr;
- }
- /// <summary>
- /// 根据SQL语句指定条件记录值绑定到input type="text" id="sDemp" list="sDemplist" 对应list ,by 版权所有:广东松山职业技术学院计算机系 刘友生(QQ:290578102,Tel:15089879808)
- /// </summary>
- /// <param name="myDropDownList"></param>
- /// <param name="BindFileName"></param>
- /// <param name="DispFileName"></param>
- /// <param name="TableName"></param>
- /// <param name="scondition"></param>
- public StringBuilder HTML5SQLBindRecValueToDDL(string BindFileName, string sSQL)
- {//将字段BindFileName绑定到myDropDownList
- StringBuilder sb = new StringBuilder();
- //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
- string SQL = sSQL;
- SqlConnection dtConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, dtConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- sb.Append(" <option value=\"" + objreader[BindFileName].ToString() + "\" />");
- }
- return sb;
- }
- /// <summary>
- /// 替换指定位置字符
- /// </summary>
- /// <param name="OleStr">原字符</param>
- /// <param name="ReplaceStr">替换字符</param>
- /// <param name="Replacelocation">起始位置</param>
- /// <returns></returns>
- public string ReplaceStr(string OleStr, string ReplaceStr, int Replacelocation)
- {
- string str1 = OleStr.Substring(0, Replacelocation - 1); //ab
- string str2 = OleStr.Substring(Replacelocation + ReplaceStr.Length - 1); //d
- return str1 + ReplaceStr + str2;
- }
- //执行SQL语句:
- public void RunCreateSQL(String SQL)
- {
- SqlConnection DBConn;
- SqlCommand DBUpdate = new SqlCommand();
- // SqlConnection DBConn;
- // SqlCommand DBUpdate = new SqlCommand();
- DBConn = new SqlConnection(connectionString);
- DBUpdate.CommandText = SQL;
- DBUpdate.Connection = DBConn;
- DBUpdate.Connection.Open();
- DBUpdate.ExecuteNonQuery();
- }
- /// <summary>
- /// 连接eXCEL数据库
- /// </summary>
- /// <param name="pathDir">上传Excel文件存放目录</param>
- /// <param name="filename">EXCEL文件名</param>
- /// <returns></returns>
- public string ConnExcelString(string pathDir, string filename)
- {
- string conn = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =" + HttpContext.Current.Server.MapPath(pathDir) + "//" + filename + ";Extended Properties=Excel 8.0";
- return conn;
- }
- /// <summary>
- /// 获得EXCEL数据库中的表名
- public void GetExcelTable(string conn, DropDownList DropDownList1)
- {
- OleDbConnection connect = new OleDbConnection(conn);
- connect.Open();
- DataTable schemaTable = connect.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
- for (int i = 0; i <= schemaTable.Rows.Count - 1; i++)
- {
- if (schemaTable.Rows[i].ItemArray[3].ToString() == "TABLE")
- { DropDownList1.Items.Add(schemaTable.Rows[i].ItemArray[2].ToString()); }
- }
- }
- public DataTable getExcelds(string conn, string Sql)
- {
- OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, conn);
- DataSet ds = new DataSet();
- mycommand.Fill(ds, "tablename");
- DataTable myTable = ds.Tables["tablename"];
- return myTable;
- }
- /// <summary>
- /// 从EXCEL文件中导入数据到SQL Server文件 并根据两个关键字段查询是否有重复
- /// </summary>
- /// <param name="excelFile"></param>
- /// <param name="sheetName"></param>
- /// <param name="connectionString"></param>
- public void ExcelToSQLKey(string tablename, string conn, DataTable myTable, string keyFieldName1, string keyFieldName2, Literal L1)
- {
- //DataTable myTable = getds(conn, Sql,tablename);
- // SqlConnection thisconnection1 = new SqlConnection(connectionString);
- SqlConnection thisconnection1 = new SqlConnection(connectionString);
- thisconnection1.Open();
- int count = myTable.Rows.Count;
- int s = 0; int rr = 0;
- string msg = "";
- string Strrec = "";
- for (int i = 0; i < count; i++)
- {
- Strrec = "有重复记录:";
- string strSql1 = "insert into " + tablename + "("; //插入到SQL数据库的语句
- string strSql2 = "Select * from " + tablename + " where "; //检查是不断中有重复数据的SQL语句
- foreach (System.Data.DataColumn c in myTable.Columns)
- {
- strSql1 += c.ColumnName + ",";
- }
- strSql1 = strSql1.Substring(0, strSql1.Length - 1) + ") values ('";
- for (int j = 0; j < myTable.Columns.Count; j++)
- {
- strSql1 += myTable.Rows[i][j].ToString() + "','";
- if (myTable.Columns[j].ToString() == keyFieldName1)
- {
- strSql2 += keyFieldName1 + "='" + myTable.Rows[i][j].ToString() + "' ";
- Strrec += keyFieldName1+ "='" + myTable.Rows[i][j].ToString();
- }
- if (myTable.Columns[j].ToString() == keyFieldName2)
- {
- strSql2 += " and " + keyFieldName2 + "='" + myTable.Rows[i][j].ToString() + "' ";
- Strrec += ";" + keyFieldName2 + "='" + myTable.Rows[i][j].ToString() + "<br>";
- }
- }
- //HttpContext.Current.Response.Write(strSql2+"<br>");
- // HttpContext.Current.Response.Write(Strrec + "<br>");
- msg = Strrec;
- if (CheckRecord(strSql2) == true)
- {
- //HttpContext.Current.Response.Write(Strrec + "<br>");
- HttpContext.Current.Response.Write("<script> alert('" + msg + "') </script>");
- // HttpContext.Current.Response.Write("<script>alert('有重复记录')</script>");
- // openWin(strSql2);
- rr = rr + 1;
- L1.Text = L1.Text + "<br>" + msg;
- }
- else
- {
- s = s + 1;
- strSql1 = strSql1.Substring(0, strSql1.Length - 2) + ")";
- SqlCommand mycommand2 = new SqlCommand(strSql1, thisconnection1);
- mycommand2.ExecuteNonQuery();
- }
- }
- thisconnection1.Close();
- //HttpContext.Current.Response.Write("<script> alert('导入完成,共导入" + s.ToString() + "条记录') </script>");
- L1.Text = L1.Text + "<font color=\"red\" size=3> 共导入" + s.ToString() + "条记录!另外有" + rr.ToString() + "条记录未导入</font>";
- // openWin("导入完成,共导入" + s.ToString() + "条记录" + msg);
- }
- //以行显示,每一行下划线显示 第一行交替显示
- public StringBuilder DispOleDbLineDataJTExcel(string SQL, string Excelconnstr)
- {
- StringBuilder sb = new StringBuilder();
- OleDbConnection dtConn = new OleDbConnection(Excelconnstr);
- OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"dataTable\">");
- sb.Append("\n <tr class=\"dataTableHeader\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9;font-size: 12px; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + " </b>");
- }
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- if (j % 2 == 0)
- { sb.Append("\n <tr class=\"odd_row\">"); }
- else
- { sb.Append("\n <tr class=\"even_row\" style=\"background-image: url('images/list_line2-1.gif')\">"); }
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- 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() + " </td>");
- }
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- /// <summary>
- /// 以行显示,每一行下划线显示 显示统计结果(总数)
- /// </summary>
- /// <param name="SQL"></param>
- /// <returns></returns>
- public StringBuilder DispLineCount(string SQL)
- { //调用
- //DateTime startTime = Convert.ToDateTime("2017-9-1");
- //DateTime endTime = Convert.ToDateTime("2017-9-11");
- //string sql = "select count(*) as 总计 from TKJL where 听课日期 >= #2017-9-1# and 听课日期 <=#2017-9-10#"; //OK
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection dtConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
- sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + " </b>");
- }
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + " </td>");
- }
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- /// <summary>
- /// 以行显示,每一行下划线显示 显示统计结果(总数)
- /// </summary>
- /// <param name="SQL"></param>
- /// <returns></returns>
- public string DispLineCountNum(string SQL)
- { //调用
- //DateTime startTime = Convert.ToDateTime("2017-9-1");
- //DateTime endTime = Convert.ToDateTime("2017-9-11");
- //string sql = "select count(*) as 总计 from TKJL where 听课日期 >= #2017-9-1# and 听课日期 <=#2017-9-10#"; //OK
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection dtConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- string cNum = "";
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- while (objreader.Read())
- {
- j = j + 1;
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- cNum = objreader.GetValue(i).ToString();
- // sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + " </td>");
- }
-
- }
- return cNum;
- }
-
- /// <summary>
- /// 动态生成添加表单
- /// </summary>
- /// <param name="SQLStr"></param>
- /// <returns></returns>
- public StringBuilder BuildAddRecordFormOK(string SQLStr)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("<ul>");
- //连接并打开数据库
- SqlConnection objConn = new SqlConnection();
- objConn.ConnectionString = connectionString;
- objConn.Open();
- //创建DataReader对象(COMMAND)
- SqlCommand objcmd = new SqlCommand();
- objcmd.Connection = objConn;
- objcmd.CommandText = SQLStr;
- SqlDataReader objreader = objcmd.ExecuteReader();
- //读取并显示数据库
- objreader.Read();
- String TypeN, dispC;
- int FieldNum = objreader.FieldCount;
- for (int i = 1; i <= FieldNum - 1; i++)
- {
- sb.Append("<li>");
- sb.Append("<label>" + objreader.GetName(i) + "</label>");
- sb.Append(" <input type=\"hidden\" name=\"MyLabel" + i.ToString() + "\" id=\"MyLabel" + i.ToString() + "\" value=\"" + objreader.GetName(i) + "\" />");
- string FV = objreader.GetValue(i).ToString();
- TypeN = objreader.GetFieldType(i).Name;
- switch (TypeN)
- {
- case "String":
- dispC = "输文字";
- break;
- case "DateTime":
- dispC = Convert.ToString(DateTime.Now);
- break;
- case "Boolean":
- dispC = "true false";
- break;
- default:
- dispC = "输数值";
- break;
- }
- if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- {
- sb.Append("<textarea name=\"MyText" + Convert.ToString(i) + "\" id=\"MyText" + Convert.ToString(i) + "\" placeholder=\"输入数据\">" + dispC + " </textarea>");
- }
- else
- { sb.Append("<input type=\"text\" name=\"MyText" + Convert.ToString(i) + "\" id=\"MyText" + Convert.ToString(i) + "\" placeholder=\"" + dispC + "\" required=\"required\" autofocus=\"autofocus\" />"); }
- sb.Append("</li>");
- }
- sb.Append("</ul>");
- objreader.Close();
- objConn.Close();
- return sb;
- }
- /// <summary>
- /// 从动态生成的表单中读取数据并添加到数据库
- /// </summary>
- /// <param name="parasql"></param>
- /// <param name="tablename"></param>
- public void AddRecordToDB(string parasql, string tablename)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- objConn.Open();
- SqlDataAdapter objcmd = new SqlDataAdapter();
- objcmd.SelectCommand = new SqlCommand("select * from " + tablename, objConn);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- objcmd.Fill(ds, tablename);
- objConn.Close();
- DataTable dt = ds.Tables[tablename];
- DataRow dtrow = dt.NewRow();
- dtrow[0] = DBNull.Value;
- int k = 0;
- for (int i = 1; i < HttpContext.Current.Request.Form.Count; i++)
- {
- string name = HttpContext.Current.Request.Form.GetKey(i);
- if (name.IndexOf("Text") > 0)
- {
- k = k + 1;
- // Response.Write(k.ToString() + ":" + HttpContext.Current.Request.Form[i] + "<br>");
- dtrow[k] = HttpContext.Current.Request.Form[i];
- }
- }
- dt.Rows.Add(dtrow);
- objcmd.Update(ds, tablename);
- }
-
- //根据菜单内容动态生成老师或学生主菜单
- public StringBuilder main1(string SQL1)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <LINK rel=stylesheet type=text/css href=\"../css/style1.css\" media=screen>");
- sb.Append("\n <SCRIPT type=text/javascript src=\"../js/js/jquery.min.js\"></SCRIPT>");
- sb.Append("\n <SCRIPT type=text/javascript src=\"../js/js/lavalamp.min.js\"></SCRIPT>");
- sb.Append("\n <SCRIPT type=text/javascript src=\"../js/js/xixi.js\"></SCRIPT>");
- sb.Append("\n <SCRIPT type=text/javascript>");
- sb.Append("\n $(function () { $(\".lavaLamp\").lavaLamp({ fx: \"backout\", speed: 700 }) });");
- sb.Append("\n </SCRIPT>");
- sb.Append("\n <DIV id=wrapper>");
- sb.Append("\n <UL class=lavaLamp>");
- //SqlConnection objConn = new SqlConnection(connectionString);
- SqlConnection dtConn = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, dtConn);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, dtConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- int i = 0;
- sb.Append("\n <li class=\"onelink\"><a href='#'>主页</a></li>");
- while (objreader1.Read())
- {
- i = i + 1;
- sb.Append("\n <li><a href='" + objreader1["URL"] + "' rel='dropmenu" + i.ToString() + "'>" + objreader1["ClassName"] + "</a></li>");
- }
- sb.Append("\n </UL>");
- sb.Append("\n </DIV>");
- return sb;
- }
- //将上传文件转换为日期格式
- public string FilenameToDateFilename(string oldfilename)
- {
- string UpfileExtension = System.IO.Path.GetExtension(oldfilename); ;
- string Newfilename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + UpfileExtension;
- return Newfilename;
- }
- //根据ID从数据库获得指定字段的值
- public string GetFieldValue(int FieldsOrderNo, int id, string Tablename)
- {
- string SQL = "Select * from " + Tablename + " where id=" + id;
- SqlConnection objConn = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn); ;
- //SqlConnection dtConn = new SqlConnection();
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- // int i = 0;
- string getValue = "";
- while (objreader.Read())
- {
- getValue = objreader.GetValue(FieldsOrderNo).ToString();
- }
- return getValue;
- }
- //根据ID,字段名从数据库获得指定字段的值
- public string GetFieldValueFromFieldName(string FieldName, int id, string Tablename)
- {
- string SQL = "Select * from " + Tablename + " where id=" + id;
- SqlConnection objConn = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn); ;
- //SqlConnection dtConn = new SqlConnection();
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- //int i = 0;
- string getValue = "";
- while (objreader.Read())
- {
- getValue = objreader[FieldName].ToString();
- }
- return getValue;
- }
- //从数据库获得指定关键字段(字符)的值
- public string GetKeyFieldValue(int FieldsOrderNo, string KeyFieldName, string KeyFieldValue, string Tablename)
- {
- string SQL = "Select * from " + Tablename + " where " + KeyFieldName + "='" + KeyFieldValue + "'";
- SqlConnection objConn = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd = new OleDbDataAdapter(SQL, dtConn);
- //SqlConnection dtConn = new SqlConnection();
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- string getValue = "";
- while (objreader.Read())
- {
- getValue = objreader.GetValue(FieldsOrderNo).ToString();
- }
- return getValue;
- }
- //确定上传文件的路径
- public string UpFilePath(string demp, Int32 CourseID, string BJ, string XH, string XM, string ChsOrEng)
- //dempukuy,系部 BJ班级+XH学号+XM姓名 ChsOrEng中文还是英文文件夹存储
- {
- System.DateTime currentTime = System.DateTime.Now;
- int strYear = Convert.ToInt32(currentTime.Year.ToString());
- int strMonth = Convert.ToInt32(currentTime.Month.ToString());
- string SavePath = "";
- if (strMonth >= 2 && strMonth <= 7)
- { SavePath = strYear.ToString() + "S" + ")"; }
- else
- { SavePath = strYear.ToString() + "X"; }
- if (ChsOrEng == "Chs")
- {
- //以中文文件夹
- string KCM = GetFieldValue(2, CourseID, "Course");
- SavePath = demp + "\\" + SavePath + "\\" + KCM + "\\" + BJ + "\\" + XH + XM + "\\";
- }
- else
- {
- //以英文文件夹XM XH BJ存数据库,文件名转换为以日期为文件名
- //HttpPostedFile postedfile = fileupload.PostedFile; (参数:System.Web.UI.WebControls.FileUpload fileupload)
- //string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
- //string UpfileExtension = System.IO.Path.GetExtension(postedfile.FileName);
- //string Newfilename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + UpfileExtension;
- //if (OldFilenameOrNewFileName == true) { UpFilename = Newfilename; }
- demp = GetKeyFieldValue(1, "FieldNameChinese", demp, "FieldCHs_Eng");
- SavePath = demp + "\\" + SavePath + "\\" + CourseID + "\\" + XH + "\\";
- }
- return SavePath;
- //上传文件查看UpfilesPathandToDB
- }
- //显示指定表的所有数据
- public void DispTableData(string TableName)
- {
- //<configuration>
- // <connectionStrings>
- // <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MYDBSQL.mdf;User Instance=true"
- // providerName="System.Data.SqlClient" />
- // <add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
- // providerName="System.Data.SqlClient" />
- // </connectionStrings>
- SqlConnection objConn = new SqlConnection();
- //objConn.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
- objConn.ConnectionString = "data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\MYDBSQL.mdf;User Instance=true";
- objConn.Open();
- //**创建DATEREADER对象(COMMAND)**//
- SqlCommand objCmd = new SqlCommand();
- //OleDbCommand objCmd=new OleDbCommand();
- objCmd.Connection = objConn;
- objCmd.CommandText = "Select * from " + TableName;
- SqlDataReader objreader = objCmd.ExecuteReader();
- // OleDbDataReader objreader=objCmd.ExecuteReader() ;
- //读取并显示数据库
- int i;
- HttpContext.Current.Response.Write("<Table border='1'><tr align='center'>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- HttpContext.Current.Response.Write("<td>" + objreader.GetName(i) + "</TD>");
- }
- HttpContext.Current.Response.Write("</tr>");
- while (objreader.Read())
- {
- HttpContext.Current.Response.Write("<tr>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- HttpContext.Current.Response.Write("<td>" + objreader.GetValue(i) + "</TD>");
- }
- HttpContext.Current.Response.Write("</tr>");
- }
- HttpContext.Current.Response.Write("</table>");
- objreader.Close();
- objConn.Close();
- }
- //获得当前学期
- public string getCurrentXQ()
- {
- // string strDay = "";
- System.DateTime currentTime = System.DateTime.Now;
- int strYear = Convert.ToInt32(currentTime.Year.ToString());
- int strMonth = Convert.ToInt32(currentTime.Month.ToString());
- string xq = "";
- if (strMonth >= 2 && strMonth <= 7)
- { xq = (strYear - 1).ToString() + "~" + strYear.ToString() + "学年第二学期" + "(" + strYear.ToString() + "年春学期" + ")"; }
- else
- { xq = strYear.ToString() + "~" + (strYear + 1).ToString() + "学年第一学期" + "(" + strYear.ToString() + "年秋学期" + ")"; }
- return xq;
- }
- /// <summary>
- /// 获得当前日期的月日
- /// </summary>
- /// <param name="userData"></param>
- /// <returns></returns>
- public string getMonthDay()
- {
- System.DateTime currentTime = System.DateTime.Now;
- int strMonth = Convert.ToInt32(currentTime.Month.ToString());
- int strDay = Convert.ToInt32(currentTime.Day.ToString());
- return (strMonth + strDay).ToString();
- }
- /// <summary>
- /// //获取用户许可字符
- /// </summary>
- /// <param name="userData"></param>
- /// <returns></returns>
- public Boolean getUserChr(string userData)
- {//获取用户著作权,是否包含LYS,是否超过指定日期
- //获取是否有使用权限(通过指定指定特定字符,如第19个字符是否是L,第49个字符是否是Y,第77个字符是否是S,),获取使用12-82为日期
- //比较时间大小
- //DateTime dat1 = DateTime.Parse("2003-12-30");
- // DateTime dat2 = DateTime.Parse(DateTime.Now.ToShortDateString());
- // Response.Write("比较日期大小=" + dat1.CompareTo(dat2));// dat2.CompareTo(dat1)) 返回1,dat1.CompareTo(dat2))返回-1
- Boolean checkUY = false;
- DateTime dat1;
- string userPer = "";
- string Y1 = "0", Y2 = "0", Y3 = "0", Y4 = "0", M1 = "0", M2 = "0", D1 = "0", D2 = "0";
- userPer = userData.Substring(18, 1) + userData.Substring(48, 1) + userData.Substring(76, 1);
- //当前时间
- DateTime dat2 = DateTime.Parse(DateTime.Now.ToShortDateString());
- if (userData.Length < 90)
- { return false; }
- Y1 = userData.Substring(12, 1);
- Y2 = userData.Substring(22, 1);
- Y3 = userData.Substring(32, 1);
- Y4 = userData.Substring(42, 1);
- M1 = userData.Substring(52, 1);
- M2 = userData.Substring(62, 1);
- D1 = userData.Substring(72, 1);
- D2 = userData.Substring(82, 1);
- dat1 = DateTime.Parse(Y1 + Y2 + Y3 + Y4 + "-" + M1 + M2 + "-" + D1 + D2 + " 0:00:00");
- //HttpContext.Current.Response.Write(dat1);
- //HttpContext.Current.Response.Write("userPer" + userPer);
- // if (dat2.CompareTo(dat1) > 0 && userPer == "LYS")
- if (dat1 > dat2 && userPer == "LYS")
- {
- checkUY = true;
- }
- return checkUY;
- }
- //SQL语句中英文字段名自动转换为中文
- public string EnglishSQLToChineseSQL(string C_ETable, string EnglishFiledNameSQL)
- { //C_ETable英文字段与中文字段对照表(FieldCHs_Eng) EnglishFiledNameSQL英文字段名的SQL语句
- //Response.Write(myud.EnglishSQLToChineseSQL("FieldCHs_Eng", "Select ID,courseID,courseName,courseTrem,courseMemo from course").ToString())
- string sql = "select * from " + C_ETable;
- // string Chs_SQL = "";
- // SqlConnection objConn = new SqlConnection(connectionString);
- // SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, dtConn);
- SqlConnection dtConn = new SqlConnection();
- SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- if (EnglishFiledNameSQL.IndexOf(objreader["FieldName"].ToString()) >= 0)
- {
- EnglishFiledNameSQL = EnglishFiledNameSQL.Replace(objreader["FieldName"].ToString(), objreader["FieldName"].ToString() + " as " + objreader["FieldNameChinese"].ToString());
- }
- }
- return EnglishFiledNameSQL;
- }
- //获得当前学期前后五个学期,用for (int i=1;i<=5;i++)
- public string getfiveXQ()
- {
- // string strDay = "";
- System.DateTime currentTime = System.DateTime.Now;
- int strYear = Convert.ToInt32(currentTime.Year.ToString());
- int strMonth = Convert.ToInt32(currentTime.Month.ToString());
- string xq = "";
- if (strMonth >= 2 && strMonth <= 7)
- { xq = (strYear - 1).ToString() + "~" + strYear.ToString() + "学年第二学期" + "(" + strYear.ToString() + "年春学期" + ")"; }
- else
- { xq = strYear.ToString() + "~" + (strYear + 1).ToString() + "学年第一学期" + "(" + strYear.ToString() + "年秋学期" + ")"; }
- return xq;
- }
- //jQuery+CSS清新蓝色水平二级菜单
- public StringBuilder main50(string SQL1, string targetWindowName)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <link rel=\"stylesheet\" type=\"text/css\" href=\"images/50/CSS/header.css\" />");
- sb.Append("\n <script language=\"javascript\" type=\"text/javascript\" src=\"images/50/js/jquery-1.3.2.min.js\"></script>");
- sb.Append("\n <script language=\"javascript\" type=\"text/javascript\">");
- sb.Append("\n $(document).ready(function(){");
- sb.Append("\n $(\".mainNav a\").mouseover(function(){");
- sb.Append("\n $(\".mainNav a\").attr(\"class\",\"\");");
- sb.Append("\n $(\"#\"+this.id).attr(\"class\",\"actived\");");
- sb.Append("\n var currentMenuNo = parseInt(this.id.substring(1));");
- sb.Append("\n $(\".secondNav div\").each(function(){");
- sb.Append("\n $(this).hide();");
- sb.Append("\n $(\"#subNav\"+currentMenuNo).show();");
- sb.Append("\n });");
- sb.Append("\n });");
- sb.Append("\n });");
- sb.Append("\n </script>");
- sb.Append("\n <div class=\"header\">");
- sb.Append("\n <div class=\"padder\">");
- sb.Append("\n <div class=\"nav\">");
- sb.Append("\n <div class=\"navLaftBg\">");
- sb.Append("\n <div class=\"navRightBg\">");
- sb.Append("\n <div class=\"mainNav\">");
- //SqlConnection objConn = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, dtConn);
- SqlConnection dtConn = new SqlConnection();
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, dtConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- int i = 0;
- Int16[] getContent = new Int16[15];
- while (objreader1.Read())
- {
- i = i + 1;
- sb.Append("\n <a href=\"" + objreader1["URL"].ToString() + "\" id=\"n" + i.ToString() + "\" class=\"actived\">" + objreader1["ClassName"].ToString() + "</a>");
- getContent[i] = Convert.ToInt16(objreader1["id"].ToString());
- }
- sb.Append("\n ");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n <div class=\"secondNav\">");
- for (int k = 1; k <= i; k++)
- {
- sb.Append("\n <div id=\"subNav" + k.ToString() + "\" class=\"subNav" + k.ToString() + "\">");
- sb.Append("\n ");
- //OleDbConnection dtConn2 = new OleDbConnection(connectionString);
- SqlConnection dtConn2 = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from TreeGJK where followid=" + getContent[k].ToString() + " Order by id asc,followid Asc", dtConn2);
- SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from TreeGJK where followid=" + getContent[k].ToString() + " Order by id asc,followid Asc", dtConn2);
- DataSet dtSet2 = new DataSet();
- dtCmd2.Fill(dtSet2);
- DataTableReader objreader2 = dtSet2.CreateDataReader();
- while (objreader2.Read())
- {
- sb.Append("\n <a href=\"" + objreader2["URL"] + "\">" + objreader2["ClassName"].ToString() + "</a>");
- }
- sb.Append("\n </div>");
- dtConn2.Close();
- }
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- return sb;
- }
- //将前后五个学期绑定到DropDownList
- public void BindFiveXQToDropDownList(DropDownList myDropDownList)
- {
- // string strDay = "";
- System.DateTime currentTime = System.DateTime.Now;
- int strYear = Convert.ToInt32(currentTime.Year.ToString());
- int strMonth = Convert.ToInt32(currentTime.Month.ToString());
- //string xq = "";
- System.Collections.ArrayList arrTableList = new System.Collections.ArrayList();
- for (int i = 1; i <= 4; i++)
- {
- arrTableList.Add((strYear - 1).ToString() + "~" + strYear.ToString() + "学年第二学期" + "(" + strYear.ToString() + "年春学期" + ")");
- arrTableList.Add(strYear.ToString() + "~" + (strYear + 1).ToString() + "学年第一学期" + "(" + strYear.ToString() + "年秋学期" + ")");
- strYear = strYear - 1;
- }
- arrTableList.Sort();
- myDropDownList.DataSource = arrTableList;
- myDropDownList.DataBind();
- myDropDownList.Visible = true;
- }
- //检查学生登录
- public Boolean check_Studlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
- {
- Boolean LoginAccess = false;
- //学生登录检查
- //OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
- //OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- // OleDbDataReader myReader = myCommand.ExecuteReader();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
- LoginAccess = true;
- }
- else
- {
- HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- ////将数据写入Cookie文件中
- //public void WriteCookies(string CookiesName, string CookiesValue, int DayNum)
- //{ // DateTime.Now.AddDays(7); DayNum=7(一周),1=一天,30
- // HttpContext.Current.Response.Cookies[CookiesName].Value = CookiesValue;
- // HttpContext.Current.Response.Cookies[CookiesName].Expires = DateTime.Now.AddDays(DayNum);
- //}
- ////将读取Cookie文件中数据
- //public string ReadCookies(string CookiesName)
- //{
- // string cookieValue = HttpContext.Current.Request.Cookies[CookiesName].Value.ToString();
- // return cookieValue;
- //}
- //将读取Cookie文件中数据2018.3.11
- public string ReadCookies(string CookiesName)
- {
- string cookieValue = HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[CookiesName].Value.ToString(), System.Text.Encoding.GetEncoding("gb2312"));
- return cookieValue;
- }
- //将数据写入Cookie文件中,2018.3.11改
- public void WriteCookies(string CookiesName, string CookiesValue, int DayNum)
- { // DateTime.Now.AddDays(7); DayNum=7(一周),1=一天,30
- HttpContext.Current.Response.Cookies[CookiesName].Value = HttpUtility.UrlEncode(CookiesValue, System.Text.Encoding.GetEncoding("gb2312")); ;
- HttpContext.Current.Response.Cookies[CookiesName].Expires = DateTime.Now.AddDays(DayNum);
- }
- //老师登录,督导系统用
- public Boolean check_userlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
- {
- WriteCookies("UserName", "", 1);
- WriteCookies("UserType", "", 1);
- WriteCookies("UserDemp", "",1);
- WriteCookies("WorkNumber", "", 1);
- Boolean LoginAccess = false;
-
- //一般教师登录检查
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
- // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- // OleDbDataReader myReader = myCommand.ExecuteReader();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- HttpContext.Current.Session["UserName"] = myReader["用户名"].ToString();
- WriteCookies("UserName", myReader["用户名"].ToString(), 7);
- //HttpContext.Current.Session["密码"] = myReader.GetValue(5);
- HttpContext.Current.Session["UserType"] = myReader["类别"].ToString();
- WriteCookies("UserType", myReader["类别"].ToString(), 7);
- HttpContext.Current.Session["UserDemp"] = myReader["部门"].ToString();
- WriteCookies("UserDemp", myReader["部门"].ToString(), 7);
- //HttpContext.Current.Session["姓名"] = myReader.GetValue(2);
- HttpContext.Current.Session["WorkNumber"] = myReader["工号"].ToString();
- WriteCookies("WorkNumber", myReader["工号"].ToString(), 7);
- HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
- LoginAccess = true;
- }
- else
- {
- HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- //老师登录,DQP系统用
- public Boolean check_Teacherlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
- {
- WriteCookies("UserName", "", 7);
- WriteCookies("UserType", "", 7);
- WriteCookies("UserDemp", "", 7);
- Boolean LoginAccess = false;
- //一般教师登录检查
- //OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
- // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- // OleDbDataReader myReader = myCommand.ExecuteReader();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- HttpContext.Current.Session["UserName"] = myReader["Username"].ToString(); //用户名
- WriteCookies("UserName", myReader["Username"].ToString(), 7);
- HttpContext.Current.Session["Tea_name"] = myReader["Tea_name"].ToString();
- WriteCookies("Tea_name", myReader["Tea_name"].ToString(), 7);
- HttpContext.Current.Session["Dempent"] = myReader["Dempent"].ToString();//系部
- WriteCookies("Dempent", myReader["Dempent"].ToString(), 7);
- HttpContext.Current.Session["TeachR_Office"] = myReader["TeachR_Office"].ToString(); //教研室
- WriteCookies("TeachR_Office", myReader["TeachR_Office"].ToString(), 7);
- //HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
- HttpContext.Current.Response.Write("<script>alert('登录成功!')</script>");
- LoginAccess = true;
- }
- else
- {
- //HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
- HttpContext.Current.Response.Write("<script>alert('登录失败!你的用户名或者密码有误!')</script>");
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- //通用查询,根据字段名,字段值,返回另一个字段值
- public string QueryRecord(string QueryFieldName, string QueryFieldValue, string RetrnValueFieldName, string TableName)
- {
- // Boolean LoginAccess = false;
- //一般教师登录检查
- OleDbConnection objConn = new OleDbConnection(connectionString);
- string searchCmd = "select * from " + TableName + " where " + QueryFieldName + " = '" + QueryFieldValue + "'";
- OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- OleDbDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- return myReader[RetrnValueFieldName].ToString();
- }
- else
- {
- return "未查询到数据";
- }
- }
- //通用查询,根据字段名,字段值,返回另一个字段值
- public string QueryRecordMaxValue(string SQL, string RetrnValueFieldName, string TableName)
- {
-
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = SQL;
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- return myReader[RetrnValueFieldName].ToString();
- }
- else
- {
- return "未查询到数据";
- }
- }
- //根据用户类型动态生成不同的菜单导航系统
- public StringBuilder Prod_menu(string userType)
- {
- //userType:用户类型
- StringBuilder sb = new StringBuilder();
- switch (userType)
- {
- case "院管理员":
- {
-
-
- 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>");
- 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>");
- 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>");
- // 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>");
-
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"登记填写专题会议、项目评审、试卷检查等其它项目\"><a href=\"AddOther.aspx\"><img alt=\"\" src=\"images/a311ec9.jpg\" width=\"80\" height=\"80\" /><br /></a>填写其它项目</div>");
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"专题会议、项目评审、试卷检查等其它项目信息图片、附件等上传\"><a href=\"DispUpList.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /><br /></a>附件上传</div>");
-
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"数据报表\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表</div>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"数据报表--部门工作量统计\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表(部门工作量)</div>");
- sb.Append("\n <div class=\"divs\" title=\"工作量统计\"><a href=\"TeacherCount.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />督导个人工作统计</div>");
-
- } break;
- case "系管理员":
- {
-
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"专题会议、项目评审、试卷检查等其它项目信息图片、附件等上传\"><a href=\"DispUpList.aspx\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /><br /></a>附件上传</div>");
- sb.Append("\n <div class=\"divs\" title=\"数据报表--部门工作量统计\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表(部门工作量)</div>");
- 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>");
- 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>");
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"督导个人工作量统计\"><a href=\"TeacherCount.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />督导个人工作量统计</div>");
-
-
- } break;
- case "督导员":
- {
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"专题会议、项目评审、试卷检查等其它项目信息图片、附件等上传\"><a href=\"DispUpList.aspx\"><img alt=\"\" src=\"images/ichat.png\" width=\"80\" height=\"80\" /><br /></a>附件上传</div>");
- 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>");
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"数据报表\"><a href=\"Count.aspx\"><img alt=\"\" src=\"images/ical.png\" width=\"80\" height=\"80\" /></a><br />数据报表</div>");
- sb.Append("\n <div class=\"divs\" title=\"督导个人工作量统计\"><a href=\"TeacherCount.aspx\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />督导个人工作量统计</div>");
-
- //sb.Append("\n <ul id=\"list\" class=\"image-grid\">");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //// 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>");
- //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>");
- //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>");
- //sb.Append("\n </ul>");
- } break;
- case "教师":
- {
- //sb.Append("\n <ul id=\"list\" class=\"image-grid\">");
- //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>");
- //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>");
- //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>");
- //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>");
- //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>");
- //sb.Append("\n </ul>");
- 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>");
- 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>");
- sb.Append("\n <div class=\"divs\" title=\"待定功能\"><a href=\"#\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />待定功能</div>");
- sb.Append("\n <div class=\"divs\" title=\"待定功能\"><a href=\"#\"><img alt=\"\" src=\"images/textedit.png\" width=\"80\" height=\"80\" /></a><br />待定功能</div>");
-
- } break;
- }
- return sb;
- }
- //将SQL表名绑定到DropDownList OK
- public void BindFieldNameToCheckBoxListSQL(string SelectTableName, CheckBoxList FieldNameList)
- {//SelectTableName 选择的表名
- //FieldNameList(CheckList的名称,用于显示字段名 FieldNameList
- string selTableName = SelectTableName;
- HttpContext.Current.Session.Add("TableName", selTableName);
- //'创建 DataAdpter 对象案例
- //OleDbConnection objConn = new OleDbConnection();
- SqlConnection objConn = new SqlConnection(connectionString);
- //OleDbDataAdapter objCmd = new OleDbDataAdapter("Select * From " + selTableName, connectionString);
- SqlDataAdapter objCmd = new SqlDataAdapter("Select * From " + selTableName, connectionString);
- //'创建 DataSet 对象案例
- DataSet DS = new DataSet();
- objCmd.Fill(DS, selTableName);
- DataTable myTable = DS.Tables[selTableName];
- ArrayList arrTableList = new ArrayList();
- int i = 0;
- for (i = 0; i <= myTable.Columns.Count - 1; i++)
- {
- arrTableList.Add(myTable.Columns[i].Caption);
- }
- FieldNameList.DataSource = arrTableList;
- FieldNameList.DataBind();
- objConn.Close();
- }
- //将字段名绑定到DropDownList
- public void BindFieldNameToCheckBoxList(string SelectTableName, CheckBoxList FieldNameList)
- {//SelectTableName 选择的表名
- //FieldNameList(CheckList的名称,用于显示字段名 FieldNameList
- string selTableName = SelectTableName;
- HttpContext.Current.Session.Add("TableName", selTableName);
- //'创建 DataAdpter 对象案例
- //OleDbConnection objConn = new OleDbConnection();
- SqlConnection objConn = new SqlConnection();
- //OleDbDataAdapter objCmd = new OleDbDataAdapter("Select * From " + selTableName, connectionString);
- SqlDataAdapter objCmd = new SqlDataAdapter("Select * From " + selTableName, connectionString);
- //'创建 DataSet 对象案例
- DataSet DS = new DataSet();
- objCmd.Fill(DS, selTableName);
- DataTable myTable = DS.Tables[selTableName];
- ArrayList arrTableList = new ArrayList();
- int i = 0;
- for (i = 0; i <= myTable.Columns.Count - 1; i++)
- {
- arrTableList.Add(myTable.Columns[i].Caption);
- }
- FieldNameList.DataSource = arrTableList;
- FieldNameList.DataBind();
- objConn.Close();
- }
- ////将表名绑定到DropDownList
- //public void BindTableNameToDropDownList(DropDownList myDropDownList)
- //{
- // int i = 0;
- // //OleDbConnection objConn = new OleDbConnection();
- // //objConn.ConnectionString = connectionString;
- // //objConn.Open();
- // SqlConnection objConn = new SqlConnection();
- // objConn.ConnectionString = connectionString;
- // objConn.Open();
- // DataTable schemaTable = objConn.GetSchema(s SOleDbSchemaGuid.Tables, null);
- // ArrayList arrTableList = new ArrayList();
- // for (i = 1; i <= schemaTable.Rows.Count - 1; i++)
- // {
- // if (schemaTable.Rows[i].ItemArray[3].ToString() == "TABLE")
- // { arrTableList.Add(schemaTable.Rows[i].ItemArray[2].ToString()); }
- // }
- // myDropDownList.DataSource = arrTableList;
- // myDropDownList.DataBind();
- // objConn.Close();
- // myDropDownList.Visible = true;
- //}
- ////将表名绑定到ListBox
- //public void BindTableNameToListBox(ListBox myDropDownList)
- //{
- //}
- //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
- //浏览更新数据(含上传和修改)
- public StringBuilder UpdateMenuBrowse1(string SQL, string TableName, int mPageSize, string SaveFileDir, Boolean bRow)
- {
- SqlConnection conn = new SqlConnection(connectionString);
- SqlCommand cmd = new SqlCommand("", conn);
- int rowIndex = 1;
- int pageId = 1;
- int maxRow = 1;
- int maxPage = 1;
- int pageSize = mPageSize;
- StringBuilder sb = new StringBuilder();
- //确定当前页
- if (HttpContext.Current.Request.QueryString["pageId"] == null)
- {
- pageId = 1;
- }
- else
- {
- pageId = int.Parse(HttpContext.Current.Request.QueryString["pageId"].Trim());
- }
- try
- {
- if (conn.State == ConnectionState.Closed)
- {
- conn.Open();
- }
- // cmd.CommandText = "select count(*) from " + TableName + QueryConditions;//"select count(*) from " + TableName;
- cmd.CommandText = "select count(*) from " + TableName;
- maxRow = (int)cmd.ExecuteScalar();
- maxPage = (maxRow % pageSize > 0) ? (maxRow / pageSize + 1) : (maxRow / pageSize);
- cmd.CommandText = SQL;// "select * from " + TableName + " order by id"; //+ QueryConditions;
- SqlDataReader dr = cmd.ExecuteReader();
- for (int i = 0; i < (pageId - 1) * pageSize; i++)
- {
- dr.Read();
- rowIndex++;
- }
- int by = (pageId > 1) ? (pageId - 1) : 1;
- int by1 = (pageId < maxPage) ? (pageId + 1) : maxPage;
- sb.Append("记录总数为:" + maxRow.ToString() + ";当前页:" + pageId.ToString() + "/" + maxPage.ToString());
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=1'>第一页</a>]");
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by.ToString() + "'>上一页</a>]");
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by1.ToString() + "'>下一页</a>]");
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + maxPage.ToString() + "'>最后页</a>]");
- sb.Append("<br />");
- // sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- if (bRow == true)
- {
- sb.Append("<tr bgcolor='#99ccff'>");
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- //sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</th>");
- sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</th>");
- }
- for (int i = rowIndex; i < (rowIndex + pageSize); i++)
- {
- if (dr.Read())
- {
- sb.Append("</tr><tr>");
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- if (dr.GetName(j).ToString().Contains("附件"))
- {
- if (dr[j].ToString().Trim().Length > 0)
- {
- if (CheckImgType(dr[j].ToString().Trim()))
- { sb.Append("<td><img src=\"Upfiles\\"+dr[j].ToString().Trim()+"\" width=\"120\" height=\"120\" /></td>"); }
- else
- {
- sb.Append("<td>" + dr[j].ToString() + "</td>");
- }
-
- }
- else
- {
- sb.Append("<td>[<a href =\"Uppic.aspx?KeyF=" + dr["ID"].ToString() + "&tn=" + TableName + "&FieldN=" + dr.GetName(j).ToString() + "&Dir=" + SaveFileDir + "\" target=\"_blank\">上传附件]</a></td>");
- }
- }
-
-
- else
- {
- if (dr.GetName(j).ToString().Contains("督导内容"))
- { sb.Append("<td>[<a href =\"#\" target=\"_blank\" title='" + dr[j].ToString() + "'>督导内容</a>]</td>"); }
- else
- {
- sb.Append("<td>" + dr[j].ToString() + "</td>");
- }
- }
- }
- //sb.Append("<hr/>");
- }
- }
- }
- else
- {
- for (int i = rowIndex; i < (rowIndex + pageSize); i++)
- {
- if (dr.Read())
- {
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- sb.Append("<tr>");
- sb.Append("<td>" + dr.GetName(j) + "</td>");
- sb.Append("<td algin=left>" + dr[j].ToString().Replace("\r\n", "<br />") + "</td>");
- //if (dr.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- //{
- // sb.Append("<td><asp:TextBox ID='TextBox1' Text='" + dr[j].ToString() + "' runat='server' Columns='60' Rows='12' TextMode='MultiLine'></asp:TextBox> </td>");
- //}
- //else
- //{ sb.Append("<td><asp:TextBox ID='TextBox1' Text='"+ dr[j].ToString() +"' runat='server' Columns='60'></asp:TextBox> </td>"); }
- sb.Append("</tr>");
- }
- }
- }
- }
- sb.Append("</Table>");
- }
- catch (OleDbException e)
- {
- sb.Append(e.Message.ToString());
- }
- finally
- {
- if (conn.State == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- return sb;
- }
- public bool CheckImgType(string strImg)
- {
- if (strImg != null && strImg.ToString().Length > 0)
- {
- int i = strImg.LastIndexOf(".");
- string StrType = strImg.Substring(i).ToLower();
- if (StrType == ".jpg" || StrType == ".gif" || StrType == ".jpeg" || StrType == ".png")
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
- public StringBuilder DispLineDataModi(string SQL, string OPtype)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection dtConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
- // sb.Append("\n <tr class=\"list_bline1\">");
- sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + " </b>");
- //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + " </td>");
- }
- // sb.Append(" <td>[预览显示操作]</td>");
- if (OPtype.Trim().Length > 0)
- {
- sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>操作 </b>");
- }
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + " </td>");
- //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> </td>");
- }
- switch (OPtype)
- {
- case "disp":
- {
- 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>");
- } break;
- case "del":
- {
- 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>");
- } break;
- case "disppj":
- {
- 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>");
- } break;
- case "modi":
- {
- 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>");
- } break;
- case "ModiAndDel":
- {
- 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> <a href=\"#\" target=\"_blank\" onclick=\"Delconfirm('" + objreader["ID"].ToString() + "')\" >删除</a></td>");
- } break;
- case "dispzhpj":
- {
- 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>");
- } break;
- case "dispzhpjAdd":
- {
- 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>");
- } break;
- case "print":
- {
- 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>");
- } break;
- case "dispother":
- {
- 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>");
- } break;
- case "":
- {
- } break;
- }
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
- public StringBuilder DispLineData(string SQL)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
- // sb.Append("\n <tr class=\"list_bline1\">");
- sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + " </b>");
- //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + " </td>");
- }
- // sb.Append(" <td>[预览显示操作]</td>");
- sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>操作 </b>");
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + " </td>");
- //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> </td>");
- }
- // 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>");
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //以行显示成绩
- //以行显示成绩
- public StringBuilder DispScorea(string SQL, string OriginalOrWeight)
- {//OriginalOrWeight Original原始分Weight权重分
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"98%\" cellspacing='0' cellpadding='0' align=\"center\" class=\"lh28 font_st\">");
- sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- // Response.Write(objreader.GetFieldType(i).Name);
- 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) + " </b></td>");
- }
- if (OriginalOrWeight != "Original")
- {
- sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>总成绩 </b>");
- }
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- Single T_Score = 0; Single s1 = 0;
- sb.Append("\n <tr class=\"list_bline1\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- //if (objreader.GetName(i) == "TotalScore ") //如果字段名为TotalScore 计算总成绩
- // {
- // for (i = 0; i <= objreader.FieldCount - 1; i++)
- if (objreader.GetName(i).Substring(0, 3).ToUpper() == "SOC")
- {
- if (!string.IsNullOrEmpty(objreader.GetValue(i).ToString()))
- {
- s1 = Convert.ToSingle(objreader.GetValue(i).ToString());
- T_Score = T_Score + s1;
- }
- }
- // }
- 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() + " </td>");
- }
- //sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \" nowrap=\"nowrap\"> </td>");
- if (OriginalOrWeight != "Original")
- {
- 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 + " </td>");
- }
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //学生成果显示及阅卷
- public StringBuilder DispSOCLineData(string SQL)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"100%\" align=\"center\" >");
- sb.Append("\n <tr>");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td align=\"center\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + " </b>");
- }
- sb.Append(" <td align=\"center\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>下载 </b></td><td align=\"center\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>评分 </b></td>");
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr>");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("\n <td align=\"center\">" + objreader.GetValue(i).ToString() + " </td>");
- }
- //sb.Append("\n <td>[下载成果查看]</td><td><a href=\"SOCYue.aspx?ID=" + objreader["ID"].ToString() + "\">");
- //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>");
- sb.Append("\n <td align=\"center\">[下载成果查看]</td><td align=\"center\">");
- //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>");
- sb.Append("<a href=\"#\" onclick=\"window.open('SaveSocScore.aspx?ID=" + objreader["ID"].ToString() + "','','width=300,height=450')\">评分</a></td>");
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //以行显示,每一行下划线显示 显示学生的课程
- public StringBuilder DispCourseLineData(string SQL, string DispFieldName)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int j = 0;
- // sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
- while (objreader.Read())
- {
- j = j + 1;
- // sb.Append("\n <tr class=\"list_bline1\">");
- // sb.Append("\n <li><a href='CourseSocList.aspx'\"?StudentID=" + HttpContext.Current.Session["stud_number"].ToString() + "&courseID=" + objreader["ID"].ToString() + "\">" + objreader[DispFieldName].ToString() + "[查看]</a> </li>");
- sb.Append("\n <li><a href=\"CourseSocList.aspx?StudentID=" + HttpContext.Current.Session["stud_number"].ToString() + "&courseID=" + objreader["ID"].ToString() + "\">" + objreader[DispFieldName].ToString() + "[查看]</a> </li>");
- //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>");
- //sb.Append("\n </tr>");
- }
- //sb.Append("</table>");
- return sb;
- }
- //课程设置
- public StringBuilder DispCourseSetLineData(string SQL, string DispFieldName)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int j = 0;
- sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- 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> </li></td>");
- //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>");
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //课程评分
- public StringBuilder DispCoursePFLineData(string SQL, string DispFieldName)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int j = 0;
- sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\">");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- 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> </li></td>");
- //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>");
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //以行显示,每一行下划线显示 单独页面可以,俚在INDEX2.aspx页面有问题
- public StringBuilder DispLineDataadmin(string SQL)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"900\" align=\"center\" class=\"lh28 font_st\">");
- // sb.Append("\n <tr class=\"list_bline1\">");
- sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td align=\"center\" nowrap=\"nowrap\" style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>" + objreader.GetName(i) + " </b>");
- //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + " </td>");
- }
- // sb.Append(" <td>[预览显示操作]</td>");
- sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\"><b>操作 </b>");
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 1; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + " </td>");
- //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> </td>");
- }
- 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>");
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //评价数据显示,以行显示,每一行下划线显示
- public StringBuilder PJLineData(string SQL, string NB)
- {
- StringBuilder sb = new StringBuilder();
- // sb.Append("\n <link href=\"css/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"98%\" align=\"center\" class=\"lh28 font_st\">");
- // sb.Append("\n <tr class=\"list_bline1\">");
- sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\">" + objreader.GetName(i) + " </td>");
- //sb.Append(" <td style=\"background-image:url(CSS/index/channel-style-orange.gif); height:32px;\">" + objreader.GetName(i) + " </td>");
- }
- sb.Append(" <td style=\"background-color:#3F98E9; color:#FFFFFF; height:30px;\">[操作]</td>");
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr class=\"list_bline1\">");
- //sb.Append("\n <tr style=\"background-image: url('images/list_line2-1.gif')\">");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("\n <td style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #C1CCD5; \">" + objreader.GetValue(i).ToString() + "</td>");
- }
- sb.Append("\n <td ><a href=\"PJ.aspx?id=" + objreader["id"].ToString() + "&NB=" + NB + "\">[评价]</a></td>");
- sb.Append("\n </tr>");
- }
- sb.Append("</table>");
- return sb;
- }
- //弹拉缩
- public StringBuilder DisplayPOC(string SQL1)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <script type=\"text/javascript\" src=\"../js/jquery.min.js\"></script>");
- sb.Append("\n <link type=\"text/css\" rel=\"stylesheet\" href=\"../JS/T8.css\" />");
- sb.Append("\n <script type=\"text/javascript\" src=\"../Js/showList.js\"></script>");
- // sb.Append("\n <link href=\"js/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- sb.Append("\n <div>");
- sb.Append("\n <div class=\"main content\" style=\"background-color:#ECF4FB;\"> ");
- sb.Append(" \n <div class=\"left-sider\">");
- sb.Append("\n <div class=\"operate\">");
- sb.Append("\n <h3>专业预期学习成果 </h3>");
- sb.Append("\n <ul id=\"J_navlist\">");
- SqlConnection objConn = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, objConn);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- StringBuilder SB = new StringBuilder();
- while (objreader1.Read())
- {
- sb.Append("\n <li >");
- sb.Append(" \n <h4 ><b>" + objreader1.GetValue(3) + "</b></h4>");
- sb.Append(" \n <div class=\"list-item none\" >");
- // OleDbConnection dtConn2 = new OleDbConnection(connectionString);
- SqlConnection objConn2 = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", objConn2);
- DataSet dtSet2 = new DataSet();
- dtCmd2.Fill(dtSet2);
- DataTableReader objreader2 = dtSet2.CreateDataReader();
- sb.Append("\n <table width=\"100%\" align=\"center\" class=\"lh28 font_st\" style=\"background-color:#F3F9FA;\">");
- while (objreader2.Read())
- {
- sb.Append("\n <tr class=\"list_bline1\" align='left'>");
- 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; \">");
- sb.Append(" <input type='checkbox' id='MS" + objreader2["ID"] + "' name='MS" + objreader2["ID"] + "' value='" + objreader2["ClassName"] + "' onclick=\"checkbox('MS" + objreader2["ID"] + "','Tv" + objreader2["ID"] + "')\" />" + objreader2["ClassName"] + "");
- 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>");
- }
- sb.Append("</table>");
- sb.Append(" \n </div>");
- sb.Append(" \n </li>");
- objConn2.Close();
- }
- objConn.Close();
- sb.Append(" \n </ul>");
- sb.Append("\n <script type=\"text/javascript\" language=\"javascript\">");
- sb.Append("\n navList(12);");
- sb.Append("\n </script>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n <div style=\"text-align:center;clear:both\"></div>");
- return sb;
- }
- //弹拉缩
- public StringBuilder main8(string SQL1)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <script type=\"text/javascript\" src=\"js/jquery.min.js\"></script>");
- sb.Append("\n <link type=\"text/css\" rel=\"stylesheet\" href=\"JS/T8.css\" />");
- sb.Append("\n <script type=\"text/javascript\" src=\"Js/showList.js\"></script>");
- // sb.Append("\n <link href=\"js/global.css\" rel=\"stylesheet\" type=\"text/css\" />");
- sb.Append("\n <div>");
- sb.Append("\n <div class=\"main content\">");
- sb.Append(" \n <div class=\"left-sider\">");
- sb.Append("\n <div class=\"operate\">");
- // sb.Append("\n <h3>主菜单 </h3>");
- sb.Append("\n <ul id=\"J_navlist\">");
- SqlConnection objConn = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, objConn);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- StringBuilder SB = new StringBuilder();
- while (objreader1.Read())
- {
- sb.Append("\n <li >");
- sb.Append(" \n <h4 ><b>" + objreader1.GetValue(3) + "</b></h4>");
- sb.Append(" \n <div class=\"list-item none\">");
- SqlConnection dtConn2 = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from DDTreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- DataSet dtSet2 = new DataSet();
- dtCmd2.Fill(dtSet2);
- DataTableReader objreader2 = dtSet2.CreateDataReader();
- sb.Append("\n <table width=\"98%\" align=\"center\" class=\"lh28 font_st\">");
- while (objreader2.Read())
- {
- sb.Append("\n <tr class=\"list_bline1\">");
- sb.Append("\n <td id='Tv" + objreader2["ID"] + "' style=\"height:30px; border-bottom-width: 1px; border-bottom-style: dotted;border-bottom-color: #C1CCD5; \">");
- sb.Append(" <input type='checkbox' id='MS" + objreader2["ID"] + "' name='MS" + objreader2["ID"] + "' value='" + objreader2["ClassName"] + "' onclick=\"checkbox('MS" + objreader2["ID"] + "','Tv" + objreader2["ID"] + "')\" />" + objreader2["ClassName"] + "");
- //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"] + "')\" />");
- //sb.Append("<a href=\"#\" target=\"_self\">" + objreader2["ClassName"].ToString() + "</a></p>");
- sb.Append("\n </td></tr>");
- }
- sb.Append("</table>");
- sb.Append(" \n </div>");
- sb.Append(" \n </li>");
- dtConn2.Close();
- }
- objConn.Close();
- sb.Append(" \n </ul>");
- sb.Append("\n <script type=\"text/javascript\" language=\"javascript\">");
- sb.Append("\n navList(12);");
- sb.Append("\n </script>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n </div>");
- sb.Append("\n <div style=\"text-align:center;clear:both\"></div>");
- return sb;
- }
- //显示预览功能,通过单击表格行,显示当前页SWF的内容
- public StringBuilder ViewInCurrentSWF(string SQL, int ViewFiledNo)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("\n <script>");
- sb.Append("\n function kai(i)");
- sb.Append("\n {");
- sb.Append("\n var DT_win=document.getElementById(i);");
- sb.Append("\n ");
- sb.Append("\n DT_win.style.display=(DT_win.style.display==\"none\"?\"block\":\"none\");");
- sb.Append("\n }");
- sb.Append("\n </script>");
- string sql = SQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0, j = 0;
- sb.Append("\n <table width=\"95%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"#E7F5FE\" bgcolor=\"#FFFFFF\" >");
- sb.Append("\n <tr height=\"32\">");
- for (i = 2; i <= objreader.FieldCount - 1; i++)
- {
- if (i != ViewFiledNo)
- {
- 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) + " </td>");
- }
- }
- 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>");
- sb.Append("\n </tr>");
- while (objreader.Read())
- {
- j = j + 1;
- sb.Append("\n <tr height=\"30\" style=\"CURSOR: pointer\" onclick=javascript:kai(" + j.ToString() + ") >");
- for (i = 2; i <= objreader.FieldCount - 1; i++)
- {
- if (i != ViewFiledNo)
- {
- 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() + " </td>");
- }
- }
- 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>");
- sb.Append("\n </tr>");
- sb.Append("\n <tr style=\"DISPLAY: none\" id=\"" + j.ToString() + "\" bgColor=\"#f0f8ff\"><td colspan=\"");
- sb.Append("\n" + (objreader.FieldCount - 1).ToString() + "\">");
- 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>");
- 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 + "\">");
- sb.Append("\n <param name=\"movie\" value=\"" + "UpFiles/" + objreader.GetValue(ViewFiledNo).ToString() + "\">");
- sb.Append("\n <param name=\"quality\" value=\"high\">");
- 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>");
- sb.Append("\n </object>");
- //sb.Append(DispSWFFile(700,680,"文件名","UpFiles//"+objreader.GetValue(ViewFiledNo).ToString()+"").ToString() );
- sb.Append("</LI></UL></td></tr></table></td>");
- //sb.Append(" <td>[操作][<asp:Button ID=\"Button" + objreader.GetName(0) + "\" CommandName=\"" + objreader.GetName(0) + "\" CommandArgument=\"+Tablename+\" runat=\"server\" onclick=\"Button1_Click\" Text=\"预览\" />]</td>");这个可以用按钮事件来管理
- }
- sb.Append("</table>");
- return sb;
- }
- //将课程名称显示为超链接
- public StringBuilder ShowKCname(string tablename, string BindFieldName)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- string SQL = "select DISTINCT(" + BindFieldName + ") , intro from " + tablename + " where followid=0";
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- string myurl = GetAddressUrl();
- while (objreader.Read())
- {
- sb.Append("<a href=\"?intro=" + objreader["intro"] + "\">" + objreader[BindFieldName] + "</a>");
- }
- return sb;
- }
- //非常不错与数据库结合,并以选项卡形式,界面清新,可用于多个FLASH等多个页面同时显示
- public StringBuilder main161(string URLFieldName, string SQL1)
- {
- //URLFieldName URL对应字段名
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <STYLE type=text/css>");
- sb.Append("\n BODY { FONT-SIZE: 14px; FONT-FAMILY: \"宋体\"; }");
- sb.Append("\n OL LI { MARGIN: 8px }");
- sb.Append("\n #con { FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH: 700px;Height:680 }");
- 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 }");
- 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 }");
- 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 }");
- sb.Append("\n #tags LI.emptyTag { BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px }");
- sb.Append("\n #tags LI.selectTag { BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 25px }");
- sb.Append("\n #tags LI.selectTag A { BACKGROUND-POSITION: right top; COLOR: #000; LINE-HEIGHT: 25px; HEIGHT: 25px }");
- 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 }");
- //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 }");
- 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 }");
- sb.Append("\n #tagContent DIV.selectTag { DISPLAY: block }");
- sb.Append("\n </STYLE>");
- sb.Append("\n ");
- sb.Append("\n <SCRIPT type=text/javascript>");
- sb.Append("\n function selectTag(showContent,selfObj){");
- sb.Append("\n // 操作标签");
- sb.Append("\n var tag = document.getElementById(\"tags\").getElementsByTagName(\"li\");");
- sb.Append("\n var taglength = tag.length;");
- sb.Append("\n for(i=0; i<taglength; i++){");
- sb.Append("\n tag[i].className = \"\";");
- sb.Append("\n }");
- sb.Append("\n selfObj.parentNode.className = \"selectTag\";");
- sb.Append("\n // 操作内容");
- sb.Append("\n for(i=0; j=document.getElementById(\"tagContent\"+i); i++){");
- sb.Append("\n j.style.display = \"none\";");
- sb.Append("\n }");
- sb.Append("\n document.getElementById(showContent).style.display = \"block\";");
- sb.Append("\n ");
- sb.Append("\n ");
- sb.Append("\n }");
- sb.Append("\n </SCRIPT>");
- sb.Append("\n ");
- sb.Append("\n <DIV id=con>");
- sb.Append("\n <UL id=tags>");
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- string[] getContent = new string[12];
- int s = 0; int i = 0;
- while (objreader1.Read())
- {
- s = s + 1;
- sb.Append("\n <LI><A onClick=\"selectTag('tagContent" + (s - 1).ToString() + "',this)\" href=\"javascript:void(0)\">当前练习内容:" + objreader1.GetValue(2) + "</A> </LI>");
- getContent[s] = objreader1[URLFieldName].ToString();
- }
- sb.Append("\n </UL>");
- sb.Append("\n <DIV id=tagContent>");
- for (i = 1; i <= s; i++)
- {
- if (i == 1)
- { sb.Append("\n <DIV class=\"tagContent selectTag\" id=tagContent" + (i - 1).ToString() + ">" + DispSWFFile(690, 660, "构件概述", "" + getContent[i].ToString().Trim() + "").ToString() + "</DIV>"); }
- else
- {
- sb.Append("\n <DIV class=\"tagContent\" id=tagContent" + (i - 1).ToString() + ">" + DispSWFFile(690, 660, "构件概述", "" + getContent[i].ToString().Trim() + "").ToString() + "</DIV>");
- }
- }
- sb.Append("\n </DIV>");
- sb.Append("\n </DIV>");
- return sb;
- }
- //显示SWF文件
- public StringBuilder DispSWFFile(int swfWidth, int swfHeight, string sTitle, string swfFileName)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append("\n <table cellspacing=\"1\" cellpadding=\"2\" width=\"" + swfWidth + "\" height=\"" + swfHeight + "\" border=\"0\" class=\"a2\" align=\"center\">");
- sb.Append("\n <tr height=20>");
- sb.Append("\n <td colspan=\"3\" align=middle valign=\"middle\" class=a1><b>上机内容</b></td>");
- sb.Append("\n </tr>");
- sb.Append("\n ");
- sb.Append("\n <tr height=25>");
- sb.Append("\n <td colspan=\"3\" align=left class=a3>");
- sb.Append("\n <object id=\"FlashID\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + swfWidth + "\" height=\"" + swfHeight + "\">");
- sb.Append("\n <param name=\"movie\" value=\"UPfiles\\" + swfFileName + "\" />");
- sb.Append("\n <param name=\"quality\" value=\"high\" />");
- sb.Append("\n<param name=\"wmode\" value=\"opaque\" />");
- sb.Append("\n<param name=\"swfversion\" value=\"6.0.65.0\" />");
- sb.Append("\n <!-- 此 param 标签提示使用 Flash Player 6.0 r65 和更高版本的用户下载最新版本的 Flash Player。如果您不想让用户看到该提示,请将其删除。 -->");
- sb.Append("\n <param name=\"expressinstall\" value=\"Scripts/expressInstall.swf\" />");
- sb.Append("\n <!-- 下一个对象标签用于非 IE 浏览器。所以使用 IECC 将其从 IE 隐藏。 -->");
- sb.Append("\n <!--[if !IE]>-->");
- sb.Append("\n <object type=\"application/x-shockwave-flash\" data=\"Upfiles\\" + swfFileName + "\" width=\"" + swfWidth + "\" height=\"" + swfHeight + "\">");
- sb.Append("\n <!--<![endif]-->");
- sb.Append("\n <param name=\"quality\" value=\"high\" />");
- sb.Append("\n <param name=\"wmode\" value=\"opaque\" />");
- sb.Append("\n <param name=\"swfversion\" value=\"6.0.65.0\" />");
- sb.Append("\n <param name=\"expressinstall\" value=\"Scripts/expressInstall.swf\" />");
- sb.Append("\n <!-- 浏览器将以下替代内容显示给使用 Flash Player 6.0 和更低版本的用户。 -->");
- sb.Append("\n <div>");
- sb.Append("\n <h4>此页面上的内容需要较新版本的 Adobe Flash Player。</h4>");
- 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>");
- sb.Append("\n </div>");
- sb.Append("\n <!--[if !IE]>-->");
- sb.Append("\n </object>");
- sb.Append("\n <!--<![endif]-->");
- sb.Append("\n</object>");
- sb.Append("\n<script type=\"text/javascript\">");
- sb.Append("\nswfobject.registerObject(\"FlashID\");");
- sb.Append("\n</script>");
- sb.Append("\n <br></td></tr></table>");
- return sb;
- }
- //一行一行读文本文件的内容
- public string LineReadTxtFile(string Txt_filename)
- {
- StringBuilder sb = new StringBuilder();
- if (!File.Exists(Txt_filename))
- {
- HttpContext.Current.Response.Write("<script>alert('文件" + Txt_filename + "不存在!')</script>");
- }
- else
- {
- StreamReader sr = new StreamReader(Txt_filename, Encoding.GetEncoding("gb2312"));
- //StreamReader sr = File.OpenText(Txt_filename); //这行容易出现乱码,改为上一行即可
- string input;
- int s = 0;
- while ((input = sr.ReadLine()) != null)
- {
- s = s + 1;
- sb.Append(input + "\n");
- //Response.Write(input + "<br>");
- }
- sr.Close();
- }
- return sb.ToString();
- }
- //访问记数:
- public void AddNum(String TableName, String UpdateFieldName, int JS_FieldsOrderNo, int KeyID)
- {
- //OleDbConnection DBConn;
- // OleDbCommand DBUpdate = new OleDbCommand();
- SqlConnection DBConn;
- SqlCommand DBUpdate = new SqlCommand();
- DBConn = new SqlConnection(connectionString);
- DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "=" + (Convert.ToInt32(GetFieldValue(JS_FieldsOrderNo, KeyID, TableName)) + 1) + " Where ID=" + KeyID;
- DBUpdate.Connection = DBConn;
- DBUpdate.Connection.Open();
- DBUpdate.ExecuteNonQuery();
- }
- //浏览更新数据(含上传和修改)
- public StringBuilder UpdateMenuBrowse(string CSSFilename, string TableName, int mPageSize, string SaveFileDir, Boolean bRow)
- {
- // OleDbConnection conn = new OleDbConnection(connectionString);
- SqlConnection conn = new SqlConnection(connectionString);
- //OleDbCommand cmd = new OleDbCommand("", conn);
- SqlCommand cmd = new SqlCommand("", conn);
- int rowIndex = 1;
- int pageId = 1;
- int maxRow = 1;
- int maxPage = 1;
- int pageSize = mPageSize;
- StringBuilder sb = new StringBuilder();
- //确定当前页
- if (HttpContext.Current.Request.QueryString["pageId"] == null)
- {
- pageId = 1;
- }
- else
- {
- pageId = int.Parse(HttpContext.Current.Request.QueryString["pageId"].Trim());
- }
- try
- {
- if (conn.State == ConnectionState.Closed)
- {
- conn.Open();
- }
- // cmd.CommandText = "select count(*) from " + TableName + QueryConditions;//"select count(*) from " + TableName;
- cmd.CommandText = "select count(*) from " + TableName;
- maxRow = (int)cmd.ExecuteScalar();
- maxPage = (maxRow % pageSize > 0) ? (maxRow / pageSize + 1) : (maxRow / pageSize);
- cmd.CommandText = "select * from " + TableName + " order by id"; //+ QueryConditions;
- //OleDbDataReader dr = cmd.ExecuteReader();
- SqlDataReader dr = cmd.ExecuteReader();
- for (int i = 0; i < (pageId - 1) * pageSize; i++)
- {
- dr.Read();
- rowIndex++;
- }
- int by = (pageId > 1) ? (pageId - 1) : 1;
- int by1 = (pageId < maxPage) ? (pageId + 1) : maxPage;
- sb.Append("记录总数为:" + maxRow.ToString() + ";当前页:" + pageId.ToString() + "/" + maxPage.ToString());
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=1'>第一页</a>]");
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by.ToString() + "'>上一页</a>]");
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + by1.ToString() + "'>下一页</a>]");
- sb.Append("[<a href='" + System.IO.Path.GetFileName(HttpContext.Current.Request.Path).ToString() + "?pageId=" + maxPage.ToString() + "'>最后页</a>]");
- sb.Append("<br />");
- sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- if (bRow == true)
- {
- sb.Append("<tr bgcolor='#99ccff'>");
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</th>");
- }
- for (int i = rowIndex; i < (rowIndex + pageSize); i++)
- {
- if (dr.Read())
- {
- sb.Append("</tr><tr>");
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- if (j == 5 && dr[5].ToString().Length == 0)
- { sb.Append("<td>[<a href =\"Uppic.aspx?KeyF=" + dr[0].ToString() + "&tn=" + TableName + "&FieldN=URL&Dir=" + SaveFileDir + "\" target=\"_blank\">上传文件]</a></td>"); }
- else if (j == 9 && dr[9].ToString().Length == 0)
- { sb.Append("<td>[<a href =\"UpdateFiledValue.aspx?KeyF=" + dr[0].ToString() + "&tn=" + TableName + "&FiledN=sContent\" target=\"_blank\">添加内容</a>]</td>"); }
- else
- {
- sb.Append("<td>" + dr[j].ToString() + "</td>");
- }
- }
- //sb.Append("<hr/>");
- }
- }
- }
- else
- {
- for (int i = rowIndex; i < (rowIndex + pageSize); i++)
- {
- if (dr.Read())
- {
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- sb.Append("<tr>");
- sb.Append("<td>" + dr.GetName(j) + "</td>");
- sb.Append("<td algin=left>" + dr[j].ToString().Replace("\r\n", "<br />") + "</td>");
- //if (dr.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- //{
- // sb.Append("<td><asp:TextBox ID='TextBox1' Text='" + dr[j].ToString() + "' runat='server' Columns='60' Rows='12' TextMode='MultiLine'></asp:TextBox> </td>");
- //}
- //else
- //{ sb.Append("<td><asp:TextBox ID='TextBox1' Text='"+ dr[j].ToString() +"' runat='server' Columns='60'></asp:TextBox> </td>"); }
- sb.Append("</tr>");
- }
- }
- }
- }
- sb.Append("</Table>");
- }
- catch (OleDbException e)
- {
- sb.Append(e.Message.ToString());
- }
- finally
- {
- if (conn.State == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- return sb;
- }
- /// <summary> 上传文件(所有类型,没有限制,以原文件名或者日期为文件名保存) </summary>
- /// <param name="fileupload">WebControls.FileUpload 控件</param>
- /// <param name="Fdir">保存的文件夹</param>
- /// <param name="OldFilenameOrNewFileName">是以原文件名保存还是以日期为文件名保存</param>
- //调用:
- //Literal1.Text = myud.UpfilesPathandToDB(FileUpload1, "upfile", true, "TreeGJK","URL",23).ToString();
- public string UpfilesPathandToDB(System.Web.UI.WebControls.FileUpload fileupload, string Fdir, Boolean OldFilenameOrNewFileName, string TableName, string SaveFieldName, Int32 KeyID)
- {// OldFilenameOrNewFileName 为True 时,以日期为文件名,否则以原文件名
- HttpPostedFile postedfile = fileupload.PostedFile;
- //if (!Directory.Exists(Server.MapPath(".") + "PIC"))
- //{ Directory.CreateDirectory(Server.MapPath(".") + "PIC"); }
- StringBuilder strmsg = new StringBuilder();
- string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
- string UpfileExtension = System.IO.Path.GetExtension(postedfile.FileName);
- string Newfilename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + UpfileExtension;
- if (OldFilenameOrNewFileName == true) { UpFilename = Newfilename; }
- if (postedfile.ContentLength > 0)
- {
- if (TableName.Length > 0 && KeyID > 0)
- { UpdateStringFieldValue(TableName, SaveFieldName, UpFilename.ToString(), KeyID); }
- if (Fdir == "")
- { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + UpFilename); }
- else
- { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + Fdir + "\\" + UpFilename); }
- strmsg.AppendFormat("【文件名:" + UpFilename.ToString() + "】");
- strmsg.AppendFormat("<br>【文件大小:" + postedfile.ContentLength.ToString() + "】");
- strmsg.AppendFormat("<br>【文件类型:" + postedfile.ContentType.ToString() + "】");
- return strmsg.ToString();
- }
- else
- { return "请选择欲上传文件"; }
- }
- //教师成果设置及显示
- public StringBuilder showmenu(string SQL1, string tablename)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd1 = new OleDbDataAdapter(SQL1, objConn);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- int i = 0;
- StringBuilder SB = new StringBuilder();
- SB.Append(" <table width='96%' border='1' align=\"center\" cellspacing='1' bordercolor=\"#C1E7FD\" bgcolor=\"#F4FCFF\">");
- 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>");
- // SB.Append("<tr bgcolor=\"#E2F2FC\" ><td height='28' width='10%' align=\"center\">序号</td><td width='30%'>课程名称</td><td width='60%'>操作</td></tr>");
- SB.Append(" <tr bgcolor=\"#E2F2FC\" ><td><p>");
- while (objreader1.Read())
- {
- i = i + 1;
- SB.Append(objreader1["courseName"].ToString());
- SB.Append("<a target=\"_blank\" href=\"../SetSOC.aspx?followid=" + objreader1.GetValue(0) + "\">[设置本课程成果]</a>");
- SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader1.GetValue(0) + "\">[删除本课程]</a>");
- SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader1.GetValue(0) + "\">[修改课程]</a></p>");
- //SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader1.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
- OleDbConnection dtConn2 = new OleDbConnection(connectionString);
- OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
- DataSet dtSet2 = new DataSet();
- dtCmd2.Fill(dtSet2);
- DataTableReader objreader2 = dtSet2.CreateDataReader();
- int k = 0;
- while (objreader2.Read())
- {
- k = k + 1;
- SB.Append("<p> 成果" + k.ToString() + "." + objreader2["SOCPoint"].ToString() + "(" + objreader2["SOCscore"].ToString() + ")");
- SB.Append("<a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[为本课程设置子成果]</a>");
- SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[删除此项成果]</a>");
- SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader2.GetValue(0) + "\">[修改此成果评分点]</a></p>");
- // SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader2.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
- }
- // SB.Append("<hr>");
- dtConn2.Close();
- }
- SB.Append("\n</td></tr> </table>");
- objConn.Close();
- return SB;
- }
- //学生根据成果上传
- public StringBuilder showCGUpfile(string SQL1, string tablename, Int32 courseID)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- // SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, dtConn);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- int i = 0;
- StringBuilder SB = new StringBuilder();
- SB.Append(" <table class=\"bordered\" align=\"center\">");
- while (objreader1.Read())
- {
- i = i + 1;
- SB.Append(" <tr><td colspan=6>");
- SB.Append("\n <h2>课程名称:" + objreader1["courseName"].ToString() + "</h2></td></tr>");
- SB.Append(" <tr><td>成果序号</td><td>成果名称</td><td>成果对应学分</td><td>成果权重</td><td>成果描述</td><td>操作</td>");
- // SB.Append(" <tr bgcolor=\"#E2F2FC\"><td>");
- SqlConnection dtConn2 = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
- DataSet dtSet2 = new DataSet();
- dtCmd2.Fill(dtSet2);
- DataTableReader objreader2 = dtSet2.CreateDataReader();
- int k = 0;
- while (objreader2.Read())
- {
- k = k + 1;
- SB.Append("\n <tr><td> [成果" + k.ToString() + "]</td><td>" + objreader2["SOCPoint"].ToString() + "</td><td>(学分:" + objreader2["SOCscore"].ToString() + ")</td><td>" + objreader2["SOCweight"].ToString() + "</td><td>" + objreader2["SOCBeWrite"].ToString() + "</td>");
- SB.Append("<td><a target=\"_blank\" href=\"Upfiles.aspx?CID=" + courseID + "&courseID=" + objreader2["ID"].ToString() + "\">[上传我的成果]</a><br></td></tr>");
- }
- //SB.Append("\n</td></tr>");
- dtConn2.Close();
- }
- SB.Append("\n </table>");
- objConn.Close();
- return SB;
- }
- //显示教师的课程设置及成果设置
- public StringBuilder showmenu1(string SQL1, string tablename)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd1 = new SqlDataAdapter(SQL1, objConn);
- DataSet dtSet1 = new DataSet();
- dtCmd1.Fill(dtSet1);
- DataTableReader objreader1 = dtSet1.CreateDataReader();
- int i = 0;
- StringBuilder SB = new StringBuilder();
- SB.Append(" <table width='96%' border='1' align=\"center\" cellspacing='1' bordercolor=\"#C1E7FD\" bgcolor=\"#F4FCFF\">");
- 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>");
- SB.Append("<tr bgcolor=\"#E2F2FC\" ><td height='28' width='10%' align=\"center\">序号</td><td width='30%'>课程名称</td><td width='60%'>操作</td></tr>");
- while (objreader1.Read())
- {
- i = i + 1;
- SB.Append(" <tr bgcolor=\"#E2F2FC\" >");
- SB.Append("<td height='28' align=\"center\">" + i.ToString() + "</td><td>" + objreader1["courseName"].ToString() + "</td>");
- SB.Append("<td><a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader1.GetValue(0) + "\">[添加子成果评分点]</a><br>");
- SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader1.GetValue(0) + "\">[删除此成果评分点]</a><br>");
- SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader1.GetValue(0) + "\">[修改此成果评分点]</a></td>");
- //SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader1.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
- // OleDbConnection dtConn2 = new OleDbConnection(connectionString);
- SqlConnection dtConn2 = new SqlConnection(connectionString);
- //OleDbDataAdapter dtCmd2 = new OleDbDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- SqlDataAdapter dtCmd2 = new SqlDataAdapter("select * from TreeGJK where followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
- DataSet dtSet2 = new DataSet();
- dtCmd2.Fill(dtSet2);
- DataTableReader objreader2 = dtSet2.CreateDataReader();
- int k = 0;
- while (objreader2.Read())
- {
- k = k + 1;
- SB.Append("<td height='28' align=\"center\"> " + k.ToString() + "</td><td>" + objreader2["courseName"].ToString() + "</td>");
- SB.Append("<td><a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[添加子成果评分点]</a><br>");
- SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader2.GetValue(0) + "\">[删除此成果评分点]</a><br>");
- SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader2.GetValue(0) + "\">[修改此成果评分点]</a></td>");
- // SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader2.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
- // OleDbConnection dtConn3 = new OleDbConnection(connectionString);
- SqlConnection dtConn3 = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd3 = new OleDbDataAdapter("select * from TreeGJK where followid=" + objreader2.GetValue(0) + " Order by id asc,followid Asc", dtConn2);
- SqlDataAdapter dtCmd3 = new SqlDataAdapter("select * from TreeGJK where followid=" + objreader2.GetValue(0) + " Order by id asc,followid Asc", dtConn3);
- // HttpContext.Current.Response.Write("select * from TreeGJK where followid !=0 and followid=" + objreader1.GetValue(0) + " Order by id asc,followid Asc" + "<BR>");
- DataSet dtSet3 = new DataSet();
- dtCmd3.Fill(dtSet3);
- DataTableReader objreader3 = dtSet3.CreateDataReader();
- int m = 0;
- while (objreader3.Read())
- {
- m = m + 1;
- SB.Append("<td height='28' align=\"center\"> " + m.ToString() + "</td><td>" + objreader3["courseName"].ToString() + "</td>");
- SB.Append("<td><a target=\"_blank\" href=\"Addmenu.aspx?followid=" + objreader3.GetValue(0) + "\">[添加子成果评分点]</a><br>");
- SB.Append("<a target=\"_blank\" href=\"DELmenu.aspx?followid=" + objreader3.GetValue(0) + "\">[删除此成果评分点]</a><br>");
- SB.Append("<a target=\"_blank\" href=\"Modifymenu.aspx?followid=" + objreader3.GetValue(0) + "\">[修改此成果评分点]</a><br></td>");
- //SB.Append(" ||<a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader3.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><br>");
- }
- SB.Append("</tr>");
- dtConn3.Close();
- }
- // SB.Append("<hr>");
- dtConn2.Close();
- }
- SB.Append("\n </table>");
- objConn.Close();
- return SB;
- }
- //文章分享功能
- public string Share(int width, int height)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + width + "px; height: " + height + "px;\">");
- sb.Append("\n <tr>");
- sb.Append("\n <td valign=\"bottom\" align=\"right\" style=\"background-position: center center; background-attachment: fixed; background-repeat: repeat-y\" align=\"center\" >");
- sb.Append("\n <DIV class=\"bshare-custom\">");
- sb.Append("\n <A class=\"bshare-qzone\" title=\"分享到QQ空间\"></A>");
- sb.Append("\n <A class=\"bshare-sinaminiblog\" title=\"分享到新浪微博\"></A>");
- sb.Append("\n <A class=\"bshare-renren\" title=\"分享到人人网\"></A>");
- sb.Append("\n <A class=\"bshare-qqmb\" title=\"分享到腾讯微博\"></A>");
- sb.Append("\n <A class=\"bshare-neteasemb\" title=\"分享到网易微博\"></A>");
- sb.Append("\n <A class=\"bshare-more bshare-more-icon more-style-addthis\" title=\"更多平台\">");
- sb.Append("\n <SPAN class=\"BSHARE_COUNT bshare-share-count\">0</SPAN></DIV>");
- sb.Append("\n <SCRIPT type=\"text/javascript\" charset=\"utf-8\" src=\"js/share/buttonLite.js#style=-1&uuid=&pophcol=2&lang=zh\"></SCRIPT>");
- sb.Append("\n <SCRIPT type=text/javascript charset=utf-8 src=\"js/share/bshareC0.js\"></SCRIPT>");
- sb.Append("\n </td><td valign=\"bottom\" align=\"left\">将该文章分享给朋友!</td>");
- sb.Append("\n </tr>");
- sb.Append("\n </table> ");
- return sb.ToString();
- }
- //检查记录是否存在
- public Boolean CheckRecord(string SQL)
- {
- Boolean LoginAccess = false;
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = SQL;
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- LoginAccess = true;
- }
- else
- {
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- //填写上传文件信息
- public void AddUpFilesInfoToDB1(string parasql, string tablename, int followid, string sTitle, string UseExam, string getBody, string isPass)
- { //sTitle 标题 UseExam文件内容说明 getBody提供者 isPass是否推荐
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- objConn.Open();
- //检测是否为重复添加
- if (CheckRecord("Select * from " + tablename + " where ClassName='" + sTitle + "'"))
- {
- HttpContext.Current.Response.Write("<script>alert('已经有相同的记录,请检查是否为同一个文件,如果不为同一个文件,请更改标题后再添加')</script>");
- HttpContext.Current.Response.Write("<script>history.bakc();</script>");
- }
- else
- {
- string sql = parasql;
- //OleDbDataAdapter objcmd = new OleDbDataAdapter();
- SqlDataAdapter objcmd = new SqlDataAdapter();
- objcmd.SelectCommand = new SqlCommand(sql, objConn);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- objcmd.Fill(ds, tablename);
- objConn.Close();
- DataTable dt = ds.Tables[tablename];
- DataRow dtrow = dt.NewRow();
- dtrow["followid"] = followid;
- dtrow["SortNum"] = 1;
- dtrow["ClassName"] = sTitle;
- dtrow["UseExam"] = UseExam;
- dtrow["intro"] = "";
- dtrow["UpdateTime"] = DateTime.Today.ToShortDateString(); ;
- dtrow["getBody"] = getBody;
- dtrow["isPass"] = isPass;
- dtrow["DownNums"] = 1;
- dt.Rows.Add(dtrow);
- objcmd.Update(ds, tablename);
- }
- }
- public void BindFiledRecValueToDropDownList1(DropDownList myDropDownList, string BindFileName, string DispFileName, string TableName)
- {//将字段BindFileName绑定到myDropDownList
- //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
- string SQL = "select " + BindFileName + "," + DispFileName + " from " + TableName;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- ListItem myit = new ListItem();
- myit.Text = objreader.GetValue(0).ToString();
- myit.Value = objreader.GetValue(1).ToString();
- myDropDownList.Items.Add(myit);
- //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
- //myDropDownList.Items.Add(
- }
- }
- //根据关键字查询后进行绑定
- public void BindFiledRecValueKeyToDropDownList(DropDownList myDropDownList, string BindFileName, string DispFileName, string TableName, string keyword)
- {//将字段BindFileName绑定到myDropDownList
- //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
- string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " LIKE '%" + keyword + "%'";
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- ListItem myit = new ListItem();
- myit.Text = objreader.GetValue(0).ToString();
- myit.Value = objreader.GetValue(1).ToString();
- myDropDownList.Items.Add(myit);
- //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
- //myDropDownList.Items.Add(
- }
- }
- //根据关键字查询后进行绑定
- public void BindFiledRecValueKetToDropDownList(DropDownList myDropDownList, string BindFileName, string TableName, string keyword)
- {//将字段BindFileName绑定到myDropDownList
- string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " LIKE '%" + keyword + "%' and " + BindFileName + " IS NOT NULL";
- //string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " IS NOT NULL";
- //string SQL = "select " + BindFileName + "," + DispFileName + " from " + TableName;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- ListItem myit = new ListItem();
- myit.Text = objreader.GetValue(0).ToString();
- myit.Value = objreader.GetValue(0).ToString();
- myDropDownList.Items.Add(myit);
- //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
- //myDropDownList.Items.Add(
- }
- objConn.Close();
- }
- public void BindFiledRecValueToDropDownList2(DropDownList myDropDownList, string BindFileName, string TableName)
- {//将字段BindFileName绑定到myDropDownList
- string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName + " where " + BindFileName + " IS NOT NULL";
- //string SQL = "select " + BindFileName + "," + DispFileName + " from " + TableName;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- ListItem myit = new ListItem();
- myit.Text = objreader.GetValue(0).ToString();
- myit.Value = objreader.GetValue(0).ToString();
- myDropDownList.Items.Add(myit);
- //myDropDownList.Items.Add(objreader.GetValue(0).ToString());
- //myDropDownList.Items.Add(
- }
- objConn.Close();
- }
- //文章分享功能
- public string Share1(int width, int height)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- sb.Append("\n <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + width + "px; height: " + height + "px;\">");
- sb.Append("\n <tr>");
- sb.Append("\n <td valign=\"bottom\" style=\"background-position: center center; background-attachment: fixed; background-repeat: repeat-y\" align=\"center\" >");
- sb.Append("\n <DIV class=\"bshare-custom\">");
- sb.Append("\n <A class=\"bshare-qzone\" title=\"分享到QQ空间\"></A>");
- sb.Append("\n <A class=\"bshare-sinaminiblog\" title=\"分享到新浪微博\"></A>");
- sb.Append("\n <A class=\"bshare-renren\" title=\"分享到人人网\"></A>");
- sb.Append("\n <A class=\"bshare-qqmb\" title=\"分享到腾讯微博\"></A>");
- sb.Append("\n <A class=\"bshare-neteasemb\" title=\"分享到网易微博\"></A>");
- sb.Append("\n <A class=\"bshare-more bshare-more-icon more-style-addthis\" title=\"更多平台\">");
- sb.Append("\n <SPAN class=\"BSHARE_COUNT bshare-share-count\">0</SPAN></DIV>");
- sb.Append("\n <SCRIPT type=\"text/javascript\" charset=\"utf-8\" src=\"js/share/buttonLite.js#style=-1&uuid=&pophcol=2&lang=zh\"></SCRIPT>");
- sb.Append("\n <SCRIPT type=text/javascript charset=utf-8 src=\"js/share/bshareC0.js\"></SCRIPT>");
- sb.Append("\n 将该文章分享给朋友!<br> </td>");
- sb.Append("\n </tr>");
- sb.Append("\n </table> ");
- return sb.ToString();
- }
- //限速下载
- public bool ResponseFile(HttpRequest _Request, HttpResponse _Response, string _fileName, string _fullPath, long _speed)
- {
- try
- {
- FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
- BinaryReader br = new BinaryReader(myFile);
- try
- {
- _Response.AddHeader("Accept-Ranges", "bytes");
- _Response.Buffer = false;
- long fileLength = myFile.Length;
- long startBytes = 0;
- int pack = 10240; //10K bytes
- int sleep = (int)Math.Floor((double)(1000 * pack / _speed)) + 1;
- if (_Request.Headers["Range"] != null)
- {
- _Response.StatusCode = 206;
- string[] range = _Request.Headers["Range"].Split(new char[] { '=', '-' });
- startBytes = Convert.ToInt64(range[1]);
- }
- _Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
- if (startBytes != 0)
- {
- _Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength - 1, fileLength));
- }
- _Response.AddHeader("Connection", "Keep-Alive");
- _Response.ContentType = "application/octet-stream";
- _Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_fileName, System.Text.Encoding.UTF8));
- br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
- int maxCount = (int)Math.Floor((double)((fileLength - startBytes) / pack)) + 1;
- for (int i = 0; i < maxCount; i++)
- {
- if (_Response.IsClientConnected)
- {
- _Response.BinaryWrite(br.ReadBytes(pack));
- Thread.Sleep(sleep);
- }
- else
- {
- i = maxCount;
- }
- }
- }
- catch
- {
- return false;
- }
- finally
- {
- br.Close();
- myFile.Close();
- }
- }
- catch
- {
- return false;
- }
- return true;
- }
- //支持任意类型文件下载
- public void FileDownLoadDel(string fullFilename)
- {
- System.IO.Stream iStream = null;
- byte[] buffer = new Byte[10000];
- int length;
- long dataToRead;
- string filepath = fullFilename;
- filepath = HttpContext.Current.Server.MapPath(filepath);
- string filename = System.IO.Path.GetFileName(filepath);
- try
- {
- iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
- System.IO.FileAccess.Read, System.IO.FileShare.Read);
- dataToRead = iStream.Length;
- HttpContext.Current.Response.ContentType = "application/octet-stream";
- HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
- while (dataToRead > 0)
- {
- if (HttpContext.Current.Response.IsClientConnected)
- {
- length = iStream.Read(buffer, 0, 10000);
- HttpContext.Current.Response.OutputStream.Write(buffer, 0, length);
- HttpContext.Current.Response.Flush();
- buffer = new Byte[10000];
- dataToRead = dataToRead - length;
- }
- else
- {
- dataToRead = -1;
- HttpContext.Current.Response.Clear();
- }
- }
- HttpContext.Current.Response.End(); //没有这句会将该页面刷新后的内容追加写入文件中。
- }
- catch (Exception ex)
- {
- HttpContext.Current.Response.Write("Error : " + ex.Message);
- }
- finally
- {
- if (iStream != null)
- {
- iStream.Close();
- }
- File.Delete(fullFilename);
- }
- }
- //显示下载列表,下载链接用ID、表名、下载文件所保存的字段名FileNameFieldName,要显示列表的字段名1DispFiledName1 dispListType显示列表类型Down(下载),PLAY(播放),READ(阅读)
- public StringBuilder DisplayDownList2(string SQL, string tablename, int LeftFiledNameNo, int FileNameFieldNo, string dispListType)
- {//sql="select id,classname,url,date from tablename
- //调用 Literal1.Text = myu.DisplayDownList1("select * from classVideo", "classVideo", 3, 8,5).ToString();
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- //int i, j;
- StringBuilder sb = new StringBuilder();
- // DateTime dt = new DateTime();
- int k = 0;
- while (objreader.Read())
- {
- k = k + 1;
- 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%;\">");
- sb.Append("<tr><td width=\"6%\"><img src=\"images/li.gif\" /></td>");
- if (objreader.GetFieldType(LeftFiledNameNo).Name == "DateTime")
- { sb.Append("<td width=\"58%\" align=\"left\" style=\"height:32px;color: #7BA9EE\">" + Convert.ToDateTime(objreader.GetValue(LeftFiledNameNo).ToString()).ToShortDateString().Trim() + "</td>"); }
- else
- { sb.Append("<td width=\"58%\" align=\"left\" >" + objreader.GetValue(LeftFiledNameNo).ToString() + "</td>"); }
- sb.Append("<td align=\"center\" width=\"36%\" style=\"height:32px;color: #7BA9EE\">");
- if (dispListType == "DOWN")
- {
- sb.Append(" <a href=\"Filedown.aspx?FFN=" + FileNameFieldNo.ToString() + "&tn=" + tablename + "&KeyF=" + objreader.GetValue(0).ToString() + "\" target=\"_blank\">[下载]</a> ");
- }
- if (dispListType == "DOWN1")
- {
- sb.Append("<a href=\"Upfiles\\" + objreader["URL"] + "\" target=\"_blank\">[下载]</a></li> ");
- }
- if (dispListType == "READ")
- {
- sb.Append("<a href=\"Upfiles\\" + objreader["URL"] + "\" target=\"_blank\">[运行效果]<img src=\"images/arr.jpg\" /></a>");
- 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>");
- string extName = myf.GetExtension(objreader.GetValue(FileNameFieldNo).ToString());
- //HttpContext.Current.Response.Write(extName + " ");
- if (extName.Trim().ToUpper() == "SWF")
- {
- sb.Append(" <a target=\"_blank\" href=\"SWF.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[上机练一练]<img src=\"images/qipao.jpg\" /></a><td>");
- }
- if (extName.Trim().ToUpper() == "HTML" || extName.Trim().ToUpper() == "HTM")
- {
- sb.Append(" <a target=\"_blank\" href=\"SJNX.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[上机练一练]<img src=\"images/qipao.jpg\" /></a><td>");
- }
- if (extName.Trim().ToUpper() == "ASPX")
- {
- sb.Append(" <a target=\"_blank\" href=\"NetSJnx.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[上机练一练]<img src=\"images/qipao.jpg\" /></a><td>");
- }
- }
- if (dispListType == "READ1")
- {
- sb.Append("<a href=\"Upfiles\\" + objreader["URL"] + "\" target=\"_blank\">[查看运行效果]<img src=\"images/arr.jpg\" /> </a> ");
- 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> ");
- sb.Append(" <a target=\"_blank\" href=\"ShowFileContent.aspx?KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[双击打开文件在线阅读!]\">[查看源代码]<img src=\"images/qipao.jpg\" /> </a><td>");
- }
- if (dispListType == "PLAY")
- {
- sb.Append(" <a href=\"RMPlay.aspx??FFN=" + FileNameFieldNo.ToString() + "&tn=" + tablename + "&KeyF=" + objreader.GetValue(0).ToString() + "\" title=\"[播放视频]\">[在线播放]</a><td>");
- }
- if (dispListType == "EDIT")
- {
- sb.Append(" <a href=\"Edit.aspx?tn=" + tablename + "&id=" + objreader.GetValue(0).ToString() + "\" target=\"_blank\" title=\"[编辑栏目内容]\">[编辑栏目内容]</a><td>");
- }
- sb.Append("</tr></table>");
- }
- return sb;
- }
- public StringBuilder ShowNewTitle(string sSQL, string DsipFieldName)
- {//页标题,样式表,表名,显示新闻数,是否显示日期,标题字数,新闻类型审核通过字段,对齐方式 NewsNumber=0 显示所有
- //公告类别:项目信息xmxx;学校信息xxxx;企业信息qyxx;项目安排信息xmzz,相关新闻sNew TitleFieldNo标题字段序号 sType:消息XX、构件GJ、其它OTHER
- string SQL = sSQL;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- // int i = 0;
- StringBuilder SB = new StringBuilder();
- string TitltID = "";
- while (objreader.Read())
- {
- TitltID = objreader.GetValue(0).ToString();
- string TitleContent = objreader[DsipFieldName].ToString();
- SB.Append("<li><a href=\"?id=" + TitltID + "\" Title=\"" + objreader[DsipFieldName].ToString() + "\">" + objreader[DsipFieldName].ToString() + "</a><span class=\"post-date\">" + "</span></li>");
- }
- return SB;
- }
- public int GetWeekOfYear(DateTime dt)
- {
- CultureInfo ci = CultureInfo.CurrentCulture;
- System.Globalization.Calendar cal = ci.Calendar;
- CalendarWeekRule cwr = ci.DateTimeFormat.CalendarWeekRule;
- DayOfWeek dow = ci.DateTimeFormat.FirstDayOfWeek;
- return cal.GetWeekOfYear(dt, cwr, dow);
- }
- public int CurrentWeek(string StartTime) {
-
- string startTime = StartTime; //起始时间
- int StartWeek, CurrentWeek = 0;
- StartWeek = GetWeekOfYear(DateTime.Parse(startTime)); //起始周
- CurrentWeek = GetWeekOfYear(DateTime.Now) + 1; //当前周
- // string myweek = "第" + (CurrentWeek - StartWeek) + "周";
- return CurrentWeek - StartWeek;
- }
- public Boolean check_QM(string tableName, string XHFieldName, string XHFieldValue, string ZJFieldName, string ZJFieldValue)
- {
- Boolean LoginAccess = false;
- //一般教师登录检查
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = "select * from " + tableName + " where " + XHFieldName + " = '" + XHFieldValue + "' and " + ZJFieldName + "='" + ZJFieldValue + "'";
- //OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- // OleDbDataReader myReader = myCommand.ExecuteReader();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- HttpContext.Current.Session["DisplayMsg"] = "今天已经签名!";
- LoginAccess = true;
- }
- else
- {
- HttpContext.Current.Session["DisplayMsg"] = "今天没有签名";
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- public Boolean check_TeacherLogin(string tableName, string m_teacherName, string m_userName, string m_Password)
- {
- Boolean LoginAccess = false;
- //一般教师登录检查
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = "select * from " + tableName + " where 姓名='" + m_teacherName + "' and 用户名='" + m_userName + "' and 密码='" + m_Password + "'";
- //string searchCmd = "select * from " + tableName + " where 用户名='" + m_userName + "' and 密码='" + m_Password + "'";
- //HttpContext.Current.Response.Write(searchCmd);
- //HttpContext.Current.Response.End();
- // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- // OleDbDataReader myReader = myCommand.ExecuteReader();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
- LoginAccess = true;
- }
- else
- {
- HttpContext.Current.Session["DisplayMsg"] = "登录失败";
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- public Boolean check_Adminlogin(string tableName, string UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
- {
- Boolean LoginAccess = false;
- //管理员登录检查
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- string searchCmd = "select * from " + tableName + " where " + UserNameFieldName + " = '" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
- // OleDbCommand myCommand = new OleDbCommand(searchCmd, objConn);
- SqlCommand myCommand = new SqlCommand(searchCmd, objConn);
- myCommand.Connection.Open();
- // OleDbDataReader myReader = myCommand.ExecuteReader();
- SqlDataReader myReader = myCommand.ExecuteReader();
- if (myReader.Read())
- {
- HttpContext.Current.Session["用户名"] = myReader.GetValue(4);
- HttpContext.Current.Session["密码"] = myReader.GetValue(5);
- HttpContext.Current.Session["类型"] = myReader.GetValue(6);
- HttpContext.Current.Session["DisplayMsg"] = "登录成功!";
- }
- else
- {
- HttpContext.Current.Session["DisplayMsg"] = "登录失败!你的用户名或者密码有误!";
- LoginAccess = false;
- }
- myCommand.Connection.Close();
- return LoginAccess;
- }
- public void UpdateUserPassword(String TableName, String NewPassword, String UserNameFieldName, string UserNameFieldValue, string PasswordFieldName, string PasswordFieldValue)
- {
- //OleDbConnection DBConn;
- SqlConnection DBConn;
- //OleDbCommand DBUpdate = new OleDbCommand();
- SqlCommand DBUpdate = new SqlCommand();
- DBConn = new SqlConnection(connectionString);
- DBUpdate.CommandText = "Update " + TableName + " Set " + PasswordFieldName + "='" + NewPassword + "' Where " + UserNameFieldName + "='" + UserNameFieldValue + "' and " + PasswordFieldName + "='" + PasswordFieldValue + "'";
- DBUpdate.Connection = DBConn;
- DBUpdate.Connection.Open();
- DBUpdate.ExecuteNonQuery();
- }
- public void UpdateStringFieldValue(String TableName, String UpdateFieldName, String UpdateFieldValue, int IDvalue)
- {
- SqlConnection DBConn;
- SqlCommand DBUpdate = new SqlCommand();
- DBConn = new SqlConnection(connectionString);
- DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "='" + UpdateFieldValue + "' Where ID=" + IDvalue;
- DBUpdate.Connection = DBConn;
- DBUpdate.Connection.Open();
- DBUpdate.ExecuteNonQuery();
- DBConn.Close();
- }
- public void UpdateDateFieldValue(String TableName, String UpdateFieldName, String UpdateFieldValue, int IDvalue)
- {
- SqlConnection DBConn;
- SqlCommand DBUpdate = new SqlCommand();
- DBConn = new SqlConnection(connectionString);
- DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "='#" + UpdateFieldValue + "#' Where ID=" + IDvalue;
- DBUpdate.Connection = DBConn;
- DBUpdate.Connection.Open();
- DBUpdate.ExecuteNonQuery();
- DBConn.Close();
- }
- public void UpdateNumberFieldValue(String TableName, String UpdateFieldName, String UpdateFieldValue, int IDvalue)
- {
- SqlConnection DBConn;
- SqlCommand DBUpdate = new SqlCommand();
- DBConn = new SqlConnection(connectionString);
- DBUpdate.CommandText = "Update " + TableName + " Set " + UpdateFieldName + "=" + UpdateFieldValue + " Where ID=" + IDvalue;
- DBUpdate.Connection = DBConn;
- DBUpdate.Connection.Open();
- DBUpdate.ExecuteNonQuery();
- }
- public StringBuilder RowDisplayData1(string CSSFilename, string SQL, string PageTitleStr)
- {
- int sum;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i;
- StringBuilder sb = new StringBuilder();
- sb.Append("<div align=center style='font-size: 12px; color: slateblue'><center ><h4>" + PageTitleStr + "</h4></center>");
- sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- sb.Append("<tr bgcolor='#99ccff'>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- sb.Append("<th nowrap=nowrap>" + objreader.GetName(i) + "</Th>");
- }
- sb.Append("<th nowrap=nowrap>缺课统计</Th>");
- sb.Append("</tr>");
- while (objreader.Read())
- {
- sb.Append("<tr>");
- sum = 0;
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- // Response.Write("<td nowrap='nowrap'>" + objreader.GetValue(i) + "</TD>");
- if (objreader.GetValue(i).ToString().Length == 0)
- { sum = sum + 1; }
- sb.Append("<td align=center>" + objreader.GetValue(i) + "</TD>");
- }
- sb.Append("<td align=center>" + sum.ToString() + "</TD>");
- sb.Append("</tr>");
- }
- sb.Append("</table></div>");
- return sb;
- }
- public void RowDisplayData(string CSSFilename, Boolean isDisplayTitile, string AddDispTitle, string AddDispContent, string SQL, string PageTitleStr)
- {
- // OleDbConnection dtConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- // OleDbDataAdapter dtCmd= new OleDbDataAdapter(SQL, objConn);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i;
- System.Web.HttpContext.Current.Response.Write("<div align=center style='font-size: 12px; color: slateblue'><center ><h4>" + PageTitleStr + "</h4></center>");
- System.Web.HttpContext.Current.Response.Write("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- System.Web.HttpContext.Current.Response.Write("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- System.Web.HttpContext.Current.Response.Write("<tr bgcolor='#99ccff'>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- System.Web.HttpContext.Current.Response.Write("<th nowrap=nowrap>" + objreader.GetName(i) + "</Th>");
- }
- if (isDisplayTitile)
- { System.Web.HttpContext.Current.Response.Write(AddDispTitle); }
- System.Web.HttpContext.Current.Response.Write("</tr>");
- while (objreader.Read())
- {
- System.Web.HttpContext.Current.Response.Write("<tr>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- // Response.Write("<td nowrap='nowrap'>" + objreader.GetValue(i) + "</TD>");
- System.Web.HttpContext.Current.Response.Write("<td align=center>" + objreader.GetValue(i) + "</TD>");
- }
- if (isDisplayTitile)
- {
- System.Web.HttpContext.Current.Response.Write(AddDispContent);
- }
- System.Web.HttpContext.Current.Response.Write("</tr>");
- }
- System.Web.HttpContext.Current.Response.Write("</table></div>");
- }
- public StringBuilder dispTableData(string CSSFilename, string SQL, string PageTitleStr)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- DataTableReader objreader = dtSet.CreateDataReader();
- int i;
- while (objreader.Read())
- {
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- HttpContext.Current.Session.Add(objreader.GetName(i), objreader.GetValue(i));
- }
- }
- StringBuilder SB = new StringBuilder();
- SB.Append("<div align=center style='font-size: 12px; color: slateblue'><center ><h4>" + PageTitleStr + "</h4></center>");
- SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- SB.Append("<table width='640' height='712' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#D0EBFD' bgcolor='#EFF7FE' >");
- SB.Append("<tr>");
- SB.Append("<td width='104' height='30' valign='middle'>姓 名</td>");
- SB.Append("<td width='120' valign='middle'>" + HttpContext.Current.Session["姓名"] + " </td>");
- SB.Append("<td width='77' valign='middle'>性 别 </td>");
- SB.Append("<td width='84' valign='middle'>" + HttpContext.Current.Session["性别"] + " </td>");
- if (HttpContext.Current.Session["个人照片"].ToString().Length == 0)
- { SB.Append("<td width='121' rowspan='7' align='center' valign='middle'><a href='UpFileAndToDB.aspx?Dir=PICFiles&FF=jhcasdkjdkwie4i23i43&KeyF=" + HttpContext.Current.Session["ID"] + "' target='_blank'>还没有照片<br />上传照片</a></td>"); }
- else
- { SB.Append("<td rowspan='7' align='center' valign='middle' nowrap='nowrap'> <img src='PICFiles/" + HttpContext.Current.Session["个人照片"].ToString() + "' width='120' height='160' /></td>"); }
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='34'><p align='center'>出生年月 </p></td>");
- if (HttpContext.Current.Session["出生年月"].ToString().Length > 0)
- { SB.Append("<td width='120'><p align='center'> " + Convert.ToDateTime(HttpContext.Current.Session["出生年月"]).ToLongDateString() + "</p></td>"); }
- else
- { SB.Append("<td width='120'><p align='center'> " + HttpContext.Current.Session["出生年月"] + "</p></td>"); }
- SB.Append("<td width='77'><p align='center'>籍贯 </p></td>");
- SB.Append("<td width='84'><p align='center'> " + HttpContext.Current.Session["籍贯"] + "</p></td>");
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='27'><p align='center'>政治面貌</p></td>");
- SB.Append("<td width='120'><p align='center'> " + HttpContext.Current.Session["政治面貌"] + "</p></td>");
- SB.Append("<td width='77'><p align='center'>学 位 </p></td>");
- SB.Append("<td width='84' align='center'>" + HttpContext.Current.Session["学位"] + " </td>");
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='23'><p align='center'>学历</p></td>");
- SB.Append("<td width='120'><p align='center'>" + HttpContext.Current.Session["学历"] + " </p></td>");
- SB.Append("<td width='77'><p align='center'>联系电话 </p></td>");
- SB.Append("<td width='84' align='center'> " + HttpContext.Current.Session["联系电话"] + " </td>");
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='27'><p align='center'>专业</p></td>");
- SB.Append("<td align='center'>" + HttpContext.Current.Session["专业"] + " </td>");
- SB.Append("<td align='center'>毕业时间 </td>");
- if (HttpContext.Current.Session["毕业时间"].ToString().Length > 0)
- { SB.Append("<td align='center'>" + Convert.ToDateTime(HttpContext.Current.Session["毕业时间"]).ToLongDateString() + " </td>"); }
- else
- { SB.Append("<td align='center'>" + HttpContext.Current.Session["毕业时间"] + " </td>"); }
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='31'><p align='center'>毕业院校 </p></td>");
- SB.Append("<td colspan='3'><p align='center'>" + HttpContext.Current.Session["毕业院校"] + " </p></td>");
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='32'><p align='center'>专业技术资格 </p></td>");
- SB.Append("<td colspan='3'><p align='center'> </p></td>");
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104'><p align='center'>身份证号 </p></td>");
- SB.Append("<td height='32'><p align='center'>" + HttpContext.Current.Session["身份证号"] + " </p></td>");
- SB.Append("<td>双师素质:" + HttpContext.Current.Session["双师素质"] + " </td>");
- SB.Append("<td>专任教师:" + HttpContext.Current.Session["专任教师"] + " </td>");
- SB.Append("<td>教师资格:" + HttpContext.Current.Session["教师资格"] + " </td>");
- SB.Append("</tr>");
- SB.Append("<tr valign='middle'>");
- SB.Append("<td width='104' height='35' nowrap='nowrap'><p align='center'>通讯地址 </p></td>");
- SB.Append("<td colspan='4'><p align='center'>" + HttpContext.Current.Session["通讯地址"] + " </p></td>");
- SB.Append("</tr>");
- SB.Append("<tr>");
- SB.Append("<td width='104' valign='top'><p align='center'>工</p>");
- SB.Append("<p align='center'>作</p>");
- SB.Append("<p align='center'>经</p>");
- SB.Append("<p align='center'>历 </p></td>");
- SB.Append("<td height='441' colspan='4' valign='top'><p align='left'><strong>工作简历(含在行业、企业的工作经历和当时从事工作的专业领域及所负责任) </strong></a></p> " + HttpContext.Current.Session["个人简历"] + "</td>");
- SB.Append("</tr>");
- SB.Append("</tr>");
- SB.Append("</table></div>");
- return SB;
- }
- public StringBuilder dispCharData(string CSSFilename, Boolean isDisplayTitile, string AddDispTitle, string AddDispContent, string SQL, string PageTitleStr, Boolean DispDataProcessing, int ProcessingType)
- {
- //ProcessingType 1,2,3,4 详细,添加,修改,删除
- string Procchar = "";
- string ProgFilename = "";
- switch (ProcessingType)
- {
- case 1: { Procchar = "详细"; ProgFilename = "DisplayJBXX.aspx"; } break;
- case 2: { Procchar = "添加"; ProgFilename = "AddData.aspx"; } break;
- case 3: { Procchar = "修改"; ProgFilename = "UpdateData.aspx"; } break;
- case 4: { Procchar = "删除"; ProgFilename = "DeleteData.aspx"; } break;
- case 5: { Procchar = "批改作业"; ProgFilename = "UpdateData.aspx"; } break;
- }
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i;
- StringBuilder SB = new StringBuilder();
- SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- SB.Append("<div align=center style='font-size: 12px; color: #063E7B'><center ><h4>" + PageTitleStr + "</h4></center>");
- SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- SB.Append("<tr bgcolor='#DCECF5'>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- SB.Append("<th nowrap='nowrap'>" + objreader.GetName(i) + "</Th>");
- }
- if (DispDataProcessing)
- { SB.Append("<th nowrap='nowrap'>数据处理</Th>"); }
- if (isDisplayTitile)
- { SB.Append(AddDispTitle); }
- SB.Append("</tr>");
- while (objreader.Read())
- {
- SB.Append("<tr>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- // Response.Write("<td nowrap='nowrap'>" + objreader.GetValue(i) + "</TD>");
- SB.Append("<td align=center>" + objreader.GetValue(i) + "</TD>");
- }
- if (DispDataProcessing)
- { SB.Append("<td align=center><a href='" + ProgFilename + "?KeyF=" + objreader.GetValue(0).ToString() + "&ProcessingType=" + ProcessingType + "' target=_blank>" + Procchar + "</a></TD>"); }
- if (isDisplayTitile)
- {
- SB.Append(AddDispContent);
- }
- SB.Append("</tr>");
- }
- SB.Append("</table></div>");
- return SB;
- }
- public StringBuilder dispCharZY(string CSSFilename, Boolean isDisplayTitile, string AddDispTitle, string AddDispContent, string SQL)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i;
- StringBuilder SB = new StringBuilder();
- SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- SB.Append("<tr bgcolor='#DCECF5'>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- SB.Append("<th nowrap='nowrap'>" + objreader.GetName(i) + "</Th>");
- }
- SB.Append("</tr>");
- while (objreader.Read())
- {
- SB.Append("<tr>");
- for (i = 0; i <= objreader.FieldCount - 1; i++)
- {
- if (objreader.GetName(i) == "文件名")
- {
- SB.Append("<td align=center>" + objreader.GetValue(i) + " [ <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>]");
- SB.Append(" [<a href='UpdateWJZYFS.aspx?KeyF=" + objreader.GetValue(0).ToString() + "' target=_blank>给分数</a>]</TD>");
- }
- else
- {
- SB.Append("<td align=center>" + objreader.GetValue(i) + "</TD>");
- }
- }
- SB.Append("</tr>");
- }
- SB.Append("</table></div>");
- return SB;
- }
- public string GetAddressUrl()
- {
- string GetUrl = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + HttpContext.Current.Request.ServerVariables["URL"];
- if (HttpContext.Current.Request.ServerVariables["QUERY_STRING"] != "")
- { GetUrl = GetUrl + "?" + HttpContext.Current.Request.ServerVariables["QUERY_STRING"]; }
- return GetUrl;
- }
- public string GetSpace(int StringLanght, string getChr)
- {
- int i;
- String TempStr = getChr;
- if (getChr.Length < StringLanght)
- {
- for (i = 1; i <= (StringLanght - getChr.Length); i++)
- { TempStr += " "; }
- }
- return TempStr;
- }
- public Panel BuildModifyForm(Panel PanelcontrolName, string SQLStr, int FieldMaxLenght)
- {
- //定义变量和控件数组
- Panel mypanel = new Panel();
- int i, FieldNum;
- TextBox[] MyText = new TextBox[30];
- Label[] MyLabel = new Label[30];
- //连接并打开数据库
- // OleDbConnection objConn = new OleDbConnection();
- SqlConnection objConn = new SqlConnection();
- StringBuilder sQueryStringValues = new StringBuilder();
- objConn.ConnectionString = connectionString;
- objConn.Open();
- //创建DataReader对象(COMMAND)
- // OleDbCommand objcmd = new OleDbCommand();
- SqlCommand objcmd = new SqlCommand();
- objcmd.Connection = objConn;
- objcmd.CommandText = SQLStr;
- // OleDbDataReader objreader = objcmd.ExecuteReader();
- SqlDataReader objreader = objcmd.ExecuteReader();
- //读取并显示数据库
- objreader.Read();
- String TypeN, dispC;
- FieldNum = objreader.FieldCount;
- for (i = 1; i <= FieldNum - 1; i++)
- {
- string FV = objreader.GetValue(i).ToString();
- //objreader.GetDataTypeName
- TypeN = objreader.GetFieldType(i).Name;
- switch (TypeN)
- {
- case "String":
- dispC = "输文字";
- break;
- case "DateTime":
- dispC = Convert.ToString(DateTime.Now);
- break;
- case "Boolean":
- dispC = "1 or 0[是为1,否为0]";
- break;
- default:
- dispC = "12";
- break;
- }
- if (FV.Trim().Length == 0) { FV = dispC; }
- MyLabel[i] = new Label();
- MyLabel[i].ID = "MyLabel" + Convert.ToString(i);
- MyLabel[i].Text = "<BR>";
- MyLabel[i].Text = MyLabel[i].Text + GetSpace(FieldMaxLenght, objreader.GetName(i));
- mypanel.Controls.Add(MyLabel[i]);
- MyText[i] = new TextBox();
- MyText[i].ID = "MyText" + Convert.ToString(i);
- MyText[i].Text = FV;
- MyText[i].Columns = 72;
- if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- {
- MyText[i].TextMode = TextBoxMode.MultiLine;
- MyText[i].Rows = 4;
- MyText[i].Columns = 48;
- }
- mypanel.Controls.Add(MyText[i]);
- }
- MyLabel[i + 1] = new Label();
- MyLabel[i + 1].ID = "AAA";
- MyLabel[i + 1].Text = "<br><br> ";
- mypanel.Controls.Add(MyLabel[i + 1]);
- objreader.Close();
- objConn.Close();
- PanelcontrolName.Controls.Add(mypanel);
- return PanelcontrolName;
- }
- //根据数据库,动态生成表格表单
- public string BuildModifyFormTable(string SQLStr)
- {
- //定义变量和控件数组
- Panel mypanel = new Panel();
- int i, FieldNum;
- TextBox[] MyText = new TextBox[30];
- Label[] MyLabel = new Label[30];
- //连接并打开数据库
- //OleDbConnection objConn = new OleDbConnection();
- SqlConnection objConn = new SqlConnection();
- StringBuilder sb = new StringBuilder();
- objConn.ConnectionString = connectionString;
- objConn.Open();
- //创建DataReader对象(COMMAND)
- SqlCommand objcmd = new SqlCommand();
- objcmd.Connection = objConn;
- objcmd.CommandText = SQLStr;
- SqlDataReader objreader = objcmd.ExecuteReader();
- //读取并显示数据库
- objreader.Read();
- FieldNum = objreader.FieldCount;
- sb.Append("<table width='96%' border='1' align=\"center\" cellspacing='0' bordercolor=\"#C1E7FD\" bgcolor=\"#F4FCFF\">");
- for (i = 1; i <= FieldNum - 1; i++)
- {
- string FV = objreader.GetValue(i).ToString();
- //objreader.GetDataTypeName
- sb.Append("<tr bgcolor=\"#E2F2FC\">");
- sb.Append("<td height='30' width=\"200\" align='center' valign='middle'>" + objreader.GetName(i) + ":</td>");
- if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- {
- 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>");
- }
- else
- { 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>"); }
- sb.Append("</tr>");
- }
- sb.Append("</table>");
- objreader.Close();
- objConn.Close();
- return sb.ToString();
- }
- public void BuildModifyFormTableToDB(string parasql, string tablename)
- {
- //OleDbDataAdapter objcmd = ExecuteDataAdapter(parasql, CommandType.Text, null);
- SqlDataAdapter objcmd = ExecuteDataAdapter(parasql, CommandType.Text, null);
- // OleDbCommandBuilder objtable = new OleDbCommandBuilder(objcmd);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- //string tablename = "table";
- objcmd.Fill(ds, tablename);
- DataTable dt = ds.Tables[tablename];
- int i, k = 0;
- for (i = 1; i < HttpContext.Current.Request.Form.Count - 1; i++)
- {
- string name = HttpContext.Current.Request.Form.GetKey(i);
- if (name.IndexOf("Text") > 0)
- {
- k = k + 1;
- dt.Rows[0][k] = HttpContext.Current.Request.Form[i];
- }
- }
- objcmd.Update(ds, tablename);
- }
- public void ModifyToDB(string parasql, string tablename)
- {
- SqlDataAdapter objcmd = ExecuteDataAdapter(parasql, CommandType.Text, null);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- //string tablename = "table";
- objcmd.Fill(ds, tablename);
- DataTable dt = ds.Tables[tablename];
- int i, k = 0;
- for (i = 1; i < HttpContext.Current.Request.Form.Count - 2; i++)
- {
- string name = HttpContext.Current.Request.Form.GetKey(i);
- if (name.IndexOf("Text") > 0)
- {
- k = k + 1;
- dt.Rows[0][k] = HttpContext.Current.Request.Form[i];
- }
- }
- objcmd.Update(ds, tablename);
- }
- public SqlDataAdapter ExecuteDataAdapter(string sql, CommandType commandType, SqlParameter[] parameters)
- {
- DataTable data = new DataTable();//实例化DataTable,用于装载查询结果集
- SqlDataAdapter adapter;
- SqlConnection connection = new SqlConnection(connectionString);
- using (SqlCommand command = new SqlCommand(sql, connection))
- {
- command.CommandType = commandType;//设置command的CommandType为指定的CommandType
- //如果同时传入了参数,则添加这些参数
- if (parameters != null)
- {
- foreach (SqlParameter parameter in parameters)
- {
- command.Parameters.Add(parameter);
- }
- }
- //通过包含查询SQL的SqlCommand实例来实例化SqlDataAdapter
- adapter = new SqlDataAdapter(command);
- //adapter.Fill(data);//填充DataTable
- }
- adapter.SelectCommand = new SqlCommand(sql, connection);
- return adapter;
- }
- public void deleteRecord(string Tablename, int RecordID)
- {
- SqlConnection DBConn = new SqlConnection(connectionString);
- SqlCommand DBDelete = new SqlCommand();
- //OleDbDataAdapter DBCommand = new OleDbDataAdapter(SelectSQL, DBConn);
- DataSet DS = new DataSet();
- //使用 Connection 对象打开数据连接
- DBDelete.CommandText = "Delete From " + Tablename + " Where ID=" + RecordID;
- DBDelete.Connection = DBConn;
- DBDelete.Connection.Open();
- DBDelete.ExecuteNonQuery();
- }
- public Panel DynamicBuildForm(Panel PanelcontrolName, string SQLStr, int FieldMaxLenght)
- {
- //定义变量和控件数组
- Panel mypanel = new Panel();
- int i, FieldNum;
- TextBox[] MyText = new TextBox[30];
- Label[] MyLabel = new Label[30];
- //连接并打开数据库
- //OleDbConnection objConn = new OleDbConnection();
- SqlConnection objConn = new SqlConnection();
- StringBuilder sQueryStringValues = new StringBuilder();
- objConn.ConnectionString = connectionString;
- objConn.Open();
- //创建DataReader对象(COMMAND)
- //OleDbCommand objcmd = new OleDbCommand();
- SqlCommand objcmd = new SqlCommand();
- objcmd.Connection = objConn;
- objcmd.CommandText = SQLStr;
- SqlDataReader objreader = objcmd.ExecuteReader();
- //读取并显示数据库
- String TypeN, dispC;
- FieldNum = objreader.FieldCount;
- for (i = 1; i <= FieldNum - 1; i++)
- {
- //objreader.GetDataTypeName
- TypeN = objreader.GetFieldType(i).Name;
- switch (TypeN)
- {
- case "String":
- dispC = "输文字";
- break;
- case "DateTime":
- dispC = Convert.ToString(DateTime.Now);
- break;
- case "Boolean":
- dispC = "1 or 0[是为1,否为0]";
- break;
- default:
- dispC = "12";
- break;
- }
- MyLabel[i] = new Label();
- MyLabel[i].ID = "MyLabel" + Convert.ToString(i);
- MyLabel[i].Text = "<BR>";
- MyLabel[i].Text = MyLabel[i].Text + GetSpace(FieldMaxLenght, objreader.GetName(i));
- mypanel.Controls.Add(MyLabel[i]);
- MyText[i] = new TextBox();
- MyText[i].ID = "MyText" + Convert.ToString(i);
- MyText[i].Text = dispC;
- MyText[i].Columns = 68;
- if (objreader.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- {
- MyText[i].TextMode = TextBoxMode.MultiLine;
- MyText[i].Rows = 4;
- MyText[i].Columns = 45;
- }
- mypanel.Controls.Add(MyText[i]);
- }
- MyLabel[i + 1] = new Label();
- MyLabel[i + 1].ID = "AAA";
- MyLabel[i + 1].Text = "<br><br> ";
- mypanel.Controls.Add(MyLabel[i + 1]);
- objreader.Close();
- objConn.Close();
- PanelcontrolName.Controls.Add(mypanel);
- return PanelcontrolName;
- }
- public void InsertDataToDB(String TableName, string sql)
- {
- //'连接并打开数据库
- SqlConnection objConn = new SqlConnection();
- objConn.ConnectionString = connectionString;
- objConn.Open();
- SqlDataAdapter objCmd = new SqlDataAdapter();
- objCmd.SelectCommand = new SqlCommand(sql, objConn);
- //创建CommandBuilder对象
- SqlCommandBuilder objCB = new SqlCommandBuilder(objCmd);
- //创建DataSet对象并填充数据
- DataSet Ds = new DataSet();
- objCmd.Fill(Ds, TableName);
- objConn.Close();
- DataTable myTable = Ds.Tables[TableName];
- //插入数据行
- DataRow myRow = myTable.NewRow();
- myRow[0] = DBNull.Value;
- int i, k = 0;
- for (i = 1; i <= HttpContext.Current.Request.Form.Count - 1; i++)
- {
- if (HttpContext.Current.Request.Form.GetKey(i).Substring(0, 6) == "MyText")
- {
- k = k + 1;
- myRow[k] = HttpContext.Current.Request.Form[i];
- }
- }
- myRow[k + 1] = HttpContext.Current.Request.ServerVariables["Remote_addr"];
- myTable.Rows.Add(myRow);
- objCmd.Update(myTable.Select(null, null, DataViewRowState.Added));
- //lblMessage.Text = "注册成功!";
- }
- public void AddDataToDB(string parasql, string tablename)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- objConn.Open();
- string sql = parasql;
- SqlDataAdapter objcmd = new SqlDataAdapter();
- objcmd.SelectCommand = new SqlCommand(sql, objConn);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- objcmd.Fill(ds, tablename);
- objConn.Close();
- DataTable dt = ds.Tables[tablename];
- DataRow dtrow = dt.NewRow();
- dtrow[0] = DBNull.Value;
- int i, k = 0;
- for (i = 1; i < HttpContext.Current.Request.Form.Count - 2; i++)
- {
- string name = HttpContext.Current.Request.Form.GetKey(i);
- if (name.IndexOf("Text") > 0)
- {
- k = k + 1;
- dtrow[k] = HttpContext.Current.Request.Form[i];
- //if (dt.Columns[k + 1].ColumnName == "IP")
- // { dtrow[k+1] = HttpContext.Current.Request.ServerVariables["Remote_addr"]; }
- }
- }
- dt.Rows.Add(dtrow);
- objcmd.Update(ds, tablename);
- }
- public void AddUpFIlesInfoToDB(string parasql, string tablename, string XH, string XM, string BC, string ZJ, string upFileName, string TeacherName)
- {
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- objConn.Open();
- string sql = parasql;
- SqlDataAdapter objcmd = new SqlDataAdapter();
- objcmd.SelectCommand = new SqlCommand(sql, objConn);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- objcmd.Fill(ds, tablename);
- objConn.Close();
- DataTable dt = ds.Tables[tablename];
- DataRow dtrow = dt.NewRow();
- dtrow[0] = DBNull.Value;
- dtrow[1] = XH;
- dtrow[2] = XM;
- dtrow[3] = BC;
- dtrow[4] = ZJ;
- dtrow[5] = upFileName;
- dtrow[6] = DateTime.Today;
- dtrow[7] = HttpContext.Current.Request.ServerVariables["Remote_addr"];
- dtrow[8] = TeacherName;
- dt.Rows.Add(dtrow);
- objcmd.Update(ds, tablename);
- }
- public void AddUsersToDB(string parasql, string tablename, string UserName, string Password, string Usertype, string dempment)
- {
- // OleDbConnection objConn = new OleDbConnection(connectionString);
- SqlConnection objConn = new SqlConnection(connectionString);
- objConn.Open();
- string sql = parasql;
- SqlDataAdapter objcmd = new SqlDataAdapter();
- objcmd.SelectCommand = new SqlCommand(sql, objConn);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- objcmd.Fill(ds, tablename);
- objConn.Close();
- DataTable dt = ds.Tables[tablename];
- DataRow dtrow = dt.NewRow();
- dtrow[0] = DBNull.Value;
- dtrow[1] = UserName;
- dtrow[2] = Password;
- dtrow[3] = Usertype;
- dtrow[4] = dempment;
- dt.Rows.Add(dtrow);
- objcmd.Update(ds, tablename);
- HttpContext.Current.Response.Write("<script>alert('添加成功!')</script>");
- }
- //将课程信息添加到数据库
- 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)
- {
- SqlConnection objConn = new SqlConnection(connectionString);
- objConn.Open();
- string sql = parasql;
- SqlDataAdapter objcmd = new SqlDataAdapter();
- objcmd.SelectCommand = new SqlCommand(sql, objConn);
- SqlCommandBuilder objtable = new SqlCommandBuilder(objcmd);
- DataSet ds = new DataSet();
- objcmd.Fill(ds, tablename);
- objConn.Close();
- DataTable dt = ds.Tables[tablename];
- DataRow dtrow = dt.NewRow();
- dtrow[0] = DBNull.Value;
- dtrow[1] = courseID;
- dtrow[2] = courseName;
- dtrow[3] = courseTrem;
- dtrow[4] = courseTro;
- dtrow[5] = mcourseClass;
- dtrow[6] = courseTeacher;
- dtrow[7] = courseStartWeek;
- dtrow[8] = courseEndWeek;
- dtrow[9] = coursecredit;
- dtrow[10] = courseMemo;
- dt.Rows.Add(dtrow);
- objcmd.Update(ds, tablename);
- HttpContext.Current.Response.Write("<script>alert('添加成功!')</script>");
- }
- public string UpfilesToPath(HttpPostedFile postedfile, string filepath, string filename, long length)
- {
- //此方法的主要功能是提取上传文件名并保存到所指路径;返回相关的文件信息,如:文件大小及文件保存路径
- string name = System.IO.Path.GetFileName(filename);
- postedfile.SaveAs(filepath + "\\" + name);
- StringBuilder strmsg = new StringBuilder();
- if (length == 0)
- {
- return "请选择欲上传文件";
- }
- strmsg.AppendFormat("文件上传成功!<br>");
- strmsg.AppendFormat("上传文件大小为:{0} kb<br>", length);
- strmsg.AppendFormat("文件存储位置为:{0} <br>", filepath + "\\" + name);
- return strmsg.ToString();
- //public void b1_Click(object sender, EventArgs e)
- //{//UpfilesToPath实例
- // file f1 = new file();
- // HttpPostedFile postedfile = this.myFile.PostedFile;//获得客户端上载的文件
- // string filepath = Server.MapPath("upload");//设置保存路径
- // string filename = postedfile.FileName;//获得上载文件的原始路径及文件名
- // long length = myFile.PostedFile.ContentLength;//获得上传文件的大小
- // Label2.Text = f1.insert(postedfile, filepath, filename, length);//调用file类中的insert方法,以实现文件上传及信息输出
- //}
- }
- public string Upfiles(HttpPostedFile postedfile, string Fdir)
- {
- //if (!Directory.Exists(Server.MapPath(".") + "PIC"))
- //{ Directory.CreateDirectory(Server.MapPath(".") + "PIC"); }
- StringBuilder strmsg = new StringBuilder();
- string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
- if (postedfile.ContentLength > 0)
- {
- if (Fdir == "")
- { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + UpFilename); }
- else
- { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + Fdir + "\\" + UpFilename); }
- strmsg.AppendFormat("【文件名:" + UpFilename.ToString() + "】");
- strmsg.AppendFormat("<br>【文件大小:" + postedfile.ContentLength.ToString() + "】");
- strmsg.AppendFormat("<br>【文件类型:" + postedfile.ContentType.ToString() + "】");
- return strmsg.ToString();
- }
- else
- { return "请选择欲上传文件"; }
- }
- public string UpfilesAndSaveToDB(HttpPostedFile postedfile, string Fdir, string TableName, string SaveFileFieldName, Int32 IDvalue)
- {
- //if (!Directory.Exists(Server.MapPath(".") + "PIC"))
- //{ Directory.CreateDirectory(Server.MapPath(".") + "PIC"); }
- StringBuilder strmsg = new StringBuilder();
- string UpFilename = System.IO.Path.GetFileName(postedfile.FileName);
- if (postedfile.ContentLength > 0)
- {
- UpdateStringFieldValue(TableName, SaveFileFieldName, UpFilename.ToString(), IDvalue);
- if (Fdir == "")
- { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + UpFilename); }
- else
- { postedfile.SaveAs(HttpContext.Current.Server.MapPath(".") + "\\" + Fdir + "\\" + UpFilename); }
- strmsg.AppendFormat("【文件名:" + UpFilename.ToString() + "】");
- strmsg.AppendFormat("<br>【文件大小:" + postedfile.ContentLength.ToString() + "】");
- strmsg.AppendFormat("<br>【文件类型:" + postedfile.ContentType.ToString() + "】");
- return strmsg.ToString();
- }
- else
- { return "请选择欲上传文件"; }
- }
- public StringBuilder F_Link(string CSSFilename, int LinkTextFieldsOrderNo, int LinkUrlFieldsOrderNo, string SQL, bool dispTitle, string PageTitleStr, int LinNumber, string aling)
- {//aling=left| center| right
- SqlConnection dtConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, dtConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0;
- StringBuilder SB = new StringBuilder();
- SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- if (dispTitle == true) { SB.Append("<tr bgcolor='#99ccff'><th nowrap='nowrap'>" + PageTitleStr + "</Th></tr>"); }
- while (objreader.Read())
- {
- if (i < LinNumber)
- {
- SB.Append("<tr>");
- SB.Append("<td align=" + aling + "><a href='" + objreader.GetValue(LinkUrlFieldsOrderNo) + "'>" + objreader.GetValue(LinkTextFieldsOrderNo) + "</a></TD>");
- SB.Append("</tr>");
- }
- }
- SB.Append("</table>");
- return SB;
- }
- public StringBuilder DispNB(string CSSFilename, string FieldName, string SQL, int LinNumber, string aling)
- {//显示类别列表
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- int i = 0;
- StringBuilder SB = new StringBuilder();
- SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- SB.Append("<Table width='90%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'>");
- while (objreader.Read())
- {
- if (i < LinNumber)
- {
- SB.Append("<tr>");
- SB.Append("<td align=" + aling + "><a href='#'>" + objreader[FieldName].ToString() + "</a></TD>");
- SB.Append("</tr>");
- }
- }
- SB.Append("</table>");
- return SB;
- }
- public string EncryptDes(string EncryptStr)
- {//标准DES对称加密的函数
- string skey = "liuys123";
- DESCryptoServiceProvider des = new DESCryptoServiceProvider();
- byte[] inputByteArray;
- inputByteArray = Encoding.Default.GetBytes(EncryptStr);
- des.Key = ASCIIEncoding.ASCII.GetBytes(skey);
- des.IV = ASCIIEncoding.ASCII.GetBytes(skey);
- MemoryStream ms = new MemoryStream();
- CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
- StreamWriter sw = new StreamWriter(cs);
- sw.Write(EncryptStr);
- sw.Flush();
- cs.FlushFinalBlock();
- ms.Flush();
- return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
- }
- public string DecryptDes(string DecryptStr)
- {//标准DES对称解密的函数
- string skey = "liuys123";
- DESCryptoServiceProvider des = new DESCryptoServiceProvider();
- des.Key = ASCIIEncoding.ASCII.GetBytes(skey);
- des.IV = ASCIIEncoding.ASCII.GetBytes(skey);
- byte[] buffer = Convert.FromBase64String(DecryptStr);
- MemoryStream ms = new MemoryStream(buffer);
- CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);
- StreamReader sr = new StreamReader(cs);
- return sr.ReadToEnd().ToString();
- }
- //public void RegAdmin(string username, string password, string userType)
- //{
- // SqlConnection objConn = new SqlConnection();
- // objConn.ConnectionString = connectionString;
- // objConn.Open();
- // SqlCommand objCmd = new SqlCommand();
- // objCmd.Connection = objConn;
- // objCmd.Parameters.Add("@用户名", OleDbType.Char).Value = username;
- // objCmd.Parameters.Add("@密码", OleDbType.Char).Value = EncryptDes(password);
- // objCmd.Parameters.Add("@类型", OleDbType.Char).Value = userType;
- // objCmd.CommandText = "Insert Into AdminUser(用户名, 密码,类型) Values(?, ?,?)";
- // objCmd.ExecuteNonQuery();
- // objConn.Close();
- //}
- public DataSet CreateDataSet(string strSQL, string TableName)
- {
- // string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~\\App_Data\\ZY.MDB");
- SqlDataAdapter objCmd = new SqlDataAdapter(strSQL, connectionString);
- //OleDbDataAdapter objCmd = new OleDbDataAdapter(strSQL, connectionString);
- DataSet DS = new DataSet();
- objCmd.Fill(DS, TableName);
- return DS;
- }
- public void BindListToGridView(GridView mygridView, string tablename, string strSQL)
- {
- mygridView.DataSource = CreateDataSet(strSQL, tablename);
- mygridView.DataBind();
- }
- public void BindFiledToDropDownList1(DropDownList myDropDownList, string sql, string tablename)
- {
- DataSet DS = CreateDataSet(sql, tablename);
- DataView DV = new DataView(DS.Tables[tablename]);
- // GridView1.DataSource = DV;
- for (int i = 1; i < DV.Table.Columns.Count; i++)
- {
- //if (DV.Table.Columns[i].DataType.ToString() == "System.String") //将字符数据绑定到DropDownList
- //{ //SQL语句中如果使用AS,如 Name as 姓名可能使查询出现问题,
- //ListItem aa=new ListItem; aa.Text="" :aa.Value=""
- myDropDownList.Items.Add(DV.Table.Columns[i].ToString());
- //}
- }
- }
- public void BindFiledToDropDownList(DropDownList myDropDownList, string sql, string tablename)
- {
- DataSet DS = CreateDataSet(sql, tablename);
- DataView DV = new DataView(DS.Tables[tablename]);
- // GridView1.DataSource = DV;
- for (int i = 1; i < DV.Table.Columns.Count; i++)
- {
- if (DV.Table.Columns[i].DataType.ToString() == "System.String") //将字符数据绑定到DropDownList
- { //SQL语句中如果使用AS,如 Name as 姓名可能使查询出现问题,
- //ListItem aa=new ListItem; aa.Text="" :aa.Value=""
- myDropDownList.Items.Add(DV.Table.Columns[i].ToString());
- }
- }
- }
- public void BindFiledRecValueToDropDownList(DropDownList myDropDownList, string BindFileName, string TableName)
- {//将字段BindFileName绑定到myDropDownList
- string SQL = "select DISTINCT(" + BindFileName + ") from " + TableName;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- myDropDownList.Items.Add(objreader.GetValue(0).ToString());
- }
- }
- public void BindFiledDataToDropDownList(DropDownList myDropDownList, string tablename, string BindFieldName, int BindFieldNameNo)
- {
- string SQL = "select DISTINCT(" + BindFieldName + ") from " + tablename;
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- myDropDownList.Items.Add(objreader.GetValue(BindFieldNameNo).ToString());
- }
- return;
- }
- /// <summary>
- /// 动态更新一个字段的值为身份证后6位
- /// </summary>
- /// <param name="SQL"></param>
- /// <returns></returns>
- public void UpdateAllFiledValue(string SQL, string UpdateFileNmae, string FromFiledName, string TableName)
- { //调用
- string sql = SQL;
- SqlConnection dtConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(sql, dtConn);
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- while (objreader.Read())
- {
- int ln = objreader[FromFiledName].ToString().Length;
- if (ln > 0)
- {
- string UV = objreader[FromFiledName].ToString().Substring(ln - 6, 6);
- UpdateStringFieldValue(TableName, UpdateFileNmae, UV, Convert.ToInt32(objreader["ID"].ToString()));
- }
- }
- }
- public StringBuilder ShowLineNavigation(string SQL, string CSSFilename, string tablename, Int32 TitleFiledNo, Int32 UrlFieldNo, string aling, string targetWindowName, string PicOrWord, Int32 PicWidth, Int32 PicHeight)
- {
- if (targetWindowName.Length == 0) { targetWindowName = "_blank"; }
- SqlConnection objConn = new SqlConnection(connectionString);
- SqlDataAdapter dtCmd = new SqlDataAdapter(SQL, objConn); ;
- DataSet dtSet = new DataSet();
- dtCmd.Fill(dtSet);
- DataTableReader objreader = dtSet.CreateDataReader();
- // int i = 0;
- StringBuilder SB = new StringBuilder();
- SB.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- SB.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'><tr>");
- while (objreader.Read())
- {
- if (PicOrWord == "Word")
- {
- SB.Append("<td align=" + aling + "><a title='" + objreader.GetValue(TitleFiledNo) + "' href='" + objreader.GetValue(UrlFieldNo) + "' target='" + targetWindowName + "'>" + objreader.GetValue(TitleFiledNo) + "</a></td>");
- }
- else
- {
- 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>");
- }
- }
- SB.Append("</tr></table>");
- return SB;
- }
- public StringBuilder DataReaderPage(string CSSFilename, string TableName, int mPageSize, string PageFilename, Boolean bRow, string QueryConditions)
- {
- //if (QueryConditions.Length == 0)
- //{
- // HttpContext.Current.Session["countSQL"] = "select count(*) from " + TableName + QueryConditions;
- // HttpContext.Current.Session["QuerySQL"] = "select * from " + TableName + QueryConditions;
- //}
- //if (HttpContext.Current.Session["countSQL"] ==null)
- //{ HttpContext.Current.Session["countSQL"] = "select count(*) from " + TableName; }
- //if (HttpContext.Current.Session["QuerySQL"]==null)
- //{ HttpContext.Current.Session["QuerySQL"] = "select * from " + TableName; }
- // OleDbConnection conn = new OleDbConnection(connectionString);
- SqlConnection conn = new SqlConnection(connectionString);
- SqlCommand cmd = new SqlCommand("", conn);
- int rowIndex = 1;
- int pageId = 1;
- int maxRow = 1;
- int maxPage = 1;
- int pageSize = mPageSize;
- StringBuilder sb = new StringBuilder();
- //确定当前页
- if (HttpContext.Current.Request.QueryString["pageId"] == null)
- {
- pageId = 1;
- }
- else
- {
- pageId = int.Parse(HttpContext.Current.Request.QueryString["pageId"].Trim());
- }
- try
- {
- if (conn.State == ConnectionState.Closed)
- {
- conn.Open();
- }
- cmd.CommandText = "select count(*) from " + TableName + QueryConditions;//"select count(*) from " + TableName;
- maxRow = (int)cmd.ExecuteScalar();
- maxPage = (maxRow % pageSize > 0) ? (maxRow / pageSize + 1) : (maxRow / pageSize);
- cmd.CommandText = "select * from " + TableName + QueryConditions;
- SqlDataReader dr = cmd.ExecuteReader();
- for (int i = 0; i < (pageId - 1) * pageSize; i++)
- {
- dr.Read();
- rowIndex++;
- }
- int by = (pageId > 1) ? (pageId - 1) : 1;
- int by1 = (pageId < maxPage) ? (pageId + 1) : maxPage;
- sb.Append("记录总数为:" + maxRow.ToString() + ";当前页:" + pageId.ToString() + "/" + maxPage.ToString());
- sb.Append("[<a href='" + PageFilename + "?pageId=1'>第一页</a>]");
- sb.Append("[<a href='" + PageFilename + "?pageId=" + by.ToString() + "'>上一页</a>]");
- sb.Append("[<a href='" + PageFilename + "?pageId=" + by1.ToString() + "'>下一页</a>]");
- sb.Append("[<a href='" + PageFilename + "?pageId=" + maxPage.ToString() + "'>最后页</a>]");
- sb.Append("<br />");
- sb.Append("<link href='" + CSSFilename + "' rel='stylesheet' type='text/css' />");
- sb.Append("<Table width='100%' border='1'align =center bordercolor='#ccccff' style='border-collapse:collapse'><tr>");
- if (bRow == true)
- {
- sb.Append("<tr bgcolor='#99ccff'>");
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- sb.Append(" <th nowrap='nowrap'>" + dr.GetName(j) + "</Th>");
- }
- for (int i = rowIndex; i < (rowIndex + pageSize); i++)
- {
- if (dr.Read())
- {
- sb.Append("</tr><tr>");
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- sb.Append("<td>" + dr[j].ToString() + "</td>");
- }
- //sb.Append("<hr/>");
- }
- }
- }
- else
- {
- for (int i = rowIndex; i < (rowIndex + pageSize); i++)
- {
- if (dr.Read())
- {
- for (int j = 0; j <= dr.FieldCount - 1; j++)
- {
- sb.Append("<tr>");
- sb.Append("<td>" + dr.GetName(j) + "</td>");
- sb.Append("<td algin=left>" + dr[j].ToString().Replace("\r\n", "<br />") + "</td>");
- //if (dr.GetDataTypeName(i) == "DBTYPE_WLONGVARCHAR")
- //{
- // sb.Append("<td><asp:TextBox ID='TextBox1' Text='" + dr[j].ToString() + "' runat='server' Columns='60' Rows='12' TextMode='MultiLine'></asp:TextBox> </td>");
- //}
- //else
- //{ sb.Append("<td><asp:TextBox ID='TextBox1' Text='"+ dr[j].ToString() +"' runat='server' Columns='60'></asp:TextBox> </td>"); }
- sb.Append("</tr>");
- }
- }
- }
- }
- sb.Append("</Table>");
- }
- catch (OleDbException e)
- {
- sb.Append(e.Message.ToString());
- }
- finally
- {
- if (conn.State == ConnectionState.Open)
- {
- conn.Close();
- }
- }
- return sb;
- }
- }
- }
|