示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(university.Model.CCOM.Father_function model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Father_function(");
            strSql.Append("Ff_name,Ff_fatherID,Ff_sort,Ff_disable");
            strSql.Append(") values (");
            strSql.Append("@Ff_name,@Ff_fatherID,@Ff_sort,@Ff_disable");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ff_name",     SqlDbType.VarChar, 128),
                new SqlParameter("@Ff_fatherID", SqlDbType.Int,       4),
                new SqlParameter("@Ff_sort",     SqlDbType.Int,       4),
                new SqlParameter("@Ff_disable",  SqlDbType.Bit, 1)
            };

            parameters[0].Value = model.Ff_name;
            parameters[1].Value = model.Ff_fatherID;
            parameters[2].Value = model.Ff_sort;
            parameters[3].Value = model.Ff_disable;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Father_function GetModel(int Ff_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Ff_id, Ff_name, Ff_fatherID, Ff_sort, Ff_disable  ");
            strSql.Append("  from Father_function ");
            strSql.Append(" where Ff_id=@Ff_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ff_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Ff_id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Ff_id"].ToString() != "")
                {
                    model.Ff_id = int.Parse(ds.Tables[0].Rows[0]["Ff_id"].ToString());
                }
                model.Ff_name = ds.Tables[0].Rows[0]["Ff_name"].ToString();
                if (ds.Tables[0].Rows[0]["Ff_fatherID"].ToString() != "")
                {
                    model.Ff_fatherID = int.Parse(ds.Tables[0].Rows[0]["Ff_fatherID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Ff_sort"].ToString() != "")
                {
                    model.Ff_sort = int.Parse(ds.Tables[0].Rows[0]["Ff_sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Ff_disable"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Ff_disable"].ToString() == "1") || (ds.Tables[0].Rows[0]["Ff_disable"].ToString().ToLower() == "true"))
                    {
                        model.Ff_disable = true;
                    }
                    else
                    {
                        model.Ff_disable = false;
                    }
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Father_function GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Ff_id, Ff_name, Ff_fatherID, Ff_sort, Ff_disable  ");
            strSql.Append("  from Father_function ");
            strSql.Append(" where " + strWhere);


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Ff_id"].ToString() != "")
                {
                    model.Ff_id = int.Parse(ds.Tables[0].Rows[0]["Ff_id"].ToString());
                }
                model.Ff_name = ds.Tables[0].Rows[0]["Ff_name"].ToString();
                if (ds.Tables[0].Rows[0]["Ff_fatherID"].ToString() != "")
                {
                    model.Ff_fatherID = int.Parse(ds.Tables[0].Rows[0]["Ff_fatherID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Ff_sort"].ToString() != "")
                {
                    model.Ff_sort = int.Parse(ds.Tables[0].Rows[0]["Ff_sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Ff_disable"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Ff_disable"].ToString() == "1") || (ds.Tables[0].Rows[0]["Ff_disable"].ToString().ToLower() == "true"))
                    {
                        model.Ff_disable = true;
                    }
                    else
                    {
                        model.Ff_disable = false;
                    }
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.Father_function model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Father_function set ");

            strSql.Append(" Ff_name = @Ff_name , ");
            strSql.Append(" Ff_fatherID = @Ff_fatherID , ");
            strSql.Append(" Ff_sort = @Ff_sort , ");
            strSql.Append(" Ff_disable = @Ff_disable  ");
            strSql.Append(" where Ff_id=@Ff_id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Ff_id",       SqlDbType.Int,       4),
                new SqlParameter("@Ff_name",     SqlDbType.VarChar, 128),
                new SqlParameter("@Ff_fatherID", SqlDbType.Int,       4),
                new SqlParameter("@Ff_sort",     SqlDbType.Int,       4),
                new SqlParameter("@Ff_disable",  SqlDbType.Bit, 1)
            };

            parameters[0].Value = model.Ff_id;
            parameters[1].Value = model.Ff_name;
            parameters[2].Value = model.Ff_fatherID;
            parameters[3].Value = model.Ff_sort;
            parameters[4].Value = model.Ff_disable;
            int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }