private void SendRadioButton_CheckedChanged(object sender, EventArgs e) { if (SendRadioButton.Checked) { SendButton.Show(); TakeButton.Hide(); SelectFileButton.Hide(); SelectedFileTextBox.Hide(); } SelectedFileTextBox.Clear(); }
} // end of sendButton /*************************** Login Button ************************************* * Takes the users name they typed in the username textbox and requests a connction * with the server, then logs in to the server enabling the create button, list * games button, and join button. */ private void LoginButton_Click_1(object sender, EventArgs e) { // handle a blank username and don't allow people to have names longer than 16 characters if (textBox3.Text.Trim() == "") { textBox1.Text = "Please enter a Username before logging in"; return; } if (textBox3.Text.Length > 16) { textBox1.Text = "You shall not enter names longer than 16 characters!"; return; } // Username is what was typed into the textbox clientNo = textBox3.Text; try { // Try to connect to the server clientSocket.Connect("18.216.181.228", 13000); // *** Loopback can be uncommented out for testing on local machine *** // just make sure you comment out the IP above //clientSocket.Connect("127.0.0.1", 13000); serverStream = clientSocket.GetStream(); // Send the user name to the server byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox3.Text + "|"); serverStream.Write(outStream, 0, outStream.Length); serverStream.Flush(); // Create a new thread top handle the client Thread ctThread = new Thread(getMessage); ctThread.Start(); } catch (Exception ex) { textBox1.AppendText(ex.ToString()); } if (clientSocket.Connected) { // If the client connects successfully, enables button functions LoginButton.Hide(); CreateButton.Show(); ListGamesButton.Show(); JoinButton.Show(); SendButton.Show(); } } // end of LoginButton
private void UnHideMainComp() { dataGridView1.Show(); LoggedInfLabel.Show(); LoggedEmailInf.Show(); LogoutButton.Show(); UpdateLabel.Show(); SubjectLabel.Show(); SubjectTextB.Show(); RecipientLabel.Show(); RecipientTextBox.Show(); BodyLabel.Show(); BodyTextBox.Show(); SendButton.Show(); MailSaveButton.Show(); DeserializeButton.Show(); RefreshButton.Show(); }
private void SaveAgency_Click(object sender, EventArgs e) { if (agency == null) { agency = new Agency(); } //Check bool flag = true; ValidateItems(NameBox); if (NameBox.Text.Length > 50 || NameBox.Text.Length < 4) { NameBox.BackColor = Color.Red; MessageBox.Show("The Length of name isn't inconsonant. \n The name is belong from 4 to 50 characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); NameBox.Text = string.Empty; NameBox.BackColor = Color.White; flag = false; } else { for (int i = 0; i < NameBox.Text.Length; i++) { if (NameBox.Text[i] >= '0' && NameBox.Text[i] <= '9') { NameBox.BackColor = Color.Red; MessageBox.Show("The Name Just Contains Number ??? \n The Name Should be Include Number and Characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); NameBox.Text = string.Empty; NameBox.BackColor = Color.White; flag = false; break; } } } agency.Name = NameBox.Text; ValidateItems(DescriptionBox); if (DescriptionBox.Text.Length > 1000 || DescriptionBox.Text.Length < 12) { DescriptionBox.BackColor = Color.Red; MessageBox.Show("The Length of Description isn't inconsonant. \n The Description is belong from 12 to 1000 characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DescriptionBox.BackColor = Color.White; DescriptionBox.Text = string.Empty; } else if (DescriptionBox.Text == null) { DescriptionBox.BackColor = Color.Red; MessageBox.Show("Please Something Into Blank space", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DescriptionBox.Text = string.Empty; DescriptionBox.BackColor = Color.White; } agency.Description = DescriptionBox.Text; agency.Image = pictureBox1.Image; bool AlreadyExist = false; if (agency.Image == null) { pictureBox1.BackColor = Color.Gray; MessageBox.Show("Have You Choose The Picture ???", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); pictureBox1.BackColor = Color.White; flag = false; } foreach (Agency a in vietTravel.Agencies) { if (a.Name == agency.Name && Odd == false) { AlreadyExist = true; break; } else { AlreadyExist = false; } } if (AlreadyExist == true) { NameBox.BackColor = Color.Red; MessageBox.Show("This Name Already Exist \n Please Try Again With Another Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); NameBox.Text = string.Empty; NameBox.BackColor = Color.White; flag = false; } if (agency.Portions.Count == 0) { MessageBox.Show("Please add some trips! It`s impossible to send agency without any trips to the client!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); flag = false; } else { agency.Portions = new List <Portion>(); agency.Portions = (List <Portion>)portionBindingSource.DataSource; foreach (Portion p in agency.Portions) { p.Agency_Name = agency.Name; } agency.Amount = agency.Portions.Count; portionBindingSource.DataSource = agency.Portions; portionBindingSource.ResetBindings(false); } if (agency.Name == "Hendrichs Cullen" || agency.Description == "Victoria City, Melbourne" || agency.Image == null || agency.Portions.Count == 0 || AlreadyExist == true) { flag = false; } if (agency.Name == "Christopher Rohit" || agency.Description == "Stuttgart , Germany" || agency.Image == null || agency.Portions.Count == 0 || AlreadyExist == true) { flag = false; } if (flag == false) { SendButton.Show(); SaveAgency.Hide(); } else { MessageBox.Show("Do you missed something !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); SaveAgency.Show(); SendButton.Hide(); } }