43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System.Reflection.Metadata.Ecma335;
|
|
using trakker.Models;
|
|
|
|
namespace trakker.Forms
|
|
{
|
|
public partial class ClientForm : Form
|
|
{
|
|
private readonly Client _client;
|
|
private BindingSource bindingSource = new BindingSource();
|
|
private ErrorProvider errorProvider = new ErrorProvider();
|
|
|
|
public ClientForm(Client client)
|
|
{
|
|
_client = client;
|
|
InitializeComponent();
|
|
|
|
bindingSource.DataSource = _client;
|
|
textBoxName.DataBindings.Add("Text", bindingSource, "Name", true);
|
|
textBoxCompany.DataBindings.Add("Text", bindingSource, "Company", true);
|
|
textBoxEmail.DataBindings.Add("Text", bindingSource, "Email", true);
|
|
maskedTextBox_Phone.DataBindings.Add("Text", bindingSource, "Phone", true);
|
|
//richTextBoxAddress.DataBindings.Add("Text", bindingSource, "Address", true);
|
|
comboBoxIsActive.DataBindings.Add("Text", bindingSource, "IsActive", true);
|
|
richTextBoxNotes.DataBindings.Add("Text", bindingSource, "Notes", true);
|
|
|
|
}
|
|
public Client Client { get => _client; private set { } }
|
|
|
|
private void textBoxName_Validating(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(textBoxName.Text))
|
|
{
|
|
errorProvider.SetError(textBoxName, "Name is required.");
|
|
e.Cancel = true;
|
|
}
|
|
else
|
|
{
|
|
errorProvider.SetError(textBoxName, "");
|
|
}
|
|
}
|
|
}
|
|
}
|