コード例 #1
0
        private void GeneratingLayout()
        {
            try
            {
                Seats = new ObservableCollection <SeatProperties>();
                IEnumerable <Seat> objScreenSeats = new SeatLayoutConfig().GetScreeSeats(Convert.ToInt32(cmbScreen.SelectedValue), 0, (cmbMovieTime.SelectedItem as Movie).Id);

                int columns = objScreenSeats.ToList <Seat>().Max(w => w.ColumnValue);

                var groupList = objScreenSeats.ToList <Seat>().GroupBy(l => l.ScreenClassId)
                                .Select(cl => new Seat
                {
                    ScreenClassId = cl.First().ScreenClassId,
                    RowValue      = cl.Max(c => c.RowValue),
                    ColumnValue   = cl.Max(c => c.ColumnValue),
                    DisplayOrder  = cl.First().DisplayOrder,
                    ScreenClass   = cl.First().ScreenClass
                }).ToList();

                int rowsforAllClasses = groupList.Sum(w => w.RowValue);
                foreach (Seat objscreenClass in groupList.OrderBy(w => w.DisplayOrder))
                {
                    int rows = objscreenClass.RowValue;
                    IEnumerable <Seat> objSubClassSeatsList = objScreenSeats.Where(w => w.ScreenClassId == objscreenClass.ScreenClassId);

                    Seats.Add(new SeatProperties()
                    {
                        CheckboxVisibility = Visibility.Visible,
                        Column             = objscreenClass.ScreenClassId,
                        ColumnText         = Convert.ToString(objscreenClass.ScreenClassId),
                        DisplayText        = objscreenClass.ScreenClass,
                        Id              = 0,
                        IsChecked       = false,
                        IsEnabled       = false,
                        Row             = objscreenClass.ScreenClassId,
                        RowNum          = objscreenClass.ScreenClassId,
                        RowText         = Convert.ToString(objscreenClass.ScreenClassId),
                        ScreenClassId   = objSubClassSeatsList.FirstOrDefault().ScreenClassId,
                        SeatColor       = Helper.ReturnColor("INACTIVE"),
                        SeatHeight      = 25,
                        SeatOrientation = Orientation.Horizontal,
                        SeatWidth       = (25 * columns) + 50,
                        TextVisibility  = Visibility.Visible,
                        VendorId        = objscreenClass.VendorId
                    });

                    for (int row = 1; row <= rows; row++)
                    {
                        GenerateRowNameColumn(objSubClassSeatsList.Where(w => w.RowValue == row).FirstOrDefault(), true, false);
                        foreach (Seat objSeat in objSubClassSeatsList.Where(w => w.RowValue == row).OrderBy(w => w.ColumnValue))
                        {
                            GenerateRowNameColumn(objSeat, false, objSeat.IsReserved != 1);
                        }

                        int currentRowColumns = objSubClassSeatsList.ToList <Seat>().Where(w => w.RowValue == row).Count() > 0 ? objSubClassSeatsList.ToList <Seat>().Where(w => w.RowValue == row).Count() : 0;

                        if (groupList.Where(w => w.ColumnValue == columns).Count() != groupList.Count())
                        {
                            currentRowColumns = currentRowColumns - 1;
                        }

                        if (currentRowColumns > 0 && currentRowColumns < columns)
                        {
                            for (int i = currentRowColumns; i <= columns; i++)
                            {
                                GenerateRowNameColumn(new Seat(), false, false);
                            }
                        }
                    }
                }

                foreach (Seat objSeat in groupList)
                {
                    SeatProperties objGroupSeat = Seats.Where(x => x.Id == 0 && x.ScreenClassId == objSeat.ScreenClassId).FirstOrDefault();

                    objGroupSeat.DisplayText = string.Format("{0} - {1}", objSeat.ScreenClass, Seats.Where(x => x.Id != 0 && x.ScreenClassId == objSeat.ScreenClassId).FirstOrDefault().TicketCost);
                }

                itmSeats.Width       = (25 * (columns + (groupList.Count > 1 ? 2 : 1)));
                itmSeats.Height      = (30 * (rowsforAllClasses + groupList.Count()));
                itmSeats.ItemsSource = Seats;

                ManageLoadingDataVisibility(false);
            }
            catch (Exception ex)
            {
                ManageLoadingDataVisibility(false);
                LogExceptions.LogException(ex);
            }
        }
コード例 #2
0
        private void LoadBookedTickets()
        {
            try
            {
                if (lstTimes.SelectedItem == null)
                {
                    return;
                }

                IEnumerable <Seat> objScreenSeats = new SeatLayoutConfig().GetShowTickets(Convert.ToInt32(lstScreen.SelectedValue), Convert.ToInt32((lstTimes.SelectedItem as Movie).Id));
                foreach (Seat obj in objScreenSeats)
                {
                    Seats.Where(x => x.Id == obj.ID).ToList <SeatProperties>().ForEach(w =>
                    {
                        w.IsEnabled  = obj.Is_Enabled;
                        w.TicketCost = obj.Price;
                        w.IsChecked  = !obj.Is_Enabled;
                        w.SeatColor  = Helper.ReturnColor(obj.Color);
                    });
                }

                var groupList = Seats.Where(l => l.ScreenClassId != 0).GroupBy(l => l.ScreenClassId)
                                .Select(cl => new Seat
                {
                    ScreenClassId = cl.First().ScreenClassId,
                    ScreenClass   = cl.First().ScreenClass,
                    Price         = cl.First().TicketCost
                }).ToList();

                brdClass2.Visibility     =
                    brdClass3.Visibility = txbClass2.Visibility = txbClass3.Visibility = Visibility.Collapsed;

                int i = 0;

                foreach (Seat objSeat in groupList)
                {
                    if (i == 0)
                    {
                        txbClass1.Text = string.Format("{0}  -  {1} Sold ({2} Rs), {3} Available", objSeat.ScreenClass, objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "RESERVED").Count(), objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "RESERVED").Sum(w => w.Price), objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "ACTIVE").Count());
                    }
                    else if (i == 1)
                    {
                        txbClass2.Visibility     =
                            brdClass2.Visibility = Visibility.Visible;

                        txbClass2.Text = string.Format("{0}  -  {1} Sold ({2} Rs), {3} Available", objSeat.ScreenClass, objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "RESERVED").Count(), objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "RESERVED").Sum(w => w.Price), objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "ACTIVE").Count());
                    }
                    else if (i == 2)
                    {
                        txbClass3.Visibility     =
                            brdClass3.Visibility = Visibility.Visible;
                        txbClass3.Text           = string.Format("{0}  -  {1} Sold ({2} Rs), {3} Available", objSeat.ScreenClass, objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "RESERVED").Count(), objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "RESERVED").Sum(w => w.Price), objScreenSeats.Where(w => w.ScreenClassId == objSeat.ScreenClassId && w.Color == "ACTIVE").Count());
                    }

                    SeatProperties objGroupSeat = Seats.Where(x => x.Id == 0 && x.ScreenClassId == objSeat.ScreenClassId).FirstOrDefault();

                    objGroupSeat.DisplayText = string.Format("{0} - {1}", objSeat.ScreenClass, Seats.Where(x => x.Id != 0 && x.CheckboxVisibility == Visibility.Visible && x.ScreenClassId == objSeat.ScreenClassId).FirstOrDefault().TicketCost);

                    i++;
                }
            }
            catch (Exception ex)
            {
                ManageLoadingDataVisibility(false);
                LogExceptions.LogException(ex);
            }
        }