コード例 #1
0
        public Atributo RelacionAtributo()
        {
            if (atrib.DirIndice == -1)
            {
                return(null);
            }
            string[] arch = Fullname.Split('\\');
            string   dicc = base.Fullname.Substring(0, Fullname.LastIndexOf('\\')) + '\\' + arch[arch.Length - 2] + ".dd";

            using (BinaryReader reader = new BinaryReader(File.Open(dicc, FileMode.Open)))
            {
                reader.BaseStream.Seek(atrib.DirIndice, SeekOrigin.Begin);
                string nomb = "";
                char[] name = reader.ReadChars(30);
                foreach (char c in name)
                {
                    nomb += c;
                }
                long dir = reader.ReadInt64();
                char tipo;
                long dirIn, dirsig;
                int  l, tipoI;

                tipo   = reader.ReadChar();
                l      = reader.ReadInt32();
                tipoI  = reader.ReadInt32();
                dirIn  = reader.ReadInt64();
                dirsig = reader.ReadInt64();

                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}, {6}", nomb, dir, tipo, l, tipoI, dirIn, dirsig);
                return(new Atributo(nomb, dir, tipo, l, tipoI, dirIn, dirsig));
            }
        }
コード例 #2
0
        public LoginViewModel()
        {
            InitApp();

            //LoginView

            this.LoginCmd = new Command(() =>
            {
                if (PersonService.AreCredentialsCorrect(Fullname, Password))
                {
                    PersonService.Login(Fullname, Password);

                    if (PersonService.SelectedPerson != null)
                    {
                        Application.Current.MainPage = new MDPage();
                    }
                    else
                    {
                        ContextPage.DisplayAlert("DbError", "Something went wrong.", "OK");
                    }
                }
                else
                {
                    ContextPage.DisplayAlert("Wrong Credentials", "Name or password ist wrong", "OK");
                    Password = string.Empty;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Password)));
                }
            });

            this.RegisterOpenCmd = new Command(() => ContextPage.Navigation.PushModalAsync(new RegisterView()));

            //RegisterView

            this.RegisterCmd = new Command(() =>
            {
                Person newPerson = new Person()
                {
                    Vorname  = Fullname.Substring(0, Fullname.LastIndexOf(" ")),
                    Nachname = Fullname.Substring(Fullname.LastIndexOf(" ") + 1, Fullname.Length - (Fullname.LastIndexOf(" ") + 1)),
                    Password = Password,
                    Id       = PersonService.GetNewId()
                };

                if (PersonService.Insert(newPerson))
                {
                    ContextPage.DisplayAlert("Success", $"{Fullname} is registered.", "OK");
                }
                else
                {
                    ContextPage.DisplayAlert("Failure", $"{Fullname} couldn't been registered, cause the name allready exists.", "OK");
                }

                Fullname = string.Empty;
                Password = string.Empty;

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Fullname)));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Password)));
            });

            this.RegisterCloseCmd = new Command(() => ContextPage.Navigation.PopModalAsync());
        }