Ejemplo n.º 1
0
        public async void GetErrorCodes()
        {
            try
            {
                var result = Dbcontext.GetICErrorCodes(Application.Current.Properties["UN"].ToString(),
                                                       Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(),
                                                       Convert.ToInt32(Application.Current.Properties["CompanyId"].ToString()));
                ErrorCodeMainGroups = new ObservableCollection <ICErrorCodeMainGroupCls>();
                ICErrorCodeMainGroupCls maingroup;
                ICErrorCodeGroupCls     group;
                ICErrorCodeCls          code;


                if (result != null)
                {
                    if (result.Length > 0)
                    {
                        foreach (ServiceReference1.ICErrorCodeMainGroupData data in result)
                        {
                            maingroup        = new ICErrorCodeMainGroupCls();
                            maingroup.Id     = data.Id;
                            maingroup.Name   = data.Name;
                            maingroup.Groups = new ObservableCollection <ICErrorCodeGroupCls>();

                            foreach (ServiceReference1.ICErrorCodeGroupData gdata in data.Groups)
                            {
                                group           = new ICErrorCodeGroupCls();
                                group.Id        = gdata.Id;
                                group.Name      = gdata.Name;
                                group.MainGroup = maingroup;
                                group.Codes     = new ObservableCollection <ICErrorCodeCls>();

                                foreach (ServiceReference1.ICErrorCodeData cdata in gdata.Codes)
                                {
                                    code       = new ICErrorCodeCls();
                                    code.Id    = cdata.Id;
                                    code.Code  = cdata.Code;
                                    code.Group = group;
                                    group.Codes.Add(code);
                                }

                                maingroup.Groups.Add(group);
                            }
                            ErrorCodeMainGroups.Add(maingroup);
                        }
                    }
                }
                GetControlRows();
            }
            catch (Exception e)
            {
                IsBusy = false;
                await Application.Current.MainPage.DisplayAlert("Fel", e.Message, "Stäng");
            }
        }