Exemple #1
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public static int Add(Tunnel.Model.Tunnel_Performance model)
        {
            string strSQL = string.Format("INSERT INTO Tunnel_Performance ([Type],Title,[file],[Name],CreateDate,CreateUser) "
                                          + "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}')", model.Type, model.Title, model.File, model.Name, model.CreateDate, model.CreateUser);
            object obj = DbHelperSQL.ExecuteSql(strSQL);

            if (null != obj)
            {
                return(Convert.ToInt32(obj));
            }
            else
            {
                return(0);
            }
        }
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tunnel.Model.Tunnel_Performance GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Type,Title,file,Name,CreateDate,CreateUser from Tunnel_Performance ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Tunnel.Model.Tunnel_Performance model = new Tunnel.Model.Tunnel_Performance();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Type"].ToString() != "")
                {
                    model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
                }
                model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                model.File  = ds.Tables[0].Rows[0]["file"].ToString();
                model.Name  = ds.Tables[0].Rows[0]["Name"].ToString();
                if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateUser"].ToString() != "")
                {
                    model.CreateUser = int.Parse(ds.Tables[0].Rows[0]["CreateUser"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="pb">分页基本信息</param>
        /// <param name="count">返回总数</param>
        /// <returns></returns>
        public List <Tunnel.Model.Tunnel_Performance> GetList(PageBase pb, ref int count)
        {
            DataTable dt = dal.GetList(pb, ref count).Tables[0];
            List <Tunnel.Model.Tunnel_Performance> modelList = new List <Tunnel.Model.Tunnel_Performance>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0 && pb.DoCount == 0)
            {
                Tunnel.Model.Tunnel_Performance model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tunnel.Model.Tunnel_Performance();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["Type"].ToString() != "")
                    {
                        model.Type = int.Parse(dt.Rows[n]["Type"].ToString());
                    }
                    model.Title = dt.Rows[n]["Title"].ToString();
                    model.File  = dt.Rows[n]["file"].ToString();
                    model.Name  = dt.Rows[n]["Name"].ToString();
                    if (dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }
                    if (dt.Rows[n]["CreateUser"].ToString() != "")
                    {
                        model.CreateUser = int.Parse(dt.Rows[n]["CreateUser"].ToString());
                    }
                    //model.CreateUser=dt.Rows[n]["CreateUser"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemple #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tunnel.Model.Tunnel_Performance> DataTableToList(DataTable dt)
        {
            List <Tunnel.Model.Tunnel_Performance> modelList = new List <Tunnel.Model.Tunnel_Performance>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tunnel.Model.Tunnel_Performance model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tunnel.Model.Tunnel_Performance();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["Type"].ToString() != "")
                    {
                        model.Type = int.Parse(dt.Rows[n]["Type"].ToString());
                    }
                    model.Title = dt.Rows[n]["Title"].ToString();
                    model.File  = dt.Rows[n]["file"].ToString();
                    model.Name  = dt.Rows[n]["Name"].ToString();
                    if (dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }
                    if (dt.Rows[n]["CreateUser"].ToString() != "")
                    {
                        model.CreateUser = int.Parse(dt.Rows[n]["CreateUser"].ToString());
                    }
                    //model.CreateUser=dt.Rows[n]["CreateUser"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemple #5
0
 /// <summary>
 /// 添加一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Add(Tunnel.Model.Tunnel_Performance model)
 {
     return(Tunnel.DAL.Tunnel_Performance.Add(model));
 }