コード例 #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtRoleID.Text))
            {
                strErr += "RoleID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtFunctionID.Text))
            {
                strErr += "FunctionID格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int ID         = int.Parse(this.lblID.Text);
            int RoleID     = int.Parse(this.txtRoleID.Text);
            int FunctionID = int.Parse(this.txtFunctionID.Text);


            zs.Model.Sys_RoleFunction model = new zs.Model.Sys_RoleFunction();
            model.ID         = ID;
            model.RoleID     = RoleID;
            model.FunctionID = FunctionID;

            zs.BLL.Sys_RoleFunction bll = new zs.BLL.Sys_RoleFunction();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(zs.Model.Sys_RoleFunction model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(zs.Model.Sys_RoleFunction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sys_RoleFunction set ");
            strSql.Append("RoleID=@RoleID,");
            strSql.Append("FunctionID=@FunctionID");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleID",     SqlDbType.Int, 4),
                new SqlParameter("@FunctionID", SqlDbType.Int, 4),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleID;
            parameters[1].Value = model.FunctionID;
            parameters[2].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
 private void ShowInfo(int ID)
 {
     zs.BLL.Sys_RoleFunction   bll   = new zs.BLL.Sys_RoleFunction();
     zs.Model.Sys_RoleFunction model = bll.GetModel(ID);
     this.lblID.Text         = model.ID.ToString();
     this.txtRoleID.Text     = model.RoleID.ToString();
     this.txtFunctionID.Text = model.FunctionID.ToString();
 }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public zs.Model.Sys_RoleFunction GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,RoleID,FunctionID from Sys_RoleFunction ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                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]["FunctionID"] != null && ds.Tables[0].Rows[0]["FunctionID"].ToString() != "")
                {
                    model.FunctionID = int.Parse(ds.Tables[0].Rows[0]["FunctionID"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }