private void Guardarbutton_Click(object sender, EventArgs e)
        {
            Factura            factura;
            bool               Paso        = false;
            RepositorioFactura repositorio = new RepositorioFactura();

            if (HayErrores())
            {
                MessageBox.Show("Favor revisar todos los campos!!", "Validación!!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            factura = LlenaClase();

            if (IdnumericUpDown.Value == 0)
            {
                int num = Convert.ToInt32(TipoPagocomboBox.SelectedIndex);
                if (num == 0)
                {
                    Paso = repositorio.GuardarNormal(factura);
                    MessageBox.Show("Guardado!!", "Exito",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (num == 1)
                {
                    Paso = repositorio.Guardar(factura);
                    MessageBox.Show("Guardado!!", "Exito",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                int id = Convert.ToInt32(IdnumericUpDown.Value);
                RepositorioBase <Factura> repositorioDos = new RepositorioBase <Factura>();
                Factura fac = repositorioDos.Buscar(id);

                if (fac != null)
                {
                    Paso = repositorio.Modificar(factura);
                    MessageBox.Show("Modificado!!", "Exito",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Id no existe", "Falló",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (Paso)
            {
                Nuevobutton.PerformClick();
            }
            else
            {
                MessageBox.Show("No se pudo guardar!!", "Fallo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected void ButtonGuardar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                RepositorioFactura rb = new RepositorioFactura();;

                int id = 0;

                if (ComprobarID(id) == 0)
                {
                    if (rb.Guardar(LlenaClase()))
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "toastr_message", script: "toastr['success']('Facturas Guardada');", addScriptTags: true);
                        ClearAll();
                        total = 0;
                    }
                }
                else
                {
                    if (rb.Modificar(LlenaClase()))
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "toastr_message", script: "toastr['success']('Factura Modificada');", addScriptTags: true);
                    }
                    ClearAll();
                }
            }
        }
        public void GuardarTest()
        {
            RepositorioFactura    repositorio = new RepositorioFactura();
            Facturas              factura     = new Facturas();
            List <DetalleFactura> detalle     = new List <DetalleFactura>();

            factura.FacturaId = 0;
            factura.ClienteId = 1;
            factura.Fecha     = DateTime.Now;
            factura.UsuarioId = 1;
            factura.Detalles  = detalle;
            factura.Total     = 0;
            Assert.IsTrue(repositorio.Guardar(factura));
        }
        protected void guardarButton_Click(object sender, EventArgs e)
        {
            bool paso = false;
            RepositorioFactura repositorio = new RepositorioFactura();
            Factura            factura     = new Factura();

            if (HayErrores())
            {
                return;
            }
            else
            {
                factura = LlenarClase();

                if (Utils.ToInt(facturaIdTextBox.Text) == 0)
                {
                    paso = repositorio.Guardar(factura);
                    Utils.ShowToastr(this, "Guardado", "Exito", "success");
                    LimpiaObjetos();
                }
                else
                {
                    RepositorioFactura repository = new RepositorioFactura();
                    int id = Utils.ToInt(facturaIdTextBox.Text);
                    factura = repository.Buscar(id);

                    if (factura != null)
                    {
                        paso = repository.Modificar(LlenarClase());
                        Utils.ShowToastr(this, "Modificado", "Exito", "success");
                        LimpiaObjetos();
                    }
                    else
                    {
                        Utils.ShowToastr(this, "Id no existe", "Error", "error");
                    }
                }

                if (paso)
                {
                    LimpiaObjetos();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo guardar", "Error", "error");
                }
            }
        }
        public void GuardarTest()
        {
            bool               paso;
            Facturas           ventas      = new Facturas();
            RepositorioFactura repositorio = new RepositorioFactura();

            ventas.IdFactura   = 1;
            ventas.IdCliente   = 1;
            ventas.Fecha       = DateTime.Now;
            ventas.Monto       = 200;
            ventas.Observacion = "Venta al contado";
            ventas.Cantidad    = 1;

            ventas.Lista.Add(new FacturasDetalle(1, 1, 1, 1, "Maria", 200, 200));
            paso = repositorio.Guardar(ventas);
            Assert.AreEqual(paso, true);
        }
예제 #6
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            if (!Validar())
            {
                return;
            }
            bool               paso;
            Facturas           facturas;
            RepositorioFactura repositorio = new RepositorioFactura();

            facturas = LlenaClase();

            if (IDnumericUpDown.Value == 0)
            {
                paso = repositorio.Guardar(facturas);
            }
            else
            {
                if (!Existe())
                {
                    MessageBox.Show("No se puede modificar porque no existe en la base de datos.",
                                    "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = repositorio.Modificar(facturas);
            }

            if (paso)
            {
                MessageBox.Show("Guardado!!", "ButterSoft", MessageBoxButtons.OK, MessageBoxIcon.Information);
                var resultado = MessageBox.Show("Deseas imprimir esta factura?.", "ButterSoft", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (resultado == DialogResult.Yes)
                {
                    ReporteFacturaConsumidor reporte = new ReporteFacturaConsumidor(Detalle);
                    reporte.ShowDialog();
                }
                Limpiar();
            }
            else
            {
                MessageBox.Show("No fue posible guardar!!", "ButterSoft", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            bool paso = false;
            RepositorioFactura repof = new RepositorioFactura();

            Facturas factura = new Facturas();

            if (!Validar())
            {
                return;
            }

            factura = LlenarClase();

            int Id = Convert.ToInt32(ClienteComboBox.SelectedValue.ToString());


            if (IDNumericUpDown.Value == 0)
            {
                paso = repof.Guardar(factura, Id);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar", "Facturacion no registrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = repof.Modificar(factura);
            }

            if (paso)
            {
                Limpiar();
                MessageBox.Show("Guardado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else
            {
                MessageBox.Show("No fue posible guardar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #8
0
        public void Guardar()
        {
            RepositorioFactura repositorio = new RepositorioFactura();
            Factura            factura     = new Factura();

            factura.FacturaId     = 15;
            factura.Fecha         = DateTime.Now;
            factura.UsuarioId     = 1;
            factura.NombreUsuario = "Lenington";
            factura.ClienteId     = 1;
            factura.NombreUsuario = "Albert";
            factura.Itbis         = 200f;
            factura.SubTotal      = 800f;
            factura.Total         = 1000;

            factura.Detalle.Add(new FacturaDetalle(18, 15, 1, "Salami Induveca", 2, 150, 300));
            factura.Detalle.Add(new FacturaDetalle(19, 15, 1, "Salami Don Pedro", 1, 200, 200));

            bool paso = repositorio.Guardar(factura);

            Assert.AreEqual(true, paso);
        }
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            RepositorioFactura repositorio = new RepositorioFactura();
            Servicios          servicios   = repositorio.Buscar(Utils.ToInt(IDTextBox.Text));

            if (Validar())
            {
                return;
            }
            if (servicios == null)
            {
                if (repositorio.Guardar(LlenaClase()))
                {
                    Utils.ShowToastr(this, "Guardado", "Exito", "success");
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this, "No existe", "Error", "error");
                    Limpiar();
                }
            }
            else
            {
                if (repositorio.Modificar(LlenaClase()))
                {
                    Utils.ShowToastr(this.Page, "Modificado con exito!!", "Guardado", "success");
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this.Page, "No se puede modificar", "Error", "error");
                    Limpiar();
                }
            }
        }