public void saveScreen(int id, string title, string description, DateTime date, SQLiteConnection con) { string longSeatsUpper = "", longSeatsDress = "", longSeatsStall = ""; foreach (Seat s in upperSeats) { longSeatsUpper += s.seatToString() + ","; } if (longSeatsUpper.Length > 1) { longSeatsUpper = longSeatsUpper.Remove(longSeatsUpper.Length - 1); } foreach (Seat s in dressSeats) { longSeatsDress += s.seatToString() + ","; } if (longSeatsDress.Length > 1) { longSeatsDress = longSeatsDress.Remove(longSeatsDress.Length - 1); } foreach (Seat s in stallsSeats) { longSeatsStall += s.seatToString() + ","; } if (longSeatsStall.Length > 1) { longSeatsStall = longSeatsStall.Remove(longSeatsStall.Length - 1); } string dateString = new dateConverter().dateToString(date); string sql = "REPLACE INTO Performances (Id, Title, Description, Date, seatsUpper, seatsDress, seatsStalls, priceUpper, priceDress, priceStalls) VALUES (@Id, @Title, @Description, @Date, @seatsUpper, @seatsDress, @seatsStalls, @priceUpper, @priceDress, @priceStalls)"; SQLiteCommand com = new SQLiteCommand(sql, con); com.Parameters.AddWithValue("@Id", id); com.Parameters.AddWithValue("@Title", title); com.Parameters.AddWithValue("@Description", description); com.Parameters.AddWithValue("@Date", dateString); com.Parameters.AddWithValue("@SeatsUpper", longSeatsUpper); com.Parameters.AddWithValue("@seatsDress", longSeatsDress); com.Parameters.AddWithValue("@seatsStalls", longSeatsStall); com.Parameters.AddWithValue("@priceUpper", getUpperPrice().ToString()); com.Parameters.AddWithValue("@priceDress", getDressPrice().ToString()); com.Parameters.AddWithValue("@priceStalls", getStallsPrice().ToString()); try { com.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public Reservation stringToReservation(string resLong) { string[] split = resLong.Split('|'); if (split.Length != 4) { throw new ArgumentOutOfRangeException(); } else { string perf = split[0]; List <Seat> listSeats = new Seat().stringToSeatList(split[1]); bool paid = Convert.ToBoolean(int.Parse(split[2])); DateTime date = new dateConverter().stringToDate(split[3]); return(new Reservation(perf, listSeats, paid, date)); } }