|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ConfigDemo {
public partial class EmployeeForm : Form {
public string _name;
public string _function;
public int _ID=-1;
public bool forEdit=false;
public EmployeeForm()
{
InitializeComponent();
}
private void buttonOK_Click(object sender, EventArgs e)
{
_name=textBoxName.Text;
_function=textBoxFunction.Text;
string strID=textBoxID.Text;
bool bOk=true;
if ((_name.Length==0 && !forEdit) || _function.Length==0 || strID.Length == 0) {
MessageBox.Show("All fields must be entered!");
bOk=false;
} else {
try {
_ID=int.Parse(strID);
} catch {
MessageBox.Show("The field Employee ID must be numeric!");
bOk=false;
}
}
if (bOk){
DialogResult = DialogResult.OK;
}
}
private void EmployeeForm_Shown(object sender, EventArgs e)
{
textBoxName.Text = _name;
if (forEdit) {
textBoxName.ReadOnly = true;
}
textBoxFunction.Text = _function;
if (_ID != -1) {
textBoxID.Text = _ID.ToString();
}
if (forEdit) {
textBoxFunction.Focus();
} else {
textBoxName.Focus();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.