예제 #1
0
        public void rel(string f)
        {
            vis1.Clear();
            Account acc = MapPage._g;

            if (filter == FilterState.ALL)
            {
                layout_b.cardType = "default";
            }
            else if (filter == FilterState.B)
            {
                if (acc is Admins)
                {
                    layout_b.cardType = "admin";
                }
                else if (acc is Guests)
                {
                    layout_b.cardType = "booked";
                }
            }
            if (!string.IsNullOrEmpty(f))
            {
                f = f.ToLower();
                if (filter == FilterState.ALL)
                {
                    foreach (Products p in DBActions.products)
                    {
                        if (p.Quantity > 0)
                        {
                            Admins ad = DBActions._p(p);
                            if (ad != null)
                            {
                                if (ad.SName.ToLower().StartsWith(f))
                                {
                                    vis1.Add(new Binary {
                                        PRODUCT = p, ADMIN = ad
                                    });
                                }
                            }
                        }
                    }
                }
                else if (filter == FilterState.B)
                {
                    if (acc is Admins)
                    {
                        var acc1 = acc as Admins;
                        var list = DBActions._a(acc1);
                        foreach (Products p in list)
                        {
                            if (p.PName.ToLower().StartsWith(f))
                            {
                                vis1.Add(new Binary {
                                    PRODUCT = p
                                });
                            }
                        }
                    }
                }
            }
            else
            {
                if (filter == FilterState.ALL)
                {
                    foreach (Products p in DBActions.products)
                    {
                        if (p.Quantity > 0)
                        {
                            Binary b = new Binary {
                                PRODUCT = p
                            };
                            vis1.Add(b);
                        }
                    }
                }
                else if (filter == FilterState.B)
                {
                    if (acc is Admins)
                    {
                        var ap = DBActions._a(acc as Admins);
                        foreach (Products prd in ap)
                        {
                            vis1.Add(new Binary {
                                PRODUCT = prd
                            });
                        }
                    }
                    else
                    {
                        var ap  = DBActions.GetProducts(acc as Guests);
                        var ap1 = DBActions.GetQuantities(acc as Guests);
                        for (int x = 0; x < ap.Count; x++)
                        {
                            vis1.Add(new Binary {
                                PRODUCT  = ap[x],
                                QUANTITY = ap1[x], OWNER = acc as Guests
                            });
                        }
                    }
                }
            }
            layout_b.visible = vis1;
            if (MapPage.mapPage.current_state == FilterState.BOOKERS)
            {
                layout_b.OpenPage(1, FilterState.ALL);
            }
            else
            {
                layout_b.OpenPage(1, filter);
            }
        }