xml| data
Public Clssimuresultbyonegoods Getonegoodssimulationxml (string pathandfilename)
{
Clssimuresultbyonegoods onegoods = new Clssimuresultbyonegoods ();//A class that you define
Hashtable Alllocationresult = new Hashtable ();
System.Xml.XmlTextReader r = new XmlTextReader (Pathandfilename);
String LocationID = "";
DataTable locationtable = null;
while (R.read ())
{
if (R.nodetype = = XmlNodeType.Element)
{
Switch (r.localname)
{
Case "Result":
Onegoods.goodscode = R.getattribute ("Goodscode");
Onegoods.from = Convert.todatetime (R.getattribute ("FromDate"));
onegoods.to = Convert.todatetime (R.getattribute ("ToDate"));
Break
Case "Location":
LocationID = R.getattribute ("ID");
locationtable = new DataTable ();
LOCATIONTABLE.COLUMNS.ADD ("Date", typeof (DateTime));
LOCATIONTABLE.COLUMNS.ADD ("Safetystock", typeof (decimal));
LOCATIONTABLE.COLUMNS.ADD ("Forecastdemand", 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));
Break
Case "Record":
if (locationtable!= null)
{
DataRow dr = Locationtable.newrow ();
dr["Date" = Convert.todatetime (R.getattribute ("date"));
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);
}
Break
Default
Break
}
}
else if (R.nodetype = = xmlnodetype.endelement)
{
Switch (r.localname)
{
Case "Location":
if (locationtable!= null)
{
Locationtable.acceptchanges ();
Alllocationresult.add (locationid,locationtable);
LocationID = "";
locationtable = null;
}
Break
Default
Break
}
}
}
Onegoods.alllocationresult = Alllocationresult;
return onegoods;
}