Click here to Skip to main content
15,909,835 members
Home / Discussions / C#
   

C#

 
GeneralC# Library needed Pin
Knowledgestudent20-Feb-08 22:44
Knowledgestudent20-Feb-08 22:44 
GeneralRe: C# Library needed Pin
Pete O'Hanlon21-Feb-08 3:02
mvePete O'Hanlon21-Feb-08 3:02 
GeneralRe: C# Library needed Pin
Knowledgestudent21-Feb-08 9:06
Knowledgestudent21-Feb-08 9:06 
GeneralRe: C# Library needed Pin
Pete O'Hanlon21-Feb-08 9:12
mvePete O'Hanlon21-Feb-08 9:12 
GeneralFocus+Validation Summary Pin
razanabanu20-Feb-08 21:03
razanabanu20-Feb-08 21:03 
GeneralRe: Focus+Validation Summary Pin
phannon8620-Feb-08 21:58
professionalphannon8620-Feb-08 21:58 
GeneralReading Data from XML Pin
nivasinfotech20-Feb-08 20:20
nivasinfotech20-Feb-08 20:20 
GeneralRe: Reading Data from XML Pin
nivasinfotech20-Feb-08 20:22
nivasinfotech20-Feb-08 20:22 
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");
DataRow dr = null;
dr = ds.Tables[0].NewRow();
int a = 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 ds.Tables(0).Rows.Count for every iteration:
int tempFor1 = ds.Tables[0].Rows.Count;
string s = "";
for (b = 0; b < tempFor1; b++)
{
if (OpNo.ToString().ToUpper() == ds.Tables[0].Rows[b]["OpNo"].ToString().ToUpper())
{
s = "abc"; a = b;
}
}
//for (b = 0; b < tempFor1; b++)
//{
if (s.ToString() == "abc")
{
if (OpNo.ToString().ToUpper().ToString() == ds.Tables[0].Rows[a]["OpNo"].ToString().ToUpper().ToString())
{
ds.Tables[0].Rows[a]["OpNo"] = OpNo.ToUpper();
ds.Tables[0].Rows[a]["Date"] = Date;
ds.Tables[0].Rows[a]["Name"] = Name;
ds.Tables[0].Rows[a]["TotalAmount"] = TotalAmount;
ds.Tables[0].Rows[a]["PaidAmount"] = PaidAmount;
ds.Tables[0].Rows[a]["BalanceAmount"] = BalanceAmount;
ds.WriteXml(Path + "/Amount.xml");
}
}
else
{
try
{
dr = ds.Tables[0].NewRow();
if (ds.Tables[0].Rows.Count > 0)
{
dr["ID"] = System.Convert.ToInt64(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["id"]) + 1;
}
else
{
dr["ID"] = 1;
}
dr["OpNo"] = OpNo.ToUpper();
dr["Date"] = Date;
dr["Name"] = Name;
dr["TotalAmount"] = TotalAmount;
dr["PaidAmount"] = PaidAmount;
dr["BalanceAmount"] = BalanceAmount;
ds.Tables[0].Rows.Add(dr);
ds.WriteXml(Path + "/Amount.xml");
return 1;
}
catch (Exception ex)
{
return 0;
}
}
//}
return 1;
}
catch (Exception ex)
{
return 0;
}
}
//*****************************************************************************
//*************** Converting mm/dd/yyyy
//*****************************************************************************
public string ConvertDate(string s)
{
string p = "";
string[] dttime = s.ToString().Split('/');
for (int i = 0; i < dttime.Length; i++)
{
if (i == 0)
{
if (int.Parse(dttime[i].ToString()) < 10)
p = "0" + int.Parse(dttime[i].ToString());
else
p = dttime[i].ToString();
}
else if (i == 1)
{
if (int.Parse(dttime[i].ToString()) < 10)
p += "/" + "0" + int.Parse(dttime[i].ToString());
else
p += "/" + int.Parse(dttime[i].ToString());
}
else if (i == 2)
p += "/" + dttime[i].ToString();
}
return p;
}

}

srinivas

GeneralRe: Reading Data from XML Pin
Pete O'Hanlon21-Feb-08 0:56
mvePete O'Hanlon21-Feb-08 0:56 
GeneralRe: Reading Data from XML Pin
Le centriste21-Feb-08 6:20
Le centriste21-Feb-08 6:20 
GeneralScolling two listviews simeltaniously Pin
DnyanAnand20-Feb-08 19:35
professionalDnyanAnand20-Feb-08 19:35 
GeneralRe: Scolling two listviews simeltaniously Pin
Christian Graus20-Feb-08 20:14
protectorChristian Graus20-Feb-08 20:14 
GeneralRe: Scolling two listviews simeltaniously Pin
DnyanAnand20-Feb-08 20:36
professionalDnyanAnand20-Feb-08 20:36 
QuestionHelp Required in File Operations. Pin
deepaks320-Feb-08 18:47
deepaks320-Feb-08 18:47 
GeneralRe: Help Required in File Operations. Pin
Christian Graus20-Feb-08 20:06
protectorChristian Graus20-Feb-08 20:06 
GeneralRe: Help Required in File Operations. Pin
Vikram A Punathambekar20-Feb-08 21:26
Vikram A Punathambekar20-Feb-08 21:26 
GeneralRe: Help Required in File Operations. Pin
Guffa20-Feb-08 22:46
Guffa20-Feb-08 22:46 
GeneralDownloading files from FTP using C#.Net 1.1 Pin
pavya_Cool20-Feb-08 18:44
pavya_Cool20-Feb-08 18:44 
GeneralRe: Downloading files from FTP using C#.Net 1.1 Pin
N a v a n e e t h20-Feb-08 19:54
N a v a n e e t h20-Feb-08 19:54 
Questionfrozen column in Listview ? Pin
Xmen Real 20-Feb-08 18:26
professional Xmen Real 20-Feb-08 18:26 
AnswerRe: frozen column in Listview ? Pin
Dave Kreskowiak21-Feb-08 5:10
mveDave Kreskowiak21-Feb-08 5:10 
Generalwhy use | instead of || and same with & and && Pin
Xmen Real 20-Feb-08 18:06
professional Xmen Real 20-Feb-08 18:06 
GeneralRe: why use | instead of || and same with & and && Pin
mav.northwind20-Feb-08 19:27
mav.northwind20-Feb-08 19:27 
GeneralRe: why use | instead of || and same with & and && Pin
darkelv20-Feb-08 19:34
darkelv20-Feb-08 19:34 
GeneralRe: why use | instead of || and same with & and && Pin
Xmen Real 21-Feb-08 2:50
professional Xmen Real 21-Feb-08 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.