




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、一.實(shí)驗(yàn)?zāi)康模和ㄟ^(guò)實(shí)驗(yàn),進(jìn)一步理解DO項(xiàng)型,熟悉各個(gè)語(yǔ)言的xml編程方法。鍛煉軟件開(kāi)發(fā)能力。二.實(shí)驗(yàn)內(nèi)容:1 、 要求做一個(gè)管理信息系統(tǒng),實(shí)現(xiàn)對(duì)某個(gè)事物的管理,做成網(wǎng)頁(yè)的形式(B/S)或者(C/S)形式。要求有界面。2 、 這個(gè)系統(tǒng)后臺(tái)的數(shù)據(jù)存放在xml 里,要實(shí)現(xiàn)對(duì)xml 文檔的增刪改查。3 、界面盡可能好看,功能盡可能貼近實(shí)際應(yīng)用。4 、編程語(yǔ)言不限。三實(shí)驗(yàn)步驟或程序(經(jīng)調(diào)試后正確的源程序)1 .登陸界面:namespace XMLpublic partial class Login : Formpublic Login()InitializeComponent();private voi
2、d Yes_Click(object sender, EventArgs e)XmlDocument xmldoc = new XmlDocument();xmldoc.Load(F:peoples.xml);foreach(XmlNodexnodeinxmldoc.SelectSingleNode(peoples).ChildNodes)if (xnode.ChildNodes0.InnerText = txtname.Text &xnode.ChildNodes1.InnerText = txtpassword.Text)MessageBox.Show(歡迎進(jìn)入個(gè)人理財(cái)系統(tǒng),登陸成功,Me
3、ssageBoxButtons.OK, MessageBoxIcon.Information);this.DialogResult = DialogResult.OK;this.Tag = true;return;MessageBox.Show(您輸入的用戶(hù)名或密碼錯(cuò)誤!請(qǐng)重試,登陸失敗, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);this.Tag = false;private void Register_Click(object sender, EventArgs e) XmlDocument xmldoc = new XmlDoc
4、ument();xmldoc.Load(F:peoples.xml);foreach(XmlNodexnodeinxmldoc.SelectSingleNode(peoples).ChildNodes)if (xnode.ChildNodes0.InnerText = txtname.Text)MessageBox.Show(用戶(hù)名已存在,注冊(cè)失敗,MessageBoxButtons.OK, MessageBoxIcon.Exclamation);this.Tag = false;return;XmlElement FirstNode = xmldoc.CreateElement(people
5、);XmlElement NameNode = xmldoc.CreateElement(name);XmlNode name = xmldoc.CreateTextNode(txtname.Text);NameNode.AppendChild(name);XmlElement PasswordNode = xmldoc.CreateElement(password);XmlNode password = xmldoc.CreateTextNode(txtpassword.Text);PasswordNode.AppendChild(password);FirstNode.AppendChil
6、d(NameNode);FirstNode.AppendChild(PasswordNode);xmldoc.DocumentElement.AppendChild(FirstNode);xmldoc.Save(F:peoples.xml);MessageBox.Show(恭喜您!成功注冊(cè),注冊(cè)成功,MessageBoxButtons.OK, MessageBoxIcon.Information);2 .本人統(tǒng)計(jì)查詢(xún)界面namespace XMLpublic partial class About_me : Formpublic About_me()InitializeComponent();
7、ShowMessage();public void ShowMessage()XmlDocument xmldoc = new XmlDocument();xmldoc.Load(F:Registration.xml);double income = 0.0, expend = 0.0;foreach(XmlNodexnodeinxmldoc.SelectSingleNode(registrations).ChildNodes)if (xnode.ChildNodes0.InnerText = 收入 )income += double.Parse(xnode.ChildNodes5.Inner
8、Text); elseexpend += double.Parse(xnode.ChildNodes5.InnerText);string message = String.Format(目前您的總收入為:0元n總支出為:1元n 總計(jì):2元”,income,expend,(income-expend);txtmessage.Text = message;private void btn_cancel_Click(object sender, EventArgs e)this.Close();3 . 添加收支項(xiàng)目界面:namespace XMLpublic partial class Add_i
9、tem : Formpublic Add_item()InitializeComponent();private void button1_Click(object sender, EventArgs e)if (txtname.Text.Trim().Length = 0)MessageBox.Show(輸入信息不完整!,信息不完整,MessageBoxButtons.OK, MessageBoxIcon.Exclamation);elsetabControl1.SelectedIndex = 1;private void tabControl1_SelectedIndexChanged(o
10、bjectsender, EventArgs e)if(tabControl1.SelectedIndex=1)if (txtname.Text.Trim().Length = 0)MessageBox.Show(輸入信息不完整!,信息不完整,MessageBoxButtons.OK, MessageBoxIcon.Exclamation);tabControl1.SelectedIndex = 0; elsestring name = txtname.Text;string t = ;if (isshouru.Checked)t = isshouru.Text;elset = iszhich
11、u.Text;string message = String.Format(要添力口的收支項(xiàng)目為:0n 所屬類(lèi)別: 1,name,t);txtInfo.Text = message;private void button2_Click(object sender, EventArgs e)MessageBox.Show(項(xiàng)目添加成功!,操作成功MessageBoxButtons.OK, MessageBoxIcon.Information);4.添加收支情況界面:namespace XMLpublic partial class Add_Registration : Formpublic Ad
12、d_Registration()InitializeComponent();private void btn_yes_Click(object sender, EventArgs e)XmlDocument xmldoc = new XmlDocument();xmldoc.Load(F:Registration.xml);XmlElement secondNode = xmldoc.CreateElement(registration);XmlElement TypeNode = xmldoc.CreateElement(type);string t=;if(isshouru.Checked
13、)t=isshouru.Text;elset=iszhichu.Text;XmlNode type = xmldoc.CreateTextNode(t);TypeNode.AppendChild(type);XmlElement KindNode = xmldoc.CreateElement(kind);string k = txtKind.SelectedItem.ToString();XmlNode kind = xmldoc.CreateTextNode(k);KindNode.AppendChild(kind);XmlElement RemarkNode = xmldoc.Create
14、Element(remark);XmlNode remark = xmldoc.CreateTextNode(txtbz.Text);RemarkNode.AppendChild(remark);XmlElement objectNode = xmldoc.CreateElement(object);string o = ;if (checkBox1.Checked) o += checkBox1.Text + ;if (checkBox2.Checked) o += checkBox2.Text + ;if (checkBox3.Checked) o += checkBox3.Text +
15、;if (checkBox4.Checked) o += checkBox4.Text + ;if (checkBox5.Checked) o += checkBox5.Text + ;if (checkBox6.Checked) o += checkBox6.Text + ;XmlNode Object = xmldoc.CreateTextNode(o);objectNode.AppendChild(Object);XmlElement DateNode = xmldoc.CreateElement(date);string d = dateTime.Value.ToShortDateSt
16、ring();XmlNode date = xmldoc.CreateTextNode(d);DateNode.AppendChild(date);XmlElement QuantityNode = xmldoc.CreateElement(quantity);XmlNode quantity = xmldoc.CreateTextNode(txtquantity.Text);QuantityNode.AppendChild(quantity);secondNode.AppendChild(TypeNode);secondNode.AppendChild(KindNode);secondNod
17、e.AppendChild(RemarkNode);secondNode.AppendChild(objectNode);secondNode.AppendChild(DateNode);secondNode.AppendChild(QuantityNode);xmldoc.DocumentElement.AppendChild(secondNode);xmldoc.Save(F:Registration.xml);MessageBox.Show(巴保存,記錄成功, MessageBoxButtons.OK,MessageBoxIcon.Information);private void bt
18、n_cancel_Click(object sender, EventArgs e)this.Close();4 . 用戶(hù)注冊(cè)界面:namespace XMLpublic partial class Add_user : Formpublic Add_user()InitializeComponent();private void btn_ok_Click(object sender, EventArgs e)XmlDocument xmldoc = new XmlDocument();xmldoc.Load(F:peoples.xml);foreach(XmlNodexnodeinxmldo
19、c.SelectSingleNode(peoples).ChildNodes)if (xnode.ChildNodes0.InnerText = txtname.Text)MessageBox.Show(用戶(hù)名已存在,注冊(cè)失敗,MessageBoxButtons.OK, MessageBoxIcon.Exclamation);this.Tag=false;return;XmlElement FirstNode = xmldoc.CreateElement(people);XmlElement NameNode = xmldoc.CreateElement(name);XmlNode name
20、= xmldoc.CreateTextNode(txtname.Text);NameNode.AppendChild(name);XmlElement PasswordNode = xmldoc.CreateElement(password);XmlNode password = xmldoc.CreateTextNode(txtpassword.Text);PasswordNode.AppendChild(password);FirstNode.AppendChild(NameNode);FirstNode.AppendChild(PasswordNode);xmldoc.DocumentE
21、lement.AppendChild(FirstNode);xmldoc.Save(F:peoples.xml);MessageBox.Show(恭喜您!成功注冊(cè),注冊(cè)成功,MessageBoxButtons.OK, MessageBoxIcon.Information);this.Tag = true;private void btn_cancel_Click(object sender, EventArgs e)this.Close();5 . 修改密碼界面:namespace XMLpublic partial class Charge_password : Formpublic Cha
22、rge_password()InitializeComponent();private void btn_next_Click(object sender, EventArgs e)XmlDocument xmldoc = new XmlDocument();xmldoc.Load(F:peoples.xml);foreach(XmlNodexnodeinxmldoc.SelectSingleNode(peoples).ChildNodes)if (xnode.ChildNodes0.InnerText = txtname.Text &xnode.ChildNodes1.InnerText =
23、 txtpassword.Text)xnode.ChildNodes1.InnerText = txtnewpassword.Text;xmldoc.Save(F:peoples.xml);MessageBox.Show(密碼修改成功!請(qǐng)重新登錄,操作成功 , MessageBoxButtons.OK, MessageBoxIcon.Information);this.Close();return;MessageBox.Show(您輸入的用戶(hù)名或密碼錯(cuò)誤!請(qǐng)重試,修改失敗, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);6 .管理收支情況界
24、面:namespace xmlpublic partial class Charge_Item : FormXmlDocument xmldoc = new XmlDocument();private static XmlNode xnode;XmlNodeList xnodelist;XmlNode xnodeparent;public static int n = 0;public Charge_Item()InitializeComponent();xmldoc.Load(F:Registration.xml);xnodeparent = xmldoc.FirstChild;xnodel
25、ist = xnodeparent.ChildNodes;xnode = xnodelistn;ShowCurrentItem(xnode);private void NextNode()if (xnode.NextSibling = null)MessageBox.ShowC已無(wú)數(shù)據(jù),此操作無(wú)效,無(wú)數(shù)據(jù),MessageBoxButtons.OK, MessageBoxIcon.Warning);return;n+;xnode=xnode.NextSibling;private void PreviousNode() if (xnode.PreviousSibling = null)Messa
26、geBox.ShowC已無(wú)數(shù)據(jù),此操作無(wú)效,無(wú)數(shù)據(jù),MessageBoxButtons.OK, MessageBoxIcon.Warning);return;n-;xnode=xnode.PreviousSibling;private void ShowCurrentItem(XmlNode xxnode)string type = xxnode.ChildNodes0.InnerText;if (type = 收入 )isshouru.Checked = true;elseiszhichu.Checked = true;txtkind.Text = xxnode.ChildNodes1.In
27、nerText;txtbz.Text = xxnode.ChildNodes2.InnerText;string Object = new string6;Object = xxnode.ChildNodes3.InnerText.Split( );checkBox1.Checked = false;checkBox2.Checked = false;checkBox3.Checked = false;checkBox4.Checked = false;checkBox5.Checked = false;checkBox6.Checked = false;foreach (string s i
28、n Object)switch (s)case 我: checkBox1.Checked = true; break;case 親戚 : checkBox2.Checked = true; break;case 家人 : checkBox3.Checked = true; break;case 朋友 : checkBox4.Checked = true; break;case 同學(xué) : checkBox5.Checked = true; break;case 其他 : checkBox6.Checked = true; break;txttime.Text = xxnode.ChildNode
29、s4.InnerText;txtquantity.Text = xxnode.ChildNodes5.InnerText;private void btnPrevious_Click(object sender, EventArgs e)PreviousNode();ShowCurrentItem(xnode);private void btnNext_Click(object sender, EventArgs e)NextNode();ShowCurrentItem(xnode);private void btnEdit_Click(object sender, EventArgs e)X
30、mlDocument doc = new XmlDocument();doc.Load(F:Registration.xml);XmlNode root = doc.DocumentElement;XmlNodeList list = root.ChildNodes;string t=;if(isshouru.Checked)t=isshouru.Text;else t=iszhichu.Text;listn.ChildNodes0.InnerText = t;if(txtkind.SelectedItem!=null)listn.ChildNodes1.InnerText = txtkind
31、.SelectedItem.ToString();listn.ChildNodes2.InnerText = txtbz.Text;string o = ;if (checkBox1.Checked) o += checkBox1.Text + ;if (checkBox2.Checked) o += checkBox2.Text + ;if (checkBox3.Checked) o += checkBox3.Text + ;if (checkBox4.Checked) o += checkBox4.Text + ;if (checkBox5.Checked) o += checkBox5.
32、Text + ;if (checkBox6.Checked) o += checkBox6.Text + ;listn.ChildNodes3.InnerText = o;listn.ChildNodes4.InnerText = txttime.Text;listn.ChildNodes5.InnerText = txtquantity.Text;doc.Save(F:Registration.xml);MessageBox.Show(巴修改!,操作成功,MessageBoxButtons.OK,MessageBoxIcon.Information); private void btnDel
33、ete_Click(object sender, EventArgs e) XmlDocument doc = new XmlDocument();doc.Load(F:Registration.xml);XmlNode root = doc.DocumentElement;XmlNodeList list = root.ChildNodes;root.RemoveChild(listn);doc.Save(F:Registration.xml);MessageBox.Show(巴刪除!,操作成功,MessageBoxButtons.OK,MessageBoxIcon.Information)
34、;DataSet ds = new DataSet();private void btn_ReadXML_Click(object sender, EventArgs e) ds.Tables.Clear();dataGridView1.DataSource = ds.Tables;ds.ReadXml(F:Registration.xml);dataGridView1.DataSource = ds.Tables0;7.主界面: namespace XML public partial class MainFrm : Formprivate bool isLogined = false;pu
35、blic MainFrm() InitializeComponent();private void tsmExit_Click(object sender, EventArgs e)Application.Exit();private void tsmNewsz_Click(object sender, EventArgs e)if (isLogined)Add_Registration rForm = new Add_Registration(); rForm.MdiParent = this;rForm.Show();tssMsg.Text = rForm.Text; elsetssMsg.Text =注意,必須先登錄才能使用本系統(tǒng)!private void tsmNewmeau_Click(object sender, EventArgs e) if (isLogined)Add_item iForm = new Add_item();iForm.MdiParent = this;iForm.Show();tssMsg.Tex
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 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ì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年高端煤機(jī)裝備項(xiàng)目發(fā)展計(jì)劃
- 2025年風(fēng)電變流器柜體系統(tǒng)項(xiàng)目發(fā)展計(jì)劃
- 2025年大型重工裝備鑄件合作協(xié)議書(shū)
- 地下工程有毒有害氣體監(jiān)測(cè)與安全監(jiān)管合同
- 離婚賭博賠償協(xié)議書(shū)及房產(chǎn)分割協(xié)議
- 小紅書(shū)電商收益結(jié)算與推廣合同
- 電動(dòng)汽車(chē)充電樁建設(shè)與電力需求側(cè)響應(yīng)合作協(xié)議
- 學(xué)前教育幼兒管理
- 金融科技股權(quán)收益權(quán)質(zhì)押合作開(kāi)發(fā)合同
- 環(huán)保產(chǎn)品銷(xiāo)售與推廣服務(wù)合同
- 余華《活著》賞析ppt
- 第8章-GNSS測(cè)量與定位-課件
- 衛(wèi)生院外傷處置方案
- 某地面工程電力安裝EC總承包工程技術(shù)文件
- 北汽昌河Q25-汽車(chē)使用手冊(cè)用戶(hù)操作圖示圖解詳解駕駛指南車(chē)主車(chē)輛說(shuō)明書(shū)電子版
- 散流器送風(fēng)氣流組織計(jì)算
- D500-D505 2016年合訂本防雷與接地圖集
- 念珠菌定植與藥物選擇
- 寧夏回族自治區(qū)社會(huì)保險(xiǎn)變更登記表
- 幼兒園小小建筑師分享課件
- 物業(yè)承接查驗(yàn)方案及查驗(yàn)方法
評(píng)論
0/150
提交評(píng)論