#region XMLCreation
public bool XMLCreation()
{
string Site_Name = "";
string Site_Date = "";
string Result = "";
int j = 1;
try
{
objbomaster = new BOFileUpload();
objbllmaster = new BLLFileUpload();
DS = new DataSet();
DSITEM = new DataSet();
objbomaster.Site = Session["Site"].ToString();
objbomaster.DocumentDate = Session["DocumentDate"].ToString();
// DS = objbllmaster.SelectXML(objbomaster);
DSITEM = objbllmaster.SelectCommonXML(objbomaster, "proc_selectXML");
if (DSITEM != null && DSITEM.Tables[0].Rows.Count > 0 && DSITEM.Tables[0].Rows[0][0].ToString() != "0")
{
for (int c = 0; c <>
{
objbomaster = new BOFileUpload();
objbllmaster = new BLLFileUpload();
objbomaster.CommonID = Convert.ToInt32(DSITEM.Tables[0].Rows[c][0]);
DS = objbllmaster.SelectCommonParamXML(objbomaster, "proc_selectXML");
XmlDocument writer = new XmlDocument();
XmlNode declaration = writer.CreateNode(XmlNodeType.XmlDeclaration, null, null);
writer.AppendChild(declaration);
XmlElement CONDOLIDATEDSALES = writer.CreateElement("LocalPurchase");
writer.AppendChild(CONDOLIDATEDSALES);
//Creating the element
XmlElement HEADER = writer.CreateElement("HEADER");
CONDOLIDATEDSALES.AppendChild(HEADER);
XmlElement SITE = writer.CreateElement("SITE");
SITE.InnerText = DS.Tables[0].Rows[0][0].ToString();
Site_Name = DS.Tables[0].Rows[0][0].ToString();
HEADER.AppendChild(SITE);
XmlElement DOCUMENTDATE = writer.CreateElement("DOCUMENTDATE");
DOCUMENTDATE.InnerText = DS.Tables[0].Rows[0][1].ToString();
Site_Date = DS.Tables[0].Rows[0][1].ToString();
HEADER.AppendChild(DOCUMENTDATE);
XmlElement POSGRNREFERENCENUMBER = writer.CreateElement("DOCUMENTNUMBER");
POSGRNREFERENCENUMBER.InnerText = DS.Tables[0].Rows[0][2].ToString();
HEADER.AppendChild(POSGRNREFERENCENUMBER);
XmlElement WAREHOUSENUMBER = writer.CreateElement("VENDORNAME");
WAREHOUSENUMBER.InnerText = DS.Tables[0].Rows[0][3].ToString();
HEADER.AppendChild(WAREHOUSENUMBER);
int RowsCount = DS.Tables[1].Rows.Count;
//Response.Write(RowsCount.ToString());
for (int i = 0; i <= RowsCount - 1; i++)
{
XmlElement ITEMDETAILS = writer.CreateElement("ITEMDETAILS");
CONDOLIDATEDSALES.AppendChild(ITEMDETAILS);
XmlElement ARTICLENUMBER = writer.CreateElement("ARTICLENUMBER");
ARTICLENUMBER.InnerText = DS.Tables[1].Rows[i][0].ToString().Trim();
ITEMDETAILS.AppendChild(ARTICLENUMBER);
XmlElement UNITOFMEASURE = writer.CreateElement("UNITOFMEASURE");
UNITOFMEASURE.InnerText = DS.Tables[1].Rows[i][1].ToString().Trim();
ITEMDETAILS.AppendChild(UNITOFMEASURE);
XmlElement INVOICEDQUANTITY = writer.CreateElement("AWACS_ITEMCODE");
INVOICEDQUANTITY.InnerText = DS.Tables[1].Rows[i][2].ToString().Trim();
ITEMDETAILS.AppendChild(INVOICEDQUANTITY);
XmlElement SALESVALUE = writer.CreateElement("INVOICEQUANTITY");
SALESVALUE.InnerText = DS.Tables[1].Rows[i][3].ToString().Trim();
ITEMDETAILS.AppendChild(SALESVALUE);
XmlElement TYPEOFCONDITION = writer.CreateElement("DELIVEREDQUANTITY");
TYPEOFCONDITION.InnerText = DS.Tables[1].Rows[i][4].ToString().Trim();
ITEMDETAILS.AppendChild(TYPEOFCONDITION);
XmlElement SALESDISCOUNTVALUE = writer.CreateElement("BATCH");
SALESDISCOUNTVALUE.InnerText = DS.Tables[1].Rows[i][5].ToString().Trim();
ITEMDETAILS.AppendChild(SALESDISCOUNTVALUE);
XmlElement TAXCODE = writer.CreateElement("EXPIRYDATE");
TAXCODE.InnerText = DS.Tables[1].Rows[i][6].ToString().Trim();
ITEMDETAILS.AppendChild(TAXCODE);
}
string Site_Folder_Path = Server.MapPath("~/FileServer/IB" + "/" + Site_Date).ToString();
if (Directory.Exists(Site_Folder_Path))
{
}
else
{
DirectoryInfo DI = Directory.CreateDirectory(Site_Folder_Path);
}
string Date_Folder_Path = Server.MapPath("~/FileServer/IB" + "/" + Site_Date + "/" + Site_Name).ToString();
if (Directory.Exists(Date_Folder_Path))
{
}
else
{
DirectoryInfo DI = Directory.CreateDirectory(Date_Folder_Path);
}
//string Consolidate_File_Path = Server.MapPath("~/FileServer/IB" + "/" + Site_Date + "/" + Site_Name + "/" + "eSales.xml").ToString();
//if (Directory.Exists(Consolidate_File_Path))
//{
//}
//else
//{
// DirectoryInfo DI = Directory.CreateDirectory(Consolidate_File_Path);
//}
writer.Save(Server.MapPath("~/FileServer/IB" + "/" + Site_Date + "/" + Site_Name + "/" + "PURCHASES_" + " " + j + ".xml"));
j++;
int retval = objbllmaster.CommonParamDeleteFile(objbomaster, "POS_GRAgainstLocalPurchases_FILEDELETE");
if (retval > 0)
{
}
}
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
// throw new Exception(ex.Message);
return false;
}
}
#endregion
0 comments:
Post a Comment