protected virtual void ValidateINUnit(InventoryItem item) { if (item == null) { return; } using (PXDataRecord record = PXDatabase.SelectSingle <INUnit>(new PXDataField <INUnit.toUnit>(), new PXDataFieldValue <INUnit.unitType>(INUnitType.InventoryItem), new PXDataFieldValue <INUnit.inventoryID>(item.InventoryID), new PXDataFieldValue <INUnit.toUnit>(PXDbType.NVarChar, 6, item.BaseUnit, PXComp.NE))) { if (record != null) { throw new PXException(Messages.WrongInventoryItemToUnitValue, record.GetString(0), item.InventoryCD, item.BaseUnit); } } IEnumerable <PXDataRecord> baseConversions = PXDatabase.SelectMulti <INUnit>(new PXDataField <INUnit.toUnit>(), new PXDataFieldValue <INUnit.unitType>(INUnitType.InventoryItem), new PXDataFieldValue <INUnit.inventoryID>(item.InventoryID), new PXDataFieldValue <INUnit.fromUnit>(PXDbType.NVarChar, item.BaseUnit), new PXDataFieldValue <INUnit.toUnit>(PXDbType.NVarChar, item.BaseUnit)); if (baseConversions.Count() != 1) { throw new PXException(Messages.BaseConversionNotFound, item.BaseUnit, item.BaseUnit, item.InventoryCD); } }
protected void Page_Init(object sender, EventArgs e) { this.usrCaption.CustomizationAvailable = false; this.ds.ReportCode = this.Request.QueryString["ID"]; if (!String.IsNullOrEmpty(this.ds.ReportCode) && this.ds.ReportCode.Contains(".rpx")) { this.ds.ReportCode = this.ds.ReportCode.Replace(".rpx", ""); } string screenID = null; object date = PX.Common.PXContext.GetBusinessDate(); PX.Common.PXContext.SetBusinessDate((DateTime?)date); if (PXSiteMap.CurrentNode != null) { this.Title = PXSiteMap.CurrentNode.Title; screenID = PXSiteMap.CurrentNode.ScreenID; } else { string url = (Request.ApplicationPath != "/" ? Request.Path.Replace(Request.ApplicationPath, "~") : "~" + Request.Path) + "?id=" + this.ds.ReportCode + ".rpx"; PXSiteMapNode node = SiteMap.Provider.FindSiteMapNode(url) as PXSiteMapNode; if (node != null) { this.Title = node.Title; this.usrCaption.ScreenTitle = node.Title; this.usrCaption.ScreenID = PX.Common.Mask.Format("CC.CC.CC.CC", node.ScreenID); screenID = node.ScreenID; } else { using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>( new PXDataField("ScreenID"), new PXDataFieldValue("Url", PXDbType.VarChar, 512, url) )) { if (record != null) { screenID = record.GetString(0); if (!String.IsNullOrEmpty(screenID) && !PXAccess.VerifyRights(screenID)) { throw new PXSetPropertyException(ErrorMessages.NotEnoughRights, this.ds.ReportCode); } } } } } if (String.IsNullOrEmpty(PX.Common.PXContext.GetScreenID()) && !String.IsNullOrEmpty(screenID)) { PX.Common.PXContext.SetScreenID(PX.Common.Mask.Format(">CC.CC.CC.CC", screenID)); } if (_canSendEmail) { viewer.EmailSend += new PXReportViewer.EmailSendHandler(viewer_EmailSend); } else { viewer.AllowSendEmails = false; } }
/// <summary> /// Append node with specified tutle to favorites. /// </summary> private void AddFavorite(string title, Guid?siteId) { if (String.IsNullOrEmpty(title) && siteId == null) { return; } Guid folderID = PXSiteMap.RootNode.NodeID; string neutralTitle; using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>(new PXDataField("Title"), new PXDataFieldValue("NodeID", siteId))) { neutralTitle = record.GetString(0); } if (!string.IsNullOrEmpty(neutralTitle)) { using (PXDataRecord rec_id = PXDatabase.SelectSingle <Favorite>( new PXDataField("Max(Position)+1"), new PXDataFieldValue("UserID", PXAccess.GetUserID()))) { int pos = 1; if (rec_id != null) { pos = rec_id.GetInt32(0) ?? 1; } PXDatabase.Insert <Favorite>( new PXDataFieldAssign("UserID", PXAccess.GetUserID()), new PXDataFieldAssign("NodeID", Guid.NewGuid()), new PXDataFieldAssign("Title", neutralTitle), new PXDataFieldAssign("ParentID", folderID), new PXDataFieldAssign("Position", pos), new PXDataFieldAssign("SiteMapID", siteId)); } } }
protected void Page_Init(object sender, EventArgs e) { // remove unum parameter PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic); // make collection editable isreadonly.SetValue(this.Request.QueryString, false, null); this.Request.QueryString.Remove(PXUrl.UNum); isreadonly.SetValue(this.Request.QueryString, true, null); this.usrCaption.CustomizationAvailable = false; var date = PXContext.GetBusinessDate(); PX.Common.PXContext.SetBusinessDate((DateTime?)date); if ((this.viewer.SchemaUrl = this.Request.QueryString["ID"]) == null) { this.viewer.SchemaUrl = ReportID; } if (SiteMap.CurrentNode != null) { this.Title = PXSiteMap.CurrentNode.Title; _screenID = PXSiteMap.CurrentNode.ScreenID; } else { string url; if (Request.ApplicationPath != "/") { url = Request.Path.Replace(Request.ApplicationPath, "~") + "?ID=" + this.viewer.SchemaUrl; } else if (Request.Path.StartsWith("/")) { url = "~" + Request.Path; } else { url = Request.Path; } PXSiteMapNode node = SiteMap.Provider.FindSiteMapNode(url) as PXSiteMapNode; if (node != null) { this.Title = node.Title; this.usrCaption.ScreenTitle = node.Title; this.usrCaption.ScreenID = PX.Common.Mask.Format(">CC.CC.CC.CC", node.ScreenID); _screenID = node.ScreenID; } else { using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>( new PXDataField("ScreenID"), new PXDataFieldValue("Url", PXDbType.VarChar, 512, url) )) { if (record != null) { _screenID = record.GetString(0); if (!String.IsNullOrEmpty(_screenID) && !PXAccess.VerifyRights(_screenID)) { throw new PXSetPropertyException(ErrorMessages.NotEnoughRights, this.viewer.SchemaUrl); } } } } } if (String.IsNullOrEmpty(PX.Common.PXContext.GetScreenID())) { if (String.IsNullOrEmpty(_screenID) && !String.IsNullOrEmpty(this.viewer.SchemaUrl)) { string schema = this.viewer.SchemaUrl; if (schema.EndsWith(".rpx", StringComparison.OrdinalIgnoreCase)) { schema = schema.Substring(0, schema.Length - 4); } if (schema.Length == 8) { _screenID = schema; } } if (!String.IsNullOrEmpty(_screenID)) { PX.Common.PXContext.SetScreenID(PX.Common.Mask.Format(">CC.CC.CC.CC", _screenID)); } } if (_canSendEmail) { viewer.EmailSend += new PXReportViewer.EmailSendHandler(viewer_EmailSend); } else { viewer.AllowSendEmails = false; } }