SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Collections;
  11.  
  12.  
  13. namespace InfoApp
  14. {
  15.    
  16.    
  17.     public partial class UserControl1: UserControl
  18.     {
  19.         public Hashtable infoTable = new Hashtable();
  20.         public bool valid = false;
  21.         public UserControl1()
  22.         {
  23.             InitializeComponent();
  24.            
  25.         }
  26.  
  27.         private void SaveButton_Click(object sender, EventArgs e)
  28.         {
  29.             EmptyLabelCheck();
  30.             if (valid)
  31.             {
  32.                 infoTable.Add(firstNameLabel.Name, firstNameTextBox.Text);
  33.                 infoTable.Add(lastNameLabel.Name, lastNameTextBox.Text);
  34.                 infoTable.Add(fatherNameLabel.Name, fatherNameTextBox.Text);
  35.                 infoTable.Add(motherNameLabel.Name, motherNameTextBox.Text);
  36.                 infoTable.Add(addressLabel.Name, addressTextBox.Text);
  37.                 ClearAllTextBox();
  38.  
  39.             }
  40.             else
  41.             {
  42.                 MessageBox.Show("Empty Field(s)!");
  43.             }
  44.            
  45.         }
  46.  
  47.         public void ClearAllTextBox()
  48.         {
  49.             firstNameTextBox.Clear();
  50.             lastNameTextBox.Clear();
  51.             fatherNameTextBox.Clear();
  52.             motherNameTextBox.Clear();
  53.             addressTextBox.Clear();
  54.         }
  55.         public void ResetInfoTable(Hashtable infotable)
  56.         {
  57.             infoTable.Clear();
  58.         }
  59.         private void EmptyLabelCheck()
  60.         {
  61.             if (string.IsNullOrWhiteSpace(firstNameTextBox.Text))
  62.             {
  63.                 //firstNameTextBox.ForeColor = Color.Red;
  64.                 valid = false;
  65.             }
  66.             else if (string.IsNullOrWhiteSpace(lastNameTextBox.Text))
  67.             {
  68.                 //lastNameTextBox.ForeColor = Color.Red;
  69.                 valid = false;
  70.             }
  71.             else if (string.IsNullOrWhiteSpace(fatherNameTextBox.Text))
  72.             {
  73.                 //fatherNameTextBox.ForeColor = Color.Red;
  74.                 valid = false;
  75.             }
  76.             else if (string.IsNullOrWhiteSpace(motherNameTextBox.Text))
  77.             {
  78.                 //motherNameTextBox.ForeColor = Color.Red;
  79.                 valid = false;
  80.             }
  81.             else if (string.IsNullOrWhiteSpace(addressTextBox.Text))
  82.             {
  83.                 //addressTextBox.ForeColor = Color.Red;
  84.                 valid = false;
  85.             }
  86.             else
  87.             {
  88.                 valid = true;
  89.             }
  90.         }
  91.  
  92.         private void ClearAllButton_Click(object sender, EventArgs e)
  93.         {
  94.             ClearAllTextBox();
  95.             infoTable.Clear();
  96.         }
  97.  
  98.         private void ShowAllButton_Click(object sender, EventArgs e)
  99.         {
  100.             firstNameTextBox.Text = (string)infoTable[firstNameLabel.Name];
  101.             lastNameTextBox.Text = (string)infoTable[lastNameLabel.Name];
  102.             fatherNameTextBox.Text = (string)infoTable[fatherNameLabel.Name];
  103.             motherNameTextBox.Text = (string)infoTable[motherNameLabel.Name];
  104.             addressTextBox.Text = (string)infoTable[addressLabel.Name];
  105.         }
  106.  
  107.         private void FirstNameButton_Click(object sender, EventArgs e)
  108.         {
  109.             ClearAllTextBox();
  110.             firstNameTextBox.Text = (string)infoTable[firstNameLabel.Name];
  111.         }
  112.  
  113.         private void LastNameButton_Click(object sender, EventArgs e)
  114.         {
  115.             ClearAllTextBox();
  116.             lastNameTextBox.Text = (string)infoTable[lastNameLabel.Name];
  117.         }
  118.  
  119.         private void FatherNameButton_Click(object sender, EventArgs e)
  120.         {
  121.             ClearAllTextBox();
  122.             fatherNameTextBox.Text = (string)infoTable[fatherNameLabel.Name];
  123.         }
  124.  
  125.         private void MotherNameButton_Click(object sender, EventArgs e)
  126.         {
  127.             ClearAllTextBox();
  128.             motherNameTextBox.Text = (string)infoTable[motherNameLabel.Name];
  129.         }
  130.  
  131.         private void Address_Click(object sender, EventArgs e)
  132.         {
  133.             ClearAllTextBox();
  134.             addressTextBox.Text = (string)infoTable[addressLabel.Name];
  135.         }
  136.     }
  137.  
  138. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top