private void btnCumpara_Click(object sender, EventArgs e) { inForma = false; List <Persoana> persoane = adminPersoane.GetPersoane(); try { List <Masina> masini = adminMasini.GetMasiniIndex(Convert.ToInt32(masina.IdMasina - 1)); if (masini.Last() != null) { if (masini.Last().NumeProprietar == OptiuneInfoForm.InfoPersoana.NumeComplet) { MessageBox.Show("Nu puteti cumpara o masina care va apartine!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (OptiuneInfoForm.InfoPersoana.Buget < masini.Last().Pret) { MessageBox.Show("Nu aveti suficiente fonduri pentru a cumpara aceasta masina!", "Fonduri insuficiente", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { OptiuneInfoForm.InfoPersoana.Buget -= masini.Last().Pret; adminPersoane.UpdatePersoana(OptiuneInfoForm.InfoPersoana); LoginForm.infoForm.lblBuget.Text = "Buget: " + OptiuneInfoForm.InfoPersoana.Buget + "$"; inForma = true; foreach (Persoana p in persoane) { if (p.NumeComplet == masini.Last().NumeProprietar) { p.Buget += masini.Last().Pret; adminPersoane.UpdatePersoana(p); } } masini.Last().NumeProprietar = OptiuneInfoForm.InfoPersoana.NumeComplet; masini.Last().istoricProprietari.Add(masini.Last().NumeProprietar); adminMasini.UpdateMasina(masini.Last()); lblProprietar.Text = "Proprietar: " + masini.Last().NumeProprietar; MessageBox.Show("Masina achizitionata cu succes!", "Info Cumparare", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch { MessageBox.Show("S-a produs o eroare!", "Eroare selectie", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public OptiuneDetaliiMasinaForm(Masina masina) { IStocareDataMasini adminMasini = StocareFactoryMasini.GetAdministratorStocare(); List <Masina> msn = adminMasini.GetMasiniIndex(masina.IdMasina - 1); Masina m = msn.Last(); InitializeComponent(); lblFirma.Text = "Firma: " + m.NumeFirma; lblModel.Text = "Model: " + m.Model; lblPretCurent.Text = "Pret: " + m.Pret + "$"; pictureMasina.ImageLocation = m.ImageLocation; foreach (string proprietar in m.istoricProprietari) { lblProprietar.Text += "Nume Proprietar: " + proprietar + "\n"; flowLayoutAfisare.Controls.Add(lblProprietar); } chartPreturi.Series = new SeriesCollection { new LineSeries { Values = m.istoricPreturi } }; radioGraficPret.Checked = true; }
private void pctModifica_Click(object sender, EventArgs e) { try { List <Masina> masini = adminMasini.GetMasiniIndex(Convert.ToInt32(dataGridAfisare.SelectedRows[0].Cells[0].Value) - 1); if (masini != null) { Masina m = masini.Last(); if (OptiuneInfoForm.InfoPersoana.NumeComplet == m.NumeProprietar) { OptiuneModificaForm modForm = new OptiuneModificaForm(m); modForm.ShowDialog(); } else { MessageBox.Show("Doar proprietarul masinii are voie sa aduca modificari la aceasta!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Selectati o masina pentru modificare!!!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error); } }