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

            strSql.Append("update ui_guzhang set ");
            strSql.Append("guzhang=@guzhang,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@guzhang", SqlDbType.NVarChar, 100),
                new SqlParameter("@remark",  SqlDbType.NVarChar,  50),
                new SqlParameter("@id",      SqlDbType.Int,        4),
                new SqlParameter("@typeid",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.guzhang;
            parameters[1].Value = model.remark;
            parameters[2].Value = model.id;
            parameters[3].Value = model.typeid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(YJUI.Model.ui_guzhang model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ui_guzhang(");
            strSql.Append("typeid,guzhang,remark)");
            strSql.Append(" values (");
            strSql.Append("@typeid,@guzhang,@remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeid",  SqlDbType.Int,        4),
                new SqlParameter("@guzhang", SqlDbType.NVarChar, 100),
                new SqlParameter("@remark",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.typeid;
            parameters[1].Value = model.guzhang;
            parameters[2].Value = model.remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public YJUI.Model.ui_guzhang DataRowToModel(DataRow row)
 {
     YJUI.Model.ui_guzhang model = new YJUI.Model.ui_guzhang();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["typeid"] != null && row["typeid"].ToString() != "")
         {
             model.typeid = int.Parse(row["typeid"].ToString());
         }
         if (row["guzhang"] != null)
         {
             model.guzhang = row["guzhang"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public YJUI.Model.ui_guzhang GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,typeid,guzhang,remark from ui_guzhang ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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