Exemplo n.º 1
0
        protected void BtnLogin_OnClick(object sender, EventArgs e)
        {
            Models.AdminApp row    = null;
            bool            result = false;

            using (Models.DataEntities context = new Models.DataEntities())
            {
                row = (
                    from p in context.AdminApp
                    where p.Username == AdminUsername.Text.Trim() && p.Password == AdminPassword.Text.Trim()
                    select p).FirstOrDefault();
            }

            if (row != null)
            {
                LoginError.Visible   = false;
                Session["UserAdmin"] = "admin";
                result = true;
                Response.Redirect("default.aspx");
            }
            else
            {
                LoginError.Visible = true;
            }
        }
        private void BindDataSource()
        {
            using (Models.DataEntities context = new Models.DataEntities())
            {
                Promo = context.Product.Where(x => x.CodiceProdottoApp != null && x.Vetrina != null)
                        .GroupBy(row => new { row.CDART, row.DEART, row.FRETIT, row.FREDES, row.NMDIS, row.DescrizionePromo, row.DescrizioneGruppoMerceologico, row.DescrizioneSottoGruppoMerceologico })
                        .AsEnumerable().Select(a => a.First()).Select(p => new Models.ProdottiDFL()
                {
                    CDART            = p.CDART,
                    DEART            = p.DEART,
                    FRETIT           = p.FRETIT,
                    FREDES           = p.FREDES,
                    NMDIS            = p.NMDIS,
                    DescrizionePromo = p.DescrizionePromo,
                    PZTID            = p.PZTID,
                    Attivo           = p.CodiceProdottoApp == null ? false : true,
                    Vetrina          = p.Vetrina == null ? false : true
                }).OrderBy(x => x.DEART).ToList();

                if (!string.IsNullOrEmpty(codicePromo))
                {
                    Promo = Promo.Where(x => x.PZTID == codicePromo).ToList();
                }

                this.Grid.DataSource = Promo;
                this.Grid.DataBind();
            }
        }
Exemplo n.º 3
0
        protected void savePass_OnClick(object _sender, EventArgs _e)
        {
            using (Models.DataEntities context = new Models.DataEntities())
            {
                var user = context.Customers.Find(id);

                if (user == null)
                {
                    throw new Exception();
                }

                if (!string.IsNullOrWhiteSpace(password.Text))
                {
                    byte[] passwordHash, passwordSalt;
                    Crypto.CreateHash(password.Text.Trim(), out passwordHash, out passwordSalt);

                    user.PasswordHash = passwordHash;
                    user.PasswordSalt = passwordSalt;
                }

                user.LastName  = surname.Text.Trim();
                user.FirstName = name.Text.Trim();
                user.Username  = username.Text.Trim();
                user.Email     = email.Text.Trim();

                context.SaveChanges();
            }
        }
        private void BindDataSource()
        {
            using (Models.DataEntities context = new Models.DataEntities())
            {
                //public string DescrizionePromo { get; set; }
                //public string DescrizioneGruppoMerceologico { get; set; }
                //public string DescrizioneSottoGruppoMerceologico { get; set; }
                Promo = context.Product
                        .GroupBy(row => new
                {
                    row.CDART, row.DEART, row.FRETIT, row.FREDES, row.NMDIS, row.PZTDE, row.PZTID,
                    row.DescrizioneGruppoMerceologico, row.DescrizioneSottoGruppoMerceologico
                })
                        .AsEnumerable().Select(a => a.First()).Select(p => new Models.ProdottiDFL()
                {
                    CDART            = p.CDART,
                    DEART            = p.DEART,
                    FRETIT           = p.FRETIT,
                    FREDES           = p.FREDES,
                    NMDIS            = p.NMDIS,
                    DescrizionePromo = p.PZTDE,
                    PZTID            = p.PZTID,
                    Attivo           = p.CodiceProdottoApp == null ? false : true
                }).OrderBy(x => x.DEART).ToList();



                this.Grid.DataSource = Promo;
                this.Grid.DataBind();
            }
        }
Exemplo n.º 5
0
        private void BindDataSource()
        {
            using (Models.DataEntities context = new Models.DataEntities())
            {
                Customers = context.Customers.ToList();
            }

            this.Grid.DataSource = Customers;
            this.Grid.DataBind();
        }
Exemplo n.º 6
0
        private void BindDataSource()
        {
            using (Models.DataEntities context = new Models.DataEntities())
            {
                Promo = context.Promo.ToList().OrderBy(row => row.PZTDE).ToList();


                //.Select<Models.PromoDFL>(p => new Models.PromoDFL()
                //{

                //}).ToList();

                this.Grid.DataSource = Promo;
                this.Grid.DataBind();
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id = int.Parse(Request.QueryString["id"]);

            if (!IsPostBack)
            {
                using (Models.DataEntities context = new Models.DataEntities())
                {
                    var user = context.Customers.Find(id);
                    name.Text     = user.FirstName;
                    surname.Text  = user.LastName;
                    email.Text    = user.Email;
                    username.Text = user.Username;
                }
            }
        }
        protected void Grid_OnServerCommandButtonClick(object sender, GridEventArgs e)
        {
            var    obj            = e.Arguments;
            string codiceArticolo = string.Empty;
            bool   attivo         = false;

            Models.ProdottiDFL prod = new Models.ProdottiDFL();

            foreach (KeyValuePair <string, object> item in obj)
            {
                Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value);
                if (item.Key == "data")
                {
                    var json = JsonConvert.SerializeObject(item.Value);
                    prod = JsonConvert.DeserializeObject <Models.ProdottiDFL>(json);
                }
            }

            using (Models.DataEntities context = new Models.DataEntities())
            {
                Models.ProdottiApp row =
                    context.ProdottiApp.SingleOrDefault(r => r.CodiceProdottoApp == prod.CDART && r.CodicePromo == prod.PZTID);
                if (prod.Attivo == true)
                {
                    // rimuove
                    context.Entry(row).State = EntityState.Deleted;
                    context.SaveChanges();
                }
                else
                {
                    if (row == null)
                    {
                        row = new Models.ProdottiApp
                        {
                            CodiceProdottoApp = prod.CDART,
                            CodicePromo       = prod.PZTID
                        };
                        context.ProdottiApp.Add(row);
                        context.SaveChanges();
                    }
                }
            }

            BindDataSource();
        }
Exemplo n.º 9
0
        private void BindDataSource()
        {
            using (Models.DataEntities context = new Models.DataEntities())
            {
                Promo = context.Promozioni_PRS2F
                        .GroupBy(row => new { row.PZTCD, row.PZTDE, row.PZTD1, row.PZTDI, row.PZTDF, row.PZTID })
                        .AsEnumerable().Select(a => a.First()).Select(p => new Models.PromoDFL()
                {
                    PZTCD = p.PZTCD,
                    PZTID = p.PZTID,
                    PZTD1 = p.PZTD1,
                    PZTDE = p.PZTDE,
                    PZTDF = p.PZTDF,
                    PZTDI = p.PZTDI
                }).ToList();

                //.Select<Models.PromoDFL>(p => new Models.PromoDFL()
                //{
                //}).ToList();

                this.Grid.DataSource = Promo;
                this.Grid.DataBind();
            }
        }