我有一个按钮,需要添加3天到当前交易日期已在ArrayList
。需要添加3天到当前交易日期
如何做到这一点?
的代码如下:
private void btnCheckCleared_Click(object sender, EventArgs e)
{
foreach (Transaction item in tranArray)
{
if (What goes here?)
{
DateTime.Today.AddDays(3).ToLongDateString();
}
}
}
如果您需要更多的代码,请让我知道。
因此,这里是我的Transaction.cs代码:
namespace TEXT TEXT TEXT
{
public class Transaction
{
//data hiding (blackbox)
//visible only to class itself
//fields (variables)
//4 member variables (instantiate object)
private decimal decAmount;
private DateTime dteTransactionDate;
private string strCheckNumber;
private string strPayee;
private string strTypeTrans;
public bool CheckCleared;
public decimal Amount
{
get
{
return decAmount;
}
set
{
decAmount = value;
}
}
public string CheckNumber
{
get
{
return strCheckNumber;
}
set
{
strCheckNumber = value;
}
}
public string Payee
{
get
{
return strPayee;
}
set
{
strPayee = value;
}
}
public DateTime TransactionDate
{
get
{
return dteTransactionDate;
}
set
{
dteTransactionDate = value;
}
}
public TransactionType TypeTrans;
//constructor
public Transaction(string payee, decimal amount, TransactionType typeTrans, DateTime transactionDate)
{
this.Payee = payee; //assignment operator =
this.Amount = amount; //this is to qualify
this.TypeTrans = typeTrans;
this.TransactionDate = transactionDate;
}
public Transaction(string payee, decimal amount, TransactionType typeTrans, DateTime transactionDate, string checkNumber)
{
this.Payee = payee; //assignment operator =
this.Amount = amount; //this is to qualify
this.CheckNumber = checkNumber;
this.TypeTrans = typeTrans;
this.TransactionDate = transactionDate;
}
//public Transaction()
public override string ToString()
{
return this.TransactionDate.ToShortDateString() + " " + this.Amount.ToString("C") + "\t" + this.TypeTrans;
}
}
}
你的问题不清楚,你能解释一下吗? –
Transaction类是什么样的?它是否有修改的日期时间字段?我们为什么会知道你想要什么作为“如果”条件? –
那么,你正在使用一个事务,所以你的“如果”可能需要对事务类中的某些事情进行有条件的检查。因此,你的if将会是“if(item。[Property] == [value])。另外,你需要设置Transaction类的一些属性来更新它。你可能想要添加3天到所以:item。[DateProperty] = item。[DateProperty] .AddDays(3); – Aaron