private void AjouterPhoto() { if (PBX_Image.BackgroundImage != null) { Image Image = PBX_Image.BackgroundImage; GUID = DB_Images.Add(Image); } }
//---------------------------------------------------------------------------- // Partie responsable des monuments // //---------------------------------------------------------------------------- private void AjouterMonument(string[] Informations, Image image) { try { string Image_GUID = mDB_Images.Add(image); string sqlAddMonument = "insert into monuments" + "(IdMonument,nom , DateDeCreation ,histoire , NbEtoiles, GUID)values" + "(seq_Monuments.nextval,:nom,:DateDeCreation,:histoire,:NbEtoiles,:GUID)"; OracleParameter nom = new OracleParameter(":nom,", OracleDbType.Varchar2, 30); OracleParameter Date = new OracleParameter(":DateDeCreation", OracleDbType.Date); OracleParameter story = new OracleParameter(":histoire", OracleDbType.Varchar2, 100); OracleParameter Star = new OracleParameter(":NbEtoiles", OracleDbType.Int32, 1); OracleParameter Guid = new OracleParameter(":GUID", OracleDbType.Varchar2, 100); nom.Value = Informations[0]; story.Value = Informations[2]; Star.Value = Informations[1]; Date.Value = mDate.Value; Guid.Value = Image_GUID; OracleCommand OraAddMonument = new OracleCommand(sqlAddMonument, mOracleConnection); OraAddMonument.CommandType = CommandType.Text; OraAddMonument.Parameters.Add(nom); OraAddMonument.Parameters.Add(Date); OraAddMonument.Parameters.Add(story); OraAddMonument.Parameters.Add(Star); OraAddMonument.Parameters.Add(Guid); OraAddMonument.ExecuteNonQuery(); int IdMonumment = 0; int NbMonuments = 0; string sql11 = "SELECT IDMONUMENT FROM MONUMENTS WHERE NOM = '" + Informations[0] + "'"; OracleCommand cmd3 = new OracleCommand(sql11, mOracleConnection); OracleDataReader reader2 = cmd3.ExecuteReader(); reader2.Read(); IdMonumment = int.Parse(reader2.GetDecimal(0).ToString()); reader2.Close(); // Lier un monument à un circuit // NbMonuments = GetNbMonumentsParCircuit(Informations[3]); NbMonuments++; string sql = "INSERT INTO CIRCUITMONUMENTS VALUES ( " + IdMonumment + ", '" + Informations[3] + "'," + NbMonuments + ")"; OracleCommand OraInsertMonumentIntoCircuit = new OracleCommand(sql, mOracleConnection); OraInsertMonumentIntoCircuit.ExecuteNonQuery(); RemplirCBB_Monument(); } catch (Exception sqlAddMonument) { MessageBox.Show(sqlAddMonument.Message.ToString()); } }
private void BTN_Accepter_Click(object sender, EventArgs e) { if (TBX_Nom.Text != "" && TBX_Nom.Text != null && RTBX_Histoire.Text != "" && RTBX_Histoire.Text != null && DATE_Monument.Text != "" && DATE_Monument.Text != null && DATE_Monument.Text != "" && DATE_Monument.Text != null && Control_Stars.Value != 0 && PBX_Monument.BackgroundImage != null) { NouveauMonument = new Monument { Nom = TBX_Nom.Text, Prix = decimal.Parse(nudPrix.Text), Etoiles = Control_Stars.Value, DateConstruction = DATE_Monument.Value, Image = DB_Images.Add(Image), Histoire = RTBX_Histoire.Text }; SaveData(NouveauMonument); } }