Пример #1
0
        private async void Delete(object value)
        {
#if XBAP
            MessageBoxResult result = MessageBox.Show("确定要删除?", "删除", MessageBoxButton.OK, MessageBoxImage.Warning);
#else
            MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("确定要删除?", "删除", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
#endif
            if (result == MessageBoxResult.OK)
            {
                if (DevicesIsSelected == true)
                {
                    T_DeviceDiagnose t_model = DeviceDiagnoseClass.ConvertToDB(SelectedDevice);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_DeviceDiagnose>(ServerIP, t_model.id);
                    }
                    Devices.Remove(SelectedDevice);
                }
                else if (ShaftsIsSelected == true)
                {
                    T_Shaft t_model = ShaftClass.ConvertToDB(SelectedShaft);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Shaft>(ServerIP, t_model.id);
                    }
                    Shafts.Remove(SelectedShaft);
                }
                else if (BearingsIsSelected == true)
                {
                    T_Bearing t_model = BearingClass.ConvertToDB(SelectedBearing);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Bearing>(ServerIP, t_model.id);
                    }
                    Bearings.Remove(SelectedBearing);
                }
                else if (BeltsIsSelected == true)
                {
                    Belts.Remove(SelectedBelt);
                    T_Belt t_model = BeltClass.ConvertToDB(SelectedBelt);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Belt>(ServerIP, t_model.id);
                    }
                }
                else if (GearsIsSelected == true)
                {
                    T_Gear t_model = GearClass.ConvertToDB(SelectedGear);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Gear>(ServerIP, t_model.id);
                    }
                    Gears.Remove(SelectedGear);
                }
                else if (ImpellersIsSelected == true)
                {
                    T_Impeller t_model = ImpellerClass.ConvertToDB(SelectedImpeller);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Impeller>(ServerIP, t_model.id);
                    }
                    Impellers.Remove(SelectedImpeller);
                }
                else if (MotorsIsSelected == true)
                {
                    T_Motor t_model = MotorClass.ConvertToDB(SelectedMotor);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Motor>(ServerIP, t_model.id);
                    }
                    Motors.Remove(SelectedMotor);
                }
            }
        }