SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | using System.Collections.Generic; | |
3 | using System.ComponentModel; | |
4 | using System.Data; | |
5 | using System.Drawing; | |
6 | using System.IO; | |
7 | using System.Linq; | |
8 | using System.Text; | |
9 | using System.Threading.Tasks; | |
10 | using System.Windows.Forms; | |
11 | ||
12 | namespace Junkie_s_ShoutBox | |
13 | { | |
14 | public partial class frmShoutBox : Form | |
15 | { | |
16 | string username = "Guest"; | |
17 | bool signIn = false; | |
18 | bool signedUp = false; | |
19 | public frmShoutBox() | |
20 | { | |
21 | InitializeComponent(); | |
22 | } | |
23 | ||
24 | private void btnSignUp_Click(object sender, EventArgs e) | |
25 | { | |
26 | username = txtUsername.Text; | |
27 | string password = txtPassword.Text; | |
28 | lblUser.Text = "Signed in as " + username + "."; | |
29 | signIn = true; | |
30 | signedUp = true; | |
31 | MessageBox.Show("You have signed up as " + username + ". You are now signed in."); | |
32 | } | |
33 | ||
34 | private void btnSignIn_Click(object sender, EventArgs e) | |
35 | { | |
36 | if (txtUsernameSignIn.Text != txtUsername.Text) | |
37 | { | |
38 | MessageBox.Show("You have entered an invalid username."); | |
39 | } | |
40 | else if (txtSignInPassword.Text != txtPassword.Text) | |
41 | { | |
42 | MessageBox.Show("You have entered an invalid password."); | |
43 | } | |
44 | else if (signedUp == false) | |
45 | { | |
46 | MessageBox.Show("You have not signed up yet"); | |
47 | } | |
48 | else if (signIn == true) | |
49 | { | |
50 | MessageBox.Show("You are already signed in as " + username + "."); | |
51 | } | |
52 | else | |
53 | MessageBox.Show("Welcome!"); | |
54 | signIn = true; | |
55 | ||
56 | } | |
57 | ||
58 | private void btnSignOut_Click(object sender, EventArgs e) | |
59 | { | |
60 | MessageBox.Show("You have been signed out."); | |
61 | lblUser.Text = "Signed in as Guest."; | |
62 | signIn = false; | |
63 | } | |
64 | ||
65 | private void btnPost_Click(object sender, EventArgs e) | |
66 | { | |
67 | if (signIn == false) | |
68 | { | |
69 | MessageBox.Show("Please sign in or post as guest"); | |
70 | } | |
71 | else if (signIn == true) | |
72 | { | |
73 | string comment = txtComment.Text; | |
74 | lblComments.Text = username + ": " + comment; | |
75 | } | |
76 | } | |
77 | private void btnGuest_Click(object sender, EventArgs e) | |
78 | { | |
79 | string comment = (txtComment.Text); | |
80 | if (signIn == true) | |
81 | { | |
82 | MessageBox.Show("You are signed in as " + username + ". Click post to comment as this poster or sign out to post as a guest"); | |
83 | } | |
84 | else | |
85 | { | |
86 | MessageBox.Show("Comment posted!"); | |
87 | lblComments.Text = "Guest: " + comment; | |
88 | System.IO.File.WriteAllText(@"C:\Users\Brooke\Documents\Visual Studio 2012\Projects\comments.txt",comment); | |
89 | } | |
90 | } | |
91 | } | |
92 | } |