There are times when we need to increase a number in database record by one or any other specific number.
the way is to retrieve the old value of the database record, add desired numbers and save it back
vappDataContext db = new vappDataContext();
Voucher voucher = new Voucher();
VoucherRep voucherRep = new VoucherRep();
var oldVno = (from lstInv in db.Vouchers where lstInv.VoucherPrefix == "CPV" select lstInv.VoucherNo).Max();
var newVno = (Int32.Parse(oldVno) + 1).ToString();
voucher.VoucherNo = newVno;
voucherRep.Add(voucher);
voucherRep.Save();
No comments:
Post a Comment