Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ROYcms.Sys.Model.ROYcms_Workflow model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + PubConstant.date_prefix + "Workflow(");
            strSql.Append("keyId,name,zhaiyao,Time)");
            strSql.Append(" values (");
            strSql.Append("@keyId,@name,@zhaiyao,@Time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@keyId",   SqlDbType.Int,    4),
                new SqlParameter("@name",    SqlDbType.NChar, 30),
                new SqlParameter("@zhaiyao", SqlDbType.NChar, 80),
                new SqlParameter("@Time",    SqlDbType.DateTime)
            };
            parameters[0].Value = model.keyId;
            parameters[1].Value = model.name;
            parameters[2].Value = model.zhaiyao;
            parameters[3].Value = model.Time;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ROYcms.Sys.Model.ROYcms_Workflow model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "Workflow set ");
            strSql.Append("keyId=@keyId,");
            strSql.Append("name=@name,");
            strSql.Append("zhaiyao=@zhaiyao,");
            strSql.Append("Time=@Time");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",      SqlDbType.Int,    4),
                new SqlParameter("@keyId",   SqlDbType.Int,    4),
                new SqlParameter("@name",    SqlDbType.NChar, 30),
                new SqlParameter("@zhaiyao", SqlDbType.NChar, 80),
                new SqlParameter("@Time",    SqlDbType.DateTime)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.keyId;
            parameters[2].Value = model.name;
            parameters[3].Value = model.zhaiyao;
            parameters[4].Value = model.Time;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_Workflow GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,keyId,name,zhaiyao,Time from " + PubConstant.date_prefix + "Workflow ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            ROYcms.Sys.Model.ROYcms_Workflow model = new ROYcms.Sys.Model.ROYcms_Workflow();
            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());
                }
                if (ds.Tables[0].Rows[0]["keyId"].ToString() != "")
                {
                    model.keyId = int.Parse(ds.Tables[0].Rows[0]["keyId"].ToString());
                }
                model.name    = ds.Tables[0].Rows[0]["name"].ToString();
                model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString();
                if (ds.Tables[0].Rows[0]["Time"].ToString() != "")
                {
                    model.Time = DateTime.Parse(ds.Tables[0].Rows[0]["Time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }