Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.T_Group model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Group(");
            strSql.Append("GroupName,AddMember,Role,Variable,deletable)");
            strSql.Append(" values (");
            strSql.Append("@GroupName,@AddMember,@Role,@Variable,@deletable)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupName", SqlDbType.NVarChar, 200),
                new SqlParameter("@AddMember", SqlDbType.Bit,        1),
                new SqlParameter("@Role",      SqlDbType.NVarChar, 500),
                new SqlParameter("@Variable",  SqlDbType.Bit,        1),
                new SqlParameter("@deletable", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.GroupName;
            parameters[1].Value = model.AddMember;
            parameters[2].Value = model.Role;
            parameters[3].Value = model.Variable;
            parameters[4].Value = model.deletable;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.T_Group DataRowToModel(DataRow row)
 {
     Maticsoft.Model.T_Group model = new Maticsoft.Model.T_Group();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["GroupName"] != null)
         {
             model.GroupName = row["GroupName"].ToString();
         }
         if (row["AddMember"] != null && row["AddMember"].ToString() != "")
         {
             if ((row["AddMember"].ToString() == "1") || (row["AddMember"].ToString().ToLower() == "true"))
             {
                 model.AddMember = true;
             }
             else
             {
                 model.AddMember = false;
             }
         }
         if (row["Role"] != null)
         {
             model.Role = row["Role"].ToString();
         }
         if (row["Variable"] != null && row["Variable"].ToString() != "")
         {
             if ((row["Variable"].ToString() == "1") || (row["Variable"].ToString().ToLower() == "true"))
             {
                 model.Variable = true;
             }
             else
             {
                 model.Variable = false;
             }
         }
         if (row["deletable"] != null && row["deletable"].ToString() != "")
         {
             if ((row["deletable"].ToString() == "1") || (row["deletable"].ToString().ToLower() == "true"))
             {
                 model.deletable = true;
             }
             else
             {
                 model.deletable = false;
             }
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.T_Group model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Group set ");
            strSql.Append("GroupName=@GroupName,");
            strSql.Append("AddMember=@AddMember,");
            strSql.Append("Role=@Role,");
            strSql.Append("Variable=@Variable,");
            strSql.Append("deletable=@deletable");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupName", SqlDbType.NVarChar, 200),
                new SqlParameter("@AddMember", SqlDbType.Bit,        1),
                new SqlParameter("@Role",      SqlDbType.NVarChar, 500),
                new SqlParameter("@Variable",  SqlDbType.Bit,        1),
                new SqlParameter("@deletable", SqlDbType.Bit,        1),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GroupName;
            parameters[1].Value = model.AddMember;
            parameters[2].Value = model.Role;
            parameters[3].Value = model.Variable;
            parameters[4].Value = model.deletable;
            parameters[5].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.T_Group GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,GroupName,AddMember,Role,Variable,deletable from T_Group ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.T_Group model = new Maticsoft.Model.T_Group();
            DataSet ds = DbPlatFormBaseHelperSQL.Query(strSql.ToString(), parameters);

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