44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using C969Project.Data;
|
|
using C969Project.Data.Models;
|
|
|
|
namespace C969Project;
|
|
|
|
public partial class AddUpdateCustomerForm : Form
|
|
{
|
|
public AddUpdateCustomerForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void InitAdd()
|
|
{
|
|
Text = "Add Customer";
|
|
label1.Text = "Add Customer";
|
|
|
|
nameTextBox.Text = string.Empty;
|
|
addressTextBox.Text = string.Empty;
|
|
cityTextBox.Text = string.Empty;
|
|
zipTextBox.Text = string.Empty;
|
|
phoneTextBox.Text = string.Empty;
|
|
|
|
ShowDialog();
|
|
}
|
|
|
|
public void InitUpdate(Customer customer)
|
|
{
|
|
Text = "Update Customer";
|
|
label1.Text = "Update Customer";
|
|
|
|
nameTextBox.Text = customer.CustomerName;
|
|
var addr = DatabaseHelper.RetrieveAddress(customer.AddressId);
|
|
addressTextBox.Text = addr.Address1;
|
|
var city = DatabaseHelper.RetrieveCity(addr.CityId);
|
|
cityTextBox.Text = city.CityName;
|
|
zipTextBox.Text = addr.PostalCode;
|
|
phoneTextBox.Text = addr.Phone;
|
|
|
|
ShowDialog();
|
|
}
|
|
|
|
// name, {address, phone}
|
|
} |