示例#1
0
 private void tsBtnDeleteInstepction_Click(object sender, System.EventArgs e)
 {
     UjfApartmentHouseInspection inspection = new UjfApartmentHouseInspection();
     inspection = this.bsHouseInspection.get_Current() as UjfApartmentHouseInspection;
     if (inspection != null)
     {
         if (System.Windows.Forms.MessageBox.Show("Вы действительно хотите удалить этот осмотр? Удаление осмотра также удалит все ссылки на него!", "Внимание", System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.No)
         {
             new UjfApartmentHouseDefectSheduleView().DeleteByCurrentInspection(inspection.Id);
             new UjfApartmentHouseDefectView().DeleteByCurrentInspection(inspection.Id);
             inspection.Delete();
             inspection.SaveChanges();
             this.UpdateBindingSourceHouseInspection();
         }
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Выберите строку для удаления");
     }
 }
示例#2
0
 private void dgvInspections_PreviewKeyDown(object sender, System.Windows.Forms.PreviewKeyDownEventArgs e)
 {
     if (this.dgvInspections.SelectedRows.get_Count() != 0)
     {
         if (e.KeyCode == System.Windows.Forms.Keys.Enter)
         {
             UjfApartmentHouseInspection inspection = (UjfApartmentHouseInspection) this.bsHouseInspection.get_Current();
             if (inspection != null)
             {
                 new UjfApartmentHousePartElementForm(inspection).ShowDialog(this);
             }
         }
         if (e.KeyCode == System.Windows.Forms.Keys.Delete)
         {
             UjfApartmentHouseInspection inspection2 = new UjfApartmentHouseInspection();
             inspection2 = this.bsHouseInspection.get_Current() as UjfApartmentHouseInspection;
             if (inspection2 != null)
             {
                 if (System.Windows.Forms.MessageBox.Show("Вы действительно хотите удалить этот осмотр? Удаление осмотра также удалит все ссылки на него!", "Внимание", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                 {
                     return;
                 }
                 new UjfApartmentHouseDefectSheduleView().DeleteByCurrentInspection(inspection2.Id);
                 new UjfApartmentHouseDefectView().DeleteByCurrentInspection(inspection2.Id);
                 inspection2.Delete();
                 inspection2.SaveChanges();
                 this.UpdateBindingSourceHouseInspection();
             }
             else
             {
                 System.Windows.Forms.MessageBox.Show("Выберите строку для удаления");
             }
         }
         if (e.KeyCode == System.Windows.Forms.Keys.Insert)
         {
             UjfApartmentHouseInspection ahi = new UjfApartmentHouseInspection {
                 HouseId = this.house.Id
             };
             new UjfApartmentHouseAddChangeInspectionsForm(ahi).ShowDialog(this);
             this.UpdateBindingSourceHouseInspection();
         }
         if (e.KeyCode == System.Windows.Forms.Keys.F2)
         {
             UjfApartmentHouseInspection inspection4 = new UjfApartmentHouseInspection();
             inspection4 = this.bsHouseInspection.get_Current() as UjfApartmentHouseInspection;
             if (inspection4 != null)
             {
                 new UjfApartmentHouseAddChangeInspectionsForm(inspection4).ShowDialog();
                 this.UpdateBindingSourceHouseInspection();
             }
             else
             {
                 System.Windows.Forms.MessageBox.Show("Выберите строку для изменения");
             }
         }
     }
 }