예제 #1
0
        protected void CbStatus_CheckedChanged(object sender, EventArgs e)
        {
            OfferedPizza offerPizza = HelperSession.GetOfferPizza(Session);

            List <Ingredient> listIngredientsOffer    = HelperSession.GetListIngredientsOffer(Session);
            List <Ingredient> listIngredientsSelected = HelperSession.GetListIngredientsSelected(Session);

            CheckBox    cbStatus = (CheckBox)sender;
            GridViewRow row      = (GridViewRow)cbStatus.NamingContainer;

            if (row != null)
            {
                int        index      = row.RowIndex;
                Ingredient ingredient = listIngredientsOffer[index];

                ingredient.Status = !(ingredient.Status);

                if (ingredient.Status)
                {
                    offerPizza.Price += ingredient.Price;

                    listIngredientsSelected.Add(ingredient);
                }
                else
                {
                    offerPizza.Price -= ingredient.Price;

                    listIngredientsSelected.Remove(ingredient);
                }

                listIngredientsOffer[index] = ingredient;

                LbPrice.Text = offerPizza.Price.ToString("0.00") + "";

                HelperSession.SetListIngredientsOffer(Session, listIngredientsOffer);
                HelperSession.SetListIngredientsSelected(Session, listIngredientsSelected);
                HelperSession.SetOfferPizza(Session, offerPizza);
            }
        }