private Decimal TakeSumOfCost(int number) { using (FinancialSettlementAppBase context = new FinancialSettlementAppBase()) { if (number == 1) { List <Cost> costs = context.cost.Where(w => w.Month == monthValue).Where(w => w.Status == "company").ToList(); Decimal sumOfCost = 0m; foreach (Cost c in costs) { sumOfCost += c.Amount; } return(sumOfCost); } else if (number == 2) { List <Cost> costs = context.cost.Where(w => w.Month == monthValue).ToList(); Decimal sumOfCost = 0m; foreach (Cost c in costs) { sumOfCost += c.Amount; } return(sumOfCost); } } return(0); }
private List <Cost> whichCostView(int number) { using (FinancialSettlementAppBase context = new FinancialSettlementAppBase()) { if (number == 1) { List <Cost> cost = context.cost.Where(w => w.Month == monthValue).ToList(); return(cost); } return(null); } }
private List <Taking> whichTakingView(int number) { using (FinancialSettlementAppBase context = new FinancialSettlementAppBase()) { if (number == 1) { List <Taking> takings = context.taking.Where(w => w.Month == monthValue).ToList(); return(takings); } return(null); } }
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(); } }
private Decimal TakeSumOfTaking(int number) { using (FinancialSettlementAppBase context = new FinancialSettlementAppBase()) { if (number == 1) { List <Taking> takings = context.taking.Where(w => w.Month == monthValue).ToList(); Decimal sumOfAmount = 0m; foreach (Taking t in takings) { sumOfAmount += t.Amount; } return(sumOfAmount); } } return(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(); } }
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)); } }