/// <summary> /// 更新一条数据 /// </summary> public bool Update(MxWeiXinPF.Model.wx_fc_yySysset model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_fc_yySysset set "); strSql.Append("wid=@wid,"); strSql.Append("address=@address,"); strSql.Append("lngX=@lngX,"); strSql.Append("latY=@latY,"); strSql.Append("telephone=@telephone,"); strSql.Append("headImg=@headImg,"); strSql.Append("detail=@detail,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("createdate=@createdate"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@address", SqlDbType.VarChar, 300), new SqlParameter("@lngX", SqlDbType.Decimal, 17), new SqlParameter("@latY", SqlDbType.Decimal, 17), new SqlParameter("@telephone", SqlDbType.VarChar, 300), new SqlParameter("@headImg", SqlDbType.VarChar, 300), new SqlParameter("@detail", SqlDbType.VarChar, 500), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@createdate", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.address; parameters[2].Value = model.lngX; parameters[3].Value = model.latY; parameters[4].Value = model.telephone; parameters[5].Value = model.headImg; parameters[6].Value = model.detail; parameters[7].Value = model.sort_id; parameters[8].Value = model.createdate; parameters[9].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_fc_yySysset DataRowToModel(DataRow row) { MxWeiXinPF.Model.wx_fc_yySysset model = new MxWeiXinPF.Model.wx_fc_yySysset(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].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["telephone"] != null) { model.telephone = row["telephone"].ToString(); } if (row["headImg"] != null) { model.headImg = row["headImg"].ToString(); } if (row["detail"] != null) { model.detail = row["detail"].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()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MxWeiXinPF.Model.wx_fc_yySysset model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_fc_yySysset("); strSql.Append("wid,address,lngX,latY,telephone,headImg,detail,sort_id,createdate)"); strSql.Append(" values ("); strSql.Append("@wid,@address,@lngX,@latY,@telephone,@headImg,@detail,@sort_id,@createdate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@address", SqlDbType.VarChar, 300), new SqlParameter("@lngX", SqlDbType.Decimal, 17), new SqlParameter("@latY", SqlDbType.Decimal, 17), new SqlParameter("@telephone", SqlDbType.VarChar, 300), new SqlParameter("@headImg", SqlDbType.VarChar, 300), new SqlParameter("@detail", SqlDbType.VarChar, 500), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@createdate", SqlDbType.DateTime) }; parameters[0].Value = model.wid; parameters[1].Value = model.address; parameters[2].Value = model.lngX; parameters[3].Value = model.latY; parameters[4].Value = model.telephone; parameters[5].Value = model.headImg; parameters[6].Value = model.detail; parameters[7].Value = model.sort_id; parameters[8].Value = model.createdate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_fc_yySysset GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,wid,address,lngX,latY,telephone,headImg,detail,sort_id,createdate from wx_fc_yySysset "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; MxWeiXinPF.Model.wx_fc_yySysset model = new MxWeiXinPF.Model.wx_fc_yySysset(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }