Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(YJUI.Model.ui_menu model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ui_menu set ");
            strSql.Append("menuorder=@menuorder,");
            strSql.Append("fatherid=@fatherid,");
            strSql.Append("menuname=@menuname,");
            strSql.Append("icon=@icon,");
            strSql.Append("url=@url,");
            strSql.Append("crdate=@crdate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@menuorder", SqlDbType.Int,         4),
                new SqlParameter("@fatherid",  SqlDbType.Int,         4),
                new SqlParameter("@menuname",  SqlDbType.NVarChar,   50),
                new SqlParameter("@icon",      SqlDbType.NVarChar,   50),
                new SqlParameter("@url",       SqlDbType.NVarChar,  200),
                new SqlParameter("@crdate",    SqlDbType.DateTime),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.menuorder;
            parameters[1].Value = model.fatherid;
            parameters[2].Value = model.menuname;
            parameters[3].Value = model.icon;
            parameters[4].Value = model.url;
            parameters[5].Value = model.crdate;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public YJUI.Model.ui_menu DataRowToModel(DataRow row)
 {
     YJUI.Model.ui_menu model = new YJUI.Model.ui_menu();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["menuorder"] != null && row["menuorder"].ToString() != "")
         {
             model.menuorder = int.Parse(row["menuorder"].ToString());
         }
         if (row["fatherid"] != null && row["fatherid"].ToString() != "")
         {
             model.fatherid = int.Parse(row["fatherid"].ToString());
         }
         if (row["menuname"] != null)
         {
             model.menuname = row["menuname"].ToString();
         }
         if (row["icon"] != null)
         {
             model.icon = row["icon"].ToString();
         }
         if (row["url"] != null)
         {
             model.url = row["url"].ToString();
         }
         if (row["crdate"] != null && row["crdate"].ToString() != "")
         {
             model.crdate = DateTime.Parse(row["crdate"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(YJUI.Model.ui_menu model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ui_menu(");
            strSql.Append("menuorder,fatherid,menuname,icon,url,crdate)");
            strSql.Append(" values (");
            strSql.Append("@menuorder,@fatherid,@menuname,@icon,@url,@crdate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@menuorder", SqlDbType.Int,        4),
                new SqlParameter("@fatherid",  SqlDbType.Int,        4),
                new SqlParameter("@menuname",  SqlDbType.NVarChar,  50),
                new SqlParameter("@icon",      SqlDbType.NVarChar,  50),
                new SqlParameter("@url",       SqlDbType.NVarChar, 200),
                new SqlParameter("@crdate",    SqlDbType.DateTime)
            };
            parameters[0].Value = model.menuorder;
            parameters[1].Value = model.fatherid;
            parameters[2].Value = model.menuname;
            parameters[3].Value = model.icon;
            parameters[4].Value = model.url;
            parameters[5].Value = model.crdate;

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

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

            strSql.Append("select  top 1 id,menuorder,fatherid,menuname,icon,url,crdate from ui_menu ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }