protected void btnDuplicar_Click(object sender, EventArgs e) { Button btn = (Button)sender; BLL.CarritoBLL cr = new BLL.CarritoBLL(db); cr.DuplicarPedido(Convert.ToInt32(btn.CommandArgument), this.Page.User.Identity.Name); db.SaveChanges(); Response.Redirect(String.Format("~/Pedido.aspx?Id={0}", cr.cr.IdCarrito)); }
protected void btnAddPedido_Click(object sender, EventArgs e) { Button btn = ((Button)sender); var car = new BLL.CarritoBLL(Convert.ToInt32(grvClientes.SelectedDataKey.Value), Convert.ToInt32(btn.CommandArgument), this.Page.User.Identity.Name, cboTipoPedido.SelectedValue, db); if (car != null) { Response.Redirect(string.Format("~/Pedido.aspx?Id={0}", car.cr.IdCarrito)); } }
BLL.CarritoBLL GetCarrito() { BLL.CarritoBLL car = null; int Id = Convert.ToInt32(Request.QueryString["Id"]); var c = db.tel_Carrito.Where(p => p.IdCarrito == Id && p.IdEmpresa == Global.IdEmpresa && p.Estado == null).FirstOrDefault(); if (c != null) { car = new BLL.CarritoBLL(c, db); } return(car); }
// El nombre de parámetro del id. debe coincidir con el valor DataKeyNames establecido en el control public void fvCarrito_UpdateItem(int IdCarrito) { //Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = ","; //Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyGroupSeparator = "."; //Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ","; //Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = "."; DAL.tel_Carrito item = null; // Cargar el elemento aquí, por ejemplo item = MyDataLayer.Find(id); item = GetPedido(IdCarrito).FirstOrDefault(); if (item == null) { // No se encontró el elemento this.Page.ModelState.AddModelError("", String.Format("No se encontró el elemento con id. {0}", IdCarrito)); return; } TryUpdateModel(item); //VG 14/02/2014 //En caso de que sea una sucursal temporal if (item.TransferTemporal.Value != true) { item.Tel_Direcciones.IdSucursal = item.IdSucursal; } if (this.Page.ModelState.IsValid) { BLL.CarritoBLL cr = new BLL.CarritoBLL(item, db, true); this.db.SaveChanges(); //GetDirecciones(Convert.ToInt32(this.grvClientes.SelectedDataKey.Value)); // Guarde los cambios aquí, por ejemplo MyDataLayer.SaveChanges(); ((Pedido)this.Page).ProductoCargado(); } }
protected void btnAgregar_Click(object sender, EventArgs e) { LinkButton btn = ((LinkButton)sender); if (Request.QueryString["Id"] == null) { ((Consultas.Productos) this.Page).CargarProducto(btn.CommandArgument); return; } ((Pedido)this.Page).CargarProducto(btn.CommandArgument); return; this.lblError.Text = ""; int Id = Convert.ToInt32(Request.QueryString["Id"]); Decimal Cantidad = 1; var p = db.tel_Carrito.Find(Id); if (p != null) { var car = new BLL.CarritoBLL(p, db); if (chkMitad.Checked) { var prod = db.tel_Productos.Find(Global.IdEmpresa, btn.CommandArgument); if (prod.PermiteMitad.HasValue && prod.PermiteMitad.Value) { //car.AgregarItem(btn.CommandArgument, (decimal).5); Cantidad = (decimal).5; } else { this.lblError.Text = "Este producto no permite Mitad/Mitad"; return; } } //else //{ // car.AgregarItem(btn.CommandArgument, 1); //} TextBox txt = (TextBox)btn.Parent.FindControl("txtObs"); String obs = null; if (txt.Text != "Indicaciones") { obs = txt.Text; } if (btn.CommandName == "C") { car.AgregarItem(btn.CommandArgument, Cantidad, obs, this.PanelCombo.TraerContenido(), false); } else { car.AgregarItem(btn.CommandArgument, Cantidad, obs); } db.SaveChanges(); // txt.Text = "Indicaciones"; if (car.Completo) { this.chkMitad.Checked = false; } this.Pedido.DataBind(); } }
public void CargarProducto(string IdProducto) { var p = BLL.Tablas.GetProductoById(IdProducto); if (p != null) { //this.imgProducto.ImageUrl = Page.ResolveUrl("~/images/productos/" + p.Imagen); chkMitad.Visible = p.PermiteMitad.HasValue ? p.PermiteMitad.Value : false; chkAgranda.Enabled = p.IdProductoAgranda != null; chkAgranda.Checked = false; if (p.IdProductoAgranda == null) { divchkAgranda.Attributes["class"] = "checkbox label-warning disabled"; } else { divchkAgranda.Attributes["class"] = "checkbox label-warning"; } //24-03/2014 //Verificamos si tiene querystring, si tiene, levantamos el carrito, si no tiene, es una consulta de productos if (Request.QueryString["Id"] != null) { int Id = Convert.ToInt32(Request.QueryString["Id"]); var c = db.tel_Carrito.Find(Id); var car = new BLL.CarritoBLL(c, db); this.lblPrecio.Text = car.TraerPrecio(IdProducto).ToString("N2"); this.cmdCancel.Visible = false; } else { this.cmdAgregar.Visible = false; var pr = db.tel_Precios.Include("tel_ListaPrecio").Where(s => s.IdEmpresa == Global.IdEmpresa && s.IdProducto == IdProducto).ToList(); if (pr != null) { StringBuilder str = new StringBuilder(); foreach (var item in pr) { str.AppendFormat("<br>{0}: {1:N2}", item.tel_ListaPrecio.Lista, item.Precio); } this.lblPrecio.Text = str.ToString(); } } this.lblProducto.Text = p.Descripcion; this.lblImporte.Text = this.lblPrecio.Text; this.IdProducto.Text = p.IdProducto.ToString(); this.EsCombo.Text = p.EsCombo.HasValue && p.EsCombo.Value ? "S" : "N"; //foreach (DAL.tel_ProductoOpcion item in p.tel_ProductoOpcion) //{ // var op = (Control.Opciones)LoadControl("~\\Control\\Opciones.ascx"); // op.IdOpcion = item.IdOpcion.Value; // this.PlaceHolder1.Controls.Add(op); //} var opciones = BLL.Tablas.GetOpciones(p.IdProducto, p.IdGrupo, p.IdFamilia, p.IdLinea); //foreach (DAL.tel_ProductoOpcion item in opciones) //{ // var op = (Control.Opciones)LoadControl("~\\Control\\Opciones.ascx"); // op.ID = item.IdOPProd.ToString(); // op.IdOpcion = item.IdOpcion.Value; // this.PlaceHolder1.Controls.Add(op); //} this.rptOpciones.DataSource = opciones; this.rptOpciones.DataBind(); this.cboMitad.DataSource = BLL.Tablas.GetOpcionesbyProducto(-1, p.IdGrupo, p.IdFamilia, p.IdLinea); this.cboMitad.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { Button btn = ((Button)sender); this.lblError.Text = ""; int Id = Convert.ToInt32(Request.QueryString["Id"]); Decimal Cantidad = Convert.ToInt16(cboCantidad.SelectedValue); var p = db.tel_Carrito.Find(Id); if (p != null) { var car = new BLL.CarritoBLL(p, db); if (chkMitad.Checked) { //var prod = db.tel_Productos.Find(this.IdProducto.Text); var prod = db.tel_Productos.Find(Global.IdEmpresa, this.IdProducto.Text); if (prod.PermiteMitad.HasValue && prod.PermiteMitad.Value) { //car.AgregarItem(btn.CommandArgument, (decimal).5); Cantidad = (decimal).5; } else { this.lblError.Text = "Este producto no permite Mitad/Mitad"; return; } } TextBox txt = txtIndicaciones; String obs = null; if (txt.Text != "Indicaciones") { obs = txt.Text; } if (this.EsCombo.Text == "S") { String[] contenidoCombo = this.TraerContenidoGrid(); if (this.OkCantidad) { car.AgregarItem(this.IdProducto.Text, Cantidad, obs, this.TraerContenidoGrid(), this.chkAgranda.Checked); } else { this.lblError.Text = "Las cantidades no corresponden a la definicion del combo"; return; } } else { car.AgregarItem(this.IdProducto.Text, Cantidad, obs, this.chkAgranda.Checked); if (chkMitad.Checked) { car.AgregarItem(this.cboMitad.SelectedValue, Cantidad, obs, false); } } //Agregamos los Toppings //foreach (ListItem item in lstAgregados.Items) //{ // car.AgregarItem(item.Value, 1, ""); //} String[] contenidoTopping = this.TraerToppingGrid(); if (contenidoTopping != null) { foreach (var item in contenidoTopping) { String[] itemDet = item.Split(new Char[] { ':' }); car.AgregarItem(itemDet[0], Convert.ToDecimal(itemDet[1]), ""); } } db.SaveChanges(); //txt.Text = "Indicaciones"; if (car.Completo) { this.chkMitad.Checked = false; } this.lstAgregados.Items.Clear(); this.cboCantidad.SelectedValue = "1"; ((Pedido)this.Page).ProductoCargado(); //this.Pedido.DataBind(); } }