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

            strSql.Append("update usertype set ");
            strSql.Append("tagname=@tagname,");
            strSql.Append("authvalue=@authvalue");
            strSql.Append(" where level=@level");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@tagname",   MySqlDbType.VarChar, 20),
                new MySqlParameter("@authvalue", MySqlDbType.Int16,    8),
                new MySqlParameter("@level",     MySqlDbType.Int16, 8)
            };
            parameters[0].Value = model.tagname;
            parameters[1].Value = model.authvalue;
            parameters[2].Value = model.level;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Jium.Model.usertype model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into usertype(");
            strSql.Append("tagname,authvalue)");
            strSql.Append(" values (");
            strSql.Append("@tagname,@authvalue)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@tagname",   MySqlDbType.VarChar, 20),
                new MySqlParameter("@authvalue", MySqlDbType.Int16, 8)
            };
            parameters[0].Value = model.tagname;
            parameters[1].Value = model.authvalue;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txttagname.Text.Trim().Length == 0)
            {
                strErr += "tagname不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtauthvalue.Text))
            {
                strErr += "authvalue格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string tagname   = this.txttagname.Text;
            int    level     = int.Parse(this.lbllevel.Text);
            int    authvalue = int.Parse(this.txtauthvalue.Text);


            Jium.Model.usertype model = new Jium.Model.usertype();
            model.tagname   = tagname;
            model.level     = level;
            model.authvalue = authvalue;

            Jium.BLL.usertype bll = new Jium.BLL.usertype();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Esempio n. 4
0
 private void ShowInfo(int level)
 {
     Jium.BLL.usertype   bll   = new Jium.BLL.usertype();
     Jium.Model.usertype model = bll.GetModel(level);
     this.lbltagname.Text   = model.tagname;
     this.lbllevel.Text     = model.level.ToString();
     this.lblauthvalue.Text = model.authvalue.ToString();
 }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Jium.Model.usertype DataRowToModel(DataRow row)
 {
     Jium.Model.usertype model = new Jium.Model.usertype();
     if (row != null)
     {
         if (row["tagname"] != null)
         {
             model.tagname = row["tagname"].ToString();
         }
         if (row["level"] != null && row["level"].ToString() != "")
         {
             model.level = int.Parse(row["level"].ToString());
         }
         if (row["authvalue"] != null && row["authvalue"].ToString() != "")
         {
             model.authvalue = int.Parse(row["authvalue"].ToString());
         }
     }
     return(model);
 }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Jium.Model.usertype GetModel(int level)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select tagname,level,authvalue from usertype ");
            strSql.Append(" where level=@level");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@level", MySqlDbType.Int16)
            };
            parameters[0].Value = level;

            Jium.Model.usertype model = new Jium.Model.usertype();
            DataSet             ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

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