private void btn_Delete_Click(object sender, EventArgs e) { if (((Button)sender).Name == btn_MaintenanceDelete.Name) { try { Occurence.Occurences.Remove(Occurence.GetOccurenceByID(dgv_Maintenance.SelectedRows[0].Cells[0].Value.ToString())); LoadMaintenanceDGV(); } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_FinancesDelete.Name) { try { Occurence.Occurences.Remove(Occurence.GetOccurenceByID(dgv_Finances.SelectedRows[0].Cells[0].Value.ToString())); LoadFinanceDGV(); } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_NotesAdd.Name) { try { SelectedTenant.Notes.Remove(SelectedTenant.Notes.Find(i => i.NoteID == dgv_Notes.SelectedRows[0].Cells[0].Value.ToString())); LoadNoteDGV(); } catch (ArgumentOutOfRangeException) { } } }
private void OpenDetailPage(string ID) { string IDType = new string(ID.Take(ID.IndexOf('_')).ToArray()); switch (IDType) { case "Prop": { PropertyDetails form = new PropertyDetails(Property.PropertyList.Find(i => i.PropertyID == ID), this); form.Show(); break; } case "Ten": { TenantDetails form = new TenantDetails(Tenant.TenantList.Find(t => t.TenantID == ID), this); form.Show(); break; } case "Occ": case "Mnt": case "Inc": case "Pay": { ViewOccurenceDataForm form = new ViewOccurenceDataForm(Occurence.GetOccurenceByID(ID)); form.Show(); break; } } }
private void btn_Edit_Click(object sender, EventArgs e) { if (((Button)sender).Name == btn_EditProperty.Name) { try { ViewPropertyDataForm form = new ViewPropertyDataForm(Property.GetPropertyByID(dgv_Properties.SelectedRows[0].Cells[0].Value.ToString())); form.Show(); } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_EditTenant.Name) { try { ViewTenantDataForm form = new ViewTenantDataForm(Tenant.GetTenantByID(dgv_Tenant.SelectedRows[0].Cells[0].Value.ToString())); form.Show(); } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_EditMaintenance.Name) { try { ViewOccurenceDataForm form = new ViewOccurenceDataForm(Occurence.GetOccurenceByID(dgv_Maintenance.SelectedRows[0].Cells[0].Value.ToString())); form.Show(); } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_EditFinance.Name) { try { ViewOccurenceDataForm form = new ViewOccurenceDataForm(Occurence.GetOccurenceByID(dgv_Finance.SelectedRows[0].Cells[0].Value.ToString())); form.Show(); } catch (ArgumentOutOfRangeException) { } } }
private void btn_Edit_Click(object sender, EventArgs e) { if (((Button)sender).Name == btn_MaintenanceEdit.Name) { try { ViewOccurenceDataForm form = new ViewOccurenceDataForm(Occurence.GetOccurenceByID(dgv_Maintenance.SelectedRows[0].Cells[0].Value.ToString())); if (form.ShowDialog() == DialogResult.Cancel) { LoadMaintenanceDGV(); } } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_FinancesEdit.Name) { try { ViewOccurenceDataForm form = new ViewOccurenceDataForm(Occurence.GetOccurenceByID(dgv_Finances.SelectedRows[0].Cells[0].Value.ToString())); if (form.ShowDialog() == DialogResult.Cancel) { LoadFinanceDGV(); } } catch (ArgumentOutOfRangeException) { } } if (((Button)sender).Name == btn_InformationEdit.Name) { try { ViewPropertyDataForm form = new ViewPropertyDataForm(Property.GetPropertyByID(SelectedProperty.PropertyID)); if (form.ShowDialog() == DialogResult.Cancel) { LoadInformationDGV(); } } catch (ArgumentOutOfRangeException) { } } }
private void btn_Delete_Click(object sender, EventArgs e) { if (((Button)sender).Name == btn_DeleteProperty.Name) { if (dgv_Properties.SelectedRows.Count > 0 && MessageBox.Show("Warning: Deleting a Property will remove all data associated with that Property.\nThis cannot be undone! \nDo you want to delete this Property?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Property p = Property.PropertyList.Find(i => i.PropertyID == dgv_Properties.SelectedRows[0].Cells[0].Value.ToString()); foreach (Tenant t in Tenant.TenantList.Where(t => (!ReferenceEquals(null, t.Residence)) && t.Residence.PropertyID == p.PropertyID)) { t.CurrentLease = null; } foreach (Lease l in Lease.Leases.Where(l => l.PropertyLeased.PropertyID == p.PropertyID)) { Lease.Leases.Remove(l); } Property.PropertyList.Remove(p); LoadPropertyPage(); } catch (ArgumentOutOfRangeException) { } } } if (((Button)sender).Name == btn_DeleteTenant.Name) { if (MessageBox.Show("Warning: Deleting a Tenant will remove all data associated with thatTenant.\nThis cannot be undone! \nDo you want to delete this Tenant?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Tenant t = Tenant.GetTenantByID(dgv_Tenant.SelectedRows[0].Cells[0].Value.ToString()); foreach (Occurence o in Occurence.Occurences.Where(i => i.TenantsInvolved.Select(n => n.TenantID).Contains(t.TenantID))) { o.TenantsInvolved.Remove(t); } foreach (Lease l in Lease.Leases.Where(i => i.Tenants.Select(n => n.TenantID).Contains(t.TenantID))) { l.Tenants.Remove(t); } Tenant.TenantList.Remove(t); LoadTenantPage(); } catch (ArgumentOutOfRangeException) { } } } if (((Button)sender).Name == btn_DeleteMaintenance.Name) { if (MessageBox.Show("Warning: Deleting a Maintenance Item will remove all data associated with that Maintenance Item.\nThis cannot be undone! \nDo you want to delete this Maintenance Item?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Occurence.Occurences.Remove(Occurence.GetOccurenceByID(dgv_Maintenance.SelectedRows[0].Cells[0].Value.ToString())); LoadMaintenancePage(); } catch (ArgumentOutOfRangeException) { } } } if (((Button)sender).Name == btn_DeleteFinance.Name) { if (MessageBox.Show("Warning: Deleting a Finance Item will remove all data associated with that Finance Item.\nThis cannot be undone! \nDo you want to delete this Finance Item?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Occurence.Occurences.Remove(Occurence.GetOccurenceByID(dgv_Finance.SelectedRows[0].Cells[0].Value.ToString())); LoadFinancePage(); } catch (ArgumentOutOfRangeException) { } } } }