Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtid.Text))
            {
                strErr += "id格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtuserid.Text))
            {
                strErr += "userid格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int id     = int.Parse(this.txtid.Text);
            int userid = int.Parse(this.txtuserid.Text);

            ncu.mao.Model.user_roles model = new ncu.mao.Model.user_roles();
            model.id     = id;
            model.userid = userid;

            ncu.mao.BLL.user_roles bll = new ncu.mao.BLL.user_roles();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ncu.mao.Model.user_roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update user_roles set ");
            strSql.Append("userid=@userid");
            strSql.Append(" where rolesid=@rolesid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userid",  SqlDbType.Int, 4),
                new SqlParameter("@id",      SqlDbType.Int, 4),
                new SqlParameter("@rolesid", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.userid;
            parameters[1].Value = model.id;
            parameters[2].Value = model.rolesid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ncu.mao.Model.user_roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into user_roles(");
            strSql.Append("id,userid)");
            strSql.Append(" values (");
            strSql.Append("@id,@userid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",     SqlDbType.Int, 4),
                new SqlParameter("@userid", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.userid;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
 private void ShowInfo(int rolesid)
 {
     ncu.mao.BLL.user_roles   bll   = new ncu.mao.BLL.user_roles();
     ncu.mao.Model.user_roles model = bll.GetModel(rolesid);
     this.lblid.Text      = model.id.ToString();
     this.lbluserid.Text  = model.userid.ToString();
     this.lblrolesid.Text = model.rolesid.ToString();
 }
Exemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ncu.mao.Model.user_roles DataRowToModel(DataRow row)
 {
     ncu.mao.Model.user_roles model = new ncu.mao.Model.user_roles();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["userid"] != null && row["userid"].ToString() != "")
         {
             model.userid = int.Parse(row["userid"].ToString());
         }
         if (row["rolesid"] != null && row["rolesid"].ToString() != "")
         {
             model.rolesid = int.Parse(row["rolesid"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ncu.mao.Model.user_roles GetModel(int rolesid)
        {
            StringBuilder strSql = new StringBuilder();

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

            ncu.mao.Model.user_roles model = new ncu.mao.Model.user_roles();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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