private void InfoSpectacol_Click(object sender, MouseButtonEventArgs e) { Spectacol s = view.getSpectacol(); if (s != null) { List <DistributieOp> l_distributie_op = spectacolRepo.getActoriOp(s); string str = s.ToString(); if (l_distributie_op.Count != 0) { str += "\n\nDistributie\n"; foreach (DistributieOp d in l_distributie_op) { str = str + "Actor: " + d.NumeActor + ", Rol: " + d.RolActor + "\n"; } view.showMessage(str); } else { List <DistributieBalet> l_distributie_balet = spectacolRepo.getActoriBalet(s); str += "\n\nDistributie\n"; foreach (DistributieBalet d in l_distributie_balet) { str = str + d.NumeActor + "\n"; } view.showMessage(str); } } }
public List <Spectacol> FindByDate(string nume) { m_dbConnection.Open(); List <Spectacol> ImportedFiles = new List <Spectacol>(); SQLiteCommand command = new SQLiteCommand("Select * from Spectacol where data=@data ", m_dbConnection); command.Parameters.AddWithValue("@data", nume); SQLiteDataReader reader = command.ExecuteReader(); Spectacol a = null; while (reader.Read()) { Artist art = repoA.findOne(int.Parse(reader["idArtist"].ToString())); a = new Spectacol(); a.Artist = art; a.locuriTotale = int.Parse(reader["locuriTotale"].ToString()); a.data = reader["data"].ToString(); a.locatie = reader["locatie"].ToString(); a.nume = reader["nume"].ToString(); a.id = int.Parse(reader["id"].ToString()); a.locuriOcupate = int.Parse(reader["locuriOcupate"].ToString()); ImportedFiles.Add(a); } m_dbConnection.Close(); return(ImportedFiles); }
public void test7() { //update actor Spectacol s = new Spectacol(); s.IdSpectacol = 6; s.Titlu = "Boema"; s.Regia = "Ina Hudea"; s.Gen = "Operă"; s.DataPremiere = "27.12.2018 18:00:00"; s.NumarBilete = 125; DistributieOp d_op = new DistributieOp(); d_op.IdActorOp = 44; d_op.IdSpectacol = 6; d_op.NumeActor = "Teodora Gheorghiu"; d_op.RolActor = "Mimi"; //la testul precedent a fost MImi _spectacolRepo.operatiiActorOp(d_op, 1); //update List <DistributieOp> ld_op = _spectacolRepo.getActoriOp(s); DistributieOp dtest = ld_op.Where(x => x.NumeActor == d_op.NumeActor).SingleOrDefault(); Assert.IsTrue(d_op.IdSpectacol == dtest.IdSpectacol && d_op.NumeActor == dtest.NumeActor && d_op.RolActor == dtest.RolActor); }
static void Main(string[] args) { Spectacol[] spectacole = { new Spectacol("A1", 8, 10), new Spectacol("A2", 10, 11), new Spectacol("A3", 9, 13), new Spectacol("A4", 12, 13), new Spectacol("A5", 14, 16), new Spectacol("A6", 17, 19) }; Ordoneaza(spectacole); List <Spectacol> raspuns = new List <Spectacol>(); Spectacol ultimul = spectacole[0]; raspuns.Add(ultimul); for (int i = 1; i < spectacole.Length; i++) { if (ultimul.sfarsit <= spectacole[i].inceput) { ultimul = spectacole[i]; raspuns.Add(ultimul); } } foreach (Spectacol spectacol in raspuns) { Console.Write(spectacol.nume + " "); } Console.ReadKey(); }
public Form3(LoginService loginServ, ConcerteService concerteServ, Spectacol spect) { this.loginServ = loginServ; this.concerteServ = concerteServ; this.spect = spect; InitializeComponent(); }
public void test9() { //insert bilet Spectacol s = new Spectacol(); s.IdSpectacol = 6; s.Titlu = "Boema"; s.Regia = "Ina Hudea"; s.Gen = "Operă"; s.DataPremiere = "2018-12-27 18:00:00"; s.NumarBilete = 125;//am schimbat numarul biletelor Bilet b = new Bilet(); b.IdSpectacol = 6; b.Rand = b.Coloana = 1; _spectacolRepo.insertBilet(b); List <Bilet> lb = _spectacolRepo.getBileteBySpectacol(s); Bilet btest = lb.Where(x => x.IdBilet == 28).SingleOrDefault();//28 = idBilet urmator in BD b.IdBilet = 28; Assert.IsTrue(btest.ToString() == b.ToString()); }
public void operatiiSpectacol(Spectacol s, int optiune) { try { helper.OpenConnection(); if (optiune == (int)E.CREATE) { helper.Session.Save(s); } else if (optiune == (int)E.UPDATE) { helper.Session.Update(s); } else if (optiune == (int)E.DELETE) { helper.Session.Delete(s); } helper.Commit(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } finally { helper.CloseConnection(); } }
public ICollection <Spectacol> GetAll() { IDbConnection connection = DButils.getConnection(props); IList <Spectacol> spectacole = new List <Spectacol>(); using (var command = connection.CreateCommand()) { command.CommandText = "select a.IdArtist,a.Nume,s.IdSpectacol,s.DataSpectacol,s.OraSpectacol,s.LocSpectacol,s.NrLocuri,s.NrLocuriVandute from Spectacole s JOIN Artisti a on s.IdArtist = a.IdArtist"; using (var dataReader = command.ExecuteReader()) { while (dataReader.Read()) { int idArtist = dataReader.GetInt32(0); string numeArtist = dataReader.GetString(1); int idSpec = dataReader.GetInt32(2); string dataSpec = dataReader.GetString(3); string oraSpec = dataReader.GetString(4); string locSpec = dataReader.GetString(5); int nrLocuri = dataReader.GetInt32(6); int nrLocuriVandute = dataReader.GetInt32(7); Spectacol spec = new Spectacol(idSpec, new Artist(idArtist, numeArtist), dataSpec, oraSpec, locSpec, nrLocuri, nrLocuriVandute); spectacole.Add(spec); } } } return(spectacole); }
public void rezervaLoc(Spectacol spect, int locuri) { Spectacol s = spectacolRepo.findOne((int)spect.id); s.locuriOcupate = (s.locuriOcupate + locuri); spectacolRepo.Update((int)spect.id, s); }
public List <Spectacol> findAll() { List <Spectacol> ImportedFiles = new List <Spectacol>(); m_dbConnection.Open(); SQLiteCommand command = new SQLiteCommand("Select * from Spectacol", m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { Artist art = repoA.findOne(int.Parse(reader["idArtist"].ToString())); Spectacol a = new Spectacol(); a.locuriTotale = int.Parse(reader["locuriTotale"].ToString()); a.Artist = art; a.data = reader["data"].ToString(); a.locatie = reader["locatie"].ToString(); a.nume = reader["nume"].ToString(); a.id = int.Parse(reader["id"].ToString()); a.locuriOcupate = int.Parse(reader["locuriOcupate"].ToString()); ImportedFiles.Add(a); } m_dbConnection.Close(); return(ImportedFiles); }
public void test8() { Spectacol s = new Spectacol(); s.IdSpectacol = 6; s.Titlu = "Boema"; s.Regia = "Ina Hudea"; s.Gen = "Operă"; s.DataPremiere = "2018-12-27 18:00:00"; s.NumarBilete = 125; //delete actor DistributieOp d_op = new DistributieOp(); d_op.IdActorOp = 44; d_op.IdSpectacol = 6; d_op.NumeActor = "Teodora Gheorghiu"; d_op.RolActor = "Mimi"; _spectacolRepo.operatiiActorOp(d_op, 2);//delete List <DistributieOp> ld_op = _spectacolRepo.getActoriOp(s); DistributieOp dtest = ld_op.Where(x => x.NumeActor == d_op.NumeActor).SingleOrDefault(); //System.Windows.MessageBox.Show(dtest.ToString()); Assert.IsTrue(dtest == null); }
private void Buy_Click(object sender, EventArgs e) { Bilet b = view.getBilet(); if (b == null) { view.showMessage("NU mai sunt bilete disponibile pentru acest spectacol"); } else { spectacolRepo.insertBilet(b); List <Spectacol> ls = spectacolRepo.getSpectacole(); Spectacol s = new Spectacol(); int index = -1; //cautam spectacolul cu id-ul de la bilet deoarece in UI se preia id-ul de la lista de spectacole returnata (spectacolele sunt in ord alfabetica si id-urile nu sunt in ordine) for (int i = 0; i < ls.Count && index == -1; i++) { if (ls[i].IdSpectacol == b.IdSpectacol) { s = ls[i]; index = i; } } view.setMatriceLocuri(index, spectacolRepo.getBileteBySpectacol(s), MoveMatrice_Event, MatriceLeave_Event, Matrice_Click); view.showMessage("Biletul a fost inregistrat"); } }
public ActionResult DeleteConfirmed(string id) { Spectacol spectacol = db.Spectacole.Find(id); db.Spectacole.Remove(spectacol); db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { UnitOfWork unitOfWork = new UnitOfWork(); unitOfWork.VerificareRepository.DeleteAll(); unitOfWork.VanzariLocuriRepository.DeleteAll(); unitOfWork.VanzareRepository.DeleteAll(); unitOfWork.SpectacolRepository.DeleteAll(); unitOfWork.SalaRepository.DeleteAll(); unitOfWork.Save(); Spectacol spectacol = new Spectacol { Data = Utils.RandomDay(), Pret = 100, Titlu = "Spectacol0", Sold = 0, }; unitOfWork.SpectacolRepository.Insert(spectacol); spectacol = new Spectacol { Data = Utils.RandomDay(), Pret = 200, Titlu = "Spectacol1", Sold = 0, }; unitOfWork.SpectacolRepository.Insert(spectacol); spectacol = new Spectacol { Data = Utils.RandomDay(), Pret = 150, Titlu = "Spectacol2", Sold = 0, }; unitOfWork.SpectacolRepository.Insert(spectacol); unitOfWork.Save(); unitOfWork.SalaRepository.Insert(new Sala { NrLocuri = 100 }); unitOfWork.Save(); unitOfWork.Dispose(); Server server = new Server(); server.Start(); }
public ActionResult Edit([Bind(Include = "Titlul,Regia,Distributia,Premiera,NrBilete")] Spectacol spectacol) { if (ModelState.IsValid) { db.Entry(spectacol).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(spectacol)); }
private void CreareMatriceLocuri_Click(object sender, EventArgs e) { int index = -1; Button b = (Button)sender; index = Convert.ToInt32(b.Name.Substring(9, b.Name.Length - 9)); Spectacol s = spectacolRepo.getSpectacole()[index]; view.setMatriceLocuri(index, spectacolRepo.getBileteBySpectacol(s), MoveMatrice_Event, MatriceLeave_Event, Matrice_Click); }
public bool cumparare(Spectacol spec, string nume, int nrbilete) { Spectacol nspec = spec; nspec.Disponibile = nspec.Disponibile - nrbilete; nspec.Vandute = nspec.Vandute + nrbilete; repoSpectacol.update(nspec.Id, nspec); repoCumparator.save(new Cumparator(nume, nrbilete, spec.Id)); notifyObservers(); return(true); }
public ActionResult Create([Bind(Include = "Titlul,Regia,Distributia,Premiera,NrBilete")] Spectacol spectacol) { if (ModelState.IsValid) { db.Spectacole.Add(spectacol); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(spectacol)); }
public int addSpectacol(Spectacol spec) { MySqlCommand command = new MySqlCommand(); command.CommandType = CommandType.Text; command.CommandText = "INSERT INTO `teatru`.`spectacole` (`titlul`, `regia`, `distributia`, `data_premiera`, `bilete_vanzare`) VALUES (@titlu, @regie, @distrib, @premiera, @bileteVanzare);"; command.Parameters.AddWithValue("@titlu", spec.titlu); command.Parameters.AddWithValue("@regie", spec.regie); command.Parameters.AddWithValue("@distrib", spec.distrib); command.Parameters.AddWithValue("@premiera", spec.premiera); command.Parameters.AddWithValue("@bileteVanzare", spec.bileteVanzare); return(ExeNonQuery(command)); }
public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Spectacol spectacol = db.Spectacole.Find(id); if (spectacol == null) { return(HttpNotFound()); } return(View(spectacol)); }
public int updateSpectacol(Spectacol spec, int idSpec) { MySqlCommand command = new MySqlCommand(); command.CommandType = CommandType.Text; command.CommandText = "UPDATE `teatru`.`spectacole` SET `titlul`=@titlu, `regia`=@regie, `distributia`=@distrib, `data_premiera`=@premiera, `bilete_vanzare`=@bilete WHERE `idspectacole`=@idSpec;"; command.Parameters.AddWithValue("@titlu", spec.titlu); command.Parameters.AddWithValue("@regie", spec.regie); command.Parameters.AddWithValue("@distrib", spec.distrib); command.Parameters.AddWithValue("@premiera", spec.premiera); command.Parameters.AddWithValue("@bilete", spec.bileteVanzare); command.Parameters.AddWithValue("@idSpec", idSpec); return(ExeNonQuery(command)); }
public void Save(Spectacol elem) { m_dbConnection.Open(); SQLiteCommand command = new SQLiteCommand("insert into Spectacol(nume,locatie,data,locuriTotale,locuriOcupate,idArtist) values (@nume,@locatie,@data,@locuriTotale,@locuriOcupate,@idArtist)", m_dbConnection); command.Parameters.AddWithValue("@nume", elem.nume); command.Parameters.AddWithValue("@locatie", elem.locatie); command.Parameters.AddWithValue("@data", elem.data); command.Parameters.AddWithValue("@locuriTotale", elem.locuriTotale); command.Parameters.AddWithValue("@locuriOcupate", elem.locuriOcupate); command.Parameters.AddWithValue("@idArtist", elem.Artist.id); command.ExecuteNonQuery(); m_dbConnection.Close(); }
private void UpdateSpectacol_Click(object senser, EventArgs e) { Spectacol s = view.getSpectacol(); if (s != null) { spectacoleRepo.operatiiSpectacol(s, 1); //view.clearSpectacolTextboxes(); view.populateTableSpectacole(spectacoleRepo.getSpectacole(), ModificareSpectacol_Click); view.showMessage("Spectacol modificat cu succes"); } else { view.showMessage("NU ati completat toate campurile"); } }
public void Update(int id, Spectacol elem) { m_dbConnection.Open(); SQLiteCommand command = new SQLiteCommand("update Spectacol set nume= @nume, locatie=@locatie,data = @data, locuriTotale = @locuriTotale, locuriOcupate = @locuriOcupate, idArtist = @idArtist where id = @id ", m_dbConnection); command.Parameters.AddWithValue("@nume", elem.nume); command.Parameters.AddWithValue("@locatie", elem.locatie); command.Parameters.AddWithValue("@data", elem.data); command.Parameters.AddWithValue("@locuriTotale", elem.locuriTotale); command.Parameters.AddWithValue("@locuriOcupate", elem.locuriOcupate); command.Parameters.AddWithValue("@idArtist", elem.Artist.id); command.Parameters.AddWithValue("@id", id); command.ExecuteNonQuery(); m_dbConnection.Close(); }
//--------------------------------------------actori---------------------------------------------- private void cautare_Click(object sender, EventArgs e) { Spectacol s = view.getSpectacolByTitlu(); if (s != null) { //view.showMessage(s.ToString()); List <DistributieOp> dist_Op = spectacoleRepo.getActoriOp(s); List <DistributieBalet> dist_Balet = spectacoleRepo.getActoriBalet(s); view.populateTableDistributie(dist_Op, dist_Balet, ModificareActor_Click); view.showTextboxes(); } else { view.showMessage("Nu ati selectat spectacolul"); } }
public Bilet findOne(int id) { m_dbConnection.Open(); SQLiteCommand command = new SQLiteCommand("Select * from Bilete where id = " + id, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); Bilet a = null; while (reader.Read()) { Spectacol spect = repo.findOne(int.Parse(reader["idSpectacol"].ToString())); a = new Bilet(reader["numeClient"].ToString(), int.Parse(reader["numarLocuri"].ToString()), spect); a.Id = int.Parse(reader["id"].ToString()); } m_dbConnection.Close(); return(a); }
private void button1_Click(object sender, EventArgs e) { if (dataGridView2.CurrentRow == null) { MessageBox.Show("Selectati un rand", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { String numeArtist = dataGridView2.CurrentRow.Cells[0].Value.ToString(); String locatie = dataGridView2.CurrentRow.Cells[1].Value.ToString(); String data = dateTimePicker1.Value.ToString("dd/MM/yyyy"); Spectacol s = concerteServ.findByDataArtistLocatie(data, numeArtist, locatie); Form3 form = new Form3(loginServ, concerteServ, s); this.Close(); form.Show(); } }
private void bAddSpec_Click(object sender, EventArgs e) { Spectacol addSpec = new Spectacol(); addSpec.titlu = tb_titlu.Text; addSpec.regie = tb_regia.Text; addSpec.distrib = tb_distrib.Text; addSpec.premiera = tb_data.Text; addSpec.bileteVanzare = tb_bilete.Text; if (ss.addSpectacol(addSpec) > 0) { MessageBox.Show("Spectacol inserted"); } else { MessageBox.Show("Spectacol not inserted"); } }
public void test10() { //delete spectacol Spectacol s = new Spectacol(); s.IdSpectacol = 6; s.Titlu = "Boema"; s.Regia = "Ina Hudea"; s.Gen = "Operă"; s.DataPremiere = "2018-12-27 18:00:00"; s.NumarBilete = 125; //am schimbat numarul biletelor _spectacolRepo.operatiiSpectacol(s, 2); //delete List <Spectacol> ls = _spectacolRepo.getSpectacole(); Spectacol stest = ls.Where(x => x.Titlu == s.Titlu).SingleOrDefault(); Assert.IsTrue(stest == null); }
public IList <int> GetLocuriLibere(string titlu) { RequestLocuriLibere request = new RequestLocuriLibere(); UnitOfWork unitOfWork = new UnitOfWork(); IList <Spectacol> spectacole = unitOfWork.SpectacolRepository.Get().ToList(); //unitOfWork.Dispose(); Spectacol spectacol = null; foreach (Spectacol sp in spectacole) { if (sp.Titlu == titlu) { spectacol = sp; } } return(unitOfWork.LocuriLibere(spectacol.Id)); }