private void ChartShow_Load(object sender, EventArgs e) { foreach (Comenzi com in comChart) { facChart = com.Factura; } }
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(); } } }
public Comenzi(int nrcomanda, DateTime datacomanda, DateTime datalivrare, Facturi _factura, List <string> _articole) { NrComanda = nrcomanda; DataComanda = datacomanda; DataLivrare = datalivrare; Factura = _factura; Articole = _articole; }
private void button2_Click(object sender, EventArgs e) { using (StreamWriter sw = new StreamWriter("order list.txt")) { sw.WriteLine("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 + ", "; } facturaNoua = comanda.Factura; sw.WriteLine(comanda.NrComanda + " " + comanda.DataComanda + " " + comanda.DataLivrare + " " + ArticoleBuilder + " " + facturaNoua.nrFactura + " " + facturaNoua.nrArticole + " " + facturaNoua.termenFactura + " " + facturaNoua.sumaPlata); } } MessageBox.Show("The order list was saved into orderlist.txt file", "Lists saved"); }
public void AdaugaFactura(Facturi factura) { var queryString = "insert into Facturi(NrFactura, TermenPlata, NrArticole, Suma)" + " values(@nrfactura, @termenplata, @nrarticole, @suma);"; using (OleDbConnection connection = new OleDbConnection(ConnectionString)) { connection.Open(); var insertCommand = new OleDbCommand(queryString, connection); var nrfacturaParameter = new OleDbParameter("@nrfactura", factura.nrFactura); var termenplataParameter = new OleDbParameter("@termenplata", factura.termenFactura.ToString()); var nrarticoleParameter = new OleDbParameter("@nrarticole", factura.nrArticole); var sumaParameter = new OleDbParameter("@suma", factura.sumaPlata); insertCommand.Parameters.Add(nrfacturaParameter); insertCommand.Parameters.Add(termenplataParameter); insertCommand.Parameters.Add(nrarticoleParameter); insertCommand.Parameters.Add(sumaParameter); insertCommand.ExecuteNonQuery(); var getIdCommand = new OleDbCommand("SELECT @@Identity;", connection); factura.nrFactura = (int)getIdCommand.ExecuteScalar(); } }