public CustomertypesViewModel() { CustomertypeModel ct = new CustomertypeModel(); DataTable CustomerTypesTable = ct.All(); this.FillAllCustomerTypes(CustomerTypesTable); }
public void Create() { CustomertypeModel ct = new CustomertypeModel { Name = Type }; ct = ct.SaveThis(); MessageBox.Show("Customer Type Created", "Success", MessageBoxButton.OK, MessageBoxImage.Information); }
public void BtnDelete(CustomertypeModel cm) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete customer type?", "Delete Customer Type", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { bool result = cm.Delete(); if (result) { MessageBox.Show("Customer Type Deleted"); } } }
private void FillAllCustomerTypes(DataTable cts) { List <CustomertypeModel> output = new List <CustomertypeModel>(); foreach (DataRow row in cts.Rows) { CustomertypeModel ctm = new CustomertypeModel { Id = System.Convert.ToInt32(row[0].ToString()), Name = row[1].ToString(), }; output.Add(ctm); } this.CustomerTypes = new BindableCollection <CustomertypeModel>(output); }
public EditCustomerViewModel(CustomerModel cm) { Customer = cm; CustomertypeModel ctm = new CustomertypeModel(); DataTable cts = ctm.All(); CustomerTypes = ctm.GetCollection(cts); Name = cm.Name; Phone = cm.Phone; Email = cm.Email; CustomerType = ctm.Get(cm.Type); for (int i = 0; i < cts.Rows.Count; i++) { string RowID = cts.Rows[i][0].ToString(); string CustomerId = CustomerType.Id.ToString(); if (RowID == CustomerId) { SelectedIndex = i; break; } } }
public void BtnEdit(CustomertypeModel cm) { ActivateItem(new EditCustomerTypeViewModel(cm)); }
public CreateCustomerViewModel() { CustomertypeModel ctm = new CustomertypeModel(); CustomerTypes = ctm.GetCollection(ctm.All()); }
public EditCustomerTypeViewModel(CustomertypeModel cm) { Customer = cm; Type = cm.Name; }