コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.User_permission model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update User_permission set ");

            strSql.Append(" User_id = @User_id , ");
            strSql.Append(" Sf_id = @Sf_id  ");
            strSql.Append(" where Upe_id=@Upe_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Upe_id",  SqlDbType.BigInt, 8),
                new SqlParameter("@User_id", SqlDbType.BigInt, 8),
                new SqlParameter("@Sf_id",   SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Upe_id;
            parameters[1].Value = model.User_id;
            parameters[2].Value = model.Sf_id;
            int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.User_permission GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Upe_id, User_id, Sf_id  ");
            strSql.Append("  from User_permission ");
            strSql.Append(" where " + strWhere);


            university.Model.CCOM.User_permission model = new university.Model.CCOM.User_permission();
            DataSet ds = DBSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Upe_id"].ToString() != "")
                {
                    model.Upe_id = long.Parse(ds.Tables[0].Rows[0]["Upe_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["User_id"].ToString() != "")
                {
                    model.User_id = long.Parse(ds.Tables[0].Rows[0]["User_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sf_id"].ToString() != "")
                {
                    model.Sf_id = int.Parse(ds.Tables[0].Rows[0]["Sf_id"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(university.Model.CCOM.User_permission model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into User_permission(");
            strSql.Append("User_id,Sf_id");
            strSql.Append(") values (");
            strSql.Append("@User_id,@Sf_id");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@User_id", SqlDbType.BigInt, 8),
                new SqlParameter("@Sf_id",   SqlDbType.Int, 4)
            };

            parameters[0].Value = model.User_id;
            parameters[1].Value = model.Sf_id;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.User_permission GetModel(long Upe_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Upe_id, User_id, Sf_id  ");
            strSql.Append("  from User_permission ");
            strSql.Append(" where Upe_id=@Upe_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Upe_id", SqlDbType.BigInt)
            };
            parameters[0].Value = Upe_id;


            university.Model.CCOM.User_permission model = new university.Model.CCOM.User_permission();
            DataSet ds = DBSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Upe_id"].ToString() != "")
                {
                    model.Upe_id = long.Parse(ds.Tables[0].Rows[0]["Upe_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["User_id"].ToString() != "")
                {
                    model.User_id = long.Parse(ds.Tables[0].Rows[0]["User_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sf_id"].ToString() != "")
                {
                    model.Sf_id = int.Parse(ds.Tables[0].Rows[0]["Sf_id"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }