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

            strSql.Append("update t_role set ");
            strSql.Append("rolename=@rolename,");
            strSql.Append("description=@description");
            strSql.Append(" where roleid=@roleid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@rolename",    SqlDbType.NVarChar, 20),
                new SqlParameter("@description", SqlDbType.NVarChar, 50),
                new SqlParameter("@roleid",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.rolename;
            parameters[1].Value = model.description;
            parameters[2].Value = model.roleid;

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

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

            strSql.Append("insert into t_role(");
            strSql.Append("rolename,description)");
            strSql.Append(" values (");
            strSql.Append("@rolename,@description)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@rolename",    SqlDbType.NVarChar, 20),
                new SqlParameter("@description", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.rolename;
            parameters[1].Value = model.description;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtrolename.Text.Trim().Length == 0)
            {
                strErr += "rolename不能为空!\\n";
            }
            if (this.txtdescription.Text.Trim().Length == 0)
            {
                strErr += "description不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    roleid      = int.Parse(this.lblroleid.Text);
            string rolename    = this.txtrolename.Text;
            string description = this.txtdescription.Text;


            ncu.mao.Model.t_role model = new ncu.mao.Model.t_role();
            model.roleid      = roleid;
            model.rolename    = rolename;
            model.description = description;

            ncu.mao.BLL.t_role bll = new ncu.mao.BLL.t_role();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Esempio n. 4
0
 private void ShowInfo(int roleid)
 {
     ncu.mao.BLL.t_role   bll   = new ncu.mao.BLL.t_role();
     ncu.mao.Model.t_role model = bll.GetModel(roleid);
     this.lblroleid.Text      = model.roleid.ToString();
     this.lblrolename.Text    = model.rolename;
     this.lbldescription.Text = model.description;
 }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ncu.mao.Model.t_role DataRowToModel(DataRow row)
 {
     ncu.mao.Model.t_role model = new ncu.mao.Model.t_role();
     if (row != null)
     {
         if (row["roleid"] != null && row["roleid"].ToString() != "")
         {
             model.roleid = int.Parse(row["roleid"].ToString());
         }
         if (row["rolename"] != null)
         {
             model.rolename = row["rolename"].ToString();
         }
         if (row["description"] != null)
         {
             model.description = row["description"].ToString();
         }
     }
     return(model);
 }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ncu.mao.Model.t_role GetModel(int roleid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 roleid,rolename,description from t_role ");
            strSql.Append(" where roleid=@roleid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@roleid", SqlDbType.Int, 4)
            };
            parameters[0].Value = roleid;

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

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