static void Main(string[] args) { // TODO: pytanie o pozostałe parametry // TODO: obsługa wyjątków var inw = new Inwestycja(); try { Console.Write("Podaj kwotę: "); double kwota = Double.Parse(Console.ReadLine()); Console.Write("Podaj oprocentowanie: "); double oprocentowanie = Double.Parse(Console.ReadLine()); Console.Write("Podaj liczbę okresów: "); double okresy = Double.Parse(Console.ReadLine()); if (kwota < 0) { throw new ArgumentException(); } else if (okresy < 0) { throw new ArgumentException(); } else if (kwota >= Double.MaxValue || oprocentowanie >= Double.MaxValue || okresy >= Double.MaxValue) { throw new OverflowException("Parametry spoza dopuszczalnych zakresów"); } Console.WriteLine(inw.wartoscPrzyszla(kwota, oprocentowanie, (int)okresy)); Console.ReadKey(); } catch (ArgumentNullException ex) { Console.WriteLine(ex.Message); } catch (FormatException ex) { Console.WriteLine(ex.Message); } catch (OverflowException ex) { Console.WriteLine(ex.Message); } }
public ActionResult Dodaj() { var domyslnyTypInwestycji = TypyInwestycjiRepository.GetDefaultId(); if (domyslnyTypInwestycji == null) { TempData["Message"] = "Brak typu inwestycji, dla którego można by stworzyć inwestycję"; return(RedirectToAction("Kartoteka")); } var Model = new Inwestycja() { IdTypuInwestycji = domyslnyTypInwestycji.Value }; return(View(Model)); }
private void dataGridView4_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView4.Columns["Buy"].Index) { DateTime data_aktualna = DateTime.Parse(czas_aktualny.Text); if (!data_aktualna.IsHoliday()) { // MessageBox.Show("Row:"+(e.RowIndex + 1) + " Column: " + (e.ColumnIndex + 1) + " Column button clicked "); // kup daną inwestycję Inwestycja inv = (Inwestycja)dataGridView4.Rows[e.RowIndex].DataBoundItem; // MessageBox.Show(inv.ToString()); //Kup inwestycję: var user = (from tmp in ctx.Użytkownik where tmp.Hasło == userPasswd select tmp).First(); try { int ilość = Int32.Parse(dataGridView4.Rows[e.RowIndex].Cells[dataGridView4.Columns["ilość"].Index].Value.ToString()); if (user.StanKonta < ilość * inv.Kurs) { MessageBox.Show("Brak środków"); } else { Operacja operation = new Operacja() { Transakcja = transakcja.kupno, StempelCzasowy = Convert.ToDateTime(czas_aktualny.Text), Ilość = ilość, Inwestycja = inv }; user.Operacja.Add(operation); user.StanKonta -= ilość * inv.Kurs * inv.Przelicznik; MessageBox.Show("zakupiłeś inwestycje " + inv.Nazwa); // Odśwież(); ctx.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Uzupełnij: pole ilość" + ex); } } } }
public ActionResult Dodaj(FormCollection collection) { var Model = new Inwestycja(); try { Model.IdFirmy = KancelariaSettings.IdFirmy(User.Identity.Name); UpdateModel(Model); if (Model.IsValid) { InwestycjeRepository.Dodaj(Model); InwestycjeRepository.Save(); TempData["Message"] = String.Format("Dodano inwestycję \"{0}\"", Model.NumerInwestycji); return(RedirectToAction("Kartoteka")); } else { foreach (var rule in Model.GetRuleViolations()) { ModelState.AddModelError(rule.PropertyName, rule.ErrorMessage); } return(View(Model)); } } catch (Exception ex) { ViewBag.ErrorMessage = "Wystąpił błąd podczas dodawania inwestycji"; Logger.ErrorFormat("Wystąpił błąd podczas dodawania inwestycji\n{0}", ex); return(View(Model)); } }
public void posprzataj() { inw = null; }
public void utworzObiekt() { inw = new Inwestycja(); }
public void Usun(Inwestycja inwestycja) { db.Inwestycjas.DeleteOnSubmit(inwestycja); }
public void Dodaj(Inwestycja inwestycja) { db.Inwestycjas.InsertOnSubmit(inwestycja); }