public void getMaps(string trv_no) { // trv_no를 통해 해당 travel의 travel_day list를 가져옴 Travel_Day inTravel_Day = new Travel_Day(); Travel_DayDao travel_DayDao = new Travel_DayDao(); inTravel_Day.Trv_no = trv_no; List <Travel_Day> travel_Days = travel_DayDao.selectTravelDayListByTrvNo(inTravel_Day); //Travel_day_no를 이용하여 Map을 가져올 준비 Map inMap = new Map(); MapDao mapDao = new MapDao(); Map tmpMap; List <Map> maps = new List <Map>(); foreach (var travel_day in travel_Days) { inMap.Trv_day_no = travel_day.Trv_day_no; tmpMap = new Map(); tmpMap = mapDao.selectMapByTrv_day_no(inMap); maps.Add(tmpMap); } Context.Response.Write(JsonConvert.SerializeObject(maps)); }
public Travel_Day selectTrvel_DayBytrv_day_no(Travel_Day travel_Day) { MyDB mydb = new MyDB(); Travel_Day result = new Travel_Day(); MySqlConnection con = null; MySqlDataReader rd = null; try { con = mydb.GetCon(); string Sql = "SELECT * FROM toourshared.travel_day where trv_day_no=@trv_day_no"; MySqlCommand cmd = new MySqlCommand(Sql, con); cmd.Parameters.AddWithValue("@trv_day_no", travel_Day.Trv_day_no); con.Open(); rd = cmd.ExecuteReader(); if (rd.Read()) { result.Trv_day_no = rd["trv_day_no"].ToString(); result.Trv_day_content = rd["trv_day_content"].ToString(); result.Trv_no = rd["trv_no"].ToString(); } rd.Close(); con.Close(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace.ToString()); rd.Close(); con.Close(); } finally { rd.Close(); con.Close(); } return(result); }
public List <Travel_Day> selectTravelDayListByTrvNo(Travel_Day travel_day) { MyDB mydb = new MyDB(); List <Travel_Day> returnList = new List <Travel_Day>(); Travel_Day result; MySqlConnection con = null; MySqlDataReader reader = null; try { con = mydb.GetCon(); string Sql = "SELECT * FROM toourshared.travel_day WHERE trv_no = @trv_no order by trv_day_no asc"; // 게시글 번호에 해당하는 데이터 여러개를 긁어오는 SQL MySqlCommand cmd = new MySqlCommand(Sql, con); cmd.Parameters.AddWithValue("@trv_no", travel_day.Trv_no); con.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { result = new Travel_Day(); result.Trv_day_no = reader["trv_day_no"].ToString(); result.Trv_day_content = reader["trv_day_content"].ToString(); result.Trv_no = reader["trv_day_content"].ToString(); returnList.Add(result); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace.ToString()); reader.Close(); con.Close(); } finally { reader.Close(); con.Close(); } return(returnList); }
public string InsertTravel_Day(Travel_Day travel_day) { string result = ""; MySqlConnection con = null; try { MyDB myDB = new MyDB(); con = myDB.GetCon(); string Sql = "INSERT INTO toourshared.travel_day (trv_day_content,trv_no)" + "VALUES (@trv_day_content,@trv_no)"; MySqlCommand cmd = new MySqlCommand(Sql, con); cmd.Parameters.AddWithValue("@trv_day_content", travel_day.Trv_day_content); cmd.Parameters.AddWithValue("@trv_no", travel_day.Trv_no); con.Open(); cmd.ExecuteNonQuery(); result = cmd.LastInsertedId.ToString(); con.Close(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace.ToString()); con.Close(); } finally { con.Close(); } return(result); }
public int UpdatetTravel_Day(Travel_Day travel_day) { int result = 0; MyDB myDB = new MyDB(); MySqlConnection con = myDB.GetCon(); try { string Sql = "UPDATE toourshared.travel_day SET trv_no =@trv_no, trv_day_content =@trv_day_content WHERE Trv_day_no =@trv_day_no"; MySqlCommand cmd = new MySqlCommand(Sql, con); cmd.Parameters.AddWithValue("@trv_no", travel_day.Trv_no); cmd.Parameters.AddWithValue("@trv_day_no", travel_day.Trv_day_no); cmd.Parameters.AddWithValue("@trv_day_content", travel_day.Trv_day_content); con.Open(); result = cmd.ExecuteNonQuery(); con.Close(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace.ToString()); con.Close(); } finally { con.Close(); } return(result); }