private void Final_Form_Load(object sender, EventArgs e) { tbClientFinal.Text = "Client " + clientNou.nume + " " + clientNou.prenume + " with ID " + clientNou.codClient.ToString() + " and address " + clientNou.adresa + " has the following orders:"; foreach (Comenzi comanda in clientNou.comenzi) { foreach (string s in comanda.Articole) { ArticoleBuilder = ArticoleBuilder + s + ", "; } var listviewitem = new ListViewItem(comanda.NrComanda.ToString()); listviewitem.SubItems.Add(comanda.DataComanda.ToShortDateString()); listviewitem.SubItems.Add(comanda.DataLivrare.ToShortDateString()); listviewitem.SubItems.Add(ArticoleBuilder.ToString()); facturaNoua = comanda.Factura; listviewitem.SubItems.Add(facturaNoua.nrFactura.ToString()); listviewitem.SubItems.Add(facturaNoua.nrArticole.ToString()); listviewitem.SubItems.Add(facturaNoua.termenFactura.ToString()); listviewitem.SubItems.Add(facturaNoua.sumaPlata.ToString()); lvComenzi.Items.Add(listviewitem); ArticoleBuilder = null; } altacomanda = clientNou.comenzi[clientNou.comenzi.Count - 1]; AdaugaFactura(altacomanda.Factura); MessageBox.Show("The order was sent! The invoice was saved to the database.", "Success"); }
public void btnFinal_Click(object sender, EventArgs e) { if (lvProduse.Items.Count == 0) { MessageBox.Show("Select at least one product", "Empty Basket"); } else { if (string.IsNullOrWhiteSpace(tbNumeClient.Text)) { epClient.SetError(btnEdit, "Create a client"); MessageBox.Show("Insert client data first", ""); } else { nrCom = nrCom + 1; DateTime dataCom = DateTime.Now; DateTime dataLiv = DateTime.Now.AddDays(3); DateTime termFact = DateTime.Now.AddDays(28); int nritems = ProduseAlese.Count; int pret = nritems * 200; Facturi factura = new Facturi(nrCom, nritems, termFact, pret); Comenzi comanda = new Comenzi(nrCom, dataCom, dataLiv, factura, ProduseAlese); Comenzi comanda2 = (Comenzi)comanda.Clone(); listaComenzi.Add(comanda2); int cod = Int32.Parse(tbIdClient.Text); Clienti client = new Clienti(tbNumeClient.Text, tbPrenumeClient.Text, cod, tbAdresaClient.Text, listaComenzi); Clienti client2 = (Clienti)client.Clone(); Final_Form finalform = new Final_Form(client2); finalform.Show(); } } }