private Payment SetNextInvoiceNumber(Payment payment) { try { long maximumSerialNo = _da.GetMaxValueBy <PAYMENT>(p => (long)p.Serial_Number); if (maximumSerialNo > 0) { maximumSerialNo = ++maximumSerialNo; } else { maximumSerialNo = 1; } payment.SerialNumber = maximumSerialNo; payment.InvoiceNumber = "OD" + DateTime.Now.ToString("yy") + SysUtil.PaddNumber(maximumSerialNo, 16); return(payment); } catch (Exception) { throw; } }