X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/e5b2b618bddda6961cfaa7c8af844245f240b300..9fd7fdefa9de8b8932cd4c3951792f80ba91b676:/gui/articulos.c?ds=sidebyside diff --git a/gui/articulos.c b/gui/articulos.c index cce691a..81bb207 100644 --- a/gui/articulos.c +++ b/gui/articulos.c @@ -3,6 +3,8 @@ t_LstArticulos *lst_articulos; +t_Articulo *art_form_buscar(WINDOW *win); + t_LstArticulos *art_cargar(const char *filename) { xmlDocPtr document; @@ -109,6 +111,20 @@ t_Articulo *art_obtener(t_LstArticulos *lst, const char *numero) return NULL; } +t_Articulo *art_form_buscar(WINDOW *win) +{ + t_Form *form; + t_Articulo *articulo; + + form = form_crear(win); + form_agregar_widget(form, INPUT, "Numero de Artículo", 8, ""); + form_ejecutar(form, 1,1); + articulo = art_obtener(NULL, form_obtener_valor(form, "Numero de Artículo")); + form_destruir(form); + + return articulo; +} + void art_modificar(char *s) { WINDOW *win; @@ -119,11 +135,7 @@ void art_modificar(char *s) box(win, 0, 0); wrefresh(win); - form = form_crear(win); - form_agregar_widget(form, INPUT, "Numero de Artículo", 8, ""); - form_ejecutar(form, 1,1); - articulo = art_obtener(NULL, form_obtener_valor(form, "Numero de Artículo")); - form_destruir(form); + articulo = art_form_buscar(win); if (articulo != NULL) { form = form_crear(win); @@ -131,9 +143,12 @@ void art_modificar(char *s) form_agregar_widget(form, INPUT, "Descripción", 50, articulo->desc); form_agregar_widget(form, INPUT, "Presentación", 30, articulo->presentacion); form_agregar_widget(form, INPUT, "Stock Actual", 8, articulo->existencia); - form_agregar_widget(form, INPUT, "PVU", 30, articulo->pvu); + form_agregar_widget(form, INPUT, "PVU", 8, articulo->pvu); form_agregar_widget(form, INPUT, "Stock Mínimo", 8, articulo->emin); form_ejecutar(form, 1,1); + + /* TODO : Actualizar registro */ + form_destruir(form); } @@ -142,3 +157,56 @@ void art_modificar(char *s) delwin(win); } +void art_eliminar(char *s) +{ + WINDOW *win; + t_Articulo *articulo; + + win = newwin(8, 68, 13, 1); + box(win, 0, 0); + wrefresh(win); + + articulo = art_form_buscar(win); + + if (articulo == NULL) { + wattron(win, COLOR_PAIR(COLOR_YELLOW)); + mvwaddstr(win, 6, 4, "No existe artículo con ese código. Abortando!"); + wattroff(win, COLOR_PAIR(COLOR_YELLOW)); + wrefresh(win); + getch(); + } else { + /* TODO : Eliminar un registro */ + } + + werase(win); + wrefresh(win); + delwin(win); +} + +void art_agregar(char *s) +{ + WINDOW *win; + t_Form *form; + + win = newwin(8, 68, 13, 1); + box(win, 0, 0); + wrefresh(win); + + form = form_crear(win); + form_agregar_widget(form, INPUT, "Numero de Artículo", 8, ""); + form_agregar_widget(form, INPUT, "Descripción", 50, ""); + form_agregar_widget(form, INPUT, "Presentación", 30, ""); + form_agregar_widget(form, INPUT, "Stock Actual", 8, ""); + form_agregar_widget(form, INPUT, "PVU", 8, ""); + form_agregar_widget(form, INPUT, "Stock Mínimo", 8, ""); + form_ejecutar(form, 1,1); + + /* TODO : Agregar el nuevo elemento */ + + form_destruir(form); + + werase(win); + wrefresh(win); + delwin(win); +} +