public static void AddProperty(string city, string streetAddress, double purchasePrice, DateTime aquisitionDate, Features features, double rent = 0, bool moveInReady = false, string state = "Illinois", byte[] imageData = null) { Property property = new Property(city, streetAddress, rent, moveInReady, state, purchasePrice, aquisitionDate, features, imageData); PropertyList.Add(property); Occurence.AddNewOccurence("Aquired new property", streetAddress, aquisitionDate, property, Occurence.Statuses.Resolved, null); }
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_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) { } } }
public ViewOccurenceDataForm(Occurence item) { InitializeComponent(); string[] values = null; if (item is Payment) { Text = "Payment Info"; List <Payment> source = new List <Payment>() { (Payment)item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status", "Amount", "AmountExpected" }; } else if (item is Incident) { Text = "Incident Info"; List <Incident> source = new List <Incident>() { (Incident)item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status", "TenantIsLiable", "PetRelated", "Amount" }; } else if (item is MaintenanceItem) { Text = "Maintenance Item Info"; List <MaintenanceItem> source = new List <MaintenanceItem>() { (MaintenanceItem)item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status", "IsServiceCall", "RequestedBy", "EstimatedTimeTaken", "EstimatedCost", "ActualTimeTaken", "ActualCost", "EarliestDueDate", "LatestDueDate", "CompletionDate" }; } else if (item is Occurence) { Text = "Occurence Info"; List <Occurence> source = new List <Occurence>() { item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status" }; } dataGridView1.AutoGenerateColumns = false; dataGridView1.Columns.Clear(); foreach (string s in values) { string name = new string(s.Where(a => !char.IsWhiteSpace(a)).ToArray()); dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = name, HeaderText = s, Name = name, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, FillWeight = 20 }); } dataGridView1.Columns[0].Visible = false; dataGridView1.AutoResizeColumns(); }
public void MoveOutOldTenants(string eventName, string reason, DateTime moveOutDate, bool evicted) { CurrentLease.MoveOutDate = moveOutDate; CurrentLease.Evicted = evicted; Occurence.AddNewOccurence(eventName, reason, moveOutDate, this, Occurence.Statuses.Resolved, CurrentTenants.ToList()); foreach (Tenant t in CurrentTenants) { t.CurrentLease = null; } CurrentLease = null; }
public void MoveInNewTenants(List <Tenant> tenants, DateTime startDate, int termLengthInMonths, double rent, double deposit, double petDeposit, byte[] imageData) { CurrentLease = new Lease(this, tenants, rent, deposit, petDeposit, startDate, termLengthInMonths, imageData); Lease.Leases.Add(CurrentLease); string[] tenantslist = new string[tenants.Count()]; int i = 0; foreach (Tenant t in tenants) { t.CurrentLease = CurrentLease; tenantslist[i++] = t.FirstName + " " + t.LastName; } Occurence.AddNewOccurence("New tenant move in", String.Join(", ", tenantslist), startDate, this, Occurence.Statuses.Resolved, tenants); Rent = rent; }
public ViewOccurenceDataForm(Occurence item) { InitializeComponent(); string[] values = null; if (item is Payment) { Text = "Payment Info"; List<Payment> source = new List<Payment>() { (Payment)item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status", "Amount", "AmountExpected" }; } else if (item is Incident) { Text = "Incident Info"; List<Incident> source = new List<Incident>() { (Incident)item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status", "TenantIsLiable", "PetRelated", "Amount" }; } else if (item is MaintenanceItem) { Text = "Maintenance Item Info"; List<MaintenanceItem> source = new List<MaintenanceItem>() { (MaintenanceItem)item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status", "IsServiceCall", "RequestedBy", "EstimatedTimeTaken", "EstimatedCost", "ActualTimeTaken", "ActualCost", "EarliestDueDate", "LatestDueDate", "CompletionDate" }; } else if (item is Occurence) { Text = "Occurence Info"; List<Occurence> source = new List<Occurence>() { item }; dataGridView1.DataSource = source; values = new string[] { "InstanceID", "InstanceName", "Description", "IncidentDate", "Status" }; } dataGridView1.AutoGenerateColumns = false; dataGridView1.Columns.Clear(); foreach (string s in values) { string name = new string(s.Where(a => !char.IsWhiteSpace(a)).ToArray()); dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { DataPropertyName = name, HeaderText = s, Name = name, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, FillWeight = 20 }); } dataGridView1.Columns[0].Visible = false; dataGridView1.AutoResizeColumns(); }
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) { } } } }