protected void rolMeasurementUnitsConverts_ItemDataBound(object sender, ReorderListItemEventArgs e) { ReorderListItem rolItem = e.Item as ReorderListItem; LinkButton btn = rolItem.FindControl("btnUpdate") as LinkButton; Label textLine = rolItem.FindControl("lbMeasurementUnitsConvertText") as Label; MeasurementUnitsConvert MeasuresConvert = e.Item.DataItem as MeasurementUnitsConvert; if (MeasuresConvert != null) { btn.PostBackUrl = string.Format("~/Admin/MeasurementUnitsConvert.aspx?ConvertId={0}", MeasuresConvert.ConvertId); string from = MeasuresConvert.FromQuantity.ToString(); string[] fromStr = from.Split('.'); if (fromStr[1] == "00") { from = fromStr[0]; } string to = MeasuresConvert.ToQuantity.ToString(); string[] toStr = to.Split('.'); if (toStr[1] == "00") { to = toStr[0]; } Food food = BusinessFacade.Instance.GetFood(MeasuresConvert.FoodId); MeasurementUnit sourceMeasureUnit = BusinessFacade.Instance.GetMeasurementUnit(MeasuresConvert.FromUnitId); MeasurementUnit targetMeasureUnit = BusinessFacade.Instance.GetMeasurementUnit(MeasuresConvert.ToUnitId); textLine.Text = string.Format("{0} {1} {2} = {3} {4}", from, sourceMeasureUnit.UnitName, food.FoodName, to, targetMeasureUnit.UnitName); } //btn = rolItem.FindControl("btnDelete") as LinkButton; // btn.Visible = MeasuresConvert.AllowDelete; }
protected void rolMeasurementUnitsConverts_ItemDataBound(object sender, ReorderListItemEventArgs e) { ReorderListItem rolItem = e.Item as ReorderListItem; LinkButton btn = rolItem.FindControl("btnUpdate") as LinkButton; Label textLine = rolItem.FindControl("lbMeasurementUnitsConvertText") as Label; MeasurementUnitsConvert MeasuresConvert = e.Item.DataItem as MeasurementUnitsConvert; if (MeasuresConvert != null) { btn.PostBackUrl = string.Format("~/Admin/MeasurementUnitsConvert.aspx?ConvertId={0}", MeasuresConvert.ConvertId); string from = MeasuresConvert.FromQuantity.ToString(); string[] fromStr = from.Split('.'); if (fromStr[1] == "00") { from = fromStr[0]; } string to = MeasuresConvert.ToQuantity.ToString(); string[] toStr = to.Split('.'); if (toStr[1] == "00") { to = toStr[0]; } textLine.Text = string.Format("{0} {1} {2} = {3} {4}", from, MeasuresConvert.SOURCE_UNIT_NAME, MeasuresConvert.FOOD_NAME, to, MeasuresConvert.TARGET_UNIT_NAME); } //btn = rolItem.FindControl("btnDelete") as LinkButton; // btn.Visible = MeasuresConvert.AllowDelete; }
protected void reorderListLocation_ItemReorder(object sender, ReorderListItemReorderEventArgs e) { #region -- Old -- //Label labelId = (Label)reorderListLocation.Items[e.NewIndex].FindControl("lblID"); //Location newIndex = Module.LocationGetById(Convert.ToInt32(labelId.Text.Substring(3))); //labelId = (Label)reorderListLocation.Items[e.OldIndex].FindControl("lblID"); //Location oldIndex = Module.LocationGetById(Convert.ToInt32(labelId.Text.Substring(3))); //// order của old sẽ thành bằng new //int newOrder = newIndex.Order; //// Tất cả nhỏ hơn new sẽ giảm order đi 1 //Module.Resort(newIndex,newOrder < oldIndex.Order); //oldIndex = Module.LocationGetById(Convert.ToInt32(labelId.Text.Substring(3))); //oldIndex.Order = newOrder; //Module.Update(oldIndex); #endregion #region -- New -- ReorderListItem OldItem = reorderListLocation.Items[e.OldIndex]; Label labelId; Location LocationItem; if (e.OldIndex > e.NewIndex) { for (int ii = e.NewIndex; ii < e.OldIndex; ii++) { ReorderListItem item = reorderListLocation.Items[ii]; item.ItemIndex += 1; labelId = (Label)item.FindControl("lblID"); LocationItem = Module.LocationGetById(Convert.ToInt32(labelId.Text.Substring(3))); LocationItem.Order = item.DisplayIndex; Module.Update(LocationItem); } } if (e.OldIndex < e.NewIndex) { for (int ii = e.NewIndex; ii > e.OldIndex; ii++) { ReorderListItem item = reorderListLocation.Items[ii]; item.ItemIndex -= 1; labelId = (Label)item.FindControl("lblID"); LocationItem = Module.LocationGetById(Convert.ToInt32(labelId.Text.Substring(3))); LocationItem.Order = item.DisplayIndex; Module.Update(LocationItem); } } OldItem.ItemIndex = e.NewIndex; labelId = (Label)OldItem.FindControl("lblID"); LocationItem = Module.LocationGetById(Convert.ToInt32(labelId.Text.Substring(3))); LocationItem.Order = OldItem.DisplayIndex; Module.Update(LocationItem); GetDataSource(); reorderListLocation.DataBind(); #endregion }
protected void rolShopDepartments_ItemDataBound(object sender, ReorderListItemEventArgs e) { ReorderListItem rolItem = e.Item as ReorderListItem; LinkButton btn = rolItem.FindControl("btnUpdate") as LinkButton; ShopDepartment dep = e.Item.DataItem as ShopDepartment; if (dep != null) { btn.PostBackUrl = string.Format("~/Admin/ShopDepartment.aspx?depId={0}", dep.ShopDepartmentId); } btn = rolItem.FindControl("btnDelete") as LinkButton; btn.Visible = dep.AllowDelete; }
protected void rolMeasurementUnits_ItemDataBound(object sender, ReorderListItemEventArgs e) { ReorderListItem rolItem = e.Item as ReorderListItem; LinkButton btn = rolItem.FindControl("btnUpdate") as LinkButton; MeasurementUnit unit = e.Item.DataItem as MeasurementUnit; if (unit != null) { btn.PostBackUrl = string.Format("~/Admin/MeasurementUnit.aspx?unitId={0}", unit.UnitId); } btn = rolItem.FindControl("btnDelete") as LinkButton; btn.Visible = unit.AllowDelete; }
protected void rolGeneralItems_ItemDataBound(object sender, ReorderListItemEventArgs e) { ReorderListItem rolItem = e.Item as ReorderListItem; LinkButton btn = rolItem.FindControl("btnUpdate") as LinkButton; GeneralItem Item = e.Item.DataItem as GeneralItem; if (Item != null) { btn.PostBackUrl = string.Format("~/Admin/GeneralItem.aspx?ItemId={0}", Item.GeneralItemId); } btn = rolItem.FindControl("btnDelete") as LinkButton; btn.Visible = Item.AllowDelete; btn.Attributes.Add("ItemId", Item.GeneralItemId.ToString()); }