SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
AddUser.xaml.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Windows;
6 using System.Windows.Controls;
7 using System.Windows.Data;
8 using System.Windows.Documents;
9 using System.Windows.Input;
10 using System.Windows.Media;
11 using System.Windows.Media.Imaging;
12 using System.Windows.Shapes;
13 using System.Text.RegularExpressions;
14 
15 namespace SeciUserInterface.Dialogs.Alerts
16 {
20  public partial class AddUser : Window
21  {
22  private static Regex regex = new Regex("^[0-9]+$", RegexOptions.Compiled);
23  public string Name = "";
24  public string Number = "";
25 
26  public AddUser()
27  {
28  InitializeComponent();
29  }
30 
31  private void btnCancel_Click(object sender, RoutedEventArgs e)
32  {
33  DialogResult = false;
34  Close();
35  }
36 
37  private void btnOk_Click(object sender, RoutedEventArgs e)
38  {
39  //Check name entered
40  if (String.IsNullOrEmpty(txtUser.Text))
41  {
42  MessageBox.Show("Please enter a name", "Enter Name", MessageBoxButton.OK, MessageBoxImage.Exclamation);
43  return;
44  }
45 
46  //Check number entered and is numbers - cannot check that it is valid
47  if (String.IsNullOrEmpty(txtNumber.Text))
48  {
49  MessageBox.Show("Please enter a mobile number", "Enter Number", MessageBoxButton.OK, MessageBoxImage.Exclamation);
50  return;
51  }
52 
53  String number = txtNumber.Text.Replace(" ", "");
54 
55  if (!regex.IsMatch(number))
56  {
57  MessageBox.Show("Mobile number can only contain numbers", "Invalid Number", MessageBoxButton.OK, MessageBoxImage.Exclamation);
58  return;
59  }
60 
61  Name = txtUser.Text;
62  Number = number;
63 
64  DialogResult = true;
65  Close();
66  }
67  }
68 }
void btnCancel_Click(object sender, RoutedEventArgs e)
Definition: AddUser.xaml.cs:31
void btnOk_Click(object sender, RoutedEventArgs e)
Definition: AddUser.xaml.cs:37
Interaction logic for AddUser.xaml
Definition: AddUser.xaml.cs:20