Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Ucet_Banka
- {
- class Ucet {
- public int Cislo { get; private set; }
- public string Nazev { get; set; }
- public decimal Zustatek { get; set; }
- public Ucet(int cislo, string nazev)
- {
- Cislo = cislo;
- Nazev = nazev;
- Zustatek = 10000;
- }
- virtual public void Preved(decimal castka, int cisloUctu)
- {
- Zustatek -= castka;
- // TODO: az budeme mit server, prevedeme na jiny ucet, zatim jen snizime zustatek
- }
- public override string ToString()
- {
- return $"{Cislo} {Nazev}";
- }
- }
- class UcetPoplatky : Ucet
- {
- public decimal Poplatek { get; set; }
- public UcetPoplatky(int cislo, string nazev) : base(cislo, nazev)
- {
- Poplatek = 10;
- }
- public override void Preved(decimal castka, int cisloUctu)
- {
- Zustatek -= castka;
- Zustatek -= Poplatek;
- }
- }
- class Polozka
- { public DateTime Datum { get; set; }
- public int Hodnota { get; set; }
- public Polozka(int hodnota)
- {
- Datum = DateTime.Now;
- Hodnota = hodnota;
- }
- public override string ToString()
- {
- return $"{Datum:MM/dd/yyyy} {Hodnota:C}";
- }
- }
- class StackForm : Form
- {
- private TableLayoutPanel panel = new TableLayoutPanel();
- private ComboBox combo = null;
- private BindingList<PolozkaVypisu> polozky = null;
- // private BindingSource source = null;
- public StackForm()
- {
- panel.AutoSize = true;
- panel.Dock = DockStyle.Fill;
- panel.ColumnCount = 4; //pocet sloupců
- panel.RowCount = 8; //pocet radku
- panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
- panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
- panel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
- panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); //rozdeleni sloupcu,procentualni rozdeleni
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); //rozdeleni radku
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- panel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- panel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
- panel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
- Label Vyberucet = new Label() { Text = "Vyber účet:" };
- Label Nadpis = new Label() { Text = "Bankovní účet" };
- Label Nadpis2 = new Label() { Text = "Výpis účtu" };
- combo = new ComboBox();
- combo.Items.Add("Běžný účet");
- combo.Items.Add("Účet s poplatky");
- combo.Items.Add("Účet 3 převody zdarma");
- Label jmeno_majitele = new Label() { Text = "Jmeno majitele" };
- ListBox listbox = new ListBox();
- listbox.Dock = DockStyle.Fill;
- listbox.DataSource = polozky;
- BindingSource bs = new BindingSource(polozky, null);
- DataGridView grid = new DataGridView();
- grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- grid.Dock = DockStyle.Fill;
- grid.DataSource = bs;
- grid.AutoGenerateColumns = false;
- DataGridViewTextBoxColumn Datum_cas = new DataGridViewTextBoxColumn();
- Datum_cas.HeaderText = "Datum a cas";
- Datum_cas.DataPropertyName = nameof(Polozka.Datum);
- Datum_cas.DefaultCellStyle.Format = "MM/dd/yyyy HH:mm:ss.fff";
- DataGridViewTextBoxColumn Typ_platby = new DataGridViewTextBoxColumn();
- Datum_cas.HeaderText = "Typ platby";
- //Datum_cas.DataPropertyName = nameof(Polozka.Hodnota);
- // Datum_cas.DefaultCellStyle.Format = "MM/dd/yyyy HH:mm:ss.fff";
- grid.Columns.Add(Datum_cas);
- grid.Columns.Add(Typ_platby);
- TextBox Zadavani_jmena = new TextBox() { Text = "Nové jméno" };
- Button ulozit_jmeno = new Button() { Text = "Uložit jmeno" };
- Label zustatek = new Label() { Text = "Zustatek" };
- TextBox Vypis_zustatku = new TextBox();
- Label PLatba_zuctu = new Label() { Text = "Platba z uctu: " };
- Label zadej_ucet = new Label() { Text = "Zadej ucet:" };
- TextBox okno_zadejucet = new TextBox();
- Button nahodne = new Button() { Text = "Nahodne" };
- nahodne.Click += (sender, e) =>
- {
- int nahoda;
- Random random = new Random();
- nahoda = random.Next(1, 4);
- if (nahoda == 1)
- {
- okno_zadejucet.Text = "Bezny ucet";
- }
- if (nahoda == 2)
- {
- okno_zadejucet.Text = "Účet s poplatky";
- }
- else
- {
- okno_zadejucet.Text = "Účet 3 převody zdarma";
- }
- };
- Label zadej_castku = new Label() { Text = "Zadej castku:" };
- TextBox okno_zadejcastku = new TextBox();
- Button Odeslat = new Button() { Text = "Odeslat" };
- Odeslat.Click += (sender, e) =>
- {
- // int nove = (int)okno_zadejcastku.?????;
- //polozky.Add(new Polozka());
- };
- // Button potvrdit_vyber = new Button() { Text = "Potvrd vyber." };
- // potvrdit_vyber.AutoSize = true;
- /* potvrdit_vyber.Click += (sender, e) =>
- {
- //zobrazit zustatek
- };*/
- // panel.Controls.Add(listbox, 3,2);
- panel.Controls.Add(Zadavani_jmena, 2, 2);
- panel.Controls.Add(ulozit_jmeno, 2, 3);
- panel.Controls.Add(Nadpis,0,0);
- panel.Controls.Add(Nadpis2, 3, 0);
- panel.Controls.Add(Vyberucet, 0, 1); //sloupec radek
- panel.Controls.Add(combo,1 , 1);
- panel.Controls.Add(grid, 3,1);
- panel.SetRowSpan(grid, 4);
- panel.SetRowSpan(listbox, 3);
- panel.Controls.Add(jmeno_majitele, 0, 2);
- panel.Controls.Add(zustatek, 0, 4);
- panel.Controls.Add(Vypis_zustatku, 1, 4);
- panel.Controls.Add(PLatba_zuctu, 0, 5);
- panel.Controls.Add(zadej_ucet, 0, 6);
- panel.Controls.Add(okno_zadejucet, 1, 6);
- panel.Controls.Add(nahodne, 2, 6);
- panel.Controls.Add(zadej_castku, 0, 7);
- panel.Controls.Add(okno_zadejcastku, 1, 7);
- panel.Controls.Add(Odeslat, 2, 7);
- //panel.Controls.Add(potvrdit_vyber, 2, 1);
- this.Controls.Add(panel);
- }
- }
- internal class PolozkaVypisu
- {
- }
- class Program
- {
- static void Main(string[] args)
- {
- StackForm form = new StackForm();
- Application.EnableVisualStyles();
- Application.Run(form);
- }
- }
- }
Add Comment
Please, Sign In to add comment