Created
September 23, 2011 01:31
-
-
Save SuperYeti/1236547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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