using system; using system.io; using system.data; using system.diagnostics; using xmlbook.com.sem.tools; //这里就包含了上一篇提供的类
namespace xmlbook.component { /// <summary> /// 版权: copyright by sem it department /// 版本: 0.0.1 /// 文件: xmlbook.component.mdldatamange.cs /// 目的: 留言数据相关的操作 /// 作者: 欧远宁 @2005-04-09 /// 邮箱: outrace@soueast-motor.com /// 修改: /// </summary> public class mdldatamanage {
#region 私有成员 private string strid = null; private string strname = null; private string strsex = null; private string stremail = “no email”; private string strpage = “no page”; private string strqq = “no qq”; private string strsubject = null; private string strcontent = null; private string strreply = “no reply”; private string strfilter = null; #endregion #region 公有成员 /// <summary> /// 姓名 /// </summary> public string strname { get{return this.strname;} set{this.strname = value;} } /// <summary> /// 性别 /// </summary> public string strsex { get{return this.strsex;} set{this.strsex = value;} } /// <summary> /// 邮箱 /// </summary> public string stremail { get{return this.stremail;} set{this.stremail = value;} } /// <summary> /// 主页 /// </summary> public string strpage { get{return this.strpage;} set{this.strpage = value;} }
/// <summary> /// oicq号码 /// </summary> public string strqq { get{return this.strqq;} set{this.strqq = value;} } /// <summary> /// 主题 /// </summary> public string strsubject { get{return this.strsubject;} set{this.strsubject = value;} } /// <summary> /// 内容 /// </summary> public string strcontent { get{return this.strcontent;} set{this.strcontent = value;} } /// <summary> /// 回复 /// </summary> public string strreply { get{return this.strreply;} set{this.strreply = value;} } /// <summary> /// id号 /// </summary> public string strid { get{return this.strid;} set{this.strid = value;} } public string strfilter { get{return this.strfilter;} set{this.strfilter = value;} } #endregion
public mdldatamanage() { // // todo: 留言数据相关的操作 // }
/// <summary> /// 新增一条留言(这里演示如何新增一笔记录) /// </summary> public void add() { string [] arrfileds = new string[10]; string [] arrvalues = new string[10]; arrfileds[0] = “id”; arrfileds[1] = “name”; arrfileds[2] = “sex”; arrfileds[3] = “email”; arrfileds[4] = “page”; arrfileds[5] = “qq”; arrfileds[6] = “subject”; arrfileds[7] = “content”; arrfileds[8] = “reply”; arrfileds[9] = “datetime”; arrvalues[0] = datetime.now.tofiletime().tostring(); arrvalues[1] = this.strname; arrvalues[2] = this.strsex; arrvalues[3] = this.stremail; arrvalues[4] = this.strpage; arrvalues[5] = this.strqq; arrvalues[6] = this.strsubject; arrvalues[7] = this.strcontent; arrvalues[8] = “no reply”; arrvalues[9] = datetime.now.tostring(); try { xmldatabase xml = new xmldatabase(); xml.strdatafile = config.datafile; xml.strfields = arrfileds; xml.strdata = arrvalues; xml.insert(); xml.clear(); } catch(exception ee) { log log = new log(); log.struser = “系统”; log.strdepartment = “签写留言”; log.strfilename = “xmlbook.component.mdldatamanage.cs”; log.strdescription = ee.message; log.writelog(); } }
/// <summary> /// 回复留言(这里演示如何修改某一笔xml记录) /// </summary> public void reply() { string [] arrfileds = new string[1]; string [] arrvalues = new string[1]; arrfileds[0] = “reply”; arrvalues[0] = this.strreply; try { xmldatabase xml = new xmldatabase(); xml.strdatafile = config.datafile; xml.strdata = arrvalues; xml.strfields = arrfileds; xml.strfilter = “id=’”+this.strid+”’”; xml.update(); xml.clear(); } catch(exception ee) { log log = new log(); log.struser = “系统”; log.strdepartment = “回复数据”; log.strfilename = “xmlbook.component.mdldatamanage.cs”; log.strdescription = ee.message; log.writelog(); } }
/// <summary> /// 删除留言(这里演示如何删除一笔记录) /// </summary> public void delete() { try { xmldatabase xml = new xmldatabase(); xml.strdatafile = config.datafile; xml.strfilter = “id = ’”+ this.strid +”’”; xml.delete(); xml.clear(); } catch(exception ee) { log log = new log(); log.struser = “系统”; log.strdepartment = “回复数据”; log.strfilename = “xmlbook.component.mdldatamanage.cs”; log.strdescription = ee.message; log.writelog(); } }
/// <summary> /// 获取几行行留言数据(这里演示获取一行或多行数据) /// </summary> /// <returns>各行数据</returns> public datarow[] getonerow() { xmldatabase xml = new xmldatabase(); datarow[] dr = null; try { xml.strdatafile = config.datafile; xml.strfilter = this.strfilter; dr = xml.selectrows(); return dr; } catch(exception ee) { log log = new log(); log.struser = “系统”; log.strdepartment = “获取一行数据”; log.strfilename = “xmlbook.component.mdldatamanage.cs”; log.strdescription = ee.message; log.writelog(); return dr; } finally { xml.clear(); } }
/// <summary> /// 获取视图 /// </summary> /// <returns>视图</returns> public dataview getview() { xmldatabase xml = new xmldatabase(); dataview dv = null; try { xml.strdatafile = config.datafile; xml.strfilter = this.strfilter; dv = xml.selectview(); return dv; } catch(exception ee) { log log = new log(); log.struser = “系统”; log.strdepartment = “获取视图”; log.strfilename = “xmlbook.component.mdldatamanage.cs”; log.strdescription = ee.message; log.writelog(); return dv; } finally { xml.clear(); } } } } |