示例#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));
                }
        }
示例#2
0
        private void registerTaxPrepayment(decimal amount, string month, string description)
        {
            DateTime nowTime = DateTime.Now;

            using (FinancialSettlementAppBase context = new FinancialSettlementAppBase())
            {
                TaxPrepayment newTaxPrepayment = new TaxPrepayment()
                {
                    Amount      = amount,
                    Month       = month,
                    Description = description,
                    Data        = nowTime
                };
                context.taxPrepayment.Add(newTaxPrepayment);
                context.SaveChanges();
            }
        }
示例#3
0
        private void registerCost(decimal amount, string month, string description, string status)
        {
            DateTime nowTime = DateTime.Now;

            using (FinancialSettlementAppBase context = new FinancialSettlementAppBase())
            {
                Cost newCost = new Cost()
                {
                    Amount      = amount,
                    Month       = month,
                    Description = description,
                    Data        = nowTime,
                    Status      = status
                };
                context.cost.Add(newCost);
                context.SaveChanges();
            }
        }