public bool AdaugareOperaArta(OperaArta operaArta) { try { XElement xElement = XElement.Load(@numeFisier); if (operaArta is Tablou) { Tablou tablou = (Tablou)operaArta; xElement.Add(new XElement("operaArta", new XElement("tipOpera", "tablou"), new XElement("titlu", tablou.GetTitlu()), new XElement("numeArtist", tablou.GetNumeArtist()), new XElement("anRealizare", tablou.GetAnRealizare().ToString()), new XElement("genPictura", tablou.GetGenPictura()), new XElement("tehnica", tablou.GetTehnica()) )); } else if (operaArta is Sculptura) { Sculptura sculptura = (Sculptura)operaArta; xElement.Add(new XElement("operaArta", new XElement("tipOpera", "sculptura"), new XElement("titlu", sculptura.GetTitlu()), new XElement("numeArtist", sculptura.GetNumeArtist()), new XElement("anRealizare", sculptura.GetAnRealizare().ToString()), new XElement("tip", sculptura.GetTip()) )); } else { xElement.Add(new XElement("operaArta", new XElement("tipOpera", "operaDeArta"), new XElement("titlu", operaArta.GetTitlu()), new XElement("numeArtist", operaArta.GetNumeArtist()), new XElement("anRealizare", operaArta.GetAnRealizare().ToString()) )); } xElement.Save(@numeFisier); return(true); } catch (Exception) { return(false); } }
private SqlCommand getUpdateSqlCommand(string titlu, OperaArta operaArta) { SqlCommand query = null; if (operaArta is Tablou) { Tablou tablou = (Tablou)operaArta; query = new SqlCommand("update OperaArta set [Titlu Opera]='" + tablou.GetTitlu() + "', [Nume Artist] ='" + tablou.GetNumeArtist() + "', [An Realizare] = '" + tablou.GetAnRealizare() + "', [Gen Pictura] ='" + tablou.GetGenPictura() + "', [Tehnica Pictura] ='" + tablou.GetTehnica() + "' where [Titlu Opera] ='" + titlu + "'", connection); } else if (operaArta is Sculptura) { Sculptura sculptura = (Sculptura)operaArta; query = new SqlCommand("update OperaArta set [Titlu Opera]='" + sculptura.GetTitlu() + "', [Nume Artist] ='" + sculptura.GetNumeArtist() + "', [An Realizare] = '" + sculptura.GetAnRealizare() + "', [Tip Sculptura] ='" + sculptura.GetTip() + "' where [Titlu Opera] ='" + titlu + "'", connection); } else if (operaArta is OperaArta) { query = new SqlCommand("update OperaArta set [Titlu Opera]='" + operaArta.GetTitlu() + "', [Nume Artist] ='" + operaArta.GetNumeArtist() + "', [An Realizare] = '" + operaArta.GetAnRealizare() + "' where [Titlu Opera] ='" + titlu + "'", connection); } return(query); }
private SqlCommand getInsertSqlCommand(OperaArta operaArta) { SqlCommand query = null; if (operaArta is Tablou) { Tablou tablou = (Tablou)operaArta; query = new SqlCommand("insert into OperaArta values('Tablou','" + tablou.GetTitlu() + "','" + tablou.GetNumeArtist() + "','" + tablou.GetAnRealizare() + "','" + tablou.GetGenPictura() + "','" + tablou.GetTehnica() + "','')", connection); } else if (operaArta is Sculptura) { Sculptura sculptura = (Sculptura)operaArta; query = new SqlCommand("insert into OperaArta values('Sculptura','" + sculptura.GetTitlu() + "','" + sculptura.GetNumeArtist() + "','" + sculptura.GetAnRealizare() + "','','','" + sculptura.GetTip() + "')", connection); } else if (operaArta is OperaArta) { query = new SqlCommand("insert into OperaArta values('Opera de Arta','" + operaArta.GetTitlu() + "','" + operaArta.GetNumeArtist() + "','" + operaArta.GetAnRealizare() + "','','','')", connection); } return(query); }