public void zapis_byt_do_html(StreamWriter sw, ceny ceny_energii, double spolecne) { double celkem = 0; sw.WriteLine("<h3>" + popis + "<h3>"); sw.WriteLine("<table>"); sw.WriteLine("<th>typ</th><th>popis</th><th>mnozstvi</th><th>cena</th>"); foreach (meric vodomer in vodomery) { sw.WriteLine("<tr>"); sw.WriteLine("<td>" + "voda" + "</td>"); sw.WriteLine("<td>" + vodomer.Popis + "</td>"); sw.WriteLine("<td>" + vodomer.rozdil_poslednich_hodnot + "</td>"); sw.WriteLine("<td>" + (vodomer.rozdil_poslednich_hodnot * ceny_energii.cena_vody_za_m3).ToString() + " Kč</td>"); sw.WriteLine("</tr>"); celkem = celkem + (vodomer.rozdil_poslednich_hodnot * ceny_energii.cena_vody_za_m3); } //elektrina sw.WriteLine("<tr>"); sw.WriteLine("<td>" + "elektrina" + "</td>"); sw.WriteLine("<td>" + elektrina.Popis + "</td>"); sw.WriteLine("<td>" + elektrina.rozdil_poslednich_hodnot + "</td>"); sw.WriteLine("<td>" + (elektrina.rozdil_poslednich_hodnot * ceny_energii.cena_elektriny_za_kwh).ToString() + " Kč</td>"); sw.WriteLine("</tr>"); celkem = celkem + (elektrina.rozdil_poslednich_hodnot * ceny_energii.cena_elektriny_za_kwh); //plyn if (plyn != null) { sw.WriteLine("<tr>"); sw.WriteLine("<td>" + "plyn" + "</td>"); sw.WriteLine("<td>" + plyn.Popis + "</td>"); sw.WriteLine("<td>" + plyn.rozdil_poslednich_hodnot + "</td>"); sw.WriteLine("<td>" + (plyn.rozdil_poslednich_hodnot * ceny_energii.cena_plynu_za_m3).ToString() + " Kč</td>"); sw.WriteLine("</tr>"); celkem = celkem + (plyn.rozdil_poslednich_hodnot * ceny_energii.cena_plynu_za_m3); } sw.WriteLine("<tr>"); sw.WriteLine("<td>" + "spolecne" + "</td>"); sw.WriteLine("<td>" + "" + "</td>"); sw.WriteLine("<td>" + "" + "</td>"); sw.WriteLine("<td>" + spolecne.ToString() + " Kč</td>"); sw.WriteLine("</tr>"); sw.WriteLine("<tr>"); sw.WriteLine("<td>" + "celkem" + "</td>"); sw.WriteLine("<td>" + "" + "</td>"); sw.WriteLine("<td>" + "" + "</td>"); sw.WriteLine("<td>" + celkem.ToString() + " Kč</td>"); sw.WriteLine("</tr>"); sw.WriteLine("</table>"); }
public ceny_Energii(ceny ceny_za_energie) { InitializeComponent(); if (ceny_za_energie != null) { this.nastavovane_ceny = ceny_za_energie; } else { nastavovane_ceny = new ceny(); } textBox_voda.Text = nastavovane_ceny.cena_vody_za_m3.ToString(); textBox_elektrina.Text = nastavovane_ceny.cena_elektriny_za_kwh.ToString(); textBox_plyn.Text = nastavovane_ceny.cena_plynu_za_m3.ToString(); }
private void cenyEnergiíToolStripMenuItem_Click(object sender, EventArgs e) { if (zobrazovany != null && zobrazovany.ulozeny == true) { ceny kopie_cen = zobrazovany.ceny_energii; ceny_Energii ceny_pro_tento_dum = new ceny_Energii(kopie_cen); ceny_pro_tento_dum.ShowDialog(); zobrazovany.ceny_energii = ceny_pro_tento_dum.nastavovane_ceny; //kontrola by neměla být potřeba pokud se ceny přidávají jen do už uloženého domu a ten je tedy už zkontrolovaný a nemohl být znovu upravovan // if (zobrazovany.kontrola_pred_ulozenim()) // { dum_ulozeni ukladany = new dum_ulozeni(zobrazovany); StringWriter sw = new StringWriter(); XmlTextWriter tw = null; XmlSerializer serializer = new XmlSerializer(typeof(dum_ulozeni)); tw = new XmlTextWriter(sw); using (StreamWriter swr = new StreamWriter("DOMY\\" + ukladany.popis + ".xml")) { serializer.Serialize(tw, ukladany); swr.Write(sw.ToString()); } zobrazovany.zobraz_dum(); // } } else { MessageBox.Show("Není načten žádný dům pro úpravu cen energií, nebo dům není uložen", "Žádný dům", MessageBoxButtons.OK); } }
public Byt_groupBox(byt tehle_byt, ceny ceny_energii, double spolecne_prostory) { tento_byt = tehle_byt; this.Width = 600; this.Height = 200; this.Text = tehle_byt.Popis; Label nadpis1 = new Label(); nadpis1.Text = "co"; nadpis1.Location = new Point(40, 20); nadpis1.Width = 50; nadpis1.ForeColor = Color.Brown; nadpis1.Parent = this; Label nadpis2 = new Label(); nadpis2.Text = "hodnota"; nadpis2.Location = new Point(120, 20); nadpis2.Width = 80; nadpis2.ForeColor = Color.Brown; nadpis2.Parent = this; Label nadpis3 = new Label(); nadpis3.Text = "cena"; nadpis3.Location = new Point(240, 20); nadpis3.Width = 80; nadpis3.ForeColor = Color.Brown; nadpis3.Parent = this; //------------------------------------------------------ Label voda = new Label(); voda.Text = "voda"; voda.Location = new Point(40, 45); voda.Width = 50; voda.Parent = this; Label elektrina = new Label(); elektrina.Text = "elektrina"; elektrina.Location = new Point(40, 70); elektrina.Width = 50; elektrina.Parent = this; Label plyn = new Label(); plyn.Text = "plyn"; plyn.Location = new Point(40, 95); plyn.Width = 50; plyn.Parent = this; Label spolecne = new Label(); spolecne.Text = "společné"; spolecne.Location = new Point(40, 120); spolecne.Width = 50; spolecne.Parent = this; //----------------------------------------------------------------------- //Hodnoty měřičů Label voda_hodnota = new Label(); voda_hodnota.Text = tehle_byt.mnozstvi_voda.ToString(); voda_hodnota.Location = new Point(120, 45); voda_hodnota.Width = 50; voda_hodnota.Parent = this; Label elektrina_hodnota = new Label(); elektrina_hodnota.Text = tehle_byt.mnozstvi_elektrina.ToString(); elektrina_hodnota.Location = new Point(120, 70); elektrina_hodnota.Width = 50; elektrina_hodnota.Parent = this; //nemusí mít!!!! if (tehle_byt.plyn != null) { Label plyn_hodnota = new Label(); plyn_hodnota.Text = tehle_byt.mnozstvi_plyn.ToString(); plyn_hodnota.Location = new Point(120, 95); plyn_hodnota.Width = 50; plyn_hodnota.Parent = this; } else { Label plyn_hodnota = new Label(); plyn_hodnota.Text = "X"; plyn_hodnota.Location = new Point(120, 95); plyn_hodnota.Width = 50; plyn_hodnota.Parent = this; } //----------------------------------------------------------------------------- // CENY double cena_voda = tehle_byt.mnozstvi_voda * ceny_energii.cena_vody_za_m3; Label voda_cena = new Label(); voda_cena.Text = cena_voda.ToString() + "Kč"; voda_cena.Location = new Point(240, 45); voda_cena.Width = 50; voda_cena.Parent = this; double cena_ele = tehle_byt.mnozstvi_elektrina * ceny_energii.cena_elektriny_za_kwh; Label elektrina_cena = new Label(); elektrina_cena.Text = cena_ele.ToString() + "Kč"; elektrina_cena.Location = new Point(240, 70); elektrina_cena.Width = 50; elektrina_cena.Parent = this; double cena_plyn = 0; if (tehle_byt.plyn != null) { cena_plyn = tehle_byt.mnozstvi_plyn * ceny_energii.cena_plynu_za_m3; Label plyn_cena = new Label(); plyn_cena.Text = cena_plyn.ToString() + "Kč"; plyn_cena.Location = new Point(240, 95); plyn_cena.Width = 50; plyn_cena.Parent = this; } else { Label plyn_cena = new Label(); plyn_cena.Text = "X"; plyn_cena.Location = new Point(240, 95); plyn_cena.Width = 50; plyn_cena.Parent = this; } Label spolecne_cena = new Label(); spolecne_cena.Text = spolecne_prostory.ToString() + "Kč"; spolecne_cena.Location = new Point(240, 120); spolecne_cena.Width = 50; spolecne_cena.Parent = this; //------------------------------------------------------------------------------ Label zalohy = new Label(); zalohy.Location = new Point(350, 80); zalohy.Text = tehle_byt.zaloha.ToString() + "Kč"; zalohy.Width = 180; zalohy.Height = 30; zalohy.ForeColor = Color.DarkBlue; zalohy.Font = new Font("Tahoma", 18, FontStyle.Bold); zalohy.Parent = this; tehle_byt.cena_voda = cena_voda; tehle_byt.cena_elektrina = cena_ele; double cena = cena_voda + cena_ele + spolecne_prostory; if (plyn != null) { tehle_byt.cena_plyn = cena_plyn; cena = cena + cena_plyn; } Label celkovacena = new Label(); celkovacena.Location = new Point(350, 30); celkovacena.Text = cena.ToString() + "Kč"; celkovacena.Width = 180; celkovacena.Height = 45; celkovacena.Font = new Font("Tahoma", 25, FontStyle.Bold); if (cena <= tehle_byt.zaloha) { celkovacena.BackColor = Color.Green; } else { celkovacena.BackColor = Color.Red; } celkovacena.Parent = this; }