版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
.NET程序設(shè)計(jì)試驗(yàn)匯報(bào)班級(jí):姓名:學(xué)號(hào):試驗(yàn)一簡(jiǎn)單程序設(shè)計(jì)一.試驗(yàn)?zāi)繕?biāo)1.熟悉VisualStudio.NETIDE界面,練習(xí)窗口浮動(dòng)、???,以及工具欄定制。2.學(xué)會(huì)使用幫助系統(tǒng),在編寫(xiě)程序時(shí)使“動(dòng)態(tài)幫助”一直打開(kāi),注意觀察“動(dòng)態(tài)幫助”窗口中內(nèi)容改變。二.試驗(yàn)內(nèi)容1.模仿書(shū)中例子,編寫(xiě)“Hello”程序。2.在“幫助”菜單下選擇“對(duì)‘幫助’幫助”,閱讀其中內(nèi)容,學(xué)習(xí)幫助使用。三.源程序創(chuàng)建Hello類,在Main中調(diào)用控制臺(tái)WriteLine方法顯示Hello,C#usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespace__1{classProgram{staticvoidMain(string[]args){Console.WriteLine("Hello,C#!");}}}四.調(diào)試和運(yùn)行結(jié)果用Ctrl+F5快捷鍵執(zhí)行程序可得到運(yùn)行結(jié)果。五.試驗(yàn)感想1、對(duì)試驗(yàn)原理有更深刻了解。2、對(duì)VisualStudio在實(shí)踐中應(yīng)用有深刻了解,在實(shí)踐基礎(chǔ)上,把所學(xué)過(guò)知識(shí)應(yīng)用于實(shí)際應(yīng)用中,更深刻了解了C#基本語(yǔ)句實(shí)際應(yīng)用。3、經(jīng)過(guò)試驗(yàn)課程設(shè)計(jì)激發(fā)了我學(xué)習(xí)主動(dòng)性,培養(yǎng)了我獨(dú)立發(fā)覺(jué)問(wèn)題、分析問(wèn)題、處理問(wèn)題能力。更增強(qiáng)了我與同學(xué)交流溝通能力和共同處理問(wèn)題合作能力。4、了解了C#基本語(yǔ)句知識(shí)點(diǎn)及學(xué)科之間融合滲透。將之前所學(xué)編程基本知識(shí)應(yīng)用于軟件設(shè)計(jì),達(dá)成了學(xué)以致用目標(biāo)。試驗(yàn)二C#.NET面向?qū)ο蟪绦蛟O(shè)計(jì)試驗(yàn)一.試驗(yàn)?zāi)繕?biāo)1.了解面向?qū)ο笏枷?,體會(huì)晤向?qū)ο笏枷朐诰幊讨袘?yīng)用。2.掌握VisualC#.NET類創(chuàng)建(組員,方法,屬性),類繼承,類多態(tài)性及類方法重載。二.試驗(yàn)內(nèi)容1.為某企業(yè)創(chuàng)建一個(gè)類來(lái)建立員工人事統(tǒng)計(jì):包含員工姓名、性別、工資、到企業(yè)日期、部門以及聯(lián)絡(luò)方式等信息。構(gòu)建該類,并做出適當(dāng)測(cè)試。2.從上面類中派生出一個(gè)類,來(lái)統(tǒng)計(jì)企業(yè)干部情況。包含職位、提職時(shí)間、管理員工人數(shù)及姓名。3.編寫(xiě)程序,使得一個(gè)大學(xué)書(shū)店能夠用它來(lái)統(tǒng)計(jì)和確定教科書(shū)零售價(jià)。全部計(jì)算應(yīng)該用一個(gè)類TextBook實(shí)例來(lái)完成。這個(gè)類應(yīng)該具備屬性Title(書(shū)名)、Author(作者)、Cost(批發(fā)費(fèi)用)、Quantity(庫(kù)存量)和Price(零售價(jià))。同時(shí)假設(shè)零售價(jià)是批發(fā)價(jià)1.25倍。4.編寫(xiě)程序相加兩個(gè)分?jǐn)?shù),并將它們和以化簡(jiǎn)后分?jǐn)?shù)形式表現(xiàn)出來(lái)。程序使用類Fraction來(lái)存放分?jǐn)?shù)分子和分母,具備方法Reduce來(lái)化簡(jiǎn)結(jié)果。三.源程序1.題目1和題目2Using指令集:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;定義Employee類publicclassEmployee{protectedstringname;privatestringsexy;privateintsalary;privatestringdate;privatestringdepartment;privatestringtelnum;publicEmployee(){}publicEmployee(string[]args){name=args[0];sexy=args[1];salary=Convert.ToInt32(args[2]);date=args[3];department=args[4];telnum=args[5];}//virtual關(guān)鍵字,方法能夠重寫(xiě)publicvirtualvoidDisplay(){Console.WriteLine("Name:{0}",name);Console.WriteLine("Sexy:{0}",sexy);Console.WriteLine("Salary:{0}",salary);Console.WriteLine("Date:{0}",date);Console.WriteLine("Department:{0}",department);Console.WriteLine("Telephone:{0}",telnum);}}定義Employer類,繼承基類EmployeepublicclassEmployer:Employee{privatestringposition;privatestringpromote_date;privatestringnumber;privatestring[]Ename=newstring[50];publicEmployer(string[]args):base(args){position=args[6];promote_date=args[7];number=args[8];for(inti=0;i<Convert.ToInt32(number);i++){Ename[i]=args[9+i];}}//重寫(xiě)基類Display方法publicoverridevoidDisplay(){base.Display();Console.WriteLine("Position:{0}",position);Console.WriteLine("Promote_date:{0}",promote_date);Console.WriteLine("Numberofemployee:{0}",number);for(inti=0;i<Convert.ToInt32(number);i++)Console.WriteLine("Nameofemployee{0}:{1}",i+1,Ename[i]);}}Main函數(shù)調(diào)用Employee和Employer結(jié)構(gòu)函數(shù)和方法并顯示:publicclassClass1{staticvoidMain(string[]args){Console.WriteLine("軟件051孔令民051023");string[]employee1=newstring[50];Console.WriteLine("Pleaseinputimformationofemployee:");Console.WriteLine("(name,sexy,salary,date,department,telephonenumber)");employee1=Console.ReadLine().Split('');//調(diào)用Employee結(jié)構(gòu)函數(shù)EmployeenewEmployee=newEmployee(employee1);Console.WriteLine("Thisistheimfomationofemployee:");//調(diào)用EmployeeDisplay()方法顯示數(shù)據(jù)newEmployee.Display();Console.WriteLine("");Console.WriteLine("Pleaseinputimformationofemployer:");Console.WriteLine("(name,sexy,salary,date,department,telephonenumber,position,promote_date,numberofemployees,nameofemployees(name1name2name3...))");employee1=Console.ReadLine().Split('');//調(diào)用Employer結(jié)構(gòu)函數(shù)EmployernewEmployer=newEmployer(employee1);Console.WriteLine("Thisistheimfomationofemployee:");//調(diào)用EmployerDisplay()方法顯示數(shù)據(jù)newEmployer.Display();");}}Console.WriteLine("題目1和題目2調(diào)試經(jīng)過(guò)運(yùn)行結(jié)果以下所表示:2.題目3定義類TextBookTextBook類包含Title,Author,Cost,Quantity,Price屬性和Display方法publicclassTextBook{publicstringTitle;publicstringAuthor;publicdoubleCost;publicintQuantity;publicdoublePrice;publicTextBook(stringt,stringa,doublec,intq){Title=t;Author=a;Cost=c;Quantity=q;Price=1.25*c;}publicvoidDisplay(){Console.WriteLine("Title:{0}",Title);Console.WriteLine("Author:{0}",Author);Console.WriteLine("Cost:{0}",Cost);Console.WriteLine("Quantity:{0}",Quantity);Console.WriteLine("Price:{0}",Price);}}Main函數(shù)調(diào)用Textbook結(jié)構(gòu)函數(shù)和方法并顯示:staticvoidMain(string[]args){Console.WriteLine("軟件051孔令民051023");Console.WriteLine("Pleaseinputinformationofthebook:");Console.WriteLine("Title,Author,Cost,Quantity");string[]info=Console.ReadLine().Split('');//不用初始化stringt=info[0];stringa=info[1];doublec=Convert.ToDouble(info[2]);intq=Convert.ToInt32(info[3]);TextBooknewTextBook=newTextBook(t,a,c,q);Console.WriteLine("Thisistheimfomationofbook:");newTextBook.Display();Console.WriteLine("");}題目3調(diào)試經(jīng)過(guò)運(yùn)行結(jié)果以下所表示:輸入C#BeginnerWaston8050vusingSystem;usingSystem.Collections.Generic;usingSystem.Text;publicclassEmployee{protectedstringname;privatestringsexy;privateintsalary;privatestringdate;privatestringdepartment;privatestringtelnum;publicEmployee(stringname,stringsexy,intsalary,stringdate,stringdepartment,stringtelnum){=name;this.sexy=sexy;this.salary=salary;this.date=date;this.department=department;this.telnum=telnum;}//virtual關(guān)?鍵¨1字á?,方¤?法¤?§可¨|以°?重?寫(xiě)??publicvirtualvoidDisplay(){Console.WriteLine("Name:{0}",name);Console.WriteLine("Sexy:{0}",sexy);Console.WriteLine("Salary:{0}",salary);Console.WriteLine("Date:{0}",date);Console.WriteLine("Department:{0}",department);Console.WriteLine("Telephone:{0}",telnum);}}publicclassClass1{staticvoidMain(){Console.WriteLine("軟¨¨a件t051孔?á令¢?民?051023");Console.WriteLine("Pleaseinputimformationofemployee:");Console.WriteLine("(name,sexy,salary,date,department,telephonenumber)");stringemployee=Console.ReadLine();Employeenewemployee=newEmployee(employee);Console.WriteLine("Thisistheimfomationofemployee:");newemployee.Display();Console.WriteLine("");}}計(jì)算得Price=Cost×1.25=1003.題目4定義了Faction類用來(lái)計(jì)算兩分?jǐn)?shù)相加Faction類包含分子和分母兩個(gè)屬性,以及Reduce()和Display()兩個(gè)方法classPraction{publicintDenominator;//分母publicintMolecule;//分子publicPraction(intm,intd){Denominator=d;Molecule=m;}publicvoidReduce(){intt=Molecule;for(inti=t;i>=1;i--){if((Molecule%i==0)&&(Denominator%i==0)){Molecule/=i;Denominator/=i;}}}publicvoidDisplay(){Console.WriteLine("{0}/{1}",Molecule,Denominator);}}Main函數(shù)staticvoidMain(string[]args){Console.WriteLine("軟件051孔令民051023");Console.WriteLine("Pleaseinputthemolecule(分子)ofthe1stpration:");intm=Convert.ToInt32(Console.ReadLine());Console.WriteLine("Pleaseinputthedenominator(分母)ofthe1stpration:");intd=Convert.ToInt32(Console.ReadLine());PractionnewPraction=newPraction(m,d);Console.Write("您輸入第一個(gè)分?jǐn)?shù)為:");newPraction.Display();Console.WriteLine("Pleaseinputthemolecule(分子)ofthe2ndpration:");intm1=Convert.ToInt32(Console.ReadLine());Console.WriteLine("Pleaseinputthedenominator(分母)ofthe2ndpration:");intd1=Convert.ToInt32(Console.ReadLine());PractionnewPraction1=newPraction(m1,d1);Console.Write("您輸入第二個(gè)分?jǐn)?shù)為:");newPraction1.Display();PractionaddPraction=newPraction(m*d1+m1*d,d*d1);//化簡(jiǎn)分?jǐn)?shù)addPraction.Reduce();Console.Write("兩分?jǐn)?shù)之和為:");addPraction.Display();Console.WriteLine("");}}題目4調(diào)試成功,運(yùn)行結(jié)果以下所表示:四.試驗(yàn)感想1、對(duì)試驗(yàn)原理有更深刻了解,掌握了VisualC#.NET類創(chuàng)建(組員,方法,屬性),類繼承,類多態(tài)性及類方法重載。2、對(duì)VisualStudio在實(shí)踐中應(yīng)用有深刻了解,在實(shí)踐基礎(chǔ)上,把所學(xué)過(guò)知識(shí)應(yīng)用于實(shí)際應(yīng)用中,更深刻了解了C#基本語(yǔ)句實(shí)際應(yīng)用。3、經(jīng)過(guò)試驗(yàn)課程設(shè)計(jì)激發(fā)了我學(xué)習(xí)主動(dòng)性,培養(yǎng)了我獨(dú)立發(fā)覺(jué)問(wèn)題、分析問(wèn)題、處理問(wèn)題能力。更增強(qiáng)了我與同學(xué)交流溝通能力和共同處理問(wèn)題合作能力。4、了解了C#基本語(yǔ)句知識(shí)點(diǎn)及學(xué)科之間融合滲透。將之前所學(xué)編程基本知識(shí)應(yīng)用于軟件設(shè)計(jì),達(dá)成了學(xué)以致用目標(biāo)。試驗(yàn)三文本編輯器設(shè)計(jì)一.試驗(yàn)?zāi)繕?biāo)1.熟悉VisualC#.NET可視化界面,掌握控件使用。2.掌握System.IO類文件流操作,會(huì)處理文件。二.試驗(yàn)內(nèi)容1.假設(shè)有要排序20個(gè)數(shù)存在文件Data.txt中。編寫(xiě)程序,打開(kāi)該文件并將排好序數(shù)重新寫(xiě)回該文件。2.重新打開(kāi)第1題創(chuàng)建文件,在文件結(jié)尾再添加10個(gè)隨機(jī)數(shù)。3.參考Windows記事本程序,編寫(xiě)一個(gè)簡(jiǎn)單文本編輯器程序。4.編寫(xiě)程序,在用戶選擇了一個(gè)目錄后,找出該目錄及其子目錄中全部后綴名為doc文件。5.假設(shè)有文本文件1.txt和2.txt。編寫(xiě)程序,創(chuàng)建一個(gè)新文本文件,將1.txt中內(nèi)容和2.txt中內(nèi)容重復(fù)兩遍,交替寫(xiě)入新文本文件,并刪除1.txt和2.txt。三.源程序Winform窗體主界面主界面由“排序/添加隨機(jī)數(shù)”,“文本編輯器”,“文件查找”,“文件合并”,“退出”,五個(gè)按鈕組成。每個(gè)按鈕實(shí)現(xiàn)內(nèi)容一個(gè)部分。主界面以下所表示:排序添加隨機(jī)數(shù)源程序://窗體載入事件,把文本文件Test.txt內(nèi)容讀入RichTextBox1中privatevoidForm2_Load(objectsender,EventArgse){FileStreamfs=newFileStream("test.txt",FileMode.Open,FileAccess.ReadWrite);StreamReadersr=newStreamReader(fs);richTextBox1.Text=sr.ReadToEnd();sr.Close();fs.Close();}//將文件中10個(gè)隨機(jī)數(shù)用冒泡法排序,并在RichTextBox2中顯示privatevoidbutton1_Click(objectsender,EventArgse){FileStreamfs=newFileStream("test.txt",FileMode.Open,FileAccess.ReadWrite);StreamReadersr=newStreamReader(fs);string[]myDate=sr.ReadToEnd().Split(',');sr.Close();fs.Close();for(inti=0;i<myDate.Length;i++){for(intj=0;j<myDate.Length-i-1;j++){if(Convert.ToInt32(myDate[j])>Convert.ToInt32(myDate[j+1])){stringt;t=myDate[j];myDate[j]=myDate[j+1];myDate[j+1]=t;}}}foreach(stringsinmyDate){Console.WriteLine(s);}//將排好序數(shù)寫(xiě)回到文件中FileStreamfs1=newFileStream("test.txt",FileMode.Open,FileAccess.ReadWrite);StreamWritersw=newStreamWriter(fs1);for(inti=0;i<myDate.Length-1;i++){sw.Write(myDate[i]);sw.Write(",");}sw.Write(myDate[myDate.Length-1]);sw.Close();fs1.Close();FileStreamfs2=newFileStream("test.txt",FileMode.Open,FileAccess.ReadWrite);StreamReadersr2=newStreamReader(fs2);richTextBox2.Text=sr2.ReadToEnd();sr2.Close();fs2.Close();}//往文件中寫(xiě)入隨機(jī)數(shù)privatevoidbutton2_Click(objectsender,EventArgse){RandomnewRandom=newRandom();//申明產(chǎn)生隨機(jī)數(shù)對(duì)象FileInfofi=newFileInfo("test.txt");using(StreamWritersw=fi.AppendText()){//寫(xiě)入隨機(jī)數(shù)for(inti=0;i<10;i++){sw.Write(',');sw.Write(newRandom.Next());}sw.Write(newRandom.Next());FileStreamfs2=newFileStream("test.txt",FileMode.Open,FileAccess.ReadWrite);StreamReadersr2=newStreamReader(fs2);richTextBox2.Text=sr2.ReadToEnd();sr2.Close();fs2.Close();}}運(yùn)行結(jié)果:2.文本編輯器界面設(shè)計(jì)以下所表示:主菜單欄設(shè)有文件,編輯,格式,幫助,返回主界面5個(gè)主菜單項(xiàng),各主菜單子菜單以下:(1)文件新建,打開(kāi),保留,退出(2)編輯剪切,粘貼,復(fù)制,撤消,恢復(fù),查找(3)格式字體,顏色功效設(shè)計(jì)以下:文件操作函數(shù):(1)檢驗(yàn)是否保留privatevoidCheckSave(){if(rtBox.Text!=""){if((MessageBox.Show("是否保留當(dāng)前文件?","確認(rèn)",MessageBoxButtons.OKCancel)==DialogResult.OK)){SaveFile();SaveInfo=true;}elseSaveInfo=false;}}(2)保留文件privatevoidSaveFile(){saveFileDialog1.Filter="全部文件(*.*)|*.*|文本文件(*.txt)|*.txt";saveFileDialog1.InitialDirectory="C:\\";if(saveFileDialog1.ShowDialog()==DialogResult.OK){rtBox.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.PlainText);}elsereturn;}(3)打開(kāi)文件privatevoidOpenFile(){CheckSave();openFileDialog1.Filter="全部文件(*.*)|*.*|文本文件(*.txt)|*.txt";openFileDialog1.InitialDirectory="C:\\";if(openFileDialog1.ShowDialog()==DialogResult.OK){rtBox.LoadFile(openFileDialog1.FileName,RichTextBoxStreamType.PlainText);}elsereturn;}文件菜單功效設(shè)計(jì)(1)新建privatevoid新建ToolStripMenuItem_Click(objectsender,EventArgse){CheckSave();if(SaveInfo==true)rtBox.Clear();}(2)打開(kāi)privatevoid打開(kāi)OToolStripMenuItem_Click(objectsender,EventArgse){OpenFile();}(3)保留privatevoid保留SToolStripMenuItem_Click(objectsender,EventArgse){SaveFile();}(4)剪切privatevoid剪切TToolStripMenuItem_Click(objectsender,EventArgse){rtBox.Cut();}(5)復(fù)制privatevoid復(fù)制CToolStripMenuItem_Click(objectsender,EventArgse){rtBox.Copy();}(6)粘貼privatevoid粘貼PToolStripMenuItem_Click(objectsender,EventArgse){rtBox.Paste();}(7)查找privatevoid查找FToolStripMenuItem_Click(objectsender,EventArgse){rtBox.Undo();}(8)字體privatevoid字體FToolStripMenuItem_Click(objectsender,EventArgse){FontDialogfg=newFontDialog();if(fg.ShowDialog()==DialogResult.OK){rtBox.SelectionFont=fg.Font;}elsereturn;}(9)恢復(fù)privatevoid恢復(fù)ToolStripMenuItem_Click(objectsender,EventArgse){rtBox.Redo();}(10)顏色privatevoid顏色CToolStripMenuItem_Click(objectsender,EventArgse){ColorDialogcg=newColorDialog();if(cg.ShowDialog()==DialogResult.OK){rtBox.SelectionColor=cg.Color;}elsereturn;}(11)關(guān)于privatevoid關(guān)ToolStripMenuItem_Click(objectsender,EventArgse){MessageBox.Show("開(kāi)發(fā)語(yǔ)言:C#作者:aight","關(guān)于記事本",MessageBoxButtons.OK);}運(yùn)行結(jié)果:3.文件查找源代碼:publicvoidFindFile(stringdir)//參數(shù)為指定目錄{//在指定目錄及子目錄下查找文件,在listBox1中列出子目錄及文件DirectoryInfoDir=newDirectoryInfo(dir);try{foreach(DirectoryInfodinDir.GetDirectories())//查找子目錄{FindFile(Dir+d.ToString()+"\\");}foreach(FileInfofinDir.GetFiles("*.doc"))//查找文件{listView1.Items.Add(Dir+f.ToString());//listBox1中填加文件名}}catch(Exceptione){MessageBox.Show(e.Message);}}privatevoidbtnSearch_Click(objectsender,EventArgse){FindFile(@textBox1.Text);}運(yùn)行結(jié)果:4.文件合并源代碼:privatevoidbutton4_Click(objectsender,EventArgse){FileStreamfs1=newFileStream("1.txt",FileMode.Open);StreamReadersr1=newStreamReader(fs1);stringtext1=sr1.ReadToEnd();fs1.Close();sr1.Close();FileStreamfs2=newFileStream("2.txt",FileMode.Open);StreamReadersr2=newStreamReader(fs2);stringtext2=sr2.ReadToEnd();fs2.Close();sr2.Close();using(StreamWritersw=File.CreateText("3.txt")){sw.WriteLine(text1);sw.WriteLine(text2);sw.WriteLine(text1);sw.WriteLine(text2);MessageBox.Show("文件添加完成!","提醒",MessageBoxButtons.OK,MessageBoxIcon.Information);File.Delete("1.txt");File.Delete("2.txt");MessageBox.Show("文件刪除完成!","提醒",MessageBoxButtons.OK,MessageBoxIcon.Information);sw.Close();}}四.試驗(yàn)感想1、對(duì)試驗(yàn)原理有更深刻了解,掌握了C#中可視化編程通常過(guò)程,包含控件使用,控件編程等,讓我了解到C#應(yīng)用廣泛性及可行性。2、對(duì)VisualStudio在實(shí)踐中應(yīng)用有深刻了解,在實(shí)踐基礎(chǔ)上,把所學(xué)過(guò)知識(shí)應(yīng)用于實(shí)際應(yīng)用中,更深刻了解了C#基本語(yǔ)句實(shí)際應(yīng)用。3、經(jīng)過(guò)試驗(yàn)課程設(shè)計(jì)激發(fā)了我學(xué)習(xí)主動(dòng)性,培養(yǎng)了我獨(dú)立發(fā)覺(jué)問(wèn)題、分析問(wèn)題、處理問(wèn)題能力。更增強(qiáng)了我與同學(xué)交流溝通能力和共同處理問(wèn)題合作能力。4、了解了C#基本語(yǔ)句知識(shí)點(diǎn)及學(xué)科之間融合滲透。將之前所學(xué)編程基本知識(shí)應(yīng)用于軟件設(shè)計(jì),達(dá)成了學(xué)以致用目標(biāo)。試驗(yàn)四C#圖形程序設(shè)計(jì)基礎(chǔ)一.試驗(yàn)?zāi)繕?biāo)1.熟悉VisualC#.NET圖形基礎(chǔ)知識(shí),繪圖基本知識(shí)2.學(xué)會(huì)GDI+基礎(chǔ)知識(shí)3.建立畫(huà)筆,畫(huà)刷4.畫(huà)圖方法及使用二.試驗(yàn)內(nèi)容1.使用圖形方法,畫(huà)出5條不一樣顏色直線并形成一個(gè)多邊形。2.使用圖形方法,畫(huà)一條經(jīng)過(guò)(200,200),(256,87),(87,9),(22,108)這4個(gè)點(diǎn)曲線。3.使用圖形方法,畫(huà)一個(gè)橢圓,并用紋理刷填充。4.將前面3題組合在一起,并設(shè)計(jì)一個(gè)菜單來(lái)完成各項(xiàng)功效。三.源程序主界面設(shè)計(jì)以下所表示:源代碼(1).定義畫(huà)筆P1Penp1=newPen(Color.Red,2); (2)畫(huà)多邊形 privatevoidbutton1_Click(objectsender,System.EventArgse) { p1.Color=Color.Red; Graphicsg=this.CreateGraphics(); g.Clear(this.BackColor); g.DrawLine(p1,100,10,250,10); p1.Color=Color.Blue; g.DrawLine(p1,250,10,300,90); p1.Color=Color.Black;g.DrawLine(p1,300,90,175,180); p1.Color=Color.Pink; g.DrawLine(p1,175,180,50,90); p1.Color=Color.Yellow; g.DrawLine(p1,50,90,100,10); }(3)畫(huà)曲線 privatevoidbutton2_Click(objectsender,System.EventArgse) { Graphicsg=this.CreateGraphics(); g.Clear(this.BackColor); g.DrawBezier(p1,200,200,256,87,87,9,22,108); }(4)畫(huà)橢圓并填充 privatevoidbutton3_Click(objectsender,System.EventArgse) { Graphicsg=this.CreateGraphics(); g.Clear(this.BackColor); g.DrawEllipse(p1,150,57,160,100); Bitmapb1=(Bitmap)Image.FromFile("1.bmp",true); Brushsp=newTextureBrush(b1); g.FillEllipse(sp,150,57,160,100); }(5)清空 privatevoidbutton4_Click(objectsender,System.EventArgse) { Graphicsg=this.CreateGraphics(); g.Clear(this.BackColor); }(6)退出privatevoidbutton5_Click(objectsender,EventArgse){Application.Exit();}四.調(diào)試和運(yùn)行結(jié)果五.試驗(yàn)感想1、對(duì)試驗(yàn)原理有更深刻了解,掌握了C#對(duì)于圖形基本知識(shí)和對(duì)繪圖基本知識(shí),學(xué)會(huì)了GDI+基礎(chǔ)知識(shí)。2、對(duì)VisualStudio在實(shí)踐中應(yīng)用有深刻了解,在實(shí)踐基礎(chǔ)上,把所學(xué)過(guò)知識(shí)應(yīng)用于實(shí)際應(yīng)用中,更深刻了解了C#基本語(yǔ)句實(shí)際應(yīng)用。3、經(jīng)過(guò)試驗(yàn)課程設(shè)計(jì)激發(fā)了我學(xué)習(xí)主動(dòng)性,培養(yǎng)了我獨(dú)立發(fā)覺(jué)問(wèn)題、分析問(wèn)題、處理問(wèn)題能力。更增強(qiáng)了我與同學(xué)交流溝通能力和共同處理問(wèn)題合作能力。4、了解了C#基本語(yǔ)句知識(shí)點(diǎn)及學(xué)科之間融合滲透。將之前所學(xué)編程基本知識(shí)應(yīng)用于軟件設(shè)計(jì),達(dá)成了學(xué)以致用目標(biāo)。試驗(yàn)五C#.NET數(shù)據(jù)庫(kù)編程一.試驗(yàn)?zāi)繕?biāo)1.熟悉VisualC#.NET數(shù)據(jù)庫(kù)基本操作2.學(xué)會(huì)使用ADO.NET對(duì)象,會(huì)使用ADO.NET控件,以及數(shù)據(jù)綁定和數(shù)據(jù)綁定控件二.試驗(yàn)內(nèi)容1.嘗試在Access中新建一個(gè)數(shù)據(jù)庫(kù),并在其中放入一張表。該表有6個(gè)字段,即學(xué)號(hào)、姓名、班級(jí)、性別、年紀(jì)、學(xué)院。2.直接在服務(wù)器資源管理器中為上面表填入一些數(shù)據(jù)。3.創(chuàng)建一個(gè)Windows程序,將上面表內(nèi)容用DataGrid控件顯示出來(lái)。4.讓用戶輸入一個(gè)學(xué)生姓名,嘗試將全部同名學(xué)生學(xué)號(hào)顯示在一個(gè)列表框中。5.嘗試創(chuàng)建一個(gè)Web程序,并用DataGrid顯示表內(nèi)容。6.為上表插入一項(xiàng)新統(tǒng)計(jì)三.源程序在數(shù)據(jù)庫(kù)中建立Student表,字段及內(nèi)容以下所表示:程序主界面以下所表示:源代碼:privatevoidForm1_Load(objectsender,EventArgse){Init();}privatestringmyConStr=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=student.mdb";/////////////////////////初始化函數(shù)//////////////////////////////////privatevoidInit(){OleDbConnectionconn=newOleDbConnection(myConStr);try{conn.Open();stringmyComStr="Select*fromStudent";OleDbDataAdaptermyDA=newOleDbDataAdapter(myComStr,conn);DataSetmyDS=newDataSet();myDA.Fill(myDS,"student");dgv_DataBase.DataSource=myDS.Tables["student"];dgv_DataBase.Columns[0].Width=73;dgv_DataBase.Columns[4].Width=90;}catch(OleDbExceptionoe){MessageBox.Show("程序好像碰到了點(diǎn)麻煩!","請(qǐng)注意",MessageBoxButtons.OK,MessageBoxIcon.Information);}finally{if(conn.State==ConnectionState.Open)conn.Close();}}///////////////////////////////////////////////////////////////////////////////////////////////////執(zhí)行操作函數(shù)(插入/刪除)////////////////////////privatevoidExcute(stringstr){OleDbConnectionconn=newOleDbConnection(myConStr);try{conn.Open();OleDbCommandmyCom=newOleDbCommand(str,conn);myCom.ExecuteNonQuery();MessageBox.Show("統(tǒng)計(jì)插入完成!","提醒",MessageBoxButtons.OK,MessageBoxIcon.Information);}catch(OleDbExceptionoe){MessageBox.Show("請(qǐng)輸入正確格式!","請(qǐng)注意",MessageBoxButtons.OK,MessageBoxIcon.Information);return;}finally{if(conn.State==ConnectionState.Open)conn.Close();}}////////////////////////////////////////////////////////////////////////////////////////////////////查詢函數(shù)//////////////////////////////////privatevoidSearch(stringstr){OleDbConnectionconn=newOleDbConnection(myConStr);try{conn.Open();OleDbDataAdaptermyDA=newOleDbDataAdapter(str,conn);DataSetmyDS=newDataSet();myDA.Fill(myDS,"searchResult");dgv_DataBase.DataSource=myDS.Tables["searchResult"];}catch(OleDbExceptionoe){MessageBox.Show("程序好像碰到了點(diǎn)麻煩!","請(qǐng)注意",MessageBoxButtons.OK,MessageBoxIcon.Information);return;}finally{if(conn.State==ConnectionState.Open)conn.Close();}}/////////////////////////////////////////////////////////////////////////privatevoidbtnSearch_Click(objectsender,EventArgse){stringSearchStr="Select學(xué)號(hào),姓名fromStudentwhere姓名='"+txtBox_Search.Text+"'";Search(SearchStr);if(dgv_DataBase.Rows.Count<1){MessageBox.Show("沒(méi)有找到要查詢數(shù)據(jù)!","注意",MessageBoxButtons.OK,MessageBoxIcon.Information);}elseMessageBox.Show("查詢完成!","提醒",MessageBoxButtons.OK,MessageBoxIcon.Information);}privatevoidbutton1_Click(objectsender,EventArgse){Init();}privatevoidbutton2_Click(objectsender,EventArgse){Application.Exit();}privatevoidbtnIns_Insert_Click(objectsender,EventArgse){stringInsertStr;InsertStr="insertintostudent(學(xué)號(hào),姓名,班級(jí),性別,年紀(jì),學(xué)院)values("+txtBoxNum_Insert.Text;InsertStr+=",'"+txtBoxName_Insert.Text+"','"+txtBoxClass_Insert.Text+"','"+cmbBoxSex_Insert.Text+"',";InsertStr+=txtBoxAge_Insert.Text+",'"+txtBoxSchool_Insert.Text+"')";Excute(InsertStr);Init();}privatevoidbtnClear_Insert_Click(objectsender,EventArgse){txtBoxAge_Insert.Text="";txtBoxClass_Insert.Text="";txtBoxName_Insert.Text="";txtBoxNum_Insert.Text="";txtBoxSchool_Insert.Text="";txtBoxNum_Insert.Focus();}在網(wǎng)頁(yè)中顯示數(shù)據(jù)庫(kù)內(nèi)表內(nèi)容源代碼:Default.aspx<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="GridView.aspx.cs"Inherits="_Default"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"""><htmlxmlns=""><headrunat="server"><title>無(wú)標(biāo)題頁(yè)</title></head><body><formid="form1"runat="server"><div><asp:GridViewID="GridView1"runat="server"Height="179px"Width="698px"BackColor="White"BorderColor="#999999"BorderStyle="None"BorderWidth="1px"CellPadding="3"GridLines="Vertical"><FooterStyleBackColor="#CCCCCC"ForeColor="Black"/><RowStyleBackColor="#EEEEEE"ForeColor="Black"/><SelectedRowStyleBackColor="#008A8C"Font-Bold="True"ForeColor="White"<PagerStyleBackColor="#999999"ForeColor="Black"HorizontalAlign="Center"/><HeaderStyleBackColor="#000084"Font-Bold="True"ForeColor="White"/><AlternatingRowStyleBackColor="#DCDCDC"/></asp:GridView></div></form></body></html>Default.aspx.csprotectedvoidPage_Load(objectsender,EventArgse){if(!Page.IsPostBack){BindData();}}privatevoidBindData(){stringconStr=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=E:\software\C#\C#\C#試驗(yàn)\kongexp5\exp5\exp5\bin\Debug\student.mdb";stringComStr="select*fromstudent";OleDbConnectionconn=newOleDbConnection(conStr);OleDbDataAdaptermyDA=newOleDbDataAdapter(ComStr,conn);DataSetmyDS=newDataSet();myDA.Fill(myDS,"student");GridView1.DataSource=myDS;GridView1.DataBind();}四.調(diào)試和運(yùn)行結(jié)果(1)查詢(2)插入(3)在Web中顯示數(shù)據(jù)表中內(nèi)容五.試驗(yàn)感想1、對(duì)試驗(yàn)原理有更深刻了解,熟悉了VisualC#.NET數(shù)據(jù)庫(kù)基本操作,學(xué)會(huì)了使用ADO.NET對(duì)象,會(huì)使用ADO.NET控件,以及數(shù)據(jù)綁定和數(shù)據(jù)綁定控件。2、對(duì)VisualStudio在實(shí)踐中應(yīng)用有深刻了解,在實(shí)踐基礎(chǔ)上,把所學(xué)過(guò)知識(shí)應(yīng)用于實(shí)際應(yīng)用中,更深刻了解了C#基本語(yǔ)句實(shí)際應(yīng)用。3、經(jīng)過(guò)試驗(yàn)課程設(shè)計(jì)激發(fā)了我學(xué)習(xí)主動(dòng)性,培養(yǎng)了我獨(dú)立發(fā)覺(jué)問(wèn)題、分析問(wèn)題、處理問(wèn)題能力。更增強(qiáng)了我與同學(xué)交流溝通能力和共同處理問(wèn)題合作能力。4、了解了C#基本語(yǔ)句知識(shí)點(diǎn)及學(xué)科之間融合滲透。將之前所學(xué)編程基本知識(shí)應(yīng)用于軟件設(shè)計(jì),達(dá)成了學(xué)以致用目標(biāo)。試驗(yàn)六WEB程序設(shè)計(jì)一.試驗(yàn)內(nèi)容1.設(shè)計(jì)網(wǎng)站注冊(cè)功效,要求驗(yàn)證用戶名和密碼。用戶信息保留在一個(gè)Access數(shù)據(jù)庫(kù)表中。使用驗(yàn)證控件,驗(yàn)證用戶輸入。2.用戶注冊(cè)成功后進(jìn)入另一個(gè)頁(yè)面,在該頁(yè)面上將網(wǎng)站中注冊(cè)用戶信息以表格形式顯示出來(lái)。二.試驗(yàn)?zāi)繕?biāo)熟練掌握WEB程序設(shè)計(jì)三.源程序創(chuàng)建了兩個(gè)頁(yè)面:default.aspx為注冊(cè)頁(yè)面,regInfo.aspx為顯示注冊(cè)信息頁(yè)面Default.aspx頁(yè)面包含4個(gè)TextBOX,4個(gè)Label,7個(gè)驗(yàn)證控件7個(gè)驗(yàn)證控件屬性設(shè)置以下:RequiredFieldValidator1ControlToValidate屬性:textBoxFirstNameErrorMessage屬性:請(qǐng)輸入用戶名RequiredFieldValidator2ControlToValidate屬性:textBoxPasswordErrorMessage屬性:請(qǐng)輸入密碼RequiredFieldValidator3ControlToValidate屬性:textBoxEmail
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度磨工職業(yè)病防治與勞動(dòng)合同結(jié)合協(xié)議3篇
- 2025年度個(gè)人二手房買賣定金合同樣本
- 2025版美食城攤位租賃與商業(yè)運(yùn)營(yíng)合同3篇
- 二零二五年度牛奶加工副產(chǎn)品綜合利用合同4篇
- 2025年度門面鋪面租賃合同-含租賃期限靈活調(diào)整選項(xiàng)4篇
- 二零二五年度農(nóng)業(yè)觀光果園休閑農(nóng)業(yè)項(xiàng)目規(guī)劃設(shè)計(jì)合同4篇
- 2025年度綠色能源項(xiàng)目代理招商合同范本4篇
- 2025年度車輛掛靠車輛維修保養(yǎng)連鎖經(jīng)營(yíng)合同4篇
- 二零二五年度商業(yè)地產(chǎn)承包經(jīng)營(yíng)招租協(xié)議8篇
- 二零二五年度無(wú)障礙電梯安裝與改造合同4篇
- 完整版秸稈炭化成型綜合利用項(xiàng)目可行性研究報(bào)告
- 油氣行業(yè)人才需求預(yù)測(cè)-洞察分析
- 《數(shù)據(jù)采集技術(shù)》課件-Scrapy 框架的基本操作
- 2025年河北省單招語(yǔ)文模擬測(cè)試二(原卷版)
- 高一化學(xué)《活潑的金屬單質(zhì)-鈉》分層練習(xí)含答案解析
- DB34∕T 4010-2021 水利工程外觀質(zhì)量評(píng)定規(guī)程
- 2024年內(nèi)蒙古中考英語(yǔ)試卷五套合卷附答案
- 四年級(jí)上冊(cè)脫式計(jì)算100題及答案
- 上海市12校2023-2024學(xué)年高考生物一模試卷含解析
- 儲(chǔ)能電站火災(zāi)應(yīng)急預(yù)案演練
- 人教版(新插圖)二年級(jí)下冊(cè)數(shù)學(xué) 第4課時(shí)用“進(jìn)一法”和“去尾法”解決簡(jiǎn)單的實(shí)際問(wèn)題 教學(xué)課件
評(píng)論
0/150
提交評(píng)論