コード例 #1
0
    private void bindComandaListView()
    {
        Comanda comanda_curenta = Session["comanda"] as Comanda;

        if (comanda_curenta != null)
        {
            ComandaListView.DataSource = comanda_curenta.ListaItem.Values;
        }
        ComandaListView.DataBind();
        showTotal();
    }
コード例 #2
0
    protected void deletePreparat(object sender, EventArgs e)
    {
        Comanda     comanda = Session["comanda"] as Comanda;
        LinkButton  adauga  = sender as LinkButton;
        int         id      = Convert.ToInt32(adauga.CommandArgument);
        ItemComanda item    = comanda.ListaItem[id] as ItemComanda;

        comanda.removeItemComanda(item);
        item.scadeCantitate();
        comanda.addItemComanda(item);
        Session["comanda"] = comanda;
        updateBadge();
        ComandaListView.DataBind();
        showTotal();
    }
コード例 #3
0
    protected void deleteItemComanda(object sender, EventArgs e)
    {
        LinkButton remove_Item = sender as LinkButton;
        int        id          = Convert.ToInt32(remove_Item.CommandArgument);
        Comanda    comanda     = Session["comanda"] as Comanda;

        comanda.removeItemComanda(comanda.ListaItem[id] as ItemComanda);
        updateBadge();
        ComandaListView.DataBind();

        //// Potriviri additions
        potriviri_.Clear();
        potriviriKeyedByPreparate_.Clear();

        List <Preparat> preparate = comanda.ListaItem.Values.Cast <ItemComanda>().Select(itemComanda => itemComanda.Preparat).ToList();

        IEnumerator <Preparat> preparate_enumerator = preparate.GetEnumerator();

        foreach (Preparat preparat in preparate)
        {
            List <Preparat> potriviri = null;
            if (potriviriPreparateCache_.ContainsKey(preparat.Id))
            {
                potriviri = potriviriPreparateCache_[preparat.Id] as List <Preparat>;
            }
            else
            {
                potriviri = DatabaseFunctions.getPotriviriPreparat(preparat);
                potriviriPreparateCache_.Add(preparat.Id, potriviri);
            }

            foreach (Preparat potrivire in potriviri)
            {
                bool potrivire_valida = true;

                preparate_enumerator.Reset();
                while (preparate_enumerator.MoveNext())
                {
                    if (preparate_enumerator.Current.Id == potrivire.Id)
                    {
                        potrivire_valida = false;
                        break;
                    }

                    if (preparate_enumerator.Current.Tip.Equals(potrivire.Tip))
                    {
                        potrivire_valida = false;
                        break;
                    }
                }

                if (potrivire_valida)
                {
                    if (!potriviri_.ContainsKey(potrivire.Id))
                    {
                        potriviri_.Add(potrivire.Id, potrivire);
                    }

                    List <int> id_potriviri = null;
                    if (potriviriKeyedByPreparate_.ContainsKey(preparat.Id))
                    {
                        id_potriviri = potriviriKeyedByPreparate_[preparat.Id] as List <int>;
                        id_potriviri.Add(potrivire.Id);
                    }
                    else
                    {
                        id_potriviri = new List <int>();
                        id_potriviri.Add(potrivire.Id);
                        potriviriKeyedByPreparate_[preparat.Id] = id_potriviri;
                    }
                }
            }
        }

        carouselRepeater.DataSource = potriviri_.Values;
        carouselRepeater.DataBind();
        if (carouselRepeater.Items.Count == 0)
        {
            potriviriDiv.Visible = false;
        }
        else
        {
            potriviriDiv.Visible = true;
        }

        // Cod vechi: tine in viata potrivirile comune cu alte preparate insa nu am luat in calcul ca
        // daca nu mai sunt potriviri, la stergere de preparat e posibil sa se revalideze unele potriviri..
        // ..asa ca am tuflit din nou toata logica (vezi mai sus)
        // lasat pentru verificari teste

        /*
         * if (potriviriKeyedByPreparate_ != null && potriviriKeyedByPreparate_.ContainsKey(id))
         * {
         *  List<int> id_potriviri_item_sters = potriviriKeyedByPreparate_[id] as List<int>;
         *  foreach (int id_potrivire_candidata_la_sters in id_potriviri_item_sters)
         *  {
         *      bool potrivire_valida = false;
         *
         *      foreach (int id_preparat in potriviriKeyedByPreparate_.Keys)
         *      {
         *          if (id_preparat == id)
         *              continue;
         *
         *          List<int> id_potriviri = potriviriKeyedByPreparate_[id_preparat] as List<int>;
         *          foreach (int id_potrivire in id_potriviri)
         *          {
         *              if (id_potrivire == id_potrivire_candidata_la_sters)
         *              {
         *                  potrivire_valida = true;
         *                  break;
         *              }
         *          }
         *
         *          if (potrivire_valida)
         *              break;
         *      }
         *
         *      if (!potrivire_valida)
         *          potriviri_.Remove(id_potrivire_candidata_la_sters);
         *  }
         *
         *  potriviriKeyedByPreparate_.Remove(id);
         *
         *  carouselRepeater.DataSource = potriviri_.Values;
         *  carouselRepeater.DataBind();
         *  if (carouselRepeater.Items.Count == 0)
         *      potriviriDiv.Visible = false;
         * }
         */

        if (potriviriPreparateCache_ != null && potriviriPreparateCache_.ContainsKey(id))
        {
            potriviriPreparateCache_.Remove(id);
        }
        ////

        showTotal();
    }