public void InfoForListBox() { using (course_work cw = new course_work()) { var info = cw.Session.ToList(); infoforsession = new ObservableCollection <AppViewSession>(); foreach (var i in info) { if (i.date == DateSession && i.filmID.Trim() == FilmID.Trim()) { AppViewSession allSession = new AppViewSession(); var forBD = cw.Database.SqlQuery <Film>($"select * from film where Film.filmID = '{i.filmID}'"); foreach (var check in forBD) { allSession.InfoForListBox(i.sessionID, i.filmID, i.date, i.time, i.hallID, i.number_of_free_seats, i.price_for_place, check.filmName); infoforsession.Add(allSession); } } } ListBoxSession.ItemsSource = infoforsession; } }
public void InfoForListBox() { TimeSpan timenow = new TimeSpan(0, 0, 0); try { StringBuilder bild = new StringBuilder($"{DateTime.Now}"); Console.WriteLine(bild); bild.Remove(0, 11); bild.Remove(2, 6); StringBuilder bild2 = new StringBuilder($"{DateTime.Now}"); bild2.Remove(0, 14); bild2.Remove(2, 3); string strr1 = Convert.ToString(bild); string strr2 = Convert.ToString(bild2); int h = Convert.ToInt32(strr1); int min = Convert.ToInt32(strr2); timenow = new TimeSpan(h, min, 0); } catch (Exception) { StringBuilder bild = new StringBuilder($"{DateTime.Now}"); Console.WriteLine(bild); bild.Remove(0, 11); bild.Remove(1, 6); StringBuilder bild2 = new StringBuilder($"{DateTime.Now}"); bild2.Remove(0, 13); bild2.Remove(2, 3); string strr1 = Convert.ToString(bild); string strr2 = Convert.ToString(bild2); int h = Convert.ToInt32(strr1); int min = Convert.ToInt32(strr2); timenow = new TimeSpan(h, min, 0); } using (SQL_course_work cw = new SQL_course_work()) { var info = cw.Session.ToList(); infoforsession = new ObservableCollection <AppViewSession>(); foreach (var i in info) { if (i.date == DateSession && i.filmID == FilmID) { if (timenow < i.time) { AppViewSession allSession = new AppViewSession(); var forBD = cw.Database.SqlQuery <Film>($"select * from film where Film.filmID = '{i.filmID}'"); foreach (var check in forBD) { allSession.InfoForListBox(i.sessionID, i.filmID, i.date, i.time, i.hallID, i.number_of_free_seats, i.price_for_place, check.filmName, i.End_date, i.End_time); infoforsession.Add(allSession); } } } } ListBoxSession.ItemsSource = infoforsession; } }