/// <summary> /// 增加一条数据 /// </summary> public int Add(MxWeiXinPF.Model.wx_fc_houseType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_fc_houseType("); strSql.Append("sid,sort_id,Name,Jieshao,houseType,storey,htimgA,htImgB,htimgC,htimgD,createDate,pid,wid,jzmj,fid)"); strSql.Append(" values ("); strSql.Append("@sid,@sort_id,@Name,@Jieshao,@houseType,@storey,@htimgA,@htImgB,@htimgC,@htimgD,@createDate,@pid,@wid,@jzmj,@fid)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@sid", SqlDbType.Int, 4), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 500), new SqlParameter("@Jieshao", SqlDbType.VarChar, 1000), new SqlParameter("@houseType", SqlDbType.VarChar, 300), new SqlParameter("@storey", SqlDbType.VarChar, 300), new SqlParameter("@htimgA", SqlDbType.VarChar, 500), new SqlParameter("@htImgB", SqlDbType.VarChar, 500), new SqlParameter("@htimgC", SqlDbType.VarChar, 500), new SqlParameter("@htimgD", SqlDbType.VarChar, 500), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@pid", SqlDbType.Int, 4), new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@jzmj", SqlDbType.Float, 8), new SqlParameter("@fid", SqlDbType.Int, 4) }; parameters[0].Value = model.sid; parameters[1].Value = model.sort_id; parameters[2].Value = model.Name; parameters[3].Value = model.Jieshao; parameters[4].Value = model.houseType; parameters[5].Value = model.storey; parameters[6].Value = model.htimgA; parameters[7].Value = model.htImgB; parameters[8].Value = model.htimgC; parameters[9].Value = model.htimgD; parameters[10].Value = model.createDate; parameters[11].Value = model.pid; parameters[12].Value = model.wid; parameters[13].Value = model.jzmj; parameters[14].Value = model.fid; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_fc_houseType GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,sid,sort_id,Name,Jieshao,houseType,storey,htimgA,htImgB,htimgC,htimgD,createDate,pid,wid,jzmj,fid from wx_fc_houseType "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; MxWeiXinPF.Model.wx_fc_houseType model = new MxWeiXinPF.Model.wx_fc_houseType(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_fc_houseType DataRowToModel(DataRow row) { MxWeiXinPF.Model.wx_fc_houseType model = new MxWeiXinPF.Model.wx_fc_houseType(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["sid"] != null && row["sid"].ToString() != "") { model.sid = int.Parse(row["sid"].ToString()); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["Jieshao"] != null) { model.Jieshao = row["Jieshao"].ToString(); } if (row["houseType"] != null) { model.houseType = row["houseType"].ToString(); } if (row["storey"] != null) { model.storey = row["storey"].ToString(); } if (row["htimgA"] != null) { model.htimgA = row["htimgA"].ToString(); } if (row["htImgB"] != null) { model.htImgB = row["htImgB"].ToString(); } if (row["htimgC"] != null) { model.htimgC = row["htimgC"].ToString(); } if (row["htimgD"] != null) { model.htimgD = row["htimgD"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["pid"] != null && row["pid"].ToString() != "") { model.pid = int.Parse(row["pid"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["jzmj"] != null && row["jzmj"].ToString() != "") { model.jzmj = decimal.Parse(row["jzmj"].ToString()); } if (row["fid"] != null && row["fid"].ToString() != "") { model.fid = int.Parse(row["fid"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MxWeiXinPF.Model.wx_fc_houseType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_fc_houseType set "); strSql.Append("sid=@sid,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("Name=@Name,"); strSql.Append("Jieshao=@Jieshao,"); strSql.Append("houseType=@houseType,"); strSql.Append("storey=@storey,"); strSql.Append("htimgA=@htimgA,"); strSql.Append("htImgB=@htImgB,"); strSql.Append("htimgC=@htimgC,"); strSql.Append("htimgD=@htimgD,"); strSql.Append("createDate=@createDate,"); strSql.Append("pid=@pid,"); strSql.Append("wid=@wid,"); strSql.Append("jzmj=@jzmj,"); strSql.Append("fid=@fid"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@sid", SqlDbType.Int, 4), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 500), new SqlParameter("@Jieshao", SqlDbType.VarChar, 1000), new SqlParameter("@houseType", SqlDbType.VarChar, 300), new SqlParameter("@storey", SqlDbType.VarChar, 300), new SqlParameter("@htimgA", SqlDbType.VarChar, 500), new SqlParameter("@htImgB", SqlDbType.VarChar, 500), new SqlParameter("@htimgC", SqlDbType.VarChar, 500), new SqlParameter("@htimgD", SqlDbType.VarChar, 500), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@pid", SqlDbType.Int, 4), new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@jzmj", SqlDbType.Float, 8), new SqlParameter("@fid", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.sid; parameters[1].Value = model.sort_id; parameters[2].Value = model.Name; parameters[3].Value = model.Jieshao; parameters[4].Value = model.houseType; parameters[5].Value = model.storey; parameters[6].Value = model.htimgA; parameters[7].Value = model.htImgB; parameters[8].Value = model.htimgC; parameters[9].Value = model.htimgD; parameters[10].Value = model.createDate; parameters[11].Value = model.pid; parameters[12].Value = model.wid; parameters[13].Value = model.jzmj; parameters[14].Value = model.fid; parameters[15].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }