Reading Data from XML
-
// 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
-
// 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
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");
-
// 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
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.
-
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.
Pete O'Hanlon wrote:
unless you've mistaken CodeProject for SourceSafe
:laugh: