Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(IPSP.Model.TCode_OtherTemplate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TCode_OtherTemplate(");
            strSql.Append("s_DisplayName,s_FileName,s_Type)");
            strSql.Append(" values (");
            strSql.Append("@s_DisplayName,@s_FileName,@s_Type)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_DisplayName", SqlDbType.NVarChar, 200),
                new SqlParameter("@s_FileName",    SqlDbType.NVarChar, 500),
                new SqlParameter("@s_Type",        SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.s_DisplayName;
            parameters[1].Value = model.s_FileName;
            parameters[2].Value = model.s_Type;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(IPSP.Model.TCode_OtherTemplate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TCode_OtherTemplate set ");
            strSql.Append("s_DisplayName=@s_DisplayName,");
            strSql.Append("s_FileName=@s_FileName,");
            strSql.Append("s_Type=@s_Type");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@s_DisplayName", SqlDbType.NVarChar, 200),
                new SqlParameter("@s_FileName",    SqlDbType.NVarChar, 500),
                new SqlParameter("@s_Type",        SqlDbType.NVarChar,  20),
                new SqlParameter("@n_ID",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.s_DisplayName;
            parameters[1].Value = model.s_FileName;
            parameters[2].Value = model.s_Type;
            parameters[3].Value = model.n_ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public IPSP.Model.TCode_OtherTemplate DataRowToModel(DataRow row)
 {
     IPSP.Model.TCode_OtherTemplate model = new IPSP.Model.TCode_OtherTemplate();
     if (row != null)
     {
         if (row["n_ID"] != null && row["n_ID"].ToString() != "")
         {
             model.n_ID = int.Parse(row["n_ID"].ToString());
         }
         if (row["s_DisplayName"] != null)
         {
             model.s_DisplayName = row["s_DisplayName"].ToString();
         }
         if (row["s_FileName"] != null)
         {
             model.s_FileName = row["s_FileName"].ToString();
         }
         if (row["s_Type"] != null)
         {
             model.s_Type = row["s_Type"].ToString();
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IPSP.Model.TCode_OtherTemplate GetModel(int n_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 n_ID,s_DisplayName,s_FileName,s_Type from TCode_OtherTemplate ");
            strSql.Append(" where n_ID=@n_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@n_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = n_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(IPSP.Model.TCode_OtherTemplate model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(IPSP.Model.TCode_OtherTemplate model)
 {
     return(dal.Add(model));
 }