All pastes #805688 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-04 15:55 UTC
rendered paste body
// MAIN FORM

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PhoneBook
{
    public partial class PhoneBook : Form
    {
        public PhoneBook()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //NameLabel.Visible = true;
            //PhoneLabel.Visible = true;
            //NameTextBox.Visible = true;
            //PhoneTextBox.Visible = true;

            if (NameTextBox.Text.Length == 0 || PhoneTextBox.Text.Length == 0)
            {
                MessageBox.Show("Fill name to be added");
            }
            else
            {
                FileIO f = new FileIO();
                f.name = NameTextBox.Text.ToString();
                f.phone = PhoneTextBox.Text.ToString();
                f.add();
                NameTextBox.Clear();
                PhoneTextBox.Clear();
            }
            
        }

        private void HandleKeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (SearchNameTextBox.Text.Length == 0)
            {
                MessageBox.Show("Fill name to be searched");
            }
            else
            {
                FileIO s = new FileIO();
                s.name = SearchNameTextBox.Text.ToString();
                SearchLabel.Text = s.search();
                SearchNameTextBox.Clear();
            }
        }

        private void Delete_Click(object sender, EventArgs e)
        {
            if (DeleteNameTextBox.Text.Length == 0)
            {
                MessageBox.Show("Fill name to be deleted");
            }
            else
            {
                FileIO d = new FileIO();
                d.name = DeleteNameTextBox.Text.ToString();
                DeleteLabel.Text = d.delete();
                DeleteNameTextBox.Clear();
            }
        }
        
    }
}