public bool InsertGtin(Gtin newGtin)
        {
            int rowsAffected = this._db.Execute(@"INSERT gtin([gtin_cd],[gtin_nm]) values (@Gtin_CD, @Gtin_NM)", new { Gtin_CD = newGtin.GTIN_CD, Gtin_NM = newGtin.GTIN_NM });

            if (rowsAffected > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// GTIN 分解成 CompanyPrefix 和 ItemReference
        /// </summary>
        private void Identify()
        {
            #region

            /*
             * switch (this.Partition)
             * {
             *  case "5":
             *      var indicatorDigit = this.Gtin.First().ToString();
             *      CompanyPrefix = Gtin.Substring(1, 7);
             *      ItemReference = indicatorDigit + Gtin.Substring(8, 13);
             *      break;
             *  case "0":
             *  case "1":
             *  case "2":
             *  case "3":
             *  case "4":
             *  case "6":
             *  default:
             *      CompanyPrefix = string.Empty;
             *      ItemReference = string.Empty;
             *      break;
             * }
             * */
            #endregion

            Partitiion _partition;
            if (PartitionTable.TryGetValue(this.Partition, out _partition))
            {
                var indicatorDigit = this.Gtin.First().ToString();
                CompanyPrefix = Gtin.Substring(1, _partition.CompanyPrefixDigits);
                ItemReference = indicatorDigit + Gtin.Substring((_partition.CompanyPrefixDigits + 1), _partition.ItemReferenceDigits - 1);
            }
            else
            {
                CompanyPrefix = string.Empty;
                ItemReference = string.Empty;
            }
        }
 public bool UpdateGtin(Gtin gtin)
 {
     throw new NotImplementedException();
 }