예제 #1
0
        public ManageEmployeeSignUpsPage()
        {
            _client = new OMGITServiceClient(binding, EndPoint);

            _client.AddLogMessageMobileAsync("In Manage Employee Sign UPs Page", "", 0, GlobalData.loginData);

            //HeaderLayout.Children.Add(RemoveLabel);
            //HeaderLayout.Children.Add(HistoryLabel);
            //HeaderLayout.Children.Add(ClinicNameLabel);
            //HeaderLayout.Children.Add(EmployeeLabel);
            ManageGrid.RowDefinitions.Add(new RowDefinition {
                Height = 25
            });
            int i = 1;

            while (i <= PageSize + 1)
            {
                ManageGrid.RowDefinitions.Add(new RowDefinition {
                    Height = 35
                });
                i += 1;
            }
            ManageGrid.RowDefinitions.Add(new RowDefinition {
                Height = 35
            });


            ManageGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ManageGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ManageGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ManageGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ManageGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            ManageGrid.Children.Add(RemoveLabel, 0, 0);
            ManageGrid.Children.Add(HistoryLabel, 1, 0);
            ManageGrid.Children.Add(ClinicNameLabel, 2, 4, 0, 1);
            ManageGrid.Children.Add(EmployeeLabel, 4, 0);

            // ManageLayout.Children.Add(HeaderLayout);

            _client.Report_GetUserSignUpsWithTableIDCompleted += ClientReport_GetUserSignUpsWithTableIDCompleted;
            _client.Report_GetUserSignUpsWithTableIDAsync(GlobalData.loginData);

            while (UserLocations.Count < 1)
            {
                continue;
            }



            NumPages += UserLocations.Count / PageSize;

            i = 1;

            int remainder = UserLocations.Count % PageSize;

            while (i < NumPages)
            {
                System.Collections.Generic.Dictionary <int, OMGITWebServices.OMGUserSignupReportRow> temp = UserLocations.Skip((i - 1) * PageSize).Take(PageSize).ToDictionary(x => x.Key, x => x.Value);
                UserLocationsList.Add(temp);
                i += 1;
            }

            System.Collections.Generic.Dictionary <int, OMGITWebServices.OMGUserSignupReportRow> lastPage = UserLocations.Skip((i - 1) * PageSize).Take(remainder).ToDictionary(x => x.Key, x => x.Value);
            UserLocationsList.Add(lastPage);



            i = 1;

            foreach (KeyValuePair <int, OMGITWebServices.OMGUserSignupReportRow> kvp in UserLocationsList[0])
            {
                Dictionary <int, string> DeleteArg = new Dictionary <int, string>();
                DeleteArg.Add(kvp.Key, kvp.Value.EmployeeName);
                //var row = new StackLayout { Orintation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center };
                var EmpName = new Label {
                    HorizontalTextAlignment = TextAlignment.Start, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), Text = kvp.Value.EmployeeName, TextColor = Color.White, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Fill
                };
                var ClinicName = new Label {
                    HorizontalTextAlignment = TextAlignment.Start, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), Text = kvp.Value.ClinicName, TextColor = Color.White, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Fill
                };
                var DeleteButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.White, Text = "Delete", CommandParameter = DeleteArg
                };
                var ViewButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, TextColor = Color.White, Text = "View", CommandParameter = kvp.Value.EmployeeName
                };

                DeleteButton.Clicked += DeleteButton_Clicked;
                ViewButton.Clicked   += ViewButton_Clicked;

                ManageGrid.Children.Add(DeleteButton, 0, i);
                ManageGrid.Children.Add(ViewButton, 1, i);
                Grid.SetColumnSpan(ClinicName, 2);
                ManageGrid.Children.Add(ClinicName, 2, 4, i, i + 1);
                ManageGrid.Children.Add(EmpName, 4, i);


                i += 1;

                //row.Children.Add(DeleteButton);
                //row.Children.Add(ViewButton);
                //row.Children.Add(ClinicName);
                //row.Children.Add(tableID);
                //row.Children.Add(EmpName);
                //ManageLayout.Children.Add(row);
            }

            //ManageLayout.Children.Add(FooterLayout);

            //Grid.SetColumnSpan(FooterLayout, 4);

            var FirstPageButton = new Button();
            var PrevPageButton  = new Button();
            var CurPageButton   = new Button();
            var NextPageButton  = new Button();
            var LastPageButton  = new Button();

            if (Device.OS == TargetPlatform.Android)
            {
                FirstPageButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "<<", IsEnabled = false
                };
                PrevPageButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "< Prev", IsEnabled = false
                };
                CurPageButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = CurrentPage.ToString() + "/" + NumPages.ToString()
                };
                if (NumPages == 1)
                {
                    NextPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "Next >", IsEnabled = false
                    };
                    LastPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = ">>", IsEnabled = false
                    };
                }
                else
                {
                    NextPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = "Next >"
                    };
                    LastPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.FromHex("14986D"), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.White, Text = ">>"
                    };
                }
            }
            else
            {
                FirstPageButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "<<", IsEnabled = false
                };
                PrevPageButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "< Prev", IsEnabled = false
                };
                CurPageButton = new Button {
                    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = CurrentPage.ToString() + "/" + NumPages.ToString()
                };
                if (NumPages == 1)
                {
                    NextPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "Next >", IsEnabled = false
                    };
                    LastPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = ">>", IsEnabled = false
                    };
                }
                else
                {
                    NextPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = "Next >"
                    };
                    LastPageButton = new Button {
                        FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Button)), BackgroundColor = Color.White, VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, TextColor = Color.Black, Text = ">>"
                    };
                }
            }

            FirstPageButton.Clicked += FirstPageButton_Clicked;
            PrevPageButton.Clicked  += PrevPageButton_Clicked;
            NextPageButton.Clicked  += NextPageButton_Clicked;
            LastPageButton.Clicked  += LastPageButton_Clicked;


            //FooterLayout.Children.Add(FirstPageButton);
            //FooterLayout.Children.Add(PrevPageButton);
            //FooterLayout.Children.Add(CurPageButton);
            //FooterLayout.Children.Add(NextPageButton);
            //FooterLayout.Children.Add(LastPageButton);

            ManageGrid.Children.Add(FirstPageButton, 0, PageSize + 2);
            ManageGrid.Children.Add(PrevPageButton, 1, PageSize + 2);
            ManageGrid.Children.Add(CurPageButton, 2, PageSize + 2);
            ManageGrid.Children.Add(NextPageButton, 3, PageSize + 2);
            ManageGrid.Children.Add(LastPageButton, 4, PageSize + 2);


            //ManageGrid.Children.Add(FooterLayout, 0, 3, 102, 103);


            //ManageScrollView.Content = ManageLayout;

            Logout.Clicked += Logout_Clicked;

            ManageLayout.Children.Add(Logout);
            ManageLayout.Children.Add(ManageGrid);

            ManageScrollView.Content = ManageLayout;

            Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

            Content = ManageScrollView;
        }