예제 #1
1
        public CategoriaController(Categoria categoria, CategoriaView categoriaView)
        {
            categoriaView.Nombre = categoria.Nombre;

            categoriaView.SaveActionDelegate = delegate {
                categoria.Nombre = categoriaView.Nombre;
                Categoria.Save(categoria);
            };
        }
예제 #2
0
 public static void Save(Categoria categoria)
 {
     IDbCommand updateDbCommand = App.Instance.DbConnection.CreateCommand ();
     updateDbCommand.CommandText = "update categoria set nombre=@nombre where id=" + categoria.Id;
     DbCommandUtil.AddParameter (updateDbCommand, "nombre", categoria.Nombre);
     updateDbCommand.ExecuteNonQuery ();
 }
예제 #3
0
        public CategoriaController(Categoria categoria, CategoriaView categoriaView)
        {
            this.categoria = categoria;
            this.categoriaView = categoriaView;
            categoriaView.Nombre = categoria.Nombre;

            categoriaView.SaveAction.Activated += delegate{
                saveActionHandler ();
            };
        }
예제 #4
0
        public static Categoria Load(string id)
        {
            IDbCommand selectDbCommand = App.Instance.DbConnection.CreateCommand ();
            selectDbCommand.CommandText = "select nombre from categoria where id=" + id;
            IDataReader dataReader = selectDbCommand.ExecuteReader();
            dataReader.Read(); //lee el primero

            Categoria categoria = new Categoria();
            categoria.Id = int.Parse (id);
            categoria.Nombre = dataReader["nombre"].ToString();
            dataReader.Close ();
            return categoria;
        }
예제 #5
0
파일: Program.cs 프로젝트: nerea123/ad
        public static Categoria Load(string id)
        {
            IDbCommand select = App.Instance.DbConnection.CreateCommand ();
            select.CommandText = string.Format("select nombre from categoria where id={0}",id);
            IDataReader reader = select.ExecuteReader ();
            reader.Read ();

            Categoria categoria = new Categoria ();
            categoria.Id = int.Parse (id);
            categoria.Nombre = reader ["nombre"].ToString ();
            reader.Close ();

            return categoria;
        }
예제 #6
0
파일: Program.cs 프로젝트: nerea123/ad
        public static void Main(string[] args)
        {
            string connectionString="Server=localhost;Database=dbprueba;" +
                                     "User Id=root;Password=sistemas";

            MySqlConnection mySqlConnection = new MySqlConnection(connectionString);

            Categoria cat = new Categoria ();
            cat.Nombre = DateTime.Now.ToString ();

            Categoria.Save (cat);

            App.Instance.DbConnection=mySqlConnection;
            Application.Init ();
            MainWindow win = new MainWindow ();
            win.Show ();
            Application.Run ();
        }