Example #1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            int res = CheckUser();

            if (res == 0)
            {
                Accounts account = new Accounts();
                account.Login      = tbLogin.Text;
                account.LoginSkype = tbLoginSkype.Text;
                account.Password   = tbPass.Password;
                account.Email      = tbEmail.Text;

                Message message = new Message();
                message.Title   = "register";
                message.Account = account;
                message.Result  = null;


                Message recieveMessage = parent.SendToServer(message);

                if (recieveMessage != null && recieveMessage.Result != null)
                {
                    if (recieveMessage.Result.Code == 0)
                    {   // нет ошибок, данные вставлены в базу можно загружать основное окно
                        this.Close();
                        parent.Hide();
                        RunWindow run = new RunWindow();
                        parent.MyAccount = account;
                        run.Owner        = parent;
                        run.Show();
                    }
                    else
                    {
                        MessageBox.Show(recieveMessage.Result.Code + " " + recieveMessage.Result.TitleError);
                    }
                }
                else
                {
                    MessageBox.Show("Нет соединения с сервером");
                }
            }
        }
Example #2
0
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            int res = CheckUser();

            if (res == 0)
            {
                Accounts account = new Accounts();
                account.Login    = tbLogin.Text;
                account.Password = tbPass.Password;
                Message message = new Message();
                message.Title   = "checkin";
                message.Account = account;
                message.Result  = null;

                Message recieveMessage = SendToServer(message);
                if (recieveMessage != null && recieveMessage.Result != null)
                {
                    if (recieveMessage.Result.Code == 0)
                    {
                        this.Hide();
                        message.Account.LoginSkype   = recieveMessage.Account.LoginSkype;
                        message.Account.Email        = recieveMessage.Account.Email;
                        message.Account.Id           = recieveMessage.Account.Id;
                        message.Account.DateRegister = recieveMessage.Account.DateRegister;
                        myAccount = message.Account;
                        RunWindow run = new RunWindow();
                        run.Owner = this;
                        run.Show();
                    }
                    else
                    {
                        tbPass.Password = "";
                        MessageBox.Show(recieveMessage.Result.TitleError);
                    }
                }
                else
                {
                    MessageBox.Show("Нет соединения с сервером");
                }
            }
        }