public MakeCustomer(MainScreen mainForm, int custId) : this(mainForm) { try { this.cust = dbcontext.customers .Where(c => c.customerId == custId) .FirstOrDefault(); } catch (NullReferenceException) { MessageBox.Show("An appointment to modify could not be loaded"); this.Hide(); } using (var ctx = new DataLayer.ScheduleEntities()) { var addressJoin = (from a in dbcontext.addresses join c in dbcontext.cities on a.cityId equals c.cityId join cn in dbcontext.countries on c.countryId equals cn.countryId where a.addressId == cust.addressId //orderby appt.start select new { a.addressId, a.address1, a.address2, a.phone, postCode = a.postalCode, cityIndex = c.cityId, countryIndex = cn.countryId }).ToList().First(); //`customerId`, `customerName`, `addressId`, `active`, `createDate`, `createdBy`, `lastUpdate`, `lastUpdateBy` textBoxName.Text = cust.customerName; textBoxAddress1.Text = addressJoin.address1; textBoxAddress2.Text = addressJoin.address2; textBoxPostCode.Text = addressJoin.postCode; comboBoxCity.SelectedIndex = addressJoin.cityIndex - 1; comboBoxCountry.SelectedIndex = addressJoin.countryIndex - 1; textBoxPhone.Text = addressJoin.phone; addr.addressId = addressJoin.addressId; checkBoxActive.Checked = cust.active; } }
public MakeAppointment(MainScreen mainForm) { InitializeComponent(); this.mainForm = mainForm; }