Exemplo n.º 1
0
        private void DeleteLastButton_Click(object sender, RoutedEventArgs e)
        {
            using (FinancialSettlementAppBase context = new FinancialSettlementAppBase())

                if (operationValue == "AddTakings")
                {
                    bool oldValidateOnSaveEnabled = context.Configuration.ValidateOnSaveEnabled;

                    try
                    {
                        context.Configuration.ValidateOnSaveEnabled = false;

                        Taking takingToRemove = (Taking)DisplayGrid.SelectedItem;

                        context.Entry(takingToRemove).State = System.Data.Entity.EntityState.Deleted;
                        context.SaveChanges();
                    }
                    finally
                    {
                        context.Configuration.ValidateOnSaveEnabled = oldValidateOnSaveEnabled;
                    }
                    viewTaking(whichTakingView(1));
                }
                else if (operationValue == "AddCost")
                {
                    bool oldValidateOnSaveEnabled = context.Configuration.ValidateOnSaveEnabled;

                    try
                    {
                        context.Configuration.ValidateOnSaveEnabled = false;

                        Cost costToRemove = (Cost)DisplayGrid.SelectedItem;

                        context.Entry(costToRemove).State = System.Data.Entity.EntityState.Deleted;
                        context.SaveChanges();
                    }
                    finally
                    {
                        context.Configuration.ValidateOnSaveEnabled = oldValidateOnSaveEnabled;
                    }
                    viewCost(whichCostView(1));
                }
        }