




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、一.實驗目的:通過實驗,進一步理解DO項型,熟悉各個語言的xml編程方法。鍛煉軟件開發(fā)能力。二.實驗內(nèi)容:1 、 要求做一個管理信息系統(tǒng),實現(xiàn)對某個事物的管理,做成網(wǎng)頁的形式(B/S)或者(C/S)形式。要求有界面。2 、 這個系統(tǒng)后臺的數(shù)據(jù)存放在xml 里,要實現(xiàn)對xml 文檔的增刪改查。3 、界面盡可能好看,功能盡可能貼近實際應用。4 、編程語言不限。三實驗步驟或程序(經(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(歡迎進入個人理財系統(tǒng),登陸成功,Me
3、ssageBoxButtons.OK, MessageBoxIcon.Information);this.DialogResult = DialogResult.OK;this.Tag = true;return;MessageBox.Show(您輸入的用戶名或密碼錯誤!請重試,登陸失敗, 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(用戶名已存在,注冊失敗,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(恭喜您!成功注冊,注冊成功,MessageBoxButtons.OK, MessageBoxIcon.Information);2 .本人統(tǒng)計查詢界面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 總計:2元”,income,expend,(income-expend);txtmessage.Text = message;private void btn_cancel_Click(object sender, EventArgs e)this.Close();3 . 添加收支項目界面: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(要添力口的收支項目為:0n 所屬類別: 1,name,t);txtInfo.Text = message;private void button2_Click(object sender, EventArgs e)MessageBox.Show(項目添加成功!,操作成功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 . 用戶注冊界面: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(用戶名已存在,注冊失敗,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(恭喜您!成功注冊,注冊成功,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(密碼修改成功!請重新登錄,操作成功 , MessageBoxButtons.OK, MessageBoxIcon.Information);this.Close();return;MessageBox.Show(您輸入的用戶名或密碼錯誤!請重試,修改失敗, 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已無數(shù)據(jù),此操作無效,無數(shù)據(jù),MessageBoxButtons.OK, MessageBoxIcon.Warning);return;n+;xnode=xnode.NextSibling;private void PreviousNode() if (xnode.PreviousSibling = null)Messa
26、geBox.ShowC已無數(shù)據(jù),此操作無效,無數(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 同學 : 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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 人教部編版一年級上冊期末學業(yè)水平測試語文試卷
- 人教部編版三年級上冊階段性檢測語文試卷
- 人教版語文三年級上冊4.2蜜蜂練習卷2
- 小學階段英語寫作常見問題及范文
- 某年度玻璃纖維仿形織物市場分析及競爭策略分析報告
- 建筑施工安全質(zhì)量控制措施
- 某年度社會救助及公益服務戰(zhàn)略市場規(guī)劃報告
- 互聯(lián)網(wǎng)企業(yè)財務主管職責
- 智能城市建設資金使用計劃與投資分析
- 圖書銷售年檢自查報告范文
- 電力公司電氣設備維護手冊
- 2024年江西省高考政治試卷真題(含答案)
- 服裝店員工考勤管理制度
- 國人毛孔粗大表征研究及護理指南 2024
- 質(zhì)量信得過班組培訓課件
- 水利工程施工監(jiān)理規(guī)范SL288-2014(CB、JL用表全套)
- 鐵路信號技師技術(shù)總結(jié)
- 洗瓶機推瓶機構(gòu)設計計算說明書+運動簡圖+運動循環(huán)圖
- DL∕T 707-2014 HS系列環(huán)錘式破碎機
- 費用組成-特殊施工增加費課件講解
- 國民經(jīng)濟行業(yè)分類代碼表
評論
0/150
提交評論