Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Roles set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Fk_Permissions_Id=@Fk_Permissions_Id");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",              SqlDbType.VarChar, 50),
                new SqlParameter("@Fk_Permissions_Id", SqlDbType.Int,      4),
                new SqlParameter("@Id",                SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Fk_Permissions_Id;
            parameters[2].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.Roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Roles(");
            strSql.Append("Name,Fk_Permissions_Id)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Fk_Permissions_Id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",              SqlDbType.VarChar, 50),
                new SqlParameter("@Fk_Permissions_Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Fk_Permissions_Id;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.Roles   bll   = new Maticsoft.BLL.Roles();
     Maticsoft.Model.Roles model = bll.GetModel(Id);
     this.lblId.Text   = model.Id.ToString();
     this.txtName.Text = model.Name;
     this.ddlFk_Permissions_Id.SelectedValue = model.Fk_Permissions_Id.ToString();
 }
Example #4
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.Roles   bll   = new Maticsoft.BLL.Roles();
     Maticsoft.Model.Roles model = bll.GetModel(Id);
     this.lblId.Text   = model.Id.ToString();
     this.lblName.Text = model.Name;
     BLL.Permissions   BLLPermissions   = new BLL.Permissions();
     Model.Permissions ModelPermissions = BLLPermissions.GetModel((int)model.Fk_Permissions_Id);
     this.lblFk_Permissions_Id.Text = ModelPermissions.Name;
 }
Example #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            String Name = this.txtName.Text;
            int    Fk_Permissions_Id = int.Parse(this.ddlFk_Permissions_Id.SelectedValue);

            Maticsoft.Model.Roles model = new Maticsoft.Model.Roles();
            model.Name = Name;
            model.Fk_Permissions_Id = Fk_Permissions_Id;

            Maticsoft.BLL.Roles bll = new Maticsoft.BLL.Roles();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "Add.aspx");
        }
Example #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Roles DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Roles model = new Maticsoft.Model.Roles();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Fk_Permissions_Id"] != null && row["Fk_Permissions_Id"].ToString() != "")
         {
             model.Fk_Permissions_Id = int.Parse(row["Fk_Permissions_Id"].ToString());
         }
     }
     return(model);
 }
Example #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Roles GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name,Fk_Permissions_Id from Roles ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Maticsoft.Model.Roles model = new Maticsoft.Model.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);
            }
        }