Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Junkie_s_ShoutBox
- {
- public partial class frmShoutBox : Form
- {
- string username = "Guest";
- bool signIn = false;
- bool signedUp = false;
- public frmShoutBox()
- {
- InitializeComponent();
- }
- private void btnSignUp_Click(object sender, EventArgs e)
- {
- username = txtUsername.Text;
- string password = txtPassword.Text;
- lblUser.Text = "Signed in as " + username + ".";
- signIn = true;
- signedUp = true;
- MessageBox.Show("You have signed up as " + username + ". You are now signed in.");
- }
- private void btnSignIn_Click(object sender, EventArgs e)
- {
- if (txtUsernameSignIn.Text != txtUsername.Text)
- {
- MessageBox.Show("You have entered an invalid username.");
- }
- else if (txtSignInPassword.Text != txtPassword.Text)
- {
- MessageBox.Show("You have entered an invalid password.");
- }
- else if (signedUp == false)
- {
- MessageBox.Show("You have not signed up yet");
- }
- else if (signIn == true)
- {
- MessageBox.Show("You are already signed in as " + username + ".");
- }
- else
- MessageBox.Show("Welcome!");
- signIn = true;
- }
- private void btnSignOut_Click(object sender, EventArgs e)
- {
- MessageBox.Show("You have been signed out.");
- lblUser.Text = "Signed in as Guest.";
- signIn = false;
- }
- private void btnPost_Click(object sender, EventArgs e)
- {
- if (signIn == false)
- {
- MessageBox.Show("Please sign in or post as guest");
- }
- else if (signIn == true)
- {
- string comment = txtComment.Text;
- lblComments.Text = username + ": " + comment;
- }
- }
- private void btnGuest_Click(object sender, EventArgs e)
- {
- string comment = (txtComment.Text);
- if (signIn == true)
- {
- MessageBox.Show("You are signed in as " + username + ". Click post to comment as this poster or sign out to post as a guest");
- }
- else
- {
- MessageBox.Show("Comment posted!");
- lblComments.Text = "Guest: " + comment;
- System.IO.File.WriteAllText(@"C:\Users\Brooke\Documents\Visual Studio 2012\Projects\comments.txt",comment);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment