protected void btnUpdate_Click(object sender, EventArgs e)
        {
            this.entidades = new marketsaveusEntities();
            TblUser table = this.entidades.TblUser.FirstOrDefault(u => u.email == this.txtEmail.Text);

            if (table != null)
            {
                table.passw    = this.txtPassword.Text;
                table.fullName = this.txtName.Text;
                char tipo;
                if (this.DropDownListTipe.Text.Equals("Administrador"))
                {
                    tipo = 'a';
                }
                else
                {
                    tipo = 'c';
                }
                table.tipo = tipo + "";

                this.entidades.SaveChanges();
                Response.Redirect("About.aspx");
            }
            else
            {
                lbNotificaciones.Text = "The entered user is not registered";
            }
        }
Beispiel #2
0
        private void fillproducts(string pCode)
        {
            this.entidades = new marketsaveusEntities();
            TblProduct products =
                this.entidades.TblProduct.FirstOrDefault(e => e.code == pCode);



            if (products != null)
            {
                this.txtCode.Text        = products.code;
                this.txtDescripcion.Text = products.productDescription;
                this.txtInventory.Text   = products.stock.ToString();
                this.txtname.Text        = products.productName;
                this.txtprize.Text       = products.prize.ToString();

                this.txtImage.Visible    = false;
                this.lblImage.Visible    = false;
                this.btnRegister.Visible = false;
                this.btnDelete.Visible   = true;
                this.btnConsult.Visible  = true;
                this.btnUpdate.Visible   = true;
                this.txtCode.Enabled     = false;
            }
        }
Beispiel #3
0
        private bool intentoAutenticacion(string userName, string password)
        {
            try
            {
                bool autenticado = false;
                marketsaveusEntities entidades = new marketsaveusEntities();

                user = entidades.TblUser.FirstOrDefault(u => u.fullName == userName);



                if (user != null)
                {
                    if (user.passw.Equals(password))
                    {
                        autenticado = true;
                    }
                }
                return(autenticado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void fillInvoiceDesc(int id)
        {
            for (int i = 0; i < this.shoppingCart.Count; i++)
            {
                this.entities = new marketsaveusEntities();
                TblDescInvoice tblDesc = new TblDescInvoice();
                tblDesc.idInvoice   = id;
                tblDesc.productCode = this.shoppingCart[i].code;
                tblDesc.quantity    = int.Parse(this.shoppingCart[i].stock.ToString());
                tblDesc.subtotal    = decimal.Parse(this.shoppingCart[i].stock.ToString()) * this.shoppingCart[i].prize;

                this.entities.TblDescInvoice.Add(tblDesc);
                this.entities.SaveChanges();
            }
        }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         this.entidades = new marketsaveusEntities();
         TblUser user = this.entidades.TblUser.FirstOrDefault(u => u.email == this.txtEmail.Text);
         this.entidades.TblUser.Remove(user);
         this.entidades.SaveChanges();
         Response.Redirect("FRMUserRegistration.aspx");
     }
     catch
     {
         lbNotificaciones.Text = "The entered user is not registered";
     }
 }
Beispiel #6
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            this.entidades = new marketsaveusEntities();


            TblProduct products = this.entidades.TblProduct.FirstOrDefault(u => u.code == this.strCode);

            products.productDescription = this.txtDescripcion.Text;
            products.productName        = this.txtname.Text;
            products.prize = Convert.ToDecimal(this.txtprize.Text);
            products.stock = Convert.ToInt32(this.txtInventory.Text);

            this.entidades.SaveChanges();


            Response.Redirect("FrmConsultarProductos.aspx");
        }
Beispiel #7
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            this.entidades = new marketsaveusEntities();


            TblProduct products =
                this.entidades.TblProduct.FirstOrDefault(u => u.code == this.strCode);


            this.entidades.TblProduct.Remove(products);


            this.entidades.SaveChanges();



            Response.Redirect("FrmConsultarProductos.aspx");
        }
 protected void btnBuy_Click(object sender, EventArgs e)
 {
     try
     {
         this.entities = new marketsaveusEntities();
         int idInv = this.createInvoice();
         if (idInv != -1)
         {
             this.fillInvoiceDesc(idInv);
             this.entities.SaveChanges();
             Session["productsList"] = null;
             Response.Redirect("About.aspx");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            this.entidades = new marketsaveusEntities();
            string  pcode   = this.txtEmail.Text;
            TblUser tblUser =
                this.entidades.TblUser.FirstOrDefault(u => u.email == pcode);

            if (tblUser == null)
            {
                TblUser table = new TblUser();

                table.email    = this.txtEmail.Text;
                table.passw    = this.txtPassword.Text;
                table.fullName = this.txtName.Text;
                char tipo;
                if (this.DropDownListTipe.Text.Equals("Administrador"))
                {
                    tipo = 'a';
                }
                else
                {
                    tipo = 'c';
                }
                table.tipo = tipo + "";
                this.entidades.TblUser.Add(table);

                //se guardan los cambios
                Session["userName"] = table.fullName;
                Session["user"]     = table.email;
                this.entidades.SaveChanges();

                this.txtEmail.Text         = "";
                this.txtPassword.Text      = "";
                this.txtName.Text          = "";
                this.DropDownListTipe.Text = "";

                Response.Redirect("About.aspx");///Falta pasarlo a lista clientes
            }
            else
            {
                lbNotificaciones.Text = "The entered user is already registered";
            }
        }
        protected void btnConsult_Click(object sender, EventArgs e)
        {
            this.entidades = new marketsaveusEntities();
            TblUser table = this.entidades.TblUser.FirstOrDefault(u => u.email == this.txtEmail.Text);

            if (table != null)
            {
                this.txtPassword.Text = table.passw;
                this.txtName.Text     = table.fullName;
                if (table.tipo.Equals("a"))
                {
                    this.DropDownListTipe.Text = "Administrador";
                }
                else
                {
                    this.DropDownListTipe.Text = "Cliente";
                }
            }
            else
            {
                lbNotificaciones.Text = "The entered user is not registered";
            }
        }
Beispiel #11
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            this.entidades = new marketsaveusEntities();
            string     pcode      = this.txtCode.Text;
            TblProduct tblProduct =
                this.entidades.TblProduct.FirstOrDefault(u => u.code == pcode);

            if (tblProduct == null)
            {
                TblProduct tableProduct = new TblProduct();

                tableProduct.code  = this.txtCode.Text;
                tableProduct.prize = Convert.ToDecimal(this.txtprize.Text);
                tableProduct.productDescription = this.txtDescripcion.Text;
                tableProduct.productName        = this.txtname.Text;
                tableProduct.stock        = Convert.ToInt32(this.txtInventory.Text);
                tableProduct.productImage = "www/img/" + txtImage.FileName;

                this.entidades.TblProduct.Add(tableProduct);

                //se guardan los cambios
                this.entidades.SaveChanges();

                this.txtCode.Text        = "";
                this.txtDescripcion.Text = "";
                this.txtInventory.Text   = "";
                this.txtname.Text        = "";
                this.txtprize.Text       = "";

                Response.Redirect("FrmConsultarProductos.aspx");
            }
            else
            {
                lbNotificaciones.Text = "The number of the entered code is already saved, please enter a new one";
            }
        }