Exemple #1
0
        private void ChangeAutodealerButton_Click(object sender, EventArgs e)
        {
            var AutodealerChooseForm = new AutodealerChooseForm();

            this.Hide();
            AutodealerChooseForm.Show();
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (Connection.NetworkStream.CanWrite && Connection.Client.Connected)
            {
                Connection.BinaryFormatter.Serialize(Connection.NetworkStream, MessageType.Action);
                Connection.BinaryFormatter.Serialize(Connection.NetworkStream, ActionType.Authorize);
                Connection.BinaryFormatter.Serialize(Connection.NetworkStream, UsernameTextBox.Text);
                Connection.BinaryFormatter.Serialize(Connection.NetworkStream, PasswordTextBox.Text);
            }

            if (Connection.NetworkStream.CanRead && Connection.Client.Connected)
            {
                var messageType = (MessageType)Connection.BinaryFormatter.Deserialize(Connection.NetworkStream);

                if (messageType == MessageType.Success)
                {
                    var AutodelaerChooseForm = new AutodealerChooseForm()
                    {
                        Owner         = this,
                        StartPosition = FormStartPosition.CenterScreen
                    };

                    this.Hide();
                    AutodelaerChooseForm.Show();
                }
                else
                {
                    var message = (string)Connection.BinaryFormatter.Deserialize(Connection.NetworkStream);
                    LoginStatusLabel.Text = $"Ошибка входа: {message}";
                }
            }
        }