/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_hotels_info GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,hotelName,hotelAddress,hotelPhone,mobilPhone,noticeEmail,emailPws,smtp,coverPic,topPic,orderLimit,listMode,messageNotice,pwd,hotelIntroduct,orderRemark,createDate,sortid,xplace,yplace from wx_hotels_info "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; MxWeiXinPF.Model.wx_hotels_info model = new MxWeiXinPF.Model.wx_hotels_info(); 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 int Add(MxWeiXinPF.Model.wx_hotels_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_hotels_info("); strSql.Append("wid,hotelName,hotelAddress,hotelPhone,mobilPhone,noticeEmail,emailPws,smtp,coverPic,topPic,orderLimit,listMode,messageNotice,pwd,hotelIntroduct,orderRemark,createDate,sortid,xplace,yplace)"); strSql.Append(" values ("); strSql.Append("@wid,@hotelName,@hotelAddress,@hotelPhone,@mobilPhone,@noticeEmail,@emailPws,@smtp,@coverPic,@topPic,@orderLimit,@listMode,@messageNotice,@pwd,@hotelIntroduct,@orderRemark,@createDate,@sortid,@xplace,@yplace)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@hotelName", SqlDbType.VarChar, 300), new SqlParameter("@hotelAddress", SqlDbType.VarChar, 300), new SqlParameter("@hotelPhone", SqlDbType.VarChar, 100), new SqlParameter("@mobilPhone", SqlDbType.VarChar, 100), new SqlParameter("@noticeEmail", SqlDbType.VarChar, 100), new SqlParameter("@emailPws", SqlDbType.VarChar, 50), new SqlParameter("@smtp", SqlDbType.VarChar, 100), new SqlParameter("@coverPic", SqlDbType.VarChar, 200), new SqlParameter("@topPic", SqlDbType.VarChar, 200), new SqlParameter("@orderLimit", SqlDbType.Int, 4), new SqlParameter("@listMode", SqlDbType.Bit, 1), new SqlParameter("@messageNotice", SqlDbType.Int, 4), new SqlParameter("@pwd", SqlDbType.VarChar, 50), new SqlParameter("@hotelIntroduct", SqlDbType.VarChar, 200), new SqlParameter("@orderRemark", SqlDbType.VarChar, 200), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@sortid", SqlDbType.Int, 4), new SqlParameter("@xplace", SqlDbType.Float, 8), new SqlParameter("@yplace", SqlDbType.Float, 8) }; parameters[0].Value = model.wid; parameters[1].Value = model.hotelName; parameters[2].Value = model.hotelAddress; parameters[3].Value = model.hotelPhone; parameters[4].Value = model.mobilPhone; parameters[5].Value = model.noticeEmail; parameters[6].Value = model.emailPws; parameters[7].Value = model.smtp; parameters[8].Value = model.coverPic; parameters[9].Value = model.topPic; parameters[10].Value = model.orderLimit; parameters[11].Value = model.listMode; parameters[12].Value = model.messageNotice; parameters[13].Value = model.pwd; parameters[14].Value = model.hotelIntroduct; parameters[15].Value = model.orderRemark; parameters[16].Value = model.createDate; parameters[17].Value = model.sortid; parameters[18].Value = model.xplace; parameters[19].Value = model.yplace; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MxWeiXinPF.Model.wx_hotels_info DataRowToModel(DataRow row) { MxWeiXinPF.Model.wx_hotels_info model = new MxWeiXinPF.Model.wx_hotels_info(); 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["hotelName"] != null) { model.hotelName = row["hotelName"].ToString(); } if (row["hotelAddress"] != null) { model.hotelAddress = row["hotelAddress"].ToString(); } if (row["hotelPhone"] != null) { model.hotelPhone = row["hotelPhone"].ToString(); } if (row["mobilPhone"] != null) { model.mobilPhone = row["mobilPhone"].ToString(); } if (row["noticeEmail"] != null) { model.noticeEmail = row["noticeEmail"].ToString(); } if (row["emailPws"] != null) { model.emailPws = row["emailPws"].ToString(); } if (row["smtp"] != null) { model.smtp = row["smtp"].ToString(); } if (row["coverPic"] != null) { model.coverPic = row["coverPic"].ToString(); } if (row["topPic"] != null) { model.topPic = row["topPic"].ToString(); } if (row["orderLimit"] != null && row["orderLimit"].ToString() != "") { model.orderLimit = int.Parse(row["orderLimit"].ToString()); } if (row["listMode"] != null && row["listMode"].ToString() != "") { if ((row["listMode"].ToString() == "1") || (row["listMode"].ToString().ToLower() == "true")) { model.listMode = true; } else { model.listMode = false; } } if (row["messageNotice"] != null && row["messageNotice"].ToString() != "") { model.messageNotice = int.Parse(row["messageNotice"].ToString()); } if (row["pwd"] != null) { model.pwd = row["pwd"].ToString(); } if (row["hotelIntroduct"] != null) { model.hotelIntroduct = row["hotelIntroduct"].ToString(); } if (row["orderRemark"] != null) { model.orderRemark = row["orderRemark"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["sortid"] != null && row["sortid"].ToString() != "") { model.sortid = int.Parse(row["sortid"].ToString()); } if (row["xplace"] != null && row["xplace"].ToString() != "") { model.xplace = decimal.Parse(row["xplace"].ToString()); } if (row["yplace"] != null && row["yplace"].ToString() != "") { model.yplace = decimal.Parse(row["yplace"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MxWeiXinPF.Model.wx_hotels_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_hotels_info set "); strSql.Append("wid=@wid,"); strSql.Append("hotelName=@hotelName,"); strSql.Append("hotelAddress=@hotelAddress,"); strSql.Append("hotelPhone=@hotelPhone,"); strSql.Append("mobilPhone=@mobilPhone,"); strSql.Append("noticeEmail=@noticeEmail,"); strSql.Append("emailPws=@emailPws,"); strSql.Append("smtp=@smtp,"); strSql.Append("coverPic=@coverPic,"); strSql.Append("topPic=@topPic,"); strSql.Append("orderLimit=@orderLimit,"); strSql.Append("listMode=@listMode,"); strSql.Append("messageNotice=@messageNotice,"); strSql.Append("pwd=@pwd,"); strSql.Append("hotelIntroduct=@hotelIntroduct,"); strSql.Append("orderRemark=@orderRemark,"); // strSql.Append("createDate=@createDate,"); strSql.Append("sortid=@sortid,"); strSql.Append("xplace=@xplace,"); strSql.Append("yplace=@yplace"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@hotelName", SqlDbType.VarChar, 300), new SqlParameter("@hotelAddress", SqlDbType.VarChar, 300), new SqlParameter("@hotelPhone", SqlDbType.VarChar, 100), new SqlParameter("@mobilPhone", SqlDbType.VarChar, 100), new SqlParameter("@noticeEmail", SqlDbType.VarChar, 100), new SqlParameter("@emailPws", SqlDbType.VarChar, 50), new SqlParameter("@smtp", SqlDbType.VarChar, 100), new SqlParameter("@coverPic", SqlDbType.VarChar, 200), new SqlParameter("@topPic", SqlDbType.VarChar, 200), new SqlParameter("@orderLimit", SqlDbType.Int, 4), new SqlParameter("@listMode", SqlDbType.Bit, 1), new SqlParameter("@messageNotice", SqlDbType.Int, 4), new SqlParameter("@pwd", SqlDbType.VarChar, 50), new SqlParameter("@hotelIntroduct", SqlDbType.VarChar, 200), new SqlParameter("@orderRemark", SqlDbType.VarChar, 200), // new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@sortid", SqlDbType.Int, 4), new SqlParameter("@xplace", SqlDbType.Float, 8), new SqlParameter("@yplace", SqlDbType.Float, 8), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.hotelName; parameters[2].Value = model.hotelAddress; parameters[3].Value = model.hotelPhone; parameters[4].Value = model.mobilPhone; parameters[5].Value = model.noticeEmail; parameters[6].Value = model.emailPws; parameters[7].Value = model.smtp; parameters[8].Value = model.coverPic; parameters[9].Value = model.topPic; parameters[10].Value = model.orderLimit; parameters[11].Value = model.listMode; parameters[12].Value = model.messageNotice; parameters[13].Value = model.pwd; parameters[14].Value = model.hotelIntroduct; parameters[15].Value = model.orderRemark; // parameters[16].Value = model.createDate; parameters[16].Value = model.sortid; parameters[17].Value = model.xplace; parameters[18].Value = model.yplace; parameters[19].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }