Beispiel #1
0
 public CardIdentity generateLastPartCardNumber()
 {
     try
     {
         var obj = new CardIdentity();
         db.TCARD_ID.Add(obj);
         db.SaveChanges();
         return(obj);
     }
     catch
     {
         return(null);
     }
 }
Beispiel #2
0
        //public string generateCardLastPartNumber(string ctryCD)
        //{
        //    var getCardList = db.TCARD.Where(x => x.CARD_CTRY_CD == ctryCD).ToList();
        //    int currentLength = getCardList.Count();
        //    if (currentLength != 0)
        //    {
        //        int lastPart = 153796 + currentLength;
        //        string strlastPart = lastPart.ToString();
        //        if (strlastPart.Length == 6) { return "00" + strlastPart; }
        //        else if (strlastPart.Length == 7) { return "0" + strlastPart; }
        //        else { return strlastPart; }
        //    }
        //    else { return "00153796"; } //00153713
        //}

        public string generateCardLastPartNumber()
        {
            var newCardIdent = new CardIdentity();
            var cardIdent    = newCardIdent.generateLastPartCardNumber();

            if (cardIdent != null)
            {
                string lastPartNbr;
                if (cardIdent.CARD_ID <= 999999)
                {
                    lastPartNbr = "00" + Convert.ToString(cardIdent.CARD_ID);
                    return(lastPartNbr);
                }
                else if (cardIdent.CARD_ID <= 9999999)
                {
                    lastPartNbr = "0" + Convert.ToString(cardIdent.CARD_ID);
                    return(lastPartNbr);
                }
                lastPartNbr = Convert.ToString(cardIdent.CARD_ID);
                return(lastPartNbr);
            }
            return(null);
        }