Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reading Data from XML

Reading Data from XML

Scheduled Pinned Locked Moved C#
designsysadminsecurityxmlhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nivasinfotech
    wrote on last edited by
    #1

    // ASCX file using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class PresentationLayer_Controls_ManagePaymentDetailsControl : System.Web.UI.UserControl { Payment ObjXMLData = new Payment(); public static int editstatus =0; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); // to avoid page refresh problem //string opno = "0p005"; //txtOpno.Text = opno; txtDate.Text = ObjXMLData.ConvertDate(DateTime.Today.Date.ToString().Substring(0, 10)); txtDate.Text = txtDate.Text.Substring(3, 2) + "/" + txtDate.Text.Substring(0, 2) + "/" + txtDate.Text.Substring(6, 4); try { //GetData(opno, Server.MapPath("Amount.xml").ToString()); BindGrid(); } catch (Exception ex) { lbl_Error.Text = ex.Message; } } } catch (Exception ex) { string s = ex.Message; } } public void GetData(string opno, string path,int estatus) { try { DataSet ds; DataTable dt = ObjXMLData.GetByOpNo(opno, path); if (dt.Columns.Count > 0) { if (estatus == 1) { txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString(); txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString(); txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString(); txtTotalAmount.Text = dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString(); txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString(); } else { txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString(); txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString(); //txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString(); //txtTot

    N P 2 Replies Last reply
    0
    • N nivasinfotech

      // ASCX file using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class PresentationLayer_Controls_ManagePaymentDetailsControl : System.Web.UI.UserControl { Payment ObjXMLData = new Payment(); public static int editstatus =0; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); // to avoid page refresh problem //string opno = "0p005"; //txtOpno.Text = opno; txtDate.Text = ObjXMLData.ConvertDate(DateTime.Today.Date.ToString().Substring(0, 10)); txtDate.Text = txtDate.Text.Substring(3, 2) + "/" + txtDate.Text.Substring(0, 2) + "/" + txtDate.Text.Substring(6, 4); try { //GetData(opno, Server.MapPath("Amount.xml").ToString()); BindGrid(); } catch (Exception ex) { lbl_Error.Text = ex.Message; } } } catch (Exception ex) { string s = ex.Message; } } public void GetData(string opno, string path,int estatus) { try { DataSet ds; DataTable dt = ObjXMLData.GetByOpNo(opno, path); if (dt.Columns.Count > 0) { if (estatus == 1) { txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString(); txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString(); txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString(); txtTotalAmount.Text = dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString(); txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString(); } else { txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString(); txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString(); //txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString(); //txtTot

      N Offline
      N Offline
      nivasinfotech
      wrote on last edited by
      #2

      using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; /// <summary> /// Summary description for Payment /// </summary> public class Payment { public Payment() { // // TODO: Add constructor logic here // } public DataTable GetAll(string Path) { DataTable dt = new DataTable(); DataSet ds = new DataSet(); ds.ReadXml(Path + ""); DataTable dt_ret = ds.Tables[0]; return dt_ret; } public DataTable GetByOpNo(string OpNo, string Path) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.ReadXml(Path); DataTable dt_ret = ds.Tables[0]; int b = 0; //INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of dt_ret.Rows.Count for every iteration: int tempFor1 = dt_ret.Rows.Count; for (b = 0; b < tempFor1; b++) { if (OpNo.ToString().ToUpper().ToString() == dt_ret.Rows[b]["OpNo"].ToString().ToUpper().ToString()) { DataRow dr = null; dt.Columns.Add("ID"); dt.Columns.Add("OpNo"); dt.Columns.Add("Date"); dt.Columns.Add("Name"); dt.Columns.Add("TotalAmount"); dt.Columns.Add("PaidAmount"); dt.Columns.Add("BalanceAmount"); dr = dt.NewRow(); dr["ID"] = dt_ret.Rows[b]["ID"]; dr["OpNo"] = dt_ret.Rows[b]["OpNo"].ToString().ToUpper(); dr["Date"] = dt_ret.Rows[b]["Date"]; dr["Name"] = dt_ret.Rows[b]["Name"]; dr["TotalAmount"] = dt_ret.Rows[b]["TotalAmount"]; dr["PaidAmount"] = dt_ret.Rows[b]["PaidAmount"]; dr["BalanceAmount"] = dt_ret.Rows[b]["BalanceAmount"]; dt.Rows.Add(dr); return dt; } } return dt; } public long Update(string OpNo, string Date, string Name, Double TotalAmount, Double PaidAmount, Double BalanceAmount, string Path) { try { DataSet ds = new DataSet(); ds.ReadXml(Path + "/Amount.xml");

      1 Reply Last reply
      0
      • N nivasinfotech

        // ASCX file using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class PresentationLayer_Controls_ManagePaymentDetailsControl : System.Web.UI.UserControl { Payment ObjXMLData = new Payment(); public static int editstatus =0; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); // to avoid page refresh problem //string opno = "0p005"; //txtOpno.Text = opno; txtDate.Text = ObjXMLData.ConvertDate(DateTime.Today.Date.ToString().Substring(0, 10)); txtDate.Text = txtDate.Text.Substring(3, 2) + "/" + txtDate.Text.Substring(0, 2) + "/" + txtDate.Text.Substring(6, 4); try { //GetData(opno, Server.MapPath("Amount.xml").ToString()); BindGrid(); } catch (Exception ex) { lbl_Error.Text = ex.Message; } } } catch (Exception ex) { string s = ex.Message; } } public void GetData(string opno, string path,int estatus) { try { DataSet ds; DataTable dt = ObjXMLData.GetByOpNo(opno, path); if (dt.Columns.Count > 0) { if (estatus == 1) { txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString(); txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString(); txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString(); txtTotalAmount.Text = dt.Rows[0].Table.Rows[0]["TotalAmount"].ToString(); txtBalanceAmount.Text = dt.Rows[0].Table.Rows[0]["BalanceAmount"].ToString(); } else { txtOpno.Text = dt.Rows[0].Table.Rows[0]["OpNo"].ToString(); txtName.Text = dt.Rows[0].Table.Rows[0]["Name"].ToString(); //txtPaidAmount.Text = dt.Rows[0].Table.Rows[0]["PaidAmount"].ToString(); //txtTot

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        And your question is what? Other than your inability to change the default name of any of the stuff you've dropped on your form, I can't actually see what you're trying to do unless you've mistaken CodeProject for SourceSafe.

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        L 1 Reply Last reply
        0
        • P Pete OHanlon

          And your question is what? Other than your inability to change the default name of any of the stuff you've dropped on your form, I can't actually see what you're trying to do unless you've mistaken CodeProject for SourceSafe.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          L Offline
          L Offline
          Le centriste
          wrote on last edited by
          #4

          Pete O'Hanlon wrote:

          unless you've mistaken CodeProject for SourceSafe

          :laugh:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups