Ejemplo n.º 1
0
        private void btnAceptar_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, object> valores;
            KeyValuePair <bool, object> result_test = new KeyValuePair <bool, object>();
            ComboItem cbtipo;
            ComboItem cbclase;
            ComboItem cbgrupo;

            cbtipo  = (ComboItem)cbTipoRecibo.SelectedItem;
            cbclase = (ComboItem)cbClaseRecibo.SelectedItem;
            cbgrupo = (ComboItem)cbGrupoRecibo.SelectedItem;


            valores = new Dictionary <string, object> {
                { "tipo", cbtipo.Valor }, { "clase", cbclase.Valor }, { "grupo", cbgrupo.Valor }, { "importe", txtImporte.Text }, { "concepto", txtConcepto.Text }, { "fecha_importe", txtFechaRecibo.Text }
            };
            result_test = ServicioFactura.Insert(valores);

            if (result_test.Key == true)
            {
                MessageBox.Show("Recibo insertado correctamente");
            }
            else
            {
                MessageBox.Show("Error al insertar el nuevo recibo: " + result_test.Value);
            }
        }
Ejemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            KeyValuePair <bool, Dictionary <int, List <string> > > tipos  = new KeyValuePair <bool, Dictionary <int, List <string> > >();
            KeyValuePair <bool, Dictionary <int, List <string> > > grupos = new KeyValuePair <bool, Dictionary <int, List <string> > >();
            KeyValuePair <bool, Dictionary <int, List <string> > > clases = new KeyValuePair <bool, Dictionary <int, List <string> > >();

            tipos  = ServicioFactura.Tipos();
            grupos = ServicioFactura.Grupos();
            clases = ServicioFactura.Clases();

            if (tipos.Key)
            {
                foreach (KeyValuePair <int, List <string> > tipo in tipos.Value)
                {
                    cbTipoRecibo.Items.Add(new ComboItem(tipo.Value[0], tipo.Key));
                }

                foreach (KeyValuePair <int, List <string> > grupo in grupos.Value)
                {
                    cbGrupoRecibo.Items.Add(new ComboItem(grupo.Value[0], grupo.Key));
                }

                foreach (KeyValuePair <int, List <string> > clase in clases.Value)
                {
                    cbClaseRecibo.Items.Add(new ComboItem(clase.Value[0], clase.Key));
                }
            }
        }
Ejemplo n.º 3
0
 public FacturasController(Context contexto) : base(contexto)
 {
     this._servicio = new ServicioFactura(this._logger, this._contexto);
 }
Ejemplo n.º 4
0
        private void TestFacturaConsulta()
        {
            Factura factura;
            Dictionary <string, object> valores;
            Dictionary <string, object> condiciones;
            ServicioFactura             sfactura;

            //Test 0: Limpiar la BD
            factura     = new Factura();
            result_test = ServicioFactura.DeleteAll();

            if (result_test.Key == true)
            {
                result.Add(new KeyValuePair <bool, object>(true, "Delete Correcto"));
            }
            else
            {
                result.Add(new KeyValuePair <bool, object>(false, "Error al insertar recibos"));
            }

            //Test 1: Insert de facturas correcto
            factura = new Factura();
            valores = new Dictionary <string, object> {
                { "tipo", 1 }, { "importe", 53.00 }, { "concepto", "Test_1" }, { "fecha_importe", "20/10/2017" }
            };
            result_test = ServicioFactura.Insert(valores);

            if (result_test.Key == true)
            {
                result.Add(new KeyValuePair <bool, object> (true, "Insert Recibo Correcto"));
            }
            else
            {
                result.Add(new KeyValuePair <bool, object>(false, "Error al insertar recibos"));
            }

            //Test 2: Insert de facturas erroneo (importe nulo)
            factura = new Factura();
            valores = new Dictionary <string, object> {
                { "tipo", 1 }, { "importe", null }, { "concepto", "Test_1" }, { "fecha_importe", "20/10/2017" }
            };
            result_test = ServicioFactura.Insert(valores);

            if (result_test.Key == false && result_test.Value == "El importe no puede estar vacio")
            {
                result.Add(new KeyValuePair <bool, object>(true, "Error de importe null Correcto"));
            }
            else
            {
                result.Add(new KeyValuePair <bool, object>(false, "Error en comprobacion de importe"));
            }

            //Test 3: Insert de facturas erroneo (tipo nulo)
            factura = new Factura();
            valores = new Dictionary <string, object> {
                { "tipo", null }, { "importe", 19.23 }, { "concepto", "Test_1" }, { "fecha_importe", "20/10/2017" }
            };
            result_test = ServicioFactura.Insert(valores);

            if (result_test.Key == false && result_test.Value == "La factura debe tener un tipo valido")
            {
                result.Add(new KeyValuePair <bool, object>(true, "Error de tipo no valido Correcto"));
            }
            else
            {
                result.Add(new KeyValuePair <bool, object>(false, "Error en comprobacion de tipo"));
            }

            //Test 4: Consulta de todas las facturas
            factura = new Factura(0);

            if (factura.total.Count == 1)
            {
                result.Add(new KeyValuePair <bool, object>(true, "Count = 1"));
            }
            else
            {
                result.Add(new KeyValuePair <bool, object>(false, "Error al consultar todas las facturas de la tabla"));
            }

            //Test 5: Modificar consultas
            factura = new Factura();
            valores = new Dictionary <string, object> {
                { "Importe", 100 }, { "Concepto", "Modificacion_1" }, { "Fecha_Importe", "24/10/2017" }
            };
            condiciones = new Dictionary <string, object> {
                { "Concepto", "Test_1" }
            };
            result_test = ServicioFactura.Modify(condiciones, valores);

            if (result_test.Key == true)
            {
                result.Add(new KeyValuePair <bool, object>(true, "Modificacion Correcta"));
            }
            else
            {
                result.Add(new KeyValuePair <bool, object>(false, "Error en la modificacion del recibo"));
            }
            //return new KeyValuePair<Boolean, string>(false, "Error al consultar la factura en la Base de Datos para los parametros: id= ");
        }