Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Collections;
- namespace InfoApp
- {
- public partial class UserControl1: UserControl
- {
- public Hashtable infoTable = new Hashtable();
- public bool valid = false;
- public UserControl1()
- {
- InitializeComponent();
- }
- private void SaveButton_Click(object sender, EventArgs e)
- {
- EmptyLabelCheck();
- if (valid)
- {
- infoTable.Add(firstNameLabel.Name, firstNameTextBox.Text);
- infoTable.Add(lastNameLabel.Name, lastNameTextBox.Text);
- infoTable.Add(fatherNameLabel.Name, fatherNameTextBox.Text);
- infoTable.Add(motherNameLabel.Name, motherNameTextBox.Text);
- infoTable.Add(addressLabel.Name, addressTextBox.Text);
- ClearAllTextBox();
- }
- else
- {
- MessageBox.Show("Empty Field(s)!");
- }
- }
- public void ClearAllTextBox()
- {
- firstNameTextBox.Clear();
- lastNameTextBox.Clear();
- fatherNameTextBox.Clear();
- motherNameTextBox.Clear();
- addressTextBox.Clear();
- }
- public void ResetInfoTable(Hashtable infotable)
- {
- infoTable.Clear();
- }
- private void EmptyLabelCheck()
- {
- if (string.IsNullOrWhiteSpace(firstNameTextBox.Text))
- {
- //firstNameTextBox.ForeColor = Color.Red;
- valid = false;
- }
- else if (string.IsNullOrWhiteSpace(lastNameTextBox.Text))
- {
- //lastNameTextBox.ForeColor = Color.Red;
- valid = false;
- }
- else if (string.IsNullOrWhiteSpace(fatherNameTextBox.Text))
- {
- //fatherNameTextBox.ForeColor = Color.Red;
- valid = false;
- }
- else if (string.IsNullOrWhiteSpace(motherNameTextBox.Text))
- {
- //motherNameTextBox.ForeColor = Color.Red;
- valid = false;
- }
- else if (string.IsNullOrWhiteSpace(addressTextBox.Text))
- {
- //addressTextBox.ForeColor = Color.Red;
- valid = false;
- }
- else
- {
- valid = true;
- }
- }
- private void ClearAllButton_Click(object sender, EventArgs e)
- {
- ClearAllTextBox();
- infoTable.Clear();
- }
- private void ShowAllButton_Click(object sender, EventArgs e)
- {
- firstNameTextBox.Text = (string)infoTable[firstNameLabel.Name];
- lastNameTextBox.Text = (string)infoTable[lastNameLabel.Name];
- fatherNameTextBox.Text = (string)infoTable[fatherNameLabel.Name];
- motherNameTextBox.Text = (string)infoTable[motherNameLabel.Name];
- addressTextBox.Text = (string)infoTable[addressLabel.Name];
- }
- private void FirstNameButton_Click(object sender, EventArgs e)
- {
- ClearAllTextBox();
- firstNameTextBox.Text = (string)infoTable[firstNameLabel.Name];
- }
- private void LastNameButton_Click(object sender, EventArgs e)
- {
- ClearAllTextBox();
- lastNameTextBox.Text = (string)infoTable[lastNameLabel.Name];
- }
- private void FatherNameButton_Click(object sender, EventArgs e)
- {
- ClearAllTextBox();
- fatherNameTextBox.Text = (string)infoTable[fatherNameLabel.Name];
- }
- private void MotherNameButton_Click(object sender, EventArgs e)
- {
- ClearAllTextBox();
- motherNameTextBox.Text = (string)infoTable[motherNameLabel.Name];
- }
- private void Address_Click(object sender, EventArgs e)
- {
- ClearAllTextBox();
- addressTextBox.Text = (string)infoTable[addressLabel.Name];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement