public int insertShow(TVShow ashow) { MySqlCommand command = connection.CreateCommand(); command.CommandText = "insert into tvshows (name,channel,estado) values ('" + ashow.name + "'," + ashow.channel + ",2)"; command.ExecuteNonQuery(); ashow.id = (int)command.LastInsertedId; return(ashow.id); }
public int existeShowChannel(TVShow ashow) { int salida; MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; int intId, intChannel, intDescription; command.CommandText = "select id from tvshows where estado = 2 and name ='" + ashow.name + "' and channel =" + ashow.channel; Reader = command.ExecuteReader(); intId = Reader.GetOrdinal("Id"); salida = 0; while (Reader.Read()) { salida = (int)Reader.GetUInt32(intId); } Reader.Close(); return(salida); }
private void buttonEjecutar_Click(object sender, EventArgs e) { // BUSCAR SI EXISTE EL NOMBRE DEL PROGRAMA CON EL NOMBRE DEL CANAL. // SI EXISTE. USAR EL PROGRAMA // SI NO EXISTE APLICAR.- TVChannel achannel; TVShow ashow; achannel = new TVChannel(); AddValue thevalue = (AddValue)thebusqueda.ChannelsDest[this.comboBoxCanalAsignar.SelectedIndex]; achannel.id = (int)thevalue.Value; achannel.name = thevalue.Display; ashow = new TVShow(); ashow.name = this.textBoxProgramaNombre.Text; ashow.channel = achannel.id; int idTVShow = thebusqueda.existeShowChannel(ashow); if (idTVShow != 0) //existe { DialogResult result1 = MessageBox.Show( "Dicho programa existe para el mismo canal\nDesea utilizar el existente?\nSi su respuesta es NO, cambie el nombre del programa.", "Depurador de Canales", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.No) { return; } else { ashow.id = idTVShow; Transaccion atransaccion; atransaccion = new Transaccion(); atransaccion.new_tvshow = ashow.id; thebusqueda.insertTransaccion(atransaccion); thebusqueda.makeRollback(atransaccion, thebusqueda.ProgramasDest); thebusqueda.updateTvdatafiles(atransaccion, thebusqueda.ProgramasDest, ashow); thebusqueda.updateTvshow(atransaccion, thebusqueda.ProgramasDest); atransaccion.estado = 1; thebusqueda.updateTransaccion(atransaccion); } } else { thebusqueda.insertShow(ashow); Transaccion atransaccion; atransaccion = new Transaccion(); atransaccion.new_tvshow = ashow.id; thebusqueda.insertTransaccion(atransaccion); thebusqueda.makeRollback(atransaccion, thebusqueda.ProgramasDest); thebusqueda.updateTvdatafiles(atransaccion, thebusqueda.ProgramasDest, ashow); thebusqueda.updateTvshow(atransaccion, thebusqueda.ProgramasDest); atransaccion.estado = 1; thebusqueda.updateTransaccion(atransaccion); } MessageBox.Show( "Transaccion realizada con exito!!!!!", "Depurador de Canales", MessageBoxButtons.OK, MessageBoxIcon.Information); buttonConsultar_Click(null, null); }
public int updateTvdatafiles(Transaccion atransaccion, ArrayList aprogramasdest, TVShow ashow) { MySqlCommand command = connection.CreateCommand(); string commaseparatedstring; int i; commaseparatedstring = "-1000"; for (i = 0; i < aprogramasdest.Count; i++) { AddValue avalue = (AddValue)aprogramasdest[i]; commaseparatedstring = commaseparatedstring + " , " + avalue.Value; } command.CommandText = "update tvdatafiles set channel = " + ashow.channel + " , tvshow = " + atransaccion.new_tvshow + " where tvshow in (" + commaseparatedstring + ")"; command.ExecuteNonQuery(); return(0); }