/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.t_custom_search model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_custom_search(");
            strSql.Append("customId,name,pudate");
            strSql.Append(") values (");
            strSql.Append("@customId,@name,@pudate");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@customId", SqlDbType.NVarChar, 50),
                new SqlParameter("@name",     SqlDbType.NVarChar, 50),
                new SqlParameter("@pudate",   SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = model.customId;
            parameters[1].Value = model.name;
            parameters[2].Value = model.pudate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.t_custom_search GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, customId, name, pudate  ");
            strSql.Append("  from t_custom_search ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            System.Model.t_custom_search model = new System.Model.t_custom_search();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.customId = ds.Tables[0].Rows[0]["customId"].ToString();
                model.name     = ds.Tables[0].Rows[0]["name"].ToString();
                model.pudate   = ds.Tables[0].Rows[0]["pudate"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.t_custom_search model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_custom_search set ");

            strSql.Append(" customId = @customId , ");
            strSql.Append(" name = @name , ");
            strSql.Append(" pudate = @pudate  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.Int,       4),
                new SqlParameter("@customId", SqlDbType.NVarChar, 50),
                new SqlParameter("@name",     SqlDbType.NVarChar, 50),
                new SqlParameter("@pudate",   SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.customId;
            parameters[2].Value = model.name;
            parameters[3].Value = model.pudate;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.t_custom_search> DataTableToList(DataTable dt)
        {
            List <System.Model.t_custom_search> modelList = new List <System.Model.t_custom_search>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.t_custom_search model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.t_custom_search();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.customId = dt.Rows[n]["customId"].ToString();
                    model.name     = dt.Rows[n]["name"].ToString();
                    model.pudate   = dt.Rows[n]["pudate"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemple #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.t_custom_search model)
 {
     return(dal.Update(model));
 }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.t_custom_search model)
 {
     return(dal.Add(model));
 }