Skip to content

Instantly share code, notes, and snippets.

@SuperYeti
Created September 23, 2011 01:31
Show Gist options
  • Save SuperYeti/1236547 to your computer and use it in GitHub Desktop.
Save SuperYeti/1236547 to your computer and use it in GitHub Desktop.
public void ShowCustomersForm(bool ShowAll)
{
EditingDialog dvc = new EditingDialog(new RootElement("Customers"), true, Application.BackgroundImage){Autorotate = true};
dvc.ViewAppearing += delegate {
LoadCustomers(dvc, ShowAll);
dvc.ReloadData();
};
dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Add, delegate {
ShowCustomerForm();
});
Application.navigation.PushViewController(dvc, true);
}
public void LoadCustomers(DialogViewController dvc, bool ShowAll)
{
dvc.Root.Caption = (ShowAll ? "All" : "Active") + " Customers";
Section sect = new Section();
foreach(var customer in Customer.GetCustomers(ShowAll))
{
Customer cust = customer;
MultilineElement element = new MultilineElement(customer.LastName + ", " + customer.FirstName){
DataItem = cust
};
element.Tapped += delegate
{
ShowCustomerForm(cust);
};
element.Deleted += delegate
{
if(Customer.DeleteCustomer(cust) == null)
{
Util.UnsuccessfulMessage("Error Deleting Customer.");
throw new Exception("CustomerHelper::DeleteCustomer Error Occurred");
}
};
sect.Add(element);
}
dvc.Root.Clear();
dvc.Root.Add(sect);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment