protected void InventoryGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (e.CommandName.StartsWith("Do_")) { switch (e.CommandName) { case "Do_Pub": // TOGGLE VISIBILITY int productId = AlwaysConvert.ToInt(e.CommandArgument); Product product = ProductDataSource.Load(productId); switch (product.Visibility) { case CatalogVisibility.Public: product.Visibility = CatalogVisibility.Hidden; break; case CatalogVisibility.Hidden: product.Visibility = CatalogVisibility.Private; break; default: product.Visibility = CatalogVisibility.Public; break; } product.Save(); InventoryGrid.DataBind(); break; } } }
private void UpdateInventory(bool sendEmails) { foreach (GridViewRow row in InventoryGrid.Rows) { int dataItemIndex = row.DataItemIndex; dataItemIndex = (dataItemIndex - (InventoryGrid.PageSize * InventoryGrid.PageIndex)); int productId = (int)InventoryGrid.DataKeys[dataItemIndex].Values[0]; int productVariantId = AlwaysConvert.ToInt(InventoryGrid.DataKeys[dataItemIndex].Values[1].ToString()); int inStock = GetControlValue(row, "InStock"); int lowStock = GetControlValue(row, "LowStock"); TextBox availDate = (TextBox)row.FindControl("AvailabilityDate"); Product product = ProductDataSource.Load(productId); if (productVariantId.Equals(0)) { product.InStock = inStock; product.InStockWarningLevel = lowStock; product.AvailabilityDate = LocaleHelper.ToLocalTime(AlwaysConvert.ToDateTime(availDate.Text, DateTime.MinValue)); product.Save(); if (sendEmails && product.InStock > 0) { RestockNotify(sendEmails, product, null); } } else { ProductVariant variant = ProductVariantDataSource.Load(productVariantId); variant.InStock = inStock; variant.InStockWarningLevel = lowStock; variant.AvailabilityDate = LocaleHelper.ToLocalTime(AlwaysConvert.ToDateTime(availDate.Text, DateTime.MinValue)); variant.Save(); if (sendEmails && variant.InStock > 0) { RestockNotify(sendEmails, product, variant); } } } SavedMessage.Text = string.Format(SavedMessage.Text, DateTime.Now); SavedMessage.Visible = true; InventoryGrid.DataBind(); }
protected void SearchButton_Click(object sender, EventArgs e) { InventoryGrid.DataBind(); }