Пример #1
0
 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) { }
     }
 }
Пример #2
0
 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
         {
             ViewTenantDataForm form = new ViewTenantDataForm(Tenant.GetTenantByID(SelectedTenant.TenantID));
             if (form.ShowDialog() == DialogResult.Cancel)
             {
             }
         }
         catch (ArgumentOutOfRangeException) { }
     }
 }
Пример #3
0
 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) { }
         }
     }
 }