Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.Notice_attach model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Notice_attach set ");

            strSql.Append(" Notice_id = @Notice_id , ");
            strSql.Append(" Notice_attach_name = @Notice_attach_name , ");
            strSql.Append(" Notice_attach_address = @Notice_attach_address  ");
            strSql.Append(" where Notice_attach_id=@Notice_attach_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Notice_attach_id",      SqlDbType.BigInt,    8),
                new SqlParameter("@Notice_id",             SqlDbType.BigInt,    8),
                new SqlParameter("@Notice_attach_name",    SqlDbType.VarChar, 128),
                new SqlParameter("@Notice_attach_address", SqlDbType.VarChar, 256)
            };

            parameters[0].Value = model.Notice_attach_id;
            parameters[1].Value = model.Notice_id;
            parameters[2].Value = model.Notice_attach_name;
            parameters[3].Value = model.Notice_attach_address;
            int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Notice_attach GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Notice_attach_id, Notice_id, Notice_attach_name, Notice_attach_address  ");
            strSql.Append("  from Notice_attach ");
            strSql.Append(" where " + strWhere);


            university.Model.CCOM.Notice_attach model = new university.Model.CCOM.Notice_attach();
            DataSet ds = DBSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Notice_attach_id"].ToString() != "")
                {
                    model.Notice_attach_id = long.Parse(ds.Tables[0].Rows[0]["Notice_attach_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Notice_id"].ToString() != "")
                {
                    model.Notice_id = long.Parse(ds.Tables[0].Rows[0]["Notice_id"].ToString());
                }
                model.Notice_attach_name    = ds.Tables[0].Rows[0]["Notice_attach_name"].ToString();
                model.Notice_attach_address = ds.Tables[0].Rows[0]["Notice_attach_address"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(university.Model.CCOM.Notice_attach model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Notice_attach(");
            strSql.Append("Notice_id,Notice_attach_name,Notice_attach_address");
            strSql.Append(") values (");
            strSql.Append("@Notice_id,@Notice_attach_name,@Notice_attach_address");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Notice_id",             SqlDbType.BigInt,    8),
                new SqlParameter("@Notice_attach_name",    SqlDbType.VarChar, 128),
                new SqlParameter("@Notice_attach_address", SqlDbType.VarChar, 256)
            };

            parameters[0].Value = model.Notice_id;
            parameters[1].Value = model.Notice_attach_name;
            parameters[2].Value = model.Notice_attach_address;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Notice_attach GetModel(long Notice_attach_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Notice_attach_id, Notice_id, Notice_attach_name, Notice_attach_address  ");
            strSql.Append("  from Notice_attach ");
            strSql.Append(" where Notice_attach_id=@Notice_attach_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Notice_attach_id", SqlDbType.BigInt)
            };
            parameters[0].Value = Notice_attach_id;


            university.Model.CCOM.Notice_attach model = new university.Model.CCOM.Notice_attach();
            DataSet ds = DBSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Notice_attach_id"].ToString() != "")
                {
                    model.Notice_attach_id = long.Parse(ds.Tables[0].Rows[0]["Notice_attach_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Notice_id"].ToString() != "")
                {
                    model.Notice_id = long.Parse(ds.Tables[0].Rows[0]["Notice_id"].ToString());
                }
                model.Notice_attach_name    = ds.Tables[0].Rows[0]["Notice_attach_name"].ToString();
                model.Notice_attach_address = ds.Tables[0].Rows[0]["Notice_attach_address"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }