Esempio n. 1
0
        private void xamDataGrid_RecordsDeleting(object sender, Infragistics.Windows.DataPresenter.Events.RecordsDeletingEventArgs e)
        {
            bool success;

            foreach (DataRecord record in e.Records)
            {
                if (record.DataItem.GetType() == typeof(PlateTypeItem))
                {
                    PlateTypeItem pti = (PlateTypeItem)record.DataItem;
                    foreach (MaskContainer mc in pti.MaskList)
                    {
                        success = wgDB.DeleteMask(mc.MaskID);
                        if (!success)
                        {
                            break;
                        }
                    }

                    success = wgDB.DeletePlateType(pti.PlateType.PlateTypeID);
                    if (!success)
                    {
                        break;
                    }
                }
                else if (record.DataItem.GetType() == typeof(MaskContainer))
                {
                    MaskContainer mc = (MaskContainer)record.DataItem;
                    success = wgDB.DeleteMask(mc.MaskID);
                    if (!success)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        private void Mask_Delete_Click(object sender, EventArgs e)
        {
            bool done = false;
            bool success;

            if (m_mask.Mask.MaskID == 0) // a mask has not been loaded or this mask has not been saved
            {
                MessageBox.Show("This Mask has not been saved, so there is nothing to delete." + m_mask.Mask.Description + " ?",
                                "Delete Not Necessary", MessageBoxButton.OK, MessageBoxImage.Information);
                done = true;
            }


            if (!done)
            {
                // get Mask from database with MaskID = m_mask.m_maskID so that we display the name of the mask that will be deleted.
                // This is done since it is possible that the Name was edited in the display but not saved.

                MaskContainer tempMask;
                success = wgDB.GetMask(m_mask.Mask.MaskID, out tempMask);

                if (success && tempMask != null)
                {
                    MessageBoxResult result = MessageBox.Show("Are you sure you want to DELETE: " + tempMask.Description + " ?",
                                                              "Verify Delete", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        success = wgDB.DeleteMask(m_mask.Mask.MaskID);
                        Init();
                        DrawMask();
                    }
                }
                else
                {
                    MessageBox.Show("No matching mask found in the database, so there is nothing to delete.",
                                    "Delete Not Necessary", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }