公共 clsSimuResultByOneGoods GetOneGoodsSimulationXML(字符串 PathAndFileName)
{
clsSimuResultByOneGoods OneGoods = new clsSimuResultByOneGoods();//自己定义的一个类
Hashtable AllLocationResult = new Hashtable();
System.Xml.XmlTextReader r = new XmlTextReader(PathAndFileName);
字符串位置ID = "";
数据表位置表= null;
while(r.Read())
{
if(r.NodeType == XmlNodeType.Element)
{
开关(r.LocalName)
{
案例“结果”:
OneGoods.GoodsCode = r.GetAttribute("GoodsCode");
OneGoods.From = Convert.ToDateTime(r.GetAttribute("FromDate"));
OneGoods.To = Convert.ToDateTime(r.GetAttribute("ToDate"));
休息;
案例“位置”:
LocationID = r.GetAttribute("ID");
位置表 = new DataTable();
LocationTable.Columns.Add("日期",typeof(DateTime));
LocationTable.Columns.Add("SafetyStock",typeof(decimal));
LocationTable.Columns.Add("预测需求",typeof(decimal));
LocationTable.Columns.Add("FinalOutput",typeof(decimal));
LocationTable.Columns.Add("FinalInput",typeof(decimal));
LocationTable.Columns.Add("SimuStock",typeof(decimal));
LocationTable.Columns.Add("SimuStockTime",typeof(decimal));
LocationTable.Columns.Add("ImportWorkDay",typeof(bool));
LocationTable.Columns.Add("ImportWorkDay",typeof(bool));
休息;
案例“记录”:
if(位置表!= null)
{
DataRow dr = LocationTable.NewRow();
dr["日期"] = Convert.ToDateTime(r.GetAttribute("日期"));
if(r.GetAttribute("SafetyStock") != null && r.GetAttribute("SafetyStock") != "")
dr["SafetyStock"] = Convert.ToDecimal(r.GetAttribute("SafetyStock"));
if(r.GetAttribute("ForecastDemand") != null && r.GetAttribute("ForecastDemand") != "")
dr["ForecastDemand"] = Convert.ToDecimal(r.GetAttribute("ForecastDemand"));
if(r.GetAttribute("FinalInput") != null && r.GetAttribute("FinalInput") != "")
dr["FinalInput"] = Convert.ToDecimal(r.GetAttribute("FinalInput"));
if(r.GetAttribute("FinalOutput") != null && r.GetAttribute("FinalOutput") != "")
dr["FinalOutput"] = Convert.ToDecimal(r.GetAttribute("FinalOutput"));
if(r.GetAttribute("SimuStock") != null && r.GetAttribute("SimuStock") != "")
dr["SimuStock"] = Convert.ToDecimal(r.GetAttribute("SimuStock"));
if(r.GetAttribute("SimuStockTime") != null && r.GetAttribute("SimuStockTime") != "")
dr["SimuStockTime"] = Convert.ToDecimal(r.GetAttribute("SimuStockTime"));
if(r.GetAttribute("ImportWorkDay") != null && r.GetAttribute("ImportWorkDay") != "")
dr["ImportWorkDay"] = Convert.ToBoolean(r.GetAttribute("ImportWorkDay"));
if(r.GetAttribute("ExportWorkDay") != null && r.GetAttribute("ExportWorkDay") != "")
dr["ExportWorkDay"] = Convert.ToBoolean(r.GetAttribute("ExportWorkDay"));
LocationTable.Rows.Add(dr);
}
休息;
默认:
休息;
}
}
else if(r.NodeType == XmlNodeType.EndElement)
{
开关(r.LocalName)
{
案例“位置”:
if(位置表!= null)
{
LocationTable.AcceptChanges();
AllLocationResult.Add(LocationID,LocationTable);
位置ID = "";
位置表=空;
}
休息;
默认:
休息;
}
}
}
OneGoods.AllLocationResult = AllLocationResult;
退回 OneGoods;
}