Personmodel handled as dbtabel and as file

This commit is contained in:
2020-03-26 20:49:46 +01:00
parent 27f406b836
commit 1a686aba60
8 changed files with 135 additions and 10 deletions

View File

@ -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;
}
}
}