示例#1
0
 protected void btnBuscarNroCredito_Click(object sender, EventArgs e)
 {
     try
     {
         NotaCredito nc;
         using (ControladorVentas c_ventas = new ControladorVentas())
         {
             nc = c_ventas.BuscarNotaCreditoXNumero(Convert.ToInt32(txtNroNotaCredito.Text));
         }
         if (nc.UtilizadaEnVenta)
         {
             mostrarExcepcionFormaPago("La nota de credito se encuentra utilizada");
         }
         else if (nc.FechaVto < DateTime.Today)
         {
             mostrarExcepcionFormaPago("La nota de credito se encuentra vencida");
         }
         else
         {
             notaCreditoActual         = nc;
             txtNroNotaCredito.Enabled = false;
             txtMontoFP.Text           = notaCreditoActual.Monto.ToString();
             txtMontoFP.Enabled        = false;
         }
     }
     catch (ExcepcionPropia myex)
     {
         mostrarExcepcionFormaPago(myex.Message);
     }
     catch (FormatException myex)
     {
         mostrarExcepcionFormaPago(myex.Message);
     }
 }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ucPanelMensajes.PanelErrorVisible   = false;
            ucPanelMensajes.PanelMensajeVisible = false;
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    cargarCbxFormaPago();
                    using (ControladorVentas c_ventas = new ControladorVentas())
                    {
                        ventaActual = c_ventas.BuscarVenta(Convert.ToInt32(Request.QueryString["id"]));
                    }
                    dgvArticulos.DataSource = ventaActual.ListLineaVenta;
                    dgvArticulos.DataBind();

                    bindGrillaFP();

                    List <Venta> listV = new List <Venta>();
                    listV.Add(ventaActual);
                    dvDetalleVenta.DataSource = listV;
                    dvDetalleVenta.DataBind();
                    lblTotal.Text = "Total : $" + ventaActual.Total.ToString();
                }
            }
        }
        catch (Exception ex)
        {
            mostrarExcepcion(ex.Message);
        }
    }
示例#3
0
 protected void btnAceptarModalFinal_Click(object sender, EventArgs e)
 {
     try
     {
         if (ventaActual.Total != ventaActual.ListFormaPago.Sum(fp => fp.Monto))
         {
             mostrarExcepcion("El total de las formas de pago debe ser igual al total de la venta");
             cerrarModal(modalConfirmarModal);
             return;
         }
         else
         {
             using (ControladorVentas c_v = new ControladorVentas())
             {
                 c_v.ModificarFormasPago(ventaActual.ListFormaPago, ventaActual.Idventa);
             }
             Response.Redirect("~/Default.aspx?m=Formas de pago modificadas con exito");
         }
     }
     catch (Exception ex)
     {
         mostrarExcepcion(ex.Message);
         cerrarModal(modalConfirmarModal);
     }
 }
示例#4
0
 protected void btnAgregarVentaFinal_Click(object sender, EventArgs e)
 {
     try
     {
         if (VentaActual.ListLineaVenta == null || VentaActual.ListLineaVenta.Count == 0)
         {
             throw new ExcepcionPropia("Debe agregar una linea de venta");
         }
         if (VentaActual.ListFormaPago == null || VentaActual.ListFormaPago.Count == 0)
         {
             throw new ExcepcionPropia("Debe agregar al menos uan forma de pago");
         }
         VentaActual.Descripcion = txtDescripcionVenta.Text;
         VentaActual.Idusuario   = ApplicationSesion.ActiveUser.Idusuario;
         VentaActual.Fecha       = DateTime.Today;
         VentaActual.Total       = Convert.ToDecimal(txtTotal.Text);
         if (VentaActual.ListFormaPago.Exists(fp => fp.AceptaNotaCredito))
         {
             if (VentaActual.Total > VentaActual.ListFormaPago.Sum(fp => fp.Monto))
             {
                 throw new ExcepcionPropia("La suma de las formas de pago debe ser igual al total de la venta");
             }
         }
         else if (VentaActual.Total != VentaActual.ListFormaPago.Sum(fp => fp.Monto))
         {
             throw new ExcepcionPropia("La suma de las formas de pago debe ser igual al total de la venta");
         }
         VentaActual.Sucursal_ = ApplicationSesion.ActiveSucursal;
         VentaActual.IdCaja    = ApplicationSesion.ActiveCaja.Idcaja;
         using (ControladorVentas c_ventas = new ControladorVentas())
         {
             c_ventas.AgregarVenta(VentaActual);
         }
         System.Text.StringBuilder sb = new System.Text.StringBuilder();
         sb.Append(@"<script type='text/javascript'>");
         sb.Append("$('#confirmModal').modal('hide');");
         sb.Append(@"</script>");
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirmaciohowModalScript", sb.ToString(), false);
         VentaActual    = null;
         ArticuloActual = null;
         Response.Redirect(ResolveUrl("~/Venta/Ventas.aspx?m='Venta Agregada Correctamente'"));
     }
     catch (ExcepcionPropia mye)
     {
         System.Text.StringBuilder sb = new System.Text.StringBuilder();
         sb.Append(@"<script type='text/javascript'>");
         sb.Append("$('#confirmModal').modal('hide');");
         sb.Append(@"</script>");
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirmaciohowModalScript", sb.ToString(), false);
         PanelError.Visible = true;
         lblError.Text      = mye.Message;
     }
 }
示例#5
0
    private void bindGrid()
    {
        try
        {
            dgvVentas.DataSource = null;
            dgvVentas.DataBind();
            lblTotal.Text = string.Empty;
            DateTime     fechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
            DateTime     fechaHasta = Convert.ToDateTime(txtFechaHasta.Text);
            List <Venta> listV      = new List <Venta>();
            using (ControladorVentas c_ventas = new ControladorVentas())
            {
                listV = c_ventas.BuscarListVentas(fechaDesde, fechaHasta, ApplicationSesion.ActiveSucursal.IdSucursal);
            }

            List <FormaPago> listFP = new List <FormaPago>();
            foreach (Venta v in listV)
            {
                listFP.AddRange(v.ListFormaPago);
            }

            string textoGastoAMostrar = "Totales [ ";
            lblTotal.Text = "";
            var groupBy = listFP.GroupBy(lv => new { lv.Descripcion });
            foreach (var grupo in groupBy)
            {
                string tipoGast = grupo.Key.Descripcion;
                string total    = listFP.Where(c => c.Descripcion == tipoGast).Sum(c => c.Monto).ToString();
                textoGastoAMostrar = textoGastoAMostrar + tipoGast + ": $" + total + " | ";
            }
            textoGastoAMostrar = textoGastoAMostrar + "] Total: $" + listV.Sum(gg => gg.Total);
            lblTotal.Text      = textoGastoAMostrar;

            dgvVentas.DataSource = listV;
            dgvVentas.DataBind();
            // lblTotal.Text = "Total: $" + listV.Sum(v => v.Total).ToString();
        }
        catch (ExcepcionPropia mye)
        {
            PanelError.Visible = true;
            lblError.Text      = mye.Message;
        }
        catch (FormatException mye)
        {
            PanelError.Visible = true;
            lblError.Text      = mye.Message;
        }
    }
示例#6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     PanelError.Visible   = false;
     PanelMensaje.Visible = false;
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != null)
         {
             int idVenta = Convert.ToInt32(Request.QueryString["id"].ToString());
             using (ControladorVentas c_ventas = new ControladorVentas())
             {
                 ventaActual = c_ventas.BuscarVenta(idVenta);
             }
         }
     }
 }
示例#7
0
 protected void btnAceptarEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         using (ControladorVentas c_ventas = new ControladorVentas())
         {
             c_ventas.EliminarVenta(Convert.ToInt32(hfIdVentaAeliminar.Value));
         }
         mostrarMensaje("Venta Eliminada Con Exito");
         bindGrid();
         cerrarModal(modalEliminar);
     }
     catch (ExcepcionPropia ex)
     {
         mostrarExcepcion(ex.Message);
         cerrarModal(modalEliminar);
     }
 }
示例#8
0
 protected void btnAceptarModificarDescModal_Click(object sender, EventArgs e)
 {
     try
     {
         int idVenta = Convert.ToInt32(hfIdVentaModificarDescripcion.Value);
         using (ControladorVentas c_ventas = new ControladorVentas())
         {
             c_ventas.ModificarVenta(idVenta, txtDescripcionModificarModal.Text);
         }
         cerrarModal(modalModificarDescripcion);
         mostrarMensaje("Descripcion de venta Modificada con exito");
         bindGrid();
     }
     catch (ExcepcionPropia ex)
     {
         cerrarModal(modalModificarDescripcion);
         mostrarExcepcion(ex.Message);
     }
 }
示例#9
0
    protected void btnAceptarModalCambio_Click(object sender, EventArgs e)
    {
        try
        {
            Articulo artAModificar = new Articulo();
            artAModificar.Idarticulo = Convert.ToInt32(hfIdArticuloACambiar.Value);

            Articulo artNuevo = new Articulo();
            artNuevo.Idarticulo = Convert.ToInt32(cbxArticulosModal.SelectedValue);

            VentaLineaCambio vdc = new VentaLineaCambio();
            vdc.IdVenta          = ventaActual.Idventa;
            vdc.Articulo         = artNuevo;
            vdc.ArticuloAnterior = artAModificar;
            vdc.Cantidad         = Convert.ToInt32(txtCantidad.Text);
            vdc.FechaCambio      = DateTime.Today;
            vdc.IdUsuario        = ApplicationSesion.ActiveUser.Idusuario;


            VentaLinea vl = new VentaLinea();
            vl.Articulo       = artNuevo;
            vl.Cantidad       = Convert.ToInt32(txtCantidad.Text);
            vl.Idventa        = ventaActual.Idventa;
            vl.PrecioUnitario = ventaActual.ListLineaVenta.FirstOrDefault(lv => lv.Idarticulo == artAModificar.Idarticulo).PrecioUnitario;

            using (ControladorVentas c_vemtas = new ControladorVentas())
            {
                c_vemtas.RealizarCambio(vl, vdc);
            }
            Response.Redirect(ResolveUrl("~/Venta/Ventas.aspx?m='Cambio Realizado Correctamete'"));
        }
        catch (ExcepcionPropia ex)
        {
            cerrarModal(modalArticulo);
            mostrarExcepcion(ex.Message);
        }
        catch (FormatException ex)
        {
            cerrarModal(modalArticulo);
            mostrarExcepcion(ex.Message);
        }
    }
示例#10
0
 private void bindGrillaNotaCredito()
 {
     try
     {
         DateTime           fechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
         DateTime           fechaHasta = Convert.ToDateTime(txtFechaHasta.Text);
         List <NotaCredito> listNc;
         using (ControladorVentas c_ventas = new ControladorVentas())
         {
             listNc = c_ventas.BuscarListNotaCredito(fechaDesde, fechaHasta);
         }
         dgvNotaCredito.DataSource = null;
         dgvNotaCredito.DataSource = listNc;
         dgvNotaCredito.DataBind();
     }
     catch (ExcepcionPropia myex)
     {
         mostrarExcepcion(myex.Message);
     }
 }
示例#11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucPanelMensajes.PanelErrorVisible   = false;
        ucPanelMensajes.PanelMensajeVisible = false;
        if (!IsPostBack)
        {
            try
            {
                if (Request.QueryString["id"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    using (ControladorVentas c_venta = new ControladorVentas())
                    {
                        ventaActual = c_venta.BuscarVenta(id);
                    }
                    txtFechaVto.Text = DateTime.Today.AddMonths(3).ToShortDateString();

                    List <Venta> listV = new List <Venta>();
                    listV.Add(ventaActual);
                    dvVentas.DataSource = listV;
                    dvVentas.DataBind();

                    dgvFormaPago.DataSource = ventaActual.ListFormaPago;
                    dgvFormaPago.DataBind();

                    dgvLinaVenta.DataSource = ventaActual.ListLineaVenta;
                    dgvLinaVenta.DataBind();
                }
                else
                {
                    Response.Redirect("");
                }
            }
            catch (ExcepcionPropia myex)
            {
                mostrarExcepcion(myex.Message);
            }
        }
    }
示例#12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ucPanelMensajes.PanelErrorVisible   = false;
        ucPanelMensajes.PanelMensajeVisible = false;
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                int idVenta = Convert.ToInt32(Request.QueryString["id"]);
                using (ControladorVentas c_ventas = new ControladorVentas())
                {
                    ventaActual = c_ventas.BuscarVenta(idVenta);
                }
                List <Venta> listV = new List <Venta>();
                listV.Add(ventaActual);
                dgvVEnta.DataSource = listV;
                dgvVEnta.DataBind();

                dgvArticulosACambiar.DataSource = ventaActual.ListLineaVenta;
                dgvArticulosACambiar.DataBind();
            }
        }
    }
示例#13
0
 protected void btnGenerarNotaCredito_Click(object sender, EventArgs e)
 {
     try
     {
         if (DateTime.Now >= Convert.ToDateTime(txtFechaVto.Text))
         {
             mostrarExcepcion("La fecha de vencimiento debe ser mayor a la fecha actual");
         }
         else
         {
             int idUsuario = ApplicationSesion.ActiveUser.Idusuario;
             using (ControladorVentas c_ventas = new ControladorVentas())
             {
                 notaCreditoActual.IdnotaCredito = c_ventas.AgregarNotaCredito(idUsuario, Convert.ToDateTime(txtFechaVto.Text), txtDescripcionNotaCredito.Text, Convert.ToDecimal(txtTotal.Text), notaCreditoActual.ListLineasVentaDevueltas);
             }
             Response.Redirect("~/Venta/Ventas.aspx?m=Nota de credito creada correctamente");
         }
     }
     catch (ExcepcionPropia myex)
     {
         mostrarExcepcion(myex.Message);
     }
 }
示例#14
0
    protected void dgvVentas_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            int index = Convert.ToInt32(e.CommandArgument);
            if (e.CommandName.Equals("detVenta"))
            {
                Venta v;
                using (ControladorVentas c_ventas = new ControladorVentas())
                {
                    v = c_ventas.BuscarVenta(Convert.ToInt32(dgvVentas.DataKeys[index].Value));
                }

                hfIdVenta.Value = v.Idventa.ToString();
                List <Venta> listv = new List <Venta>();
                listv.Add(v);
                dvDetalleVenta.DataSource = listv;
                dvDetalleVenta.DataBind();
                dgvArticulos.DataSource = v.ListLineaVenta;
                dgvArticulos.DataBind();

                dgvFormaPago.DataSource = v.ListFormaPago;
                dgvFormaPago.DataBind();

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$('#detModal').modal('show');");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "confirmaciohowModalScript", sb.ToString(), false);
            }
            else if (e.CommandName.Equals("cambio"))
            {
                Response.Redirect("~/Venta/VentaCambio.aspx?id=" + dgvVentas.DataKeys[index].Value.ToString());
            }
            else if (e.CommandName.Equals("notaCredito"))
            {
                Response.Redirect("~/Venta/VentaNotaCredito.aspx?id=" + dgvVentas.DataKeys[index].Value.ToString());
            }
            else if (e.CommandName.Equals("cambios"))
            {
                int idVenta = Convert.ToInt32(dgvVentas.DataKeys[index].Value);
                List <VentaLineaCambio> listV;
                using (ControladorVentas c_venta = new ControladorVentas())
                {
                    listV = c_venta.BuscarListCambios(idVenta);
                }
                dgvHistorialCambio.DataSource = listV;
                dgvHistorialCambio.DataBind();
                abrirModal(modalHistorial);
            }
            else if (e.CommandName.Equals("editarDescripcion"))
            {
                Venta v;
                using (ControladorVentas c_ventas = new ControladorVentas())
                {
                    v = c_ventas.BuscarVenta(Convert.ToInt32(dgvVentas.DataKeys[index].Value));
                }
                hfIdVentaModificarDescripcion.Value = v.Idventa.ToString();
                txtDescripcionModificarModal.Text   = v.Descripcion;
                abrirModal(modalModificarDescripcion);
            }
            else if (e.CommandName.Equals("eliminar"))
            {
                hfIdVentaAeliminar.Value = dgvVentas.DataKeys[index].Value.ToString();
                abrirModal(modalEliminar);
            }
            else if (e.CommandName.Equals("editarFormaPago"))
            {
                Response.Redirect("~/Venta/FormaPagoModificar.aspx?id=" + dgvVentas.DataKeys[index].Value.ToString());
            }
        }
        catch (ExcepcionPropia ex)
        {
            mostrarExcepcion(ex.Message);
        }
    }