Esempio n. 1
0
        public void GuardarTest()
        {
            List <DetalleVentas> lista = new List <DetalleVentas>();

            lista.Add(new DetalleVentas()
            {
                ProductoId = 1,
                Cantidad   = 2,
                Precio     = 200
            });

            lista[0].CalularSubTotal();

            Ventas venta = new Ventas()
            {
                ClienteId    = 1,
                VentaId      = 1,
                ITBIS        = 3,
                Monto        = 300,
                Balance      = 500,
                Fecha        = DateTime.Now.AddDays(2),
                DetalleVenta = lista
            };
            RepositorioVentas contexto = new RepositorioVentas();

            Assert.IsTrue(contexto.Guardar(venta));
        }
Esempio n. 2
0
        public void GuardarTest()
        {
            List <VentaDetalles> lista = new List <VentaDetalles>();

            lista.Add(new VentaDetalles()
            {
                IdProducto = 1,
                Cantidad   = 2,
                Precio     = 2500
            });

            lista[0].CalularSubTotal();

            Ventas venta = new Ventas()
            {
                IdCliente   = 1,
                IdUsuario   = 1,
                IdVendedor  = 1,
                IdVenta     = 0,
                HastaFecha  = DateTime.Now.AddDays(5),
                TasaInteres = 5,
                TipoVeta    = TiposVentas.Contado,
                Total       = 0,
                Detalles    = lista
            };


            RepositorioVentas db = new RepositorioVentas();


            Assert.IsTrue(db.Guardar(venta));
        }
 public void Guardar(Venta venta)
 {
     try
     {
         conexion = new ConexionBd();
         SqlConnection cn = conexion.AbrirConexion();
         sqlTransaction                = cn.BeginTransaction();
         repositorioVentas             = new RepositorioVentas(cn, sqlTransaction);
         repositorioVentasMedicamentos = new RepositorioVentasMedicamentos(cn, sqlTransaction);
         repositorioMedicamentos       = new RepositorioMedicamentos(cn, sqlTransaction);
         repositorioVentas.Guardar(venta);
         foreach (var vm in venta.ventasMedicamentos)
         {
             vm.venta = venta;
             repositorioVentasMedicamentos.Guardar(vm);
             repositorioMedicamentos.ModificarStok(-vm.Cantidad, vm.medicamento.MedicamentoId);
         }
         sqlTransaction.Commit();
         conexion.CerrarConexion();
     }
     catch (Exception ex)
     {
         sqlTransaction.Rollback();
         throw new Exception(ex.Message);
     }
 }
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            RepositorioVentas repositorio = new RepositorioVentas();
            Ventas            ventas      = LlenaClase();

            bool paso = false;

            if (UsuarioDropDownList != null)
            {
                if (Page.IsValid)
                {
                    if (ventas.VentaId == 0 && Utils.ToInt(TotalLabel.Text) != 0)
                    {
                        paso = repositorio.Guardar(ventas);
                    }
                    else if (Utils.ToInt(VentaIdTextBox.Text) != 0)
                    {
                        var verificar = repositorio.Buscar(Utils.ToInt(VentaIdTextBox.Text));
                        if (verificar != null)
                        {
                            paso = repositorio.Modificar(ventas);
                        }
                        else
                        {
                            Utils.ShowToastr(this, "No se encuentra el ID", "Fallo", "error");
                            return;
                        }
                    }
                    if (paso)
                    {
                        Utils.ShowToastr(this, "Registro Con Exito", "Exito", "success");
                    }
                    else
                    {
                        Utils.ShowToastr(this, "No se pudo Guardar", "Fallo", "error");
                    }
                    LimpiarCampos();
                    return;
                }
            }
            else
            {
                Utils.ShowToastr(this, "El numero de cuenta no existe", "Fallo", "error");
                return;
            }
        }
Esempio n. 5
0
        private void GuardarmetroButton_Click(object sender, EventArgs e)
        {
            if (!ValidarGuardar())
            {
                return;
            }
            _ = new Ventas();
            Ventas ventas = LlenaClase();

            RepositorioVentas contexto = new RepositorioVentas();

            try
            {
                if (IDnumericUpDown.Value == 0)
                {
                    if (contexto.Guardar(ventas))
                    {
                        MessageBox.Show("Se Guardo correctamente", "Registrada la venta!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimpiarCampos();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo guardar", "Ups!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    if (contexto.Modificar(ventas))
                    {
                        MessageBox.Show("Modificado correctamente", "Registrada la venta!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimpiarCampos();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo modificar", "Ups!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrio un error", "Ups!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        public void GuardarTest()
        {
            bool              paso;
            Ventas            ventas      = new Ventas();
            RepositorioVentas repositorio = new RepositorioVentas();

            ventas.VentaId         = 1;
            ventas.UsuarioId       = 1;
            ventas.Fecha           = DateTime.Now;
            ventas.Descripcion     = "Venta de equipo";
            ventas.NombreCliente   = "Marledy";
            ventas.TelefonoCliente = "809-361-1686";
            ventas.Itbis           = 2700;
            ventas.SubTotal        = 15000;
            ventas.Total           = 17700;

            ventas.Detalle.Add(new VentasDetalle(1, 1, 1, "Iphone 6", 1, 15000, 15000));
            paso = repositorio.Guardar(ventas);
            Assert.AreEqual(paso, true);
        }
Esempio n. 7
0
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            Ventas ventas;
            bool   paso = false;


            if (Validar())
            {
                return;
            }

            ventas = LlenaClase();

            if (VentaIdTextBox.Text == 0.ToString())
            {
                paso = RepositorioVentas.Guardar(ventas);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    Utilitarios.Utils.ShowToastr(this.Page, "El campo descripcion no puede estar vacio", "Error", "error");
                    return;
                }
                paso = RepositorioVentas.Modificar(ventas);
                Utilitarios.Utils.ShowToastr(this.Page, "Modificado", "Exito", "success");
                LimpiarCampos();
                return;
            }

            if (paso)
            {
                Utilitarios.Utils.ShowToastr(this.Page, " Se ha Guardado", "Exito", "success");
            }
            else
            {
                Utilitarios.Utils.ShowToastr(this.Page, "Se profujo un error", "Error", "error");
            }
            LimpiarCampos();
        }
Esempio n. 8
0
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            RepositorioVentas db     = new RepositorioVentas();
            Ventas            ventas = new Ventas();

            try
            {
                ventas = LlenarClase();

                if (db.Guardar(ventas))
                {
                    Utilidades.Mensaje("Guardado", this, GetType());
                    Limpiar();
                    return;
                }


                Utilidades.Mensaje("No se pudo guardar", this, GetType());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 9
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            if (!Validar())
            {
                return;
            }

            RepositorioVentas db    = new RepositorioVentas();
            Ventas            venta = LlenarClase();

            try
            {
                RepositorioBase <Clientes> dbC = new RepositorioBase <Clientes>();
                var cliente = dbC.Buscar((int)IdClientenumericUpDown.Value);

                if (TipoVentacomboBox.SelectedIndex == (int)TiposVentas.Contado)
                {
                    if (cliente.LimiteVenta < decimal.Parse(TotaltextBox.Text))
                    {
                        MessageBox.Show("Este cliente no tiene permitido comprar tanto");
                        return;
                    }
                }
                else
                if (TipoVentacomboBox.SelectedIndex == (int)TiposVentas.Credito)
                {
                    if (cliente.LimiteCredito < decimal.Parse(TotaltextBox.Text))
                    {
                        MessageBox.Show("Este cliente no tiene permitido comprar tanto a credito");
                        return;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Hubo un error!!", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                if (IdVentanumericUpDown.Value == 0)
                {
                    if (db.Guardar(venta))
                    {
                        MessageBox.Show("Guardado correctamente", "Información!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo guardar", "Atencion!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (db.Modificar(venta))
                    {
                        MessageBox.Show("Modificado correctamente", "Información!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo modificar", "Atencion!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }catch (Exception)
            {
                MessageBox.Show("Hubo un error!!", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
 public void Guardar(Venta venta)
 {
     repo.Guardar(venta);
 }