/// <summary> /// 增加一条数据 /// </summary> public int Add(Hotel_app.Model.X_yw_lang_type model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into X_yw_lang_type("); strSql.Append("yydh,qymc,language_bh,language_type)"); strSql.Append(" values ("); strSql.Append("@yydh,@qymc,@language_bh,@language_type)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@language_bh", SqlDbType.VarChar, 50), new SqlParameter("@language_type", SqlDbType.VarChar, 50) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.language_bh; parameters[3].Value = model.language_type; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hotel_app.Model.X_yw_lang_type model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update X_yw_lang_type set "); strSql.Append("yydh=@yydh,"); strSql.Append("qymc=@qymc,"); strSql.Append("language_bh=@language_bh,"); strSql.Append("language_type=@language_type"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@language_bh", SqlDbType.VarChar, 50), new SqlParameter("@language_type", SqlDbType.VarChar, 50), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.language_bh; parameters[3].Value = model.language_type; parameters[4].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hotel_app.Model.X_yw_lang_type GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,yydh,qymc,language_bh,language_type from X_yw_lang_type "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Hotel_app.Model.X_yw_lang_type model = new Hotel_app.Model.X_yw_lang_type(); 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]["language_bh"] != null && ds.Tables[0].Rows[0]["language_bh"].ToString() != "") { model.language_bh = ds.Tables[0].Rows[0]["language_bh"].ToString(); } if (ds.Tables[0].Rows[0]["language_type"] != null && ds.Tables[0].Rows[0]["language_type"].ToString() != "") { model.language_type = ds.Tables[0].Rows[0]["language_type"].ToString(); } return(model); } else { return(null); } }