Ejemplo n.º 1
0
        private void atbHallSearch_SelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var obj = atbHallSearch.SelectedItem as string;

            for (int i = 0; i < datagrid.Items.Count; i++)
            {
                rows.Add((DataGridRow)datagrid.ItemContainerGenerator.ContainerFromIndex(i));
            }
            if (obj != null)
            {
                hall newHall = hall.SelectById(halls.FirstOrDefault(h => h.Value.Equals(obj)).Key);
                rows.ForEach(r =>
                {
                    if (((price_list)r.Item).hall_id != newHall.id)
                    {
                        r.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        r.Visibility = Visibility.Visible;
                    }
                });
            }
            else
            {
                rows.ForEach(r => r.Visibility = Visibility.Visible);
            }
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            hall hall = db.hall.Find(id);

            db.hall.Remove(hall);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            hall hall = await db.halls.FindAsync(id);

            db.halls.Remove(hall);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        private void atbHallSearch_SelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var obj = atbHallSearch.SelectedItem as string;

            if (obj != null)
            {
                hall newHall = hall.SelectById(halls.FirstOrDefault(h => h.Value.Equals(obj)).Key);
            }
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "name_hall,capacity,holl_id")] hall hall)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hall).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hall));
 }
Ejemplo n.º 6
0
        public async Task <ActionResult> Create([Bind(Include = "Id,date_of_session,filmname,time_of_session,hallname,hallId,filmId,price_of_tickets")] sessions sessions)
        {
            if (ModelState.IsValid)
            {
                var film = db.films.Where(c => c.Id == sessions.filmId).FirstOrDefault();

                if (DateTime.Parse(sessions.date_of_session) >= DateTime.Parse(film.release_date))
                {
                    string todaydate = DateTime.Today.ToString("yyyy.MM.dd");
                    int    dd        = DateTime.Parse(todaydate).CompareTo(DateTime.Parse(sessions.date_of_session));
                    if (dd <= 0)
                    {
                        db.session.Add(sessions);
                        await db.SaveChangesAsync();

                        hall current_hall = db.halls
                                            .Where(d => d.Id == sessions.hallId).FirstOrDefault();
                        film current_film = db.films
                                            .Where(d => d.Id == sessions.filmId).FirstOrDefault();
                        int number_rows  = current_hall.number_of_rows;
                        int number_seats = current_hall.number_of_seats_in_a_row;
                        for (int i = 1; i < number_rows + 1; i++)
                        {
                            for (int j = 1; j < number_seats + 1; j++)
                            {
                                places place = new places();
                                {
                                    place.sessionsId              = sessions.Id;
                                    place.number_of_row           = i;
                                    place.number_of_seat_in_a_row = j;
                                    place.status = "Свободно";

                                    //place.date_of_operation = DateTime.Now;
                                };

                                db.places_list.Add(place);
                                await db.SaveChangesAsync();
                            }
                        }
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("date_of_session", "Неверная дата начала сеанса. Введите коррекную дату(Нельзя задать прошедший день)");
                    }
                }
                else
                {
                    ModelState.AddModelError("date_of_session", "Неверная дата начала сеанса. Введите коррекную дату(позднее даты релиза фильма)");
                }
            }
            ViewBag.filmId = new SelectList(db.films, "Id", "film_name", sessions.filmId);
            ViewBag.hallId = new SelectList(db.halls, "Id", "hall_name", sessions.hallId);
            return(View(sessions));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "name_hall,capacity,holl_id")] hall hall)
        {
            if (ModelState.IsValid)
            {
                db.hall.Add(hall);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hall));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "id,name")] hall hall)
        {
            if (ModelState.IsValid)
            {
                db.halls.Add(hall);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hall));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,hall_name,type,number_of_rows,number_of_seats_in_a_row")] hall hall)
        {
            if (ModelState.IsValid)
            {
                db.Entry(hall).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(hall));
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> Create([Bind(Include = "hall_name,type,number_of_rows,number_of_seats_in_a_row")] hall hall)
        {
            if (ModelState.IsValid)
            {
                db.halls.Add(hall);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(hall));
        }
Ejemplo n.º 11
0
        private void atbHallSearch_SelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var obj = atbHallSearch.SelectedItem as string;

            if (obj != null)
            {
                hall oldHall = hall.SelectById(halls.FirstOrDefault(h => h.Value.Equals(obj)).Key);
                EntityFactory.Hall     = oldHall;
                TextBox_NazivSale.Text = oldHall.name;
                EntityFactory.Hall.price_lists.Cast <price_list>().ToList().ForEach(p => p.daySr = items[(int)Enum.Parse(typeof(DayInWeek), p.day)]);
                datagrid.ItemsSource = oldHall.price_lists;
                editPricelist        = true;
            }
        }
Ejemplo n.º 12
0
        // GET: halls/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hall hall = db.hall.Find(id);

            if (hall == null)
            {
                return(HttpNotFound());
            }
            return(View(hall));
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hall hall = await db.halls.FindAsync(id);

            if (hall == null)
            {
                return(HttpNotFound());
            }
            return(View(hall));
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hall hall = await db.halls.FindAsync(id);

            if (hall == null)
            {
                return(HttpNotFound());
            }
            SelectList types = new SelectList(db.types, "Hall_Type", "Hall_Type");

            ViewBag.Types = types;
            return(View(hall));
        }
Ejemplo n.º 15
0
        // GET: /Halls/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Session["logged"] == null)
            {
                return(RedirectToAction("Index", "login", null));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hall hall = db.halls.Find(id);

            if (hall == null)
            {
                return(HttpNotFound());
            }
            return(View(hall));
        }
Ejemplo n.º 16
0
        private void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            BindingExpression bindingExpr2 = TextBox_NazivSale.GetBindingExpression(TextBox.TextProperty);

            bindingExpr2.UpdateSource();
            if (!bindingExpr2.HasValidationError)
            {
                hall newHall = EntityFactory.CreateHall(TextBox_NazivSale.Text, datagrid.Items.Cast <price_list>().ToList());
                if (Label_CreateHall.Content.Equals("Kreiranje sale"))
                {
                    hall.Insert(newHall);
                }
                else
                {
                    hall.Update(newHall, EntityFactory.Hall.id);
                }
            }
            delete();
        }
Ejemplo n.º 17
0
        private void Add_Term_Click(object sender, RoutedEventArgs e)
        {
            BindingExpression timeFromV  = tpTimeFrom.GetBindingExpression(TimePicker.TextProperty);
            BindingExpression timeUntilV = tpTimeUntil.GetBindingExpression(TimePicker.TextProperty);

            if (tpTimeFrom.SelectedTime == null)
            {
                AddError(timeFromV, "Morate unijeti vrijeme pocetka");
                return;
            }
            if (tpTimeUntil.SelectedTime == null)
            {
                AddError(timeUntilV, "Morate unijeti vrijeme kraja");
                return;
            }

            RemoveError(timeFromV);
            RemoveError(timeUntilV);

            var obj       = atbHallSearch.SelectedItem as string;
            var dates     = calendar.SelectedDates;
            var note      = notes.Text;
            var timeFrom  = (DateTime)tpTimeFrom.SelectedTime;
            var timeUntil = (DateTime)tpTimeUntil.SelectedTime;

            if (timeFrom > timeUntil)
            {
                AddError(timeUntilV, "Morate unijeti validno vrijeme kraja");
                return;
            }
            else
            {
                RemoveError(timeUntilV);
            }



            TimeSpan timeFromTS  = new TimeSpan(timeFrom.Hour, timeFrom.Minute, timeFrom.Second);
            TimeSpan timeUntilTS = new TimeSpan(timeUntil.Hour, timeUntil.Minute, timeUntil.Second);
            hall     newHall     = null;

            if (obj != null)
            {
                newHall = hall.SelectById(halls.FirstOrDefault(h => h.Value.Equals(obj)).Key);
            }
            if (newHall != null)
            {
                if (dates != null)
                {
                    if (ChangeTerm)
                    {
                        term selected = (term)termDatagrid.SelectedItem;
                        int  index    = termIndex;
                        var  newTerm  = new term(newHall.id, (DateTime)calendar.SelectedDate, timeFromTS, timeUntilTS, itemDatagrid.Items.Cast <item_list>().ToList(), note);
                        if (term.SelectAll().Where(t => t.hall_id == ((term)newTerm).hall_id && t.rental_date.CompareTo(((term)newTerm).rental_date) == 0 &&
                                                   t.rent_time_end.CompareTo(((term)newTerm).rent_time_start) == 1).ToList().Count > 0)
                        {
                            newTerm.status = true;
                        }
                        terms[terms.IndexOf(selected)] = newTerm;
                        termDatagrid.Items.Refresh();
                        ChangeTerm = false;
                    }
                    else
                    {
                        terms = new ObservableCollection <term>();
                        dates.ToList().ForEach(d => {
                            List <item_list> items = new List <item_list>();
                            itemDatagrid.Items.Cast <item_list>().ToList().ForEach(i => items.Add(new item_list(i.item_id, i.quantity)));
                            var newTerm = new term(newHall.id, d, timeFromTS, timeUntilTS, items, note);
                            if (term.SelectAll().Where(t => t.hall_id == ((term)newTerm).hall_id && t.rental_date.CompareTo(((term)newTerm).rental_date) == 0 &&
                                                       t.rent_time_end.CompareTo(((term)newTerm).rent_time_start) == 1).ToList().Count > 0)
                            {
                                newTerm.status = true;
                                terms.Insert(0, newTerm);
                            }
                            else
                            {
                                terms.Add(newTerm);
                            }
                        });
                        termDatagrid.ItemsSource = terms;
                        expander.IsExpanded      = false;
                    }
                    if (terms.Count > 0 && terms.Where(t => t.status == true).ToList().Count > 0)
                    {
                        lbTermError.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        lbTermError.Visibility = Visibility.Hidden;
                    }
                    itemDatagrid.Items.Clear();
                    tbHallSearch.Text        = "";
                    txtCalendar.Text         = "Odaberite datum";
                    tpTimeFrom.SelectedTime  = null;
                    tpTimeUntil.SelectedTime = null;
                    notes.Text = "";
                }
            }
        }
 private IHall ToHall(hall hall)
 {
     return(new Hall(hall.halId, hall.halName, hall.halSitscount, hall.cinemaId));
 }
Ejemplo n.º 19
0
 public int RegisterHall(hall h)
 {
     db.halls.Add(h);
     db.SaveChanges();
     return(1);
 }