Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_wq_yuyue DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_wq_yuyue model = new WeiXinPF.Model.wx_wq_yuyue();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["telephone"] != null)
         {
             model.telephone = row["telephone"].ToString();
         }
         if (row["coverpic"] != null)
         {
             model.coverpic = row["coverpic"].ToString();
         }
         if (row["address"] != null)
         {
             model.address = row["address"].ToString();
         }
         if (row["lngX"] != null && row["lngX"].ToString() != "")
         {
             model.lngX = decimal.Parse(row["lngX"].ToString());
         }
         if (row["latY"] != null && row["latY"].ToString() != "")
         {
             model.latY = decimal.Parse(row["latY"].ToString());
         }
         if (row["headpic"] != null)
         {
             model.headpic = row["headpic"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["createdate"] != null && row["createdate"].ToString() != "")
         {
             model.createdate = DateTime.Parse(row["createdate"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_wq_yuyue model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_wq_yuyue set ");
            strSql.Append("Name=@Name,");
            strSql.Append("telephone=@telephone,");
            strSql.Append("coverpic=@coverpic,");
            strSql.Append("address=@address,");
            strSql.Append("lngX=@lngX,");
            strSql.Append("latY=@latY,");
            strSql.Append("headpic=@headpic,");
            strSql.Append("remark=@remark,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("createdate=@createdate,");
            strSql.Append("wid=@wid,");
            strSql.Append("type=@type");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",       SqlDbType.VarChar,   4000),
                new SqlParameter("@telephone",  SqlDbType.VarChar,    300),
                new SqlParameter("@coverpic",   SqlDbType.VarChar,    800),
                new SqlParameter("@address",    SqlDbType.VarChar,    500),
                new SqlParameter("@lngX",       SqlDbType.Float,        8),
                new SqlParameter("@latY",       SqlDbType.Float,        8),
                new SqlParameter("@headpic",    SqlDbType.VarChar,    500),
                new SqlParameter("@remark",     SqlDbType.VarChar,   2000),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@createdate", SqlDbType.DateTime),
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@type",       SqlDbType.NVarChar,   300),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Name;
            parameters[1].Value  = model.telephone;
            parameters[2].Value  = model.coverpic;
            parameters[3].Value  = model.address;
            parameters[4].Value  = model.lngX;
            parameters[5].Value  = model.latY;
            parameters[6].Value  = model.headpic;
            parameters[7].Value  = model.remark;
            parameters[8].Value  = model.sort_id;
            parameters[9].Value  = model.createdate;
            parameters[10].Value = model.wid;
            parameters[11].Value = model.type;
            parameters[12].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_wq_yuyue model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_wq_yuyue(");
            strSql.Append("Name,telephone,coverpic,address,lngX,latY,headpic,remark,sort_id,createdate,wid,type)");
            strSql.Append(" values (");
            strSql.Append("@Name,@telephone,@coverpic,@address,@lngX,@latY,@headpic,@remark,@sort_id,@createdate,@wid,@type)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",       SqlDbType.VarChar,   4000),
                new SqlParameter("@telephone",  SqlDbType.VarChar,    300),
                new SqlParameter("@coverpic",   SqlDbType.VarChar,    800),
                new SqlParameter("@address",    SqlDbType.VarChar,    500),
                new SqlParameter("@lngX",       SqlDbType.Float,        8),
                new SqlParameter("@latY",       SqlDbType.Float,        8),
                new SqlParameter("@headpic",    SqlDbType.VarChar,    500),
                new SqlParameter("@remark",     SqlDbType.VarChar,   2000),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@createdate", SqlDbType.DateTime),
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@type",       SqlDbType.NVarChar, 300)
            };
            parameters[0].Value  = model.Name;
            parameters[1].Value  = model.telephone;
            parameters[2].Value  = model.coverpic;
            parameters[3].Value  = model.address;
            parameters[4].Value  = model.lngX;
            parameters[5].Value  = model.latY;
            parameters[6].Value  = model.headpic;
            parameters[7].Value  = model.remark;
            parameters[8].Value  = model.sort_id;
            parameters[9].Value  = model.createdate;
            parameters[10].Value = model.wid;
            parameters[11].Value = model.type;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_wq_yuyue GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name,telephone,coverpic,address,lngX,latY,headpic,remark,sort_id,createdate,wid,type from wx_wq_yuyue ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

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