예제 #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtroleName.Text.Trim().Length == 0)
            {
                strErr += "roleName不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    roleId   = int.Parse(this.lblroleId.Text);
            string roleName = this.txtroleName.Text;


            hm.Model.role model = new hm.Model.role();
            model.roleId   = roleId;
            model.roleName = roleName;

            hm.BLL.role bll = new hm.BLL.role();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
예제 #2
0
 private void ShowInfo(int roleId)
 {
     hm.BLL.role   bll   = new hm.BLL.role();
     hm.Model.role model = bll.GetModel(roleId);
     this.lblroleId.Text   = model.roleId.ToString();
     this.txtroleName.Text = model.roleName;
 }
예제 #3
0
파일: role.cs 프로젝트: tcld2269/HM_ED
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(hm.Model.role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update role set ");
            strSql.Append("roleName=@roleName");
            strSql.Append(" where roleId=@roleId");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@roleName", OleDbType.VarChar, 0),
                new OleDbParameter("@roleId",   OleDbType.Integer, 4)
            };
            parameters[0].Value = model.roleName;
            parameters[1].Value = model.roleId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
파일: role.cs 프로젝트: tcld2269/HM_ED
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(hm.Model.role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into role(");
            strSql.Append("roleName)");
            strSql.Append(" values (");
            strSql.Append("@roleName)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@roleName", OleDbType.VarChar, 0)
            };
            parameters[0].Value = model.roleName;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
파일: role.cs 프로젝트: tcld2269/HM_ED
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.role GetModel(int roleId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select roleId,roleName from role ");
            strSql.Append(" where roleId=@roleId");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@roleId", OleDbType.Integer, 4)
            };
            parameters[0].Value = roleId;

            hm.Model.role model = new hm.Model.role();
            DataSet       ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["roleId"] != null && ds.Tables[0].Rows[0]["roleId"].ToString() != "")
                {
                    model.roleId = int.Parse(ds.Tables[0].Rows[0]["roleId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["roleName"] != null && ds.Tables[0].Rows[0]["roleName"].ToString() != "")
                {
                    model.roleName = ds.Tables[0].Rows[0]["roleName"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
파일: role.cs 프로젝트: tcld2269/hmdfs
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.role GetModel(int roleId)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 roleId,roleName from role ");
            strSql.Append(" where roleId=@roleId");
            SqlParameter[] parameters = {
                    new SqlParameter("@roleId", SqlDbType.Int,4)
            };
            parameters[0].Value = roleId;

            hm.Model.role model=new hm.Model.role();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["roleId"]!=null && ds.Tables[0].Rows[0]["roleId"].ToString()!="")
                {
                    model.roleId=int.Parse(ds.Tables[0].Rows[0]["roleId"].ToString());
                }
                if(ds.Tables[0].Rows[0]["roleName"]!=null && ds.Tables[0].Rows[0]["roleName"].ToString()!="")
                {
                    model.roleName=ds.Tables[0].Rows[0]["roleName"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }