protected override void SetButtons() { ShowDeactivate = false; if (this.PrimaryKeyIndex > 0) { ShowDeactivate = true; hccPreference CurrentPref = hccPreference.GetById(this.PrimaryKeyIndex); if (CurrentPref != null) { if (!CurrentPref.IsRetired) { btnDeactivate.Text = "Retire"; UseReactivateBehavior = false; } else { btnDeactivate.Text = "Reactivate"; UseReactivateBehavior = true; } } } btnDeactivate.Visible = ShowDeactivate; }
protected override void SaveForm() { try { hccPreference pref = hccPreference.GetById(this.PrimaryKeyIndex); if (pref == null) { pref = new hccPreference { IsRetired = false } } ; pref.Name = txtPrefName.Text.Trim(); pref.Description = txtPrefDesc.Text.Trim(); pref.PreferenceType = (int)(Enums.PreferenceType)Enum.Parse(typeof(Enums.PreferenceType), ddlPrefTypes.SelectedValue); pref.Save(); this.OnSaved(new ControlSavedEventArgs(pref.PreferenceID)); } catch { throw; } }
protected void cstName_ServerValidate(object source, ServerValidateEventArgs args) { hccPreference existPref = hccPreference.GetBy(int.Parse(ddlPrefTypes.SelectedValue), txtPrefName.Text.Trim()); if (existPref != null && existPref.PreferenceID != this.PrimaryKeyIndex) { args.IsValid = false; } }
protected void btnRetire_Click(object sender, EventArgs e) { hccPreference pref = hccPreference.GetById(this.PrimaryKeyIndex); if (pref != null) { pref.Retire(!UseReactivateBehavior); SaveForm(); } }
protected override void LoadForm() { try { hccPreference pref = hccPreference.GetById(this.PrimaryKeyIndex); if (pref != null) { txtPrefName.Text = pref.Name; txtPrefDesc.Text = pref.Description; BindddlPrefTypes(); ddlPrefTypes.SelectedIndex = ddlPrefTypes.Items.IndexOf(ddlPrefTypes.Items.FindByValue(pref.PreferenceType.ToString())); } SetButtons(); } catch { throw; } }
protected void btnAddToCartClick(object sender, EventArgs e) { bool itemAdded = false; try { Button btnAddToCart = (Button)sender; ListViewDataItem dataItem = (ListViewDataItem)btnAddToCart.Parent; int menuItemId = int.Parse(lvwMealItems.DataKeys[dataItem.DataItemIndex].Value.ToString()); hccMenuItem menuItem = hccMenuItem.GetById(menuItemId); hccCart userCart = hccCart.GetCurrentCart(); MembershipUser user = Helpers.LoggedUser; int profileId = GetProfileId(dataItem); int sizeId = GetSizeId(btnAddToCart); hccCartItem newItem = new hccCartItem { CartID = userCart.CartID, CreatedBy = (user == null ? Guid.Empty : (Guid)user.ProviderUserKey), CreatedDate = DateTime.Now, IsTaxable = menuItem.IsTaxEligible, ItemDesc = menuItem.Description, ItemPrice = hccMenuItem.GetItemPriceBySize(menuItem, sizeId), ItemTypeID = (int)Enums.CartItemType.AlaCarte, DeliveryDate = CurrentDeliveryDate, Meal_MenuItemID = menuItem.MenuItemID, Meal_MealSizeID = sizeId, Meal_ShippingCost = hccDeliverySetting.GetBy(menuItem.MealType).ShipCost, UserProfileID = profileId, Quantity = GetQuantity(dataItem), IsCompleted = false }; newItem.GetOrderNumber(userCart); List <CheckBox> prefChks = new List <CheckBox>(); List <RepeaterItem> rptPrefs = dataItem.FindControl("rptMealPrefs").Controls.OfType <RepeaterItem>().ToList(); rptPrefs.ForEach(delegate(RepeaterItem ri) { prefChks.AddRange(ri.Controls.OfType <CheckBox>().Where(a => a.Checked)); }); string prefsString = string.Empty; List <hccCartItemMealPreference> cartPrefs = new List <hccCartItemMealPreference>(); foreach (CheckBox chkPref in prefChks) { int prefId = int.Parse(chkPref.Attributes["value"]); hccPreference pref = hccPreference.GetById(prefId); if (pref != null) { if (string.IsNullOrWhiteSpace(prefsString)) { prefsString += pref.Name; } else { prefsString += ", " + pref.Name; } cartPrefs.Add(new hccCartItemMealPreference { CartItemID = newItem.CartItemID, PreferenceID = prefId }); } } //newItem.ItemName = hccCartItem.BuildCartItemName(menuItem.MealType, (Enums.CartItemSize)sizeId, menuItem.Name, GetMealSides(dataItem), prefsString, newItem.DeliveryDate, newItem.Quantity); newItem.ItemName = hccCartItem.BuildCartItemName(menuItem.MealType, (Enums.CartItemSize)sizeId, menuItem.Name, GetMealSides(dataItem), prefsString, newItem.DeliveryDate);//, newItem.Quantity hccCartItem existItem = hccCartItem.GetBy(userCart.CartID, newItem.ItemName, profileId); if (existItem == null) { newItem.Save(); cartPrefs.ForEach(delegate(hccCartItemMealPreference cartPref) { cartPref.CartItemID = newItem.CartItemID; cartPref.Save(); }); } else { existItem.Quantity += newItem.Quantity; existItem.AdjustQuantity(existItem.Quantity); } AddCartALCMenuItem(dataItem, existItem ?? newItem, menuItem.MealTypeID); itemAdded = true; } catch (Exception ex) { throw ex; } if (itemAdded) { HealthyChef.Templates.HealthyChef.Controls.TopHeader header = (HealthyChef.Templates.HealthyChef.Controls.TopHeader) this.Page.Master.FindControl("TopHeader1"); if (header != null) { header.SetCartCount(); } } }
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 } }); }