Ejemplo n.º 1
0
        protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                FormsAuthentication.RedirectToLoginPage();
                e.Cancel = true;
            }
            else if ((dtpCalendario.SelectedDate < DateTime.Now.AddDays(1)) || (txtDirEntrega.Text.Trim() == "") || (txtDirFactura.Text.Trim() == ""))
            {
                lblValidar.Visible = true;
                e.Cancel           = true;
            }
            else //Guardando Pedido
            {
                using (dbLQDataContext db = new dbLQDataContext())
                {
                    pedido nuevo_pedido = new pedido
                    {
                        idusuario     = HttpContext.Current.User.Identity.Name,
                        fecha         = DateTime.Now,
                        fecha_entrega = dtpCalendario.SelectedDate,
                        dir_entrega   = txtDirEntrega.Text.Trim(),
                        dir_factura   = txtDirFactura.Text.Trim(),
                        subtotal      = precioTotal,
                        iva           = precioTotal * decimal.Parse("0.13"),
                        total         = precioTotal * decimal.Parse("0.13") + precioTotal
                    };

                    List <ListaCompras> listado = (List <ListaCompras>)Session["ListaCompras"];

                    foreach (ListaCompras item in listado)
                    {
                        pedido_detalle cupcake = new pedido_detalle
                        {
                            iddiseno = item.iddiseno,
                            cantidad = item.cantidad,
                            precio   = item.precio,
                        };
                        nuevo_pedido.pedido_detalles.Add(cupcake);
                    }

                    db.pedidos.InsertOnSubmit(nuevo_pedido);
                    try
                    {
                        db.SubmitChanges();
                    }
                    catch (ChangeConflictException)
                    {
                        db.ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues);
                        db.SubmitChanges();
                    }
                    //Response.Redirect("~/Clientes/Pedidos.aspx");
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                using (dbLQDataContext db = new dbLQDataContext())
                {
                    try
                    {
                        int usua = (from c in db.usuarios where c.idusuario == UserName.Text.Trim() select c.idusuario).Count();
                        if (usua > 0)
                        {
                            ErrorMessage1.Text = "El usuario ya existe.";
                        }
                        else
                        {
                            usuario nuevo = new usuario
                            {
                                idusuario = UserName.Text.Trim(),
                                correo    = Email.Text.Trim(),
                                clave     = Password.Text.Trim(),
                            };

                            db.usuarios.InsertOnSubmit(nuevo);
                            db.SubmitChanges();
                            bool admin = (from c in db.usuarios
                                          where c.idusuario == UserName.Text.Trim()
                                          where c.clave == Password.Text.Trim()
                                          select c.admin).First();

                            Session["idUsuario"] = UserName.Text.Trim();
                            Session["admin"]     = admin;

                            FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
                        }
                    }
                    catch (ChangeConflictException)
                    {
                        db.ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues);
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        ErrorMessage1.Text = "Ha ocurrido un problema. El proceso de registro no pudo completarse satisfactoriamente. Por favor, intentelo en otro momento.";
                        //throw;
                    }
                }
                //FormsAuthentication.SetAuthCookie(UserName.Text, false /* createPersistentCookie */);
            }
            else
            {
                ErrorMessage1.Text = "(*) Campos obligatorios";
            }
        }
Ejemplo n.º 3
0
        protected int AgregarDiseño()
        {
            using (dbLQDataContext db = new dbLQDataContext())
            {
                diseno nuevo_diseno = new diseno
                {
                    nombre    = txtNombre.Text.Trim(),
                    idbase    = int.Parse(lsvMasas.SelectedDataKey.Value.ToString()),
                    idcrema   = int.Parse(lsvCrema.SelectedDataKey.Value.ToString()),
                    idtopping = int.Parse(lsvtopping.SelectedDataKey.Value.ToString()),
                };

                if (User.Identity.IsAuthenticated)
                {
                    nuevo_diseno.idusuario = User.Identity.Name;
                }
                else
                {
                    nuevo_diseno.idusuario = "anonimo";
                }

                db.disenos.InsertOnSubmit(nuevo_diseno);

                db.SubmitChanges();
                return(nuevo_diseno.iddiseno);
            }
        }