//Agrega Combos a la orden protected void CombosGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); Expression <Func <Combos, bool> > filtro = p => true; RepositorioBase <Combos> repositorio = new RepositorioBase <Combos>(); var lista = repositorio.GetList(c => true); Ventas ventas = new Ventas(); var combos = repositorio.Buscar(lista[index].ComboId); if (CarritodeCombosGridView.Rows.Count != 0) { ventas.DetalleCombo = (List <CombosDetalle>)ViewState["CombosDetalle"]; } ventas.DetalleCombo.Add(new CombosDetalle(combos.NombreCombo, combos.PrecioTotalCombo)); Decimal.TryParse(TotalTextBox.Text, out decimal calculo); calculo = calculo + combos.PrecioTotalCombo; TotalTextBox.Text = calculo.ToString(); ViewState["CombosDetalle"] = ventas.DetalleCombo; CarritodeCombosGridView.DataSource = ViewState["CombosDetalle"]; CarritodeCombosGridView.DataBind(); } }
protected void LimpiaOrden() { CarritodeProductosGridView.DataSource = null; CarritodeProductosGridView.DataBind(); CarritodeCombosGridView.DataSource = null; CarritodeCombosGridView.DataBind(); }
protected void CarritodeCombosGridView_RowCommand(object sender, GridViewCommandEventArgs e) { //Removiendo combo y restando el precio del combo removido if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); //List<VentaProductosDetalle> detalle2 = new List<VentaProductosDetalle>(); Expression <Func <Combos, bool> > filtro = p => true; RepositorioBase <Combos> repositorio = new RepositorioBase <Combos>(); var lista = repositorio.GetList(c => true); var combos = repositorio.Buscar(lista[index].ComboId); decimal Total = 0; Total = Convert.ToDecimal(TotalTextBox.Text); Total -= combos.PrecioTotalCombo; TotalTextBox.Text = Total.ToString(); ((List <CombosDetalle>)ViewState["CombosDetalle"]).RemoveAt(index); CarritodeCombosGridView.DataSource = ViewState["CombosDetalle"]; CarritodeCombosGridView.DataBind(); } }
//Refescando el grid con los combos eliminados protected void CarritodeCombosGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { CarritodeCombosGridView.DataSource = ViewState["CombosDetalle"]; CarritodeCombosGridView.PageIndex = e.NewPageIndex; CarritodeCombosGridView.DataBind(); }