我有一個按鈕,需要添加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