protected override void SetButtons()
        {
            ShowDeactivate = false;

            if (this.PrimaryKeyIndex > 0)
            {
                ShowDeactivate = true;

                hccAllergen CurrentAllergen = hccAllergen.GetById(this.PrimaryKeyIndex);

                if (CurrentAllergen != null)
                {
                    if (CurrentAllergen.IsActive)
                    {
                        btnDeactivate.Text    = "Retire";
                        UseReactivateBehavior = false;
                    }
                    else
                    {
                        btnDeactivate.Text    = "Reactivate";
                        UseReactivateBehavior = true;
                    }
                }
            }

            btnDeactivate.Visible = ShowDeactivate;
        }
        protected override void SaveForm()
        {
            try
            {
                hccAllergen allergen = hccAllergen.GetById(this.PrimaryKeyIndex);

                if (allergen == null)
                {
                    allergen = new hccAllergen {
                        IsActive = true
                    }
                }
                ;

                allergen.Name        = txtAllergenName.Text.Trim();
                allergen.Description = txtAllergenDesc.Text.Trim();
                allergen.Save();

                this.OnSaved(new ControlSavedEventArgs(allergen.AllergenID));
            }
            catch
            {
                throw;
            }
        }
        protected void cstName_ServerValidate(object source, ServerValidateEventArgs args)
        {
            hccAllergen existAllergen = hccAllergen.GetBy(txtAllergenName.Text.Trim());

            if (existAllergen != null && existAllergen.AllergenID != this.PrimaryKeyIndex)
            {
                args.IsValid = false;
            }
        }
        protected void btnRetire_Click(object sender, EventArgs e)
        {
            hccAllergen allergen = hccAllergen.GetById(this.PrimaryKeyIndex);

            if (allergen != null)
            {
                allergen.Retire(!UseReactivateBehavior);
                SaveForm();
            }
        }
        protected override void LoadForm()
        {
            allergenID.Value = this.PrimaryKeyIndex.ToString();
            hccAllergen allergen = hccAllergen.GetById(this.PrimaryKeyIndex);

            if (allergen != null)
            {
                txtAllergenName.Text = allergen.Name;
                txtAllergenDesc.Text = allergen.Description;

                BindgvwIngUsage();
            }

            SetButtons();
        }
Exemple #6
0
        void lstSelectedItems_DataBound(object sender, EventArgs e)
        {
            ListBox         lstSelectedItems = (ListBox)sender;
            List <ListItem> items            = lstSelectedItems.Items.OfType <ListItem>().ToList();

            items.ForEach(delegate(ListItem item)
            {
                if (EntityType == typeof(hccMenuItem))
                {
                    hccMenuItem t1 = hccMenuItem.GetById(int.Parse(item.Value));
                    if (t1.IsRetired)
                    {
                        item.Attributes.Add("class", "retired");
                    }
                    else
                    {
                        item.Attributes.Add("class", "active");
                    }

                    List <hccIngredient> ings = t1.GetIngredients();

                    ings.ForEach(delegate(hccIngredient ing) { if (ing.IsRetired)
                                                               {
                                                                   item.Attributes.Add("class", "retired_child");
                                                               }
                                 });
                }
                else if (EntityType == typeof(hccPreference))
                {
                    hccPreference t1 = hccPreference.GetById(int.Parse(item.Value));
                    if (t1.IsRetired)
                    {
                        item.Text += " - Retired"; item.Attributes.Add("class", "retired");
                    }
                    else
                    {
                        item.Attributes.Add("class", "active");
                    }
                }
                else if (EntityType == typeof(hccAllergen))
                {
                    hccAllergen t1 = hccAllergen.GetById(int.Parse(item.Value));
                    if (!t1.IsActive)
                    {
                        item.Text += " - Retired"; item.Attributes.Add("class", "retired");
                    }
                    else
                    {
                        item.Attributes.Add("class", "active");
                    }
                }
                else if (EntityType == typeof(hccIngredient))
                {
                    hccIngredient t1 = hccIngredient.GetById(int.Parse(item.Value));
                    if (t1.IsRetired)
                    {
                        item.Text += " - Retired"; item.Attributes.Add("class", "retired");
                    }
                    else
                    {
                        item.Attributes.Add("class", "active");
                    }
                }
                else
                {//do nothing
                }
            });
        }