Ejemplo n.º 1
0
 /// <summary>
 /// 判断名称是否存在
 /// </summary>
 /// <param name="">信息</param>
 /// <returns>true:已存在;fasel:不存在。</returns>
 public bool ExistsMaterial(SupplyMaterialInfo model)
 {
     try
     {
         return(new SupplyInfoDAL().ExistsMaterial(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断名称是否存在
        /// </summary>
        /// <param name="info"></param>
        /// <returns>true:已存在;fasel:不存在。</returns>
        public bool ExistsMaterial(SupplyMaterialInfo model)
        {
            StringBuilder        sqlBuilder   = new StringBuilder();
            StringBuilder        whereBuilder = new StringBuilder();
            List <DataParameter> parameters   = new List <DataParameter>();
            int count = 0;

            try
            {
                sqlBuilder.Append("SELECT COUNT(0) FROM T_FP_SUPPLYMATERIALINFO");
                whereBuilder.Append(" AND PID <> @PID ");
                parameters.Add(new DataParameter {
                    ParameterName = "PID", DataType = DbType.String, Value = model.PID
                });
                if (!string.IsNullOrEmpty(model.MATRIALID))
                {
                    whereBuilder.Append(" AND MATRIALID = @MATRIALID ");
                    parameters.Add(new DataParameter {
                        ParameterName = "MATRIALID", DataType = DbType.String, Value = model.MATRIALID
                    });
                }
                if (whereBuilder.Length > 0)
                {
                    sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
                }
                using (IDataSession session = AppDataFactory.CreateMainSession())
                {
                    count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), parameters.ToArray()));
                }
                return(count > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }