Personmodel handled as dbtabel and as file
This commit is contained in:
@ -7,6 +7,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TrackerLibrary;
|
||||
using TrackerLibrary.Models;
|
||||
|
||||
namespace TrackerUI
|
||||
{
|
||||
@ -16,5 +18,54 @@ namespace TrackerUI
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void createMemberButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ValidateForm())
|
||||
{
|
||||
PersonModel p = new PersonModel();
|
||||
|
||||
p.FirstName = firstNameValue.Text;
|
||||
p.LastName = lastNameValue.Text;
|
||||
p.EmailAddress = emailValue.Text;
|
||||
p.CellPhoneNumber = cellphoneValue.Text;
|
||||
|
||||
GlobalConfig.Connection.CreatePerson(p);
|
||||
|
||||
firstNameValue.Text = string.Empty;
|
||||
lastNameValue.Text = string.Empty;
|
||||
emailValue.Text = string.Empty;
|
||||
cellphoneValue.Text = string.Empty;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("You need to fill in all of the fiealds.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool ValidateForm()
|
||||
{
|
||||
// TODO - add validation to the form
|
||||
if(firstNameValue.Text.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (lastNameValue.Text.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (emailValue.Text.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (cellphoneValue.Text.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user