/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hotel_app.Model.Szw_zz_fj_temp model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Szw_zz_fj_temp set "); strSql.Append("yydh=@yydh,"); strSql.Append("qymc=@qymc,"); strSql.Append("jzbh=@jzbh,"); strSql.Append("id_app=@id_app,"); strSql.Append("lsbh=@lsbh,"); strSql.Append("czy=@czy,"); strSql.Append("is_top=@is_top,"); strSql.Append("is_select=@is_select,"); strSql.Append("czsj=@czsj"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@jzbh", SqlDbType.VarChar, 50), new SqlParameter("@id_app", SqlDbType.VarChar, 50), new SqlParameter("@lsbh", SqlDbType.VarChar, 50), new SqlParameter("@czy", SqlDbType.VarChar, 50), new SqlParameter("@is_top", SqlDbType.Bit, 1), new SqlParameter("@is_select", SqlDbType.Bit, 1), new SqlParameter("@czsj", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.jzbh; parameters[3].Value = model.id_app; parameters[4].Value = model.lsbh; parameters[5].Value = model.czy; parameters[6].Value = model.is_top; parameters[7].Value = model.is_select; parameters[8].Value = model.czsj; parameters[9].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hotel_app.Model.Szw_zz_fj_temp model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Szw_zz_fj_temp("); strSql.Append("yydh,qymc,jzbh,id_app,lsbh,czy,is_top,is_select,czsj)"); strSql.Append(" values ("); strSql.Append("@yydh,@qymc,@jzbh,@id_app,@lsbh,@czy,@is_top,@is_select,@czsj)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@jzbh", SqlDbType.VarChar, 50), new SqlParameter("@id_app", SqlDbType.VarChar, 50), new SqlParameter("@lsbh", SqlDbType.VarChar, 50), new SqlParameter("@czy", SqlDbType.VarChar, 50), new SqlParameter("@is_top", SqlDbType.Bit, 1), new SqlParameter("@is_select", SqlDbType.Bit, 1), new SqlParameter("@czsj", SqlDbType.DateTime) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.jzbh; parameters[3].Value = model.id_app; parameters[4].Value = model.lsbh; parameters[5].Value = model.czy; parameters[6].Value = model.is_top; parameters[7].Value = model.is_select; parameters[8].Value = model.czsj; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hotel_app.Model.Szw_zz_fj_temp GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,yydh,qymc,jzbh,id_app,lsbh,czy,is_top,is_select,czsj from Szw_zz_fj_temp "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Hotel_app.Model.Szw_zz_fj_temp model = new Hotel_app.Model.Szw_zz_fj_temp(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["yydh"] != null && ds.Tables[0].Rows[0]["yydh"].ToString() != "") { model.yydh = ds.Tables[0].Rows[0]["yydh"].ToString(); } if (ds.Tables[0].Rows[0]["qymc"] != null && ds.Tables[0].Rows[0]["qymc"].ToString() != "") { model.qymc = ds.Tables[0].Rows[0]["qymc"].ToString(); } if (ds.Tables[0].Rows[0]["jzbh"] != null && ds.Tables[0].Rows[0]["jzbh"].ToString() != "") { model.jzbh = ds.Tables[0].Rows[0]["jzbh"].ToString(); } if (ds.Tables[0].Rows[0]["id_app"] != null && ds.Tables[0].Rows[0]["id_app"].ToString() != "") { model.id_app = ds.Tables[0].Rows[0]["id_app"].ToString(); } if (ds.Tables[0].Rows[0]["lsbh"] != null && ds.Tables[0].Rows[0]["lsbh"].ToString() != "") { model.lsbh = ds.Tables[0].Rows[0]["lsbh"].ToString(); } if (ds.Tables[0].Rows[0]["czy"] != null && ds.Tables[0].Rows[0]["czy"].ToString() != "") { model.czy = ds.Tables[0].Rows[0]["czy"].ToString(); } if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "") { if ((ds.Tables[0].Rows[0]["is_top"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_top"].ToString().ToLower() == "true")) { model.is_top = true; } else { model.is_top = false; } } if (ds.Tables[0].Rows[0]["is_select"] != null && ds.Tables[0].Rows[0]["is_select"].ToString() != "") { if ((ds.Tables[0].Rows[0]["is_select"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_select"].ToString().ToLower() == "true")) { model.is_select = true; } else { model.is_select = false; } } if (ds.Tables[0].Rows[0]["czsj"] != null && ds.Tables[0].Rows[0]["czsj"].ToString() != "") { model.czsj = DateTime.Parse(ds.Tables[0].Rows[0]["czsj"].ToString()); } return(model); } else { return(null); } }