コード例 #1
0
        private string generateReceiptNum(ReceivingModel model)
        {
            var    currentDocument = service.GetAll(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId).OrderByDescending(rec => rec.Id).FirstOrDefault();
            string newDocNo        = "";

            if (currentDocument != null)
            {
                int  outVal;
                bool isNumeric = int.TryParse(currentDocument.ReceiptNo, out outVal);
                if (isNumeric && currentDocument.ReceiptNo.Length == 8)
                {
                    newDocNo = (int.Parse(currentDocument.ReceiptNo) + 1).ToString();
                    return(newDocNo);
                }
            }

            //Create New DocNum..
            string yearDigit  = model.Date.ToString("yy");
            string monthDigit = model.Date.ToString("MM");
            string docNo      = int.Parse("1").ToString().PadLeft(4, '0');

            return(yearDigit + monthDigit + docNo);
        }