protected void OnEditActionActivated(object sender, EventArgs e) { TreeIter treeIter; treeView.Selection.GetSelected (out treeIter); object id = listStore.GetValue (treeIter, 0); ArticuloView articuloView = new ArticuloView (id); }
protected void OnEditActionActivated(object sender, EventArgs e) { long id = getSelectedId(); ArticuloView articuloView = new ArticuloView(id); articuloView.Show (); // Console.WriteLine=("id={0}", id); // IDbCommand dbCommand = dbConnection.CreateCommand(); // //dbCommand.CommandText ="select * from articulo where id ="+id; //MAL // dbCommand.CommandText ="select * from articulo where id=:id"; //sql parameter con nombre,el nombre es lo que hay a la derecha de los : // IDbDataParameter dbDataParameter= dbCommand.CreateParameter(); // dbDataParameter.ParameterName="id"; // dbCommand.Parameters.Add(dbDataParameter); // dbDataParameter.Value=id; // // // IDataReader dataReader = dbCommand.ExecuteReader(); // // ArticuloView articuloView = new ArticuloView(); // articuloView.Nombre= dataReader["nombre"].ToString(); // articuloView.Precio= double.Parse (dataReader["precio"].ToString()); // articuloView.Show(); // dataReader.Close(); }
protected void OnEditActionActivated(object sender, System.EventArgs e) { long id = getSelectedId(); ArticuloView articuloView = new ArticuloView( id ); articuloView.Show (); }
protected void OnEditActionActivated(object sender, System.EventArgs e) { long id = getSelectedId(); Console.WriteLine("id={0}", id); ArticuloView articuloView = new ArticuloView(id); articuloView.Show(); dataReader.Close(); }
private void showArticulo(long id) { ArticuloView articuloView = new ArticuloView( id ); articuloView.Show (); }
protected void OnEditActionActivated(object sender, System.EventArgs e) { long id = getSelectedId(); Console.WriteLine ("id={0}", id); IDbCommand dbCommand = dbConnection.CreateCommand(); //dbCommand.CommandText = "select * from articulo where id="+id; dbCommand.CommandText = string.Format ("select * from articulo where id={0}", id); // dbCommand.CommandText = "select * from articulo where id=:id"; // IDbDataParameter dbDataParameter = dbCommand.CreateParameter(); // dbCommand.Parameters.Add (dbDataParameter); // dbDataParameter.ParameterName = "id"; // dbDataParameter.Value = id; IDataReader dataReader = dbCommand.ExecuteReader (); dataReader.Read (); ArticuloView articuloView = new ArticuloView(); articuloView.Nombre = (string)dataReader["nombre"]; articuloView.Precio = (decimal)dataReader["precio"]; articuloView.Show (); dataReader.Close (); articuloView.SaveAction.Activated += delegate { Console.WriteLine("articuloView.SaveAction.Activated"); IDbCommand dbUpdateCommand = dbConnection.CreateCommand (); dbUpdateCommand.CommandText = "update articulo set nombre=:nombre, precio=:precio where id=:id"; AddParameter (dbUpdateCommand, "nombre", articuloView.Nombre); AddParameter (dbUpdateCommand, "precio", articuloView.Precio); AddParameter (dbUpdateCommand, "id", id); // Si usamos sustitución de cadenas tendremos problemas con: // los "'" en los string, las "," en los decimal y el formato de las fechas // dbUpdateCommand.CommandText = // String.Format ("update articulo set nombre='{0}', precio={1} where id={2}", // articuloView.Nombre, articuloView.Precio, id); dbUpdateCommand.ExecuteNonQuery (); articuloView.Destroy (); }; }
protected void OnAddActionActivated(object sender, System.EventArgs e) { ArticuloView articuloView = new ArticuloView (-1); articuloView.Show (); }