CreateNewUser.cs

00001 using System;
00002 using System.Collections.Generic;
00003 using System.ComponentModel;
00004 using System.Data;
00005 using System.Drawing;
00006 using System.Text;
00007 using System.Windows.Forms;
00008 using Shared;
00009 
00010 namespace Client
00011 {
00015     public partial class UserForm : Form
00016     {
00018         private PersonInfo personinfo;
00020         private bool editUser = false;
00022         public string user;
00024         public string password;
00025 
00029         public UserForm()
00030         {
00031             InitializeComponent();
00032         }
00033 
00038         public UserForm(PersonInfo personinfo)
00039         {
00040             this.personinfo = personinfo;
00041             editUser = true;
00042 
00043             InitializeComponent();
00044             
00045             textBoxName.Text = personinfo.name;
00046             textBoxDepartment.Text = personinfo.department;
00047             textBoxUsername.Text = personinfo.username;
00048             textBoxEmail.Text = personinfo.email;
00049             
00050             this.Text = "Edit Person";
00051             textBoxUsername.Visible = false;
00052             label5.Visible = false;
00053             label8.Visible = false;
00054             label12.Text = "Change your password here:";
00055             button1.Text = "OK"; 
00056         }
00057         
00063         private void button2_Click(object sender, EventArgs e)
00064         {
00065             personinfo = new PersonInfo();
00066             this.DialogResult = DialogResult.Cancel;
00067         }
00068 
00074         private void button1_Click(object sender, EventArgs e)
00075         {
00076             personinfo.name = textBoxName.Text;
00077             personinfo.department = textBoxDepartment.Text;
00078             personinfo.email = textBoxEmail.Text;
00079             personinfo.username = textBoxUsername.Text;
00080             personinfo.password = textBoxPassword.Text;
00081 
00082             if (editUser)
00083             {
00084                 if (textBoxPassword.Text != "" && textBoxPassword.Text.Length < 3)
00085                 {
00086                     MessageBox.Show("Passwords too short, use atleast 3 characters!", "Try again!", MessageBoxButtons.OK, MessageBoxIcon.Error);
00087                     return;
00088                 }
00089             }
00090             else
00091             {
00092                 if (textBoxPassword.Text.Length < 3)
00093                 {
00094                     MessageBox.Show("Passwords too short, use atleast 3 characters!", "Try again!", MessageBoxButtons.OK, MessageBoxIcon.Error);
00095                     return;
00096                 }
00097             }
00098 
00099             if (textBoxConfirm.Text != textBoxPassword.Text)
00100             {
00101                 MessageBox.Show("Passwords do not match!", "Try again!", MessageBoxButtons.OK, MessageBoxIcon.Error);
00102                 return;
00103             }
00104 
00105             if (personinfo.username.Trim().Length < 1)
00106             {
00107                 MessageBox.Show("Username is required!", "Try again!", MessageBoxButtons.OK, MessageBoxIcon.Error);
00108                 return;
00109             }
00110 
00111             if (personinfo.name.Trim().Length < 1)
00112             {
00113                 MessageBox.Show("Name is required!", "Try again!", MessageBoxButtons.OK, MessageBoxIcon.Error);
00114                 return;
00115             }
00116 
00117             DialogResult = DialogResult.OK;
00118             
00119             if (!editUser)
00120             {
00121                 password = personinfo.password;
00122                 user = personinfo.username;
00123             }
00124             this.Close();
00125         }
00126 
00128         public PersonInfo PersonInfo
00129         {
00130             get { return personinfo; }
00131             set { personinfo = value; }
00132         }
00133 
00134         private void textBoxPassword_Enter(object sender, EventArgs e)
00135         {
00136             textBoxPassword.SelectAll();
00137         }
00138 
00139         private void textBoxConfirm_Enter(object sender, EventArgs e)
00140         {
00141             textBoxConfirm.SelectAll();
00142         }
00143 
00144         private void textBoxConfirm_MouseClick(object sender, MouseEventArgs e)
00145         {
00146             textBoxConfirm.SelectAll();
00147         }
00148 
00149         private void textBoxPassword_MouseClick(object sender, MouseEventArgs e)
00150         {
00151             textBoxPassword.SelectAll();
00152         }
00153 
00154                         
00155     }
00156 }

Generated on Thu Dec 21 06:21:54 2006 for SCRAML by  doxygen 1.5.1-p1