using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Text.RegularExpressions;
string strFileName = "";
strFileName = DateTime.Now.ToBinary().ToString() + "_" + System.IO.Path.GetFileName(fupXMLUpload.PostedFile.FileName);
string SaveLocation = Server.MapPath("XMLFiles") + "\\" + strFileName;
fupXMLUpload.PostedFile.SaveAs(SaveLocation);
XmlTextReader reader = new XmlTextReader(SaveLocation);
reader.WhitespaceHandling = WhitespaceHandling.None;
XmlDocument xmlDoc = new XmlDocument();
//Load the file into the XmlDocument
xmlDoc.Load(reader);
//Close off the connection to the file.
reader.Close();
string strXMLDoc = xmlDoc.InnerXml.ToString();
XmlNode xnod = xmlDoc.DocumentElement;
XmlNodeList objXmlNodeList = xmlDoc.GetElementsByTagName("VCHLEDNARREXPLOSION");
Regex regDate = new Regex("<DSPVCHDATE>([^<]*)</DSPVCHDATE>");
MatchCollection oMCDate = regDate.Matches(strXMLDoc);
Regex regAmount = new Regex("<DSPVCHCRAMT>([^<]*)</DSPVCHCRAMT>");
MatchCollection oMCAmount = regAmount.Matches(strXMLDoc);
Regex regNameBatchInfo = new Regex("<VCHLEDNARREXPLOSION>([^,]*),\\s*[^,]*,\\s*[^;]*;([^\\s]*)\\s*[^<]*</VCHLEDNARREXPLOSION>");
MatchCollection oMCNameBatchInfo = regNameBatchInfo.Matches(strXMLDoc);
string strDate = string.Empty;
int intDateIndex = 0;
string strAmount = string.Empty;
int intAmountIndex = 0;
string strName = string.Empty;
string strBatchNo = string.Empty;
int intNameBatchIndex = 0;
string[] strArrDate;
//for (int j = 0; j < objXmlNodeList.Count; j++)
for (int j = 0; j < oMCNameBatchInfo.Count; j++)
{
strDate = oMCDate[intDateIndex].Groups[1].Value;
strArrDate = strDate.Split('-');
oCATDDR.CatDtl_DateOfJoining = Convert.ToDateTime(strArrDate[1] + "-" + strArrDate[0] + "-" + strArrDate[2]);
intDateIndex = intDateIndex + 2;
strAmount = oMCAmount[intAmountIndex].Groups[1].Value;
oCATDDR.CatDtl_Fees = Convert.ToDecimal(strAmount);
//intAmountIndex = intAmountIndex + 2;
intAmountIndex = intAmountIndex + 1;
strName = oMCNameBatchInfo[intNameBatchIndex].Groups[1].Value;
//if ("RAVI BHADRESA" == strName)
//{
// string strHello = "";
//}
strBatchNo = oMCNameBatchInfo[intNameBatchIndex].Groups[2].Value;
oCATDDR.CatDtl_StudentName = strName;
oCATDDR.CatDtl_BatchNo = strBatchNo;
intNameBatchIndex = intNameBatchIndex + 1;
if (oCATDetail_CDO.CATDtl_Insert(oCATDDR))
{
fnMessage(true, "Record Inserted Successfully.");
}
else
{
fnMessage(true, "Record Record already Exist.");
}
}
No comments:
Post a Comment