public void AddAction(MoneyAction MA) { if (MA.ProductName != this.ProductName) { return; } ActionTypeDefinition = MA.ActionTypeDefinition; IsEaring = MA.IsEarning; if (IDs.IndexOf(MA.ID) == -1) { IDs.Add(MA.ID); } if (OrderIDs.IndexOf(MA.OrderID) == -1) { OrderIDs.Add(MA.OrderID); } if (dateStart > MA.Date) { dateStart = MA.Date; } if (dateFinish < MA.Date) { dateFinish = MA.Date; } ProductCount += MA.ProductCount; if (MinProductPrice == -1 && MaxProductPrice == -1) { MinProductPrice = MA.ProductPrice; MaxProductPrice = MA.ProductPrice; } else { if (MA.ProductPrice < MinProductPrice) { MinProductPrice = MA.ProductPrice; } if (MA.ProductPrice > MaxProductPrice) { MaxProductPrice = MA.ProductPrice; } } TotalPrice += MA.TotalPrice; Earned += MA.Earned; Spent += MA.Spent; if (Persons.IndexOf(MA.Person) == -1) { Persons.Add(MA.Person); } }
public void AddAction(MoneyAction MA) { if (MA.Person != this.Person) { return; } ActionTypeDefinition = MA.ActionTypeDefinition; IsEarning = MA.IsEarning; if (IDs.IndexOf(MA.ID) == -1) { IDs.Add(MA.ID); } if (OrderIDs.IndexOf(MA.OrderID) == -1) { OrderIDs.Add(MA.OrderID); } if (dateStart > MA.Date) { dateStart = MA.Date; } if (dateFinish < MA.Date) { dateFinish = MA.Date; } int productIndex = ProductNames.IndexOf(MA.ProductName); if (productIndex == -1) { ProductNames.Add(MA.ProductName); ProductCounts.Add(MA.ProductCount); MinProductPrices.Add(MA.ProductPrice); MaxProductPrices.Add(MA.ProductPrice); } else { ProductCounts[productIndex] += MA.ProductCount; if (MA.ProductPrice < MinProductPrices[productIndex]) { MinProductPrices[productIndex] = MA.ProductPrice; } if (MA.ProductPrice > MaxProductPrices[productIndex]) { MaxProductPrices[productIndex] = MA.ProductPrice; } } TotalPrice += MA.TotalPrice; Earned += MA.Earned; State = TotalPrice < Earned ? Constants.STATE_OWN_DEBT : (TotalPrice > Earned ? Constants.STATE_SALDO : Constants.STATE_DEBT_GOT); }
public void AddAction(MoneyAction action) { if (action.OrderID != OrderID) { return; } moneyActions.Add(action); MaxActionID = action.ID; }
public void AddAction(MoneyAction MA) { if (MA.Date < dateStart || MA.Date > dateFinish) { return; } if (MA.IsEarning) { AddActionEarn(MA); } else { AddActionSpend(MA); } }
private void AddActionEarn(MoneyAction MA) { if (IDs_earned.IndexOf(MA.ID) == -1) { IDs_earned.Add(MA.ID); } if (OrderIDs_earned.IndexOf(MA.OrderID) == -1) { OrderIDs_earned.Add(MA.OrderID); } int productIndex = ProductNames_earned.IndexOf(MA.ProductName); if (productIndex == -1) { ProductNames_earned.Add(MA.ProductName); ProductCounts_earned.Add(MA.ProductCount); MinProductPrices_earned.Add(MA.ProductPrice); MaxProductPrices_earned.Add(MA.ProductPrice); } else { ProductCounts_earned[productIndex] += MA.ProductCount; if (MA.ProductPrice < MinProductPrices_earned[productIndex]) { MinProductPrices_earned[productIndex] = MA.ProductPrice; } if (MA.ProductPrice > MaxProductPrices_earned[productIndex]) { MaxProductPrices_earned[productIndex] = MA.ProductPrice; } } TotalPrice_earned += MA.TotalPrice; Earned += MA.Payed; if (Persons_earned.IndexOf(MA.Person) == -1) { Persons_earned.Add(MA.Person); } }
private void AddActionSpend(MoneyAction MA) { if (IDs_spend.IndexOf(MA.ID) == -1) { IDs_spend.Add(MA.ID); } if (OrderIDs_spend.IndexOf(MA.OrderID) == -1) { OrderIDs_spend.Add(MA.OrderID); } int productIndex = ProductNames_spend.IndexOf(MA.ProductName); if (productIndex == -1) { ProductNames_spend.Add(MA.ProductName); ProductCounts_spend.Add(MA.ProductCount); MinProductPrices_spend.Add(MA.ProductPrice); MaxProductPrices_spend.Add(MA.ProductPrice); } else { ProductCounts_spend[productIndex] += MA.ProductCount; if (MA.ProductPrice < MinProductPrices_spend[productIndex]) { MinProductPrices_spend[productIndex] = MA.ProductPrice; } if (MA.ProductPrice > MaxProductPrices_spend[productIndex]) { MaxProductPrices_spend[productIndex] = MA.ProductPrice; } } TotalPrice_spend += MA.TotalPrice; Spend += MA.Payed; }
public void Load(string fileOrdersPath, string fileNominationsPath, string fileClientsPath) { if (!File.Exists(fileNominationsPath)) { Stream str = File.Create(fileNominationsPath); str.Close(); } StreamReader strNom = new StreamReader(fileNominationsPath); while (!strNom.EndOfStream) { ProductNames.AddNomination(strNom.ReadLine()); } strNom.Close();//Product names if (!File.Exists(fileClientsPath)) { Stream str = File.Create(fileClientsPath); str.Close(); } StreamReader strCli = new StreamReader(fileClientsPath); while (!strCli.EndOfStream) { ClientNames.AddClient(new Client(strCli.ReadLine())); } strCli.Close();//Client names if (!File.Exists(fileOrdersPath)) { Stream str = File.Create(fileOrdersPath); str.Close(); } StreamReader strOrd = new StreamReader(fileOrdersPath); while (!strOrd.EndOfStream) { string info = strOrd.ReadLine(); int orderID = Convert.ToInt32(info.Substring(0, info.IndexOf(' '))); int countOfActions = Convert.ToInt32(info.Substring(info.IndexOf(' ') + 1, info.Length - info.IndexOf(' ') - 1)); Order order = new Order(orderID); for (int i = 0; i < countOfActions && !strOrd.EndOfStream; i++) { string[] actionData = strOrd.ReadLine().Split(';'); MoneyAction action = new MoneyAction(actionData[0], Convert.ToInt32(actionData[1]), Convert.ToInt32(actionData[2]), new DateTime(Convert.ToInt32(actionData[3]), Convert.ToInt32(actionData[4]), Convert.ToInt32(actionData[5])), actionData[6], actionData[7], Convert.ToDouble(actionData[8]), Convert.ToDouble(actionData[9]), Convert.ToDouble(actionData[10]), actionData[11], actionData[12], actionData[0] == Constants.ACTION_TYPE_DEF_EARNING); order.AddAction(action); } MoneyActions.AddOrder(order); } strOrd.Close();//orders }