c#物资管理系统(xml存储)

c#物资管理系统(xml存储)

ID:27449753

大小:28.27 KB

页数:18页

时间:2018-12-03

c#物资管理系统(xml存储)_第1页
c#物资管理系统(xml存储)_第2页
c#物资管理系统(xml存储)_第3页
c#物资管理系统(xml存储)_第4页
c#物资管理系统(xml存储)_第5页
资源描述:

《c#物资管理系统(xml存储)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、用Xml存储的c#物资管理系统usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Xml;usingSystem.IO;namespace物资库存管理系统{publicpartialclassWuZi:Form{publicWuZi(){InitializeComponent();}

2、privatevoidbtnC_Click(objectsender,EventArgse)//库存创建{stringid=textBox1.Text;stringname=textBox2.Text;stringsize=textBox3.Text;stringspecies=textBox4.Text;stringunit=textBox5.Text;stringnumber=textBox6.Text;XmlTextWriterdoc=newXmlTextWriter("goods.xml",null);doc.Formatting=Format

3、ting.Indented;//使用自动缩进便于阅读doc.WriteStartElement("huowu");doc.WriteStartElement("goods");doc.WriteAttributeString("id",id);doc.WriteElementString("name",name);doc.WriteElementString("size",size);doc.WriteElementString("species",species);doc.WriteElementString("unit",unit);doc.Wri

4、teElementString("number",number);doc.WriteEndElement();doc.Close();}privatevoidbtnAdd_Click(objectsender,EventArgse)//库存添加{stringid=textBox1.Text;stringname=textBox2.Text;stringsize=textBox3.Text;stringspecies=textBox4.Text;stringunit=textBox5.Text;stringnumber=textBox6.Text;Xml

5、Documentdoc=newXmlDocument();doc.Load("goods.xml");//加载xml文件,路径未指定时默认在当前项目环境下XmlNoderoot=doc.SelectSingleNode("huowu");//选择要添加子节点的节点XmlElementstu=doc.CreateElement("goods");//创建一个具有指定名称的子节点stu.SetAttribute("id",id);XmlElementxmlsub1=doc.CreateElement("name");xmlsub1.InnerText=na

6、me;stu.AppendChild(xmlsub1);XmlElementxmlsub2=doc.CreateElement("size");xmlsub2.InnerText=size;stu.AppendChild(xmlsub2);XmlElementxmlsub3=doc.CreateElement("species");xmlsub3.InnerText=species;stu.AppendChild(xmlsub3);XmlElementxmlsub4=doc.CreateElement("unit");xmlsub4.InnerText

7、=unit;stu.AppendChild(xmlsub4);XmlElementxmlsub5=doc.CreateElement("number");xmlsub5.InnerText=number;stu.AppendChild(xmlsub5);root.AppendChild(stu);//将创建的item子节点添加到items节点的尾部doc.Save("goods.xml");//保存xml文件,}privatevoidbtnUpdate_Click(objectsender,EventArgse)//库存修改{stringid=text

8、Box1.Text;stringname=textBox2.Text;stringsize=t

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。