private void toolStripBtExportTXT_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Salveaza fisier TXT"; sfd.Filter = "Fisiere txt (*.txt)|*.txt|Toate fisierele (*.*)|*.*"; sfd.FilterIndex = 1; if (DialogResult.Cancel != sfd.ShowDialog()) { StreamWriter sw = new StreamWriter(sfd.FileName); foreach (Clienti each in listaClienti) { sw.Write(each.Nume + " | " + each.Prenume + " | " + each.SerieBuletin + " | " + each.Telefon + " | " + each.Adresa + " | " + each.CNP.ToString() + " | " + each.DataNasterii); sw.Write("\n{\n"); foreach (Asigurari each2 in each.listaAsigurari) { if (each2.tipAsigurare.ToString() == "Locuinta") { Locuinta local = each2 as Locuinta; sw.Write(local.tipAsigurare.ToString() + " | " + local.denumireBun + " | " + local.numeAsigurator + " | " + local.sumaAsigurare.ToString() + " | " + local.locatieBun + " | " + local.dataPolitaInceput + " | " + local.dataPolitaSfarsit + " | " + local.Adresa + " | " + local.tip.ToString() + " | " + local.numarNiveluri.ToString() + " | " + local.suprafataTotala.ToString() + " | " + local.suprafataUtilizabila.ToString() + " | " + local.numarCamere.ToString()); sw.Write("\n"); } else if (each2.tipAsigurare.ToString() == "Automobil") { Automobil local = each2 as Automobil; sw.Write(local.tipAsigurare.ToString() + " | " + local.denumireBun + " | " + local.numeAsigurator + " | " + local.sumaAsigurare.ToString() + " | " + local.locatieBun + " | " + local.dataPolitaInceput + " | " + local.dataPolitaSfarsit + " | " + local.marca + " | " + local.model + " | " + local.numarImatriculare + " | " + local.serieSasiu + " | " + local.capacitateCilindrica.ToString() + " | " + local.numarLocuri.ToString() + " | " + local.masaMaximaAdmisa.ToString()); sw.Write("\n"); } else if (each2.tipAsigurare.ToString() == "Viata") { Viata local = each2 as Viata; sw.Write(local.tipAsigurare.ToString() + " | " + local.denumireBun + " | " + local.numeAsigurator + " | " + local.sumaAsigurare.ToString() + " | " + local.locatieBun + " | " + local.dataPolitaInceput + " | " + local.dataPolitaSfarsit + " | " + local.varsta + " | " + local.grupaSangvina + " | " + local.inaltime.ToString() + " | " + local.greutate.ToString() + " | " + local.gen.ToString() + " | " + local.stareCivila.ToString()); sw.Write("\n"); } else { AlteBunuri local = each2 as AlteBunuri; sw.Write(local.tipAsigurare.ToString() + " | " + local.denumireBun + " | " + local.numeAsigurator + " | " + local.sumaAsigurare.ToString() + " | " + local.locatieBun + " | " + local.dataPolitaInceput + " | " + local.dataPolitaSfarsit + " | " + local.detaliiBun); sw.Write("\n"); } } sw.Write("}\n"); } sw.Close(); } }
private void btAdauga_Click(object sender, EventArgs e) { String denumireBun = tbDenumire.Text; String locatie = tbLocatie.Text; String nume = tbNume.Text; float.TryParse(tbSuma.Text, out float suma); String dataI = dtpInceput.Text; String dataS = dtpSfarsit.Text; String tipAsigurare = cbTip.Text; if (tipAsigurare == "AlteBunuri") { AlteBunuri asigurare = new AlteBunuri(denumireBun, nume, locatie, suma, dataI, dataS, tipAsigurare); local.listaAsigurari.Add(asigurare); } else if (tipAsigurare == "Viata") { Viata asigurare = new Viata(denumireBun, nume, locatie, suma, dataI, dataS, tipAsigurare); local.listaAsigurari.Add(asigurare); } else if (tipAsigurare == "Locuinta") { Locuinta asigurare = new Locuinta(denumireBun, nume, locatie, suma, dataI, dataS, tipAsigurare); local.listaAsigurari.Add(asigurare); } else { Automobil asigurare = new Automobil(denumireBun, nume, locatie, suma, dataI, dataS, tipAsigurare); local.listaAsigurari.Add(asigurare); } populareListViewAsigurari(); }
private void btAdaugaDetalii_Click(object sender, EventArgs e) { if (lvAsigurari.CheckedItems.Count != 1) { } else { Console.Write(lvAsigurari.Items[lvAsigurari.CheckedIndices[0]].SubItems[6].Text); if (lvAsigurari.Items[lvAsigurari.CheckedIndices[0]].SubItems[6].Text == "Viata") { Viata item = local.listaAsigurari.ElementAt(lvAsigurari.CheckedIndices[0]) as Viata; AsigurareViataForm form = new AsigurareViataForm(item); form.ShowDialog(); } else if (lvAsigurari.Items[lvAsigurari.CheckedIndices[0]].SubItems[6].Text == "AlteBunuri") { AlteBunuri item = local.listaAsigurari.ElementAt(lvAsigurari.CheckedIndices[0]) as AlteBunuri; AsigurareAlteBunuriForm form = new AsigurareAlteBunuriForm(item); form.ShowDialog(); } else if (lvAsigurari.Items[lvAsigurari.CheckedIndices[0]].SubItems[6].Text == "Locuinta") { Locuinta item = local.listaAsigurari.ElementAt(lvAsigurari.CheckedIndices[0]) as Locuinta; AsigurariLocuintaForm form = new AsigurariLocuintaForm(item); form.ShowDialog(); } else if (lvAsigurari.Items[lvAsigurari.CheckedIndices[0]].SubItems[6].Text == "Automobil") { Automobil item = local.listaAsigurari.ElementAt(lvAsigurari.CheckedIndices[0]) as Automobil; AsigurareAutomobilForm form = new AsigurareAutomobilForm(item); form.ShowDialog(); } } }
public AsigurareAlteBunuriForm(Asigurari c) { InitializeComponent(); local = c as AlteBunuri; }
private void menuExportCSV_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Salveaza fisier CSV"; sfd.Filter = "Fisier CSV(*.csv)|*.csv|All files(*.*)|*.*"; sfd.FilterIndex = 1; if (DialogResult.OK == sfd.ShowDialog()) { StreamWriter sw = new StreamWriter(sfd.FileName); sw.Write("Nume/Tip Asigurare,Prenume/Denumire Bun," + "Serie Buletin/Nume Asigurator," + "Telefon/Suma Asigurare," + "Adresa/Locatie Bun," + "CNP/Data inceput," + "Data Nasterii/Data Sfarsit," + "Adresa/Marca/Varsta/Alte Detalii," + "Tip Casa/Model/Grupa Sanguina," + "Numar niveluri/Numar Inmatriculare/Inaltime," + "Suprafata Totala/Serie Inmatriculare/Greutate," + "Suprafata Utila/CC/Sex," + "Numar Camere/Numar Locuri/Stare Civila," + "Masa Maxima\n"); foreach (Clienti each in listaClienti) { sw.Write(each.Nume + "," + each.Prenume + "," + each.SerieBuletin + "," + each.Telefon + "," + each.Adresa + "," + each.CNP.ToString() + "," + each.DataNasterii); sw.Write("\n\n"); foreach (Asigurari each2 in each.listaAsigurari) { if (each2.tipAsigurare.ToString() == "Locuinta") { Locuinta local = each2 as Locuinta; sw.Write(local.tipAsigurare.ToString() + "," + local.denumireBun + "," + local.numeAsigurator + "," + local.sumaAsigurare.ToString() + "," + local.locatieBun + "," + local.dataPolitaInceput + "," + local.dataPolitaSfarsit + "," + local.Adresa + "," + local.tip.ToString() + "," + local.numarNiveluri.ToString() + "," + local.suprafataTotala.ToString() + "," + local.suprafataUtilizabila.ToString() + "," + local.numarCamere.ToString()); sw.Write("\n"); } else if (each2.tipAsigurare.ToString() == "Automobil") { Automobil local = each2 as Automobil; sw.Write(local.tipAsigurare.ToString() + "," + local.denumireBun + "," + local.numeAsigurator + "," + local.sumaAsigurare.ToString() + "," + local.locatieBun + "," + local.dataPolitaInceput + "," + local.dataPolitaSfarsit + "," + local.marca + "," + local.model + "," + local.numarImatriculare + "," + local.serieSasiu + "," + local.capacitateCilindrica.ToString() + "," + local.numarLocuri.ToString() + "," + local.masaMaximaAdmisa.ToString()); sw.Write("\n"); } else if (each2.tipAsigurare.ToString() == "Viata") { Viata local = each2 as Viata; sw.Write(local.tipAsigurare.ToString() + "," + local.denumireBun + "," + local.numeAsigurator + "," + local.sumaAsigurare.ToString() + "," + local.locatieBun + "," + local.dataPolitaInceput + "," + local.dataPolitaSfarsit + "," + local.varsta + "," + local.grupaSangvina + "," + local.inaltime.ToString() + "," + local.greutate.ToString() + "," + local.gen.ToString() + "," + local.stareCivila.ToString()); sw.Write("\n"); } else if (each2.tipAsigurare.ToString() == "AlteBunuri") { AlteBunuri local = each2 as AlteBunuri; sw.Write(local.tipAsigurare.ToString() + "," + local.denumireBun + "," + local.numeAsigurator + "," + local.sumaAsigurare.ToString() + "," + local.locatieBun + "," + local.dataPolitaInceput + "," + local.dataPolitaSfarsit + "," + local.detaliiBun); sw.Write("\n"); } else { sw.Write(each2.tipAsigurare.ToString() + "," + each2.denumireBun + "," + each2.numeAsigurator + "," + each2.sumaAsigurare.ToString() + "," + each2.locatieBun + "," + each2.dataPolitaInceput + "," + each2.dataPolitaSfarsit); } } sw.Write("\n\n\n"); } sw.Close(); } }