Exemplo n.º 1
0
        /// <summary>更新一条数据
        ///
        /// </summary>
        public bool Update(Nikita.Assist.DBManager.Model.Bse_ExcuteAnalyze model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Bse_ExcuteAnalyze set ");
            strSql.Append("ExcuteName=@ExcuteName, ExcuteSql=@ExcuteSql, ExcuteType=@ExcuteType, DbType=@DbType, Remark=@Remark, CreateDate=@CreateDate  ");
            strSql.Append(" where id=@id ");
            MSSQLHelper h = new MSSQLHelper(GlobalHelp.ConfigConn);

            h.CreateCommand(strSql.ToString());
            if (model.id == null)
            {
                h.AddParameter("@id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@id", model.id);
            }
            if (model.ExcuteName == null)
            {
                h.AddParameter("@ExcuteName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ExcuteName", model.ExcuteName);
            }
            if (model.ExcuteSql == null)
            {
                h.AddParameter("@ExcuteSql", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ExcuteSql", model.ExcuteSql);
            }
            if (model.ExcuteType == null)
            {
                h.AddParameter("@ExcuteType", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ExcuteType", model.ExcuteType);
            }
            if (model.DbType == null)
            {
                h.AddParameter("@DbType", DBNull.Value);
            }
            else
            {
                h.AddParameter("@DbType", model.DbType);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }

            return(h.ExecuteNonQuery());
        }
Exemplo n.º 2
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Assist.DBManager.Model.Bse_ExcuteAnalyze model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Bse_ExcuteAnalyze(");
            strSql.Append("ExcuteName, ExcuteSql, ExcuteType, DbType, Remark, CreateDate  )");
            strSql.Append(" values (");
            strSql.Append("@ExcuteName, @ExcuteSql, @ExcuteType, @DbType, @Remark, @CreateDate  )");
            strSql.Append(";select @@IDENTITY");
            MSSQLHelper h = new MSSQLHelper(GlobalHelp.ConfigConn);

            h.CreateCommand(strSql.ToString());
            if (model.ExcuteName == null)
            {
                h.AddParameter("@ExcuteName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ExcuteName", model.ExcuteName);
            }
            if (model.ExcuteSql == null)
            {
                h.AddParameter("@ExcuteSql", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ExcuteSql", model.ExcuteSql);
            }
            if (model.ExcuteType == null)
            {
                h.AddParameter("@ExcuteType", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ExcuteType", model.ExcuteType);
            }
            if (model.DbType == null)
            {
                h.AddParameter("@DbType", DBNull.Value);
            }
            else
            {
                h.AddParameter("@DbType", model.DbType);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }

            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }