Exemplo n.º 1
0
 /// <summary>
 /// 唯一码是否存在
 /// </summary>
 /// <param name="uniqueCode">唯一码</param>
 /// <param name="tableName"表名</param>
 /// <returns></returns>
 public bool IsExistsUniqueCode(string uniqueCode, string tableName, string oid = "")
 {
     lock (lockObj)
     {
         try
         {
             int           count      = 0;
             StringBuilder queryStrbd = new StringBuilder();
             queryStrbd.Append("select count(1) from ")
             .Append(tableName)
             .Append(" where UniqueCode='")
             .Append(uniqueCode)
             .Append("'");
             if (!string.IsNullOrEmpty(oid))
             {
                 queryStrbd.Append(" and Oid!=").Append(oid);
             }
             var countobj = new SQLiteHelper().ExecuteScalar(queryStrbd.ToString());
             count = Int32.TryParse(countobj.ToString(), out count) ? count : 0;
             return(count > 0);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取总记录数
        /// </summary>
        /// <param name="countSelectStr"></param>
        /// <returns></returns>
        public virtual int TotalCount(string countSelectStr)
        {
            int count   = 0;
            var countdt = new SQLiteHelper().ExecuteScalar(countSelectStr);

            count = Int32.TryParse(countdt.ToString(), out count) ? count : 0;
            return(count);
        }
Exemplo n.º 3
0
 public string UploadItemCodeAndSNList(ItemCodeSN_UploadDTO value)
 {
     if (value == null || value.SNList == null || value.SNList.Count <= 0)
     {
         return("SN List is null !");
     }
     if (string.IsNullOrEmpty(value.RoNumber))
     {
         return("RoNumber is null !");
     }
     if (string.IsNullOrEmpty(value.ItemCode))
     {
         return("Raw Material Label isn't scanned !");
     }
     try
     {
         string roNumber             = value.RoNumber;
         string itemCode             = value.ItemCode;
         string itemName             = string.Empty;
         string finishedProductNum   = value.FinishedProductNum;
         List <ItemCodeSNDTO> snList = value.SNList;
         #region 查询原材料备案
         StringBuilder rawMaterialReaderStrbd = new StringBuilder();
         rawMaterialReaderStrbd.Append(@"select m.Code from Material m where m.Name = @Name ");
         SQLiteParameter[] readParameter     = { SQLiteHelper.MakeSQLiteParameter("@Name", DbType.String, itemCode) };
         object            rawMaterialObject = new SQLiteHelper().ExecuteScalar(rawMaterialReaderStrbd.ToString(), readParameter);
         if (rawMaterialObject == null)
         {
             return("Raw Material Name is empty !");
         }
         itemName = rawMaterialObject.ToString();
         #endregion
         #region 插入原材料SN列表
         StringBuilder noQueryStrbd = new StringBuilder();
         noQueryStrbd.Append(@"insert into ItemCodeSN (ItemCode,ItemName,FinishedProductNum,SerivalNum,RoNumber) ")
         .Append(@"values ( ")
         .Append(@"@ItemCode,@ItemName,@FinishedProductNum,@SerivalNum,@RoNumber ")
         .Append(@") ");
         List <SQLiteParameter[]> paramList = new List <SQLiteParameter[]>();
         foreach (var dto in snList)
         {
             SQLiteParameter[] parameter =
             {
                 SQLiteHelper.MakeSQLiteParameter("@ItemCode",           DbType.String, dto.ItemCode),
                 SQLiteHelper.MakeSQLiteParameter("@ItemName",           DbType.String, itemName),
                 SQLiteHelper.MakeSQLiteParameter("@FinishedProductNum", DbType.String, finishedProductNum),
                 SQLiteHelper.MakeSQLiteParameter("@SerivalNum",         DbType.String, dto.SerivalNum),
                 SQLiteHelper.MakeSQLiteParameter("@RoNumber",           DbType.String, roNumber)
             };
             paramList.Add(parameter);
         }
         new SQLiteHelper().ExecuteNonQueryBatch(noQueryStrbd.ToString(), paramList);
         #endregion
         return(string.Empty);
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog("UploadItemCodeAndSNList", ex);
         return(ex.Message);
     }
 }