예제 #1
0
        protected void LinkButton_Click(object sender, EventArgs e)
        {
            var  ventaAnt = FacturaRepositorio.Buscar(Utils.ToInt(VentaIdTextBox.Text));
            bool paso     = false;

            //if (Utils.ToInt(ProductoDropDownList.SelectedValue == DetalleGridView.ro))
            if (DetalleGridView.Rows.Count > 0)
            {
                for (int i = 0; i < ((Ventas)ViewState["Detalle"]).Detalle.Count; i++)
                {
                    if (((Ventas)ViewState["Detalle"]).Detalle[i].ProductoId == Utils.ToInt(ProductoDropDownList.SelectedValue.ToString()))
                    {
                        ((Ventas)ViewState["Detalle"]).Detalle[i].Cantidad = ((Ventas)ViewState["Detalle"]).Detalle[i].Cantidad + Utils.ToInt(CantidadTextBox.Text.ToString());
                        ((Ventas)ViewState["Detalle"]).Detalle[i].Importe  = ((Ventas)ViewState["Detalle"]).Detalle[i].Cantidad * ((Ventas)ViewState["Detalle"]).Detalle[i].Precio;
                        paso = true;
                        break;
                    }
                }
                if (!paso)
                {
                    if (ventaAnt == null)
                    {
                        venta = (Ventas)ViewState["Detalle"];
                        venta.AgregarProductos(Utils.ToInt(ProductoDropDownList.SelectedValue), Utils.ToInt(CantidadTextBox.Text), Utils.ToInt(PrecioTextBox.Text), Utils.ToInt(CantidadTextBox.Text) * Utils.ToInt(PrecioTextBox.Text));
                    }
                    else
                    {
                        Utils.ShowToastr(this, "Agregado", "Exito!!", "info");
                        ventaAnt = (Ventas)ViewState["Detalle"];
                        ventaAnt.AgregarProductos(Utils.ToInt(ProductoDropDownList.SelectedValue), Utils.ToInt(CantidadTextBox.Text), Utils.ToInt(PrecioTextBox.Text), Utils.ToInt(CantidadTextBox.Text) * Utils.ToInt(PrecioTextBox.Text));
                    }
                }
            }
            else
            {
                if (ventaAnt == null)
                {
                    venta = (Ventas)ViewState["Detalle"];
                    venta.AgregarProductos(Utils.ToInt(ProductoDropDownList.SelectedValue), Utils.ToInt(CantidadTextBox.Text), Utils.ToInt(PrecioTextBox.Text), Utils.ToDouble(ImporteTextBox.Text));
                }
                else
                {
                    Utils.ShowToastr(this, "Agregado", "Exito!!", "info");
                    ventaAnt = (Ventas)ViewState["Detalle"];
                    ventaAnt.AgregarProductos(Utils.ToInt(ProductoDropDownList.SelectedValue), Utils.ToInt(CantidadTextBox.Text), Utils.ToInt(PrecioTextBox.Text), Utils.ToDouble(ImporteTextBox.Text));
                }
            }


            ViewState["Venta"]         = venta;
            DetalleGridView.DataSource = ((Ventas)ViewState["Detalle"]).Detalle;
            DetalleGridView.DataBind();
            SubTotal();
        }
예제 #2
0
        protected void eliminarutton_Click(object sender, EventArgs e)
        {
            VentaDetalle repositorio = new VentaDetalle();
            Ventas       vent        = repositorio.Buscar(Utils.ToInt(VentaIdTextBox.Text));

            if (vent != null)
            {
                repositorio.Eliminar(vent.VentaId);
                Utils.ShowToastr(this, "Registro eliminado", "Exito", "success");
                Limpiar();
            }
            else
            {
                Utils.ShowToastr(this, "Error al   eliminr", "Error", "error");

                Limpiar();
            }
        }
예제 #3
0
        protected void BuscarLinkButton_Click(object sender, EventArgs e)
        {
            VentaDetalle repositorio = new VentaDetalle();
            var          ventas      = repositorio.Buscar(
                Utils.ToInt(VentaIdTextBox.Text));

            if (ventas != null)
            {
                LlenarCampos(ventas);
                Utils.ShowToastr(this, "Busqueda exitosa", "Exito");
            }
            else
            {
                //Limpiar();
                Utils.ShowToastr(this,
                                 "No se pudo encontrar el presupuesto especificado",
                                 "Error", "error");
            }
        }