2,743
edits
mNo edit summary |
No edit summary |
||
Line 15:
BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc = cmd.AddNew();
if (IsValidDepositMethod(source.DepositMethod, dbSetting))
doc.DocNo = source.DocumentNo;▼
{
doc.DepositPaymentMethod = source.DepositMethod;
}
else
{
BCE.Application.AppMessage.ShowErrorMessage(string.Format("Invalid Deposit Payment Method of \"{0}\"", source.DepositMethod));
//log error on Deposit Payment Method error
return;
}
▲ doc.DocNo = source.DocumentNo ?? doc.DocNo;
doc.DocDate = source.DocumentDate;
doc.Description = source.Description ?? doc.Description;
doc.
doc.DebtorCode = source.CustomerAccount;
doc.DebtorName = source.CustomerName;
Line 34 ⟶ 44:
doc.Save();
BCE.Application.AppMessage.ShowMessage(string.Format("{0} is Created.", doc.DocNo));
//Log Success created
}
catch (BCE.Application.AppException ex)
{
BCE.Application.AppMessage.ShowErrorMessage(ex.Message);
//Log Error saving
}
}
Line 65 ⟶ 77:
</syntaxhighlight>
====
<syntaxhighlight lang="csharp">
private bool IsValidDepositMethod(string depositMethod, BCE.Data.DBSetting dbSetting)
{
return GetDepositPaymentMethod(dbSetting).AsEnumerable()
.Count(r => r.Field<string>("PaymentMethod") == depositMethod) > 0;
}
</syntaxhighlight>
====Get Deposit Payment Method Table with AutoCount Lookup Edit Builder====
<syntaxhighlight lang="csharp">
Line 72 ⟶ 93:
BCE.AutoCount.XtraUtils.LookupEditBuilder.DepositPaymentMethodLookupEditBuilder depositBuilder =
new BCE.AutoCount.XtraUtils.LookupEditBuilder.DepositPaymentMethodLookupEditBuilder();
//The return table contains of 3 columns: (1) PaymentMethod, (2) BankAccount, (3) CurrencyCode (in version 1.8.28.184)
return depositBuilder.BuildDataTable(dbSetting);
}
</syntaxhighlight>
Line 124 ⟶ 143:
</syntaxhighlight>
===Implementation===
[[File:ProgrammerNewARDeposit1.PNG|link=]]
[[File:ProgrammerNewARDeposit2.PNG|link=]]
<syntaxhighlight lang="csharp">
public void MainEntry(BCE.Data.DBSetting dbSetting)
{
//Example of deposit without DebtorCode defined
ARDepositSource newDoc = new ARDepositSource()
{
//DEPOSIT RECEIVED must be a Payment Method created for Deposit Account
DepositMethod = "DEPOSIT RECEIVED",
Description = "DEPOSIT",
DocumentDate = new DateTime(2017, 11, 25)
};
newDoc.Detail.Add(new ARDepositDetailSource()
{
PaymentMethod = "BANK",
ChequeNo = "CHQ00010",
PaymentBy = "CHEQUE",
DepositAmount = 500
});
NewARDeposit(newDoc, dbSetting);
//Example of deposit with Debtor Code
newDoc = new ARDepositSource()
{
//DEPOSIT RECEIVED must be a Payment Method created for Deposit Account
DepositMethod = "DEPOSIT RECEIVED",
CustomerAccount = "300-A001",
Description = "DEPOSIT",
DocumentDate = new DateTime(2017, 11, 26),
Attention = "MR.Tan"
};
newDoc.Detail.Add(new ARDepositDetailSource()
{
PaymentMethod = "BANK",
ChequeNo = "CHQ00010",
PaymentBy = "CHEQUE",
DepositAmount = 800
});
NewARDeposit(newDoc, dbSetting);
}
</syntaxhighlight>
==See Also==
|