protected void rptChanges_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.IsDataItem()) { ServiceLocationAssetTypeChangeLogEntity dfcl = e.Item.DataItem as ServiceLocationAssetTypeChangeLogEntity; Label lblDate = e.Item.FindControl("lblDate") as Label; Label lblUsername = e.Item.FindControl("lblUsername") as Label; Label lblRevisionInfo = e.Item.FindControl("lblRevisionInfo") as Label; lblDate.Text = dfcl.ChangeLog.ChangeDate.ToShortDateString() + " " + dfcl.ChangeLog.ChangeDate.ToLongTimeString(); lblUsername.Text = dfcl.ChangeLog.User.Username; lblRevisionInfo.Text = dfcl.ChangeLog.ChangeType.Description; } }
protected void btnSaveAssetTypePrices_Click(object sender, EventArgs e) { foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items) { GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem; if (detailView != null) { GridTableView tableView = detailView.NestedTableViews.First(); foreach (GridDataItem assetTypeItem in tableView.Items) { Hashtable assetTypeValues = new Hashtable(); assetTypeItem.ExtractValues(assetTypeValues); int serviceLocationAssetTypeId = Convert.ToInt32(assetTypeValues["ServiceLocationAssetTypeId"].ToString()); ServiceLocationAssetTypeEntity serviceLocationAssetType = new ServiceLocationAssetTypeEntity(serviceLocationAssetTypeId); TextBox txtPricePerUnit = assetTypeItem.FindControl("txtPricePerUnit") as TextBox; HiddenField hdnOrigPrice = assetTypeItem.FindControl("hdnOrigPrice") as HiddenField; decimal price = 0; decimal origPrice = Convert.ToDecimal(hdnOrigPrice.Value.Trim().Replace("$", "")); if (txtPricePerUnit.Text.Trim().Length > 0) { price = Convert.ToDecimal(txtPricePerUnit.Text.Trim().Replace("$", "")); } serviceLocationAssetType.PricePerUnit = price; serviceLocationAssetType.Save(); if (price != origPrice) { ChangeLogEntity cle = new ChangeLogEntity(); cle.UserId = sm.AuthenticatedUser.UserId; cle.ChangeDate = DateTime.Now; cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.AssetTypePriceChange; cle.Save(); ServiceLocationAssetTypeChangeLogEntity slatcle = new ServiceLocationAssetTypeChangeLogEntity(); slatcle.ServiceLocationAssetTypeId = serviceLocationAssetType.ServiceLocationAssetTypeId; slatcle.ChangeLog = cle; slatcle.Save(); } } } } messages.AddSuccessDiv("Asset types successfully saved"); }