Пример #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(Tunnel.Model.Tunnel_vannewpaper model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@v_id",    SqlDbType.Int,       8),
                new SqlParameter("@v_title", SqlDbType.VarChar, 200),
                new SqlParameter("@v_img",   SqlDbType.VarChar, 100),
                new SqlParameter("@v_file",  SqlDbType.VarChar, 100),
                new SqlParameter("@v_user",  SqlDbType.Int,       4),
                new SqlParameter("@v_sort",  SqlDbType.Int,       4),
                new SqlParameter("@v_ip",    SqlDbType.VarChar,  20),
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.v_title;
            parameters[2].Value     = model.v_img;
            parameters[3].Value     = model.v_file;
            parameters[4].Value     = model.v_user;
            parameters[5].Value     = model.v_sort;
            parameters[6].Value     = model.v_Ip;

            DbHelperSQL.RunProcedure("Tunnel_vannewpaper_ADD", parameters, out rowsAffected);
            return((int)parameters[0].Value);
        }
Пример #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(Tunnel.Model.Tunnel_vannewpaper model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@v_id",    SqlDbType.BigInt,      8),
                new SqlParameter("@v_title", SqlDbType.VarChar,   200),
                new SqlParameter("@v_img",   SqlDbType.VarChar,   100),
                new SqlParameter("@v_file",  SqlDbType.VarBinary, 200),
                new SqlParameter("@v_user",  SqlDbType.Int,         4),
                new SqlParameter("@v_sort",  SqlDbType.Int,         4),
                new SqlParameter("@v_ip",    SqlDbType.VarChar,    20),
            };
            parameters[0].Value = model.v_id;
            parameters[1].Value = model.v_title;
            parameters[2].Value = model.v_img;
            parameters[3].Value = model.v_file;
            parameters[4].Value = model.v_user;
            parameters[5].Value = model.v_sort;
            parameters[6].Value = model.v_Ip;


            DbHelperSQL.RunProcedure("Tunnel_vannewpaper_Update", parameters, out rowsAffected);
        }
Пример #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tunnel.Model.Tunnel_vannewpaper> DataTableToList(DataTable dt)
        {
            List <Tunnel.Model.Tunnel_vannewpaper> modelList = new List <Tunnel.Model.Tunnel_vannewpaper>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tunnel.Model.Tunnel_vannewpaper model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model         = new Tunnel.Model.Tunnel_vannewpaper();
                    model.v_id    = Convert.ToInt64(dt.Rows[n]["v_id"].ToString());
                    model.v_title = dt.Rows[n]["v_title"].ToString();
                    model.v_img   = dt.Rows[n]["v_img"].ToString();
                    if (dt.Rows[n]["v_file"].ToString() != "")
                    {
                        model.v_file = dt.Rows[n]["v_file"].ToString();
                    }
                    if (dt.Rows[n]["v_user"].ToString() != "")
                    {
                        model.v_user = int.Parse(dt.Rows[n]["v_user"].ToString());
                    }
                    if (dt.Rows[n]["v_sort"].ToString() != "")
                    {
                        model.v_sort = int.Parse(dt.Rows[n]["v_sort"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="pb">分页基本信息</param>
        /// <param name="count">返回总数</param>
        /// <returns></returns>
        public List <Tunnel.Model.Tunnel_vannewpaper> GetList(PageBase pb, ref int count)
        {
            DataTable dt = dal.GetList(pb, ref count).Tables[0];
            List <Tunnel.Model.Tunnel_vannewpaper> modelList = new List <Tunnel.Model.Tunnel_vannewpaper>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0 && pb.DoCount == 0)
            {
                Tunnel.Model.Tunnel_vannewpaper model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model         = new Tunnel.Model.Tunnel_vannewpaper();
                    model.v_id    = Convert.ToInt64(dt.Rows[n]["v_id"].ToString());
                    model.v_title = dt.Rows[n]["v_title"].ToString();
                    model.v_img   = dt.Rows[n]["v_img"].ToString();
                    if (dt.Rows[n]["v_file"].ToString() != "")
                    {
                        model.v_file = dt.Rows[n]["v_file"].ToString();
                    }
                    if (dt.Rows[n]["v_user"].ToString() != "")
                    {
                        model.v_user = int.Parse(dt.Rows[n]["v_user"].ToString());
                    }
                    if (dt.Rows[n]["v_sort"].ToString() != "")
                    {
                        model.v_sort = int.Parse(dt.Rows[n]["v_sort"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tunnel.Model.Tunnel_vannewpaper GetModel(long v_id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@v_id", SqlDbType.BigInt)
            };
            parameters[0].Value = v_id;

            Tunnel.Model.Tunnel_vannewpaper model = new Tunnel.Model.Tunnel_vannewpaper();
            DataSet ds = DbHelperSQL.RunProcedure("Tunnel_vannewpaper_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["v_id"].ToString() != "")
                {
                    model.v_id = long.Parse(ds.Tables[0].Rows[0]["v_id"].ToString());
                }
                model.v_title = ds.Tables[0].Rows[0]["v_title"].ToString();
                model.v_img   = ds.Tables[0].Rows[0]["v_img"].ToString();
                if (ds.Tables[0].Rows[0]["v_file"].ToString() != "")
                {
                    model.v_file = ds.Tables[0].Rows[0]["v_file"].ToString();
                }
                if (ds.Tables[0].Rows[0]["v_user"].ToString() != "")
                {
                    model.v_user = int.Parse(ds.Tables[0].Rows[0]["v_user"].ToString());
                }
                if (ds.Tables[0].Rows[0]["v_sort"].ToString() != "")
                {
                    model.v_sort = int.Parse(ds.Tables[0].Rows[0]["v_sort"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Tunnel.Model.Tunnel_vannewpaper model)
 {
     dal.Update(model);
 }
Пример #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Tunnel.Model.Tunnel_vannewpaper model)
 {
     return(dal.Add(model));
 }