private void NewCustomerButton_Click(object sender, RoutedEventArgs e) { JDB.Library.Controls.CustomInputBox win = new JDB.Library.Controls.CustomInputBox(); string cust = win.Show(this, "Enter name of customer:", "New Customer", ""); if (!string.IsNullOrEmpty(cust) && win.WasOkClicked) { if (this._DB.Customer.Count(o => o.Name == cust) > 0) { MessageBox.Show("A customer with that name already exists. Please specify a different name."); return; } _DB.Customer.InsertOnSubmit(new Customer { Name = cust }); _DB.SubmitChanges(); this.RefreshCustomerList(); string receiptFolder = Path.Combine(DexterPricingApp.Properties.Settings.Default.StorageLocation, "Receipts", cust); Directory.CreateDirectory(receiptFolder); if (this.Customers.Count > 0) { long maxID = this.Customers.Max(o => o.CustomerID); this.SelectedCustomer = this.Customers.Where(o => o.CustomerID == maxID).FirstOrDefault(); } } }
private void ChangeNameCustomer_Click(object sender, RoutedEventArgs e) { if (this.SelectedCustomer == null) { return; } JDB.Library.Controls.CustomInputBox win = new JDB.Library.Controls.CustomInputBox(); string cust = win.Show(this, "Enter name of customer:", "Rename Customer", this.SelectedCustomer.Name); if (win.WasOkClicked && !string.IsNullOrEmpty(cust) && !cust.Equals(this.SelectedCustomer.Name)) { Directory.Move ( Path.Combine(DexterPricingApp.Properties.Settings.Default.StorageLocation, "Receipts", this.SelectedCustomer.Name), Path.Combine(DexterPricingApp.Properties.Settings.Default.StorageLocation, "Receipts", cust) ); Customer customer = this._DB.Customer.Where(o => o.CustomerID == this.SelectedCustomer.CustomerID).FirstOrDefault(); customer.Name = cust; this._DB.SubmitChanges(); this.RefreshCustomerList(); this.SelectedCustomer = this.Customers.Where(o => o.Name == cust).FirstOrDefault(); } }
private void NewCustomerButton_Click(object sender, RoutedEventArgs e) { JDB.Library.Controls.CustomInputBox win = new JDB.Library.Controls.CustomInputBox(); string cust = win.Show(this, "Enter name of customer:", "New Customer", ""); if (!string.IsNullOrEmpty(cust) && win.WasOkClicked) { _DB.Customer.InsertOnSubmit(new Customer { Name = cust }); _DB.SubmitChanges(); this.RefreshCustomerList(); long maxID = this.Customers.Max(o => o.CustomerID); this.SelectedCustomer = this.Customers.Where(o => o.CustomerID == maxID).FirstOrDefault(); } }