/// <summary> /// Loads the data. /// </summary> public void LoadData() { CompanyPaymentPackage companyPaymentPackage = this.GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(CompanyId); if (companyPaymentPackage != null) { //This does not get NULL. 0 values as default CompanyCurrentUsage companyCurrentUsage = this.GetBL <FinanceBL>().GetCompanyCurrentUsage(CompanyId, null); CompanyPaymentPackage futurePackage = this.GetBL <FinanceBL>().GetLatestRequestForTheCompany(CompanyId); ProjectPaymentPackageDetails projectPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(companyPaymentPackage.ProjectPaymentPackageTypeId); InventoryPaymentPackageDetails inventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(companyPaymentPackage.InventoryPaymentPackageTypeId); litActiveProjects.Text = string.Concat(projectPackageDetails.ProjectCount, projectPackageDetails.ProjectCount == 1 ? " Active Project" : " Active Projects"); litCurrentProjectCount.Text = companyCurrentUsage.ProjectCount.ToString(); if (this.GetBL <FinanceBL>().IsEducationalCompany(companyPaymentPackage)) { litActiveUsers.Text = "Unlimited Users"; } else { litActiveUsers.Text = string.Concat(projectPackageDetails.HeadCount, projectPackageDetails.HeadCount == 1 ? " Active User" : " Active Users"); } litCurrentUserCount.Text = companyCurrentUsage.UserCount.ToString(); litInventoryItems.Text = string.Concat(inventoryPaymentPackageDetails.ItemCount == null ? "Unlimited " : inventoryPaymentPackageDetails.ItemCount.ToString(), inventoryPaymentPackageDetails.ItemCount == 1 ? " Inventory Item" : " Inventory Items"); litInvCurrentCount.Text = companyCurrentUsage.InventoryCount.ToString(); divDefaultText.Visible = false; } else { //Show the default message tblPlanMonitor.Visible = false; if (this.GetBL <CompanyBL>().IsFreeTrialCompany(this.CompanyId)) { paraFreeTrailIndication.Visible = true; } } if (Request.Browser.Type.Contains("Firefox")) //firefox has a margin issue { btnViewPricingPlan.Style.Add("margin", "0px"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CompanyPaymentPackage companyPaymentPackage = this.GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(CompanyId); CompanyCurrentUsage companyCurrentUsage = this.GetBL <FinanceBL>().GetCompanyCurrentUsage(CompanyId, null); txtCurrentProjectCount.Value = companyCurrentUsage.ProjectCount; txtCurrentUserCount.Value = companyCurrentUsage.UserCount; txtInvCurrentCount.Value = companyCurrentUsage.InventoryCount; if (companyPaymentPackage != null) { //This does not get NULL. 0 values as default CompanyPaymentPackage futurePackage = this.GetBL <FinanceBL>().GetLatestRequestForTheCompany(CompanyId); ProjectPaymentPackageDetails projectPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(companyPaymentPackage.ProjectPaymentPackageTypeId); InventoryPaymentPackageDetails inventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(companyPaymentPackage.InventoryPaymentPackageTypeId); litActiveProjects.Text = string.Concat(projectPackageDetails.ProjectCount, projectPackageDetails.ProjectCount == 1 ? " Active Project" : " Active Projects"); if (this.GetBL <FinanceBL>().IsEducationalCompany(companyPaymentPackage)) { litActiveUsers.Text = "Unlimited Users"; } else { litActiveUsers.Text = string.Concat(projectPackageDetails.HeadCount, projectPackageDetails.HeadCount == 1 ? " Active User" : " Active Users"); } litInventoryItems.Text = string.Concat(inventoryPaymentPackageDetails.ItemCount == null ? "Unlimited " : inventoryPaymentPackageDetails.ItemCount.ToString(), inventoryPaymentPackageDetails.ItemCount == 1 ? " Inventory Item" : " Inventory Items"); } else { const string NoPaymentPackageMsg = "No Payment Package"; litActiveProjects.Text = NoPaymentPackageMsg; litActiveUsers.Text = NoPaymentPackageMsg; litInventoryItems.Text = NoPaymentPackageMsg; } } }
/// <summary> /// Validates this instance of User control. /// </summary> /// <param name="bulkUploadCount">The bulk upload count.</param> /// <returns></returns> public bool Validate(int?bulkUploadCount = null) { bool isValid = true; bool isFreeTrailCompany = GetBL <CompanyBL>().IsFreeTrialCompany(this.CompanyId); CompanyPaymentPackage companyPaymentPackage = this.GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(CompanyId); ProjectPaymentPackageDetails projectPaymentPackageDetails = null; InventoryPaymentPackageDetails inventoryPaymentPackageDetails = null; if (companyPaymentPackage != null) { projectPaymentPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(companyPaymentPackage.ProjectPaymentPackageTypeId); inventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(companyPaymentPackage.InventoryPaymentPackageTypeId); } CompanyCurrentUsage companyCurrentUsage = GetBL <FinanceBL>().GetCompanyCurrentUsage(CompanyId, null); switch (DisplayMode) { case ViewMode.CreateProjects: if (isFreeTrailCompany) { if (GetBL <FinanceBL>().HasExceededProjectLimit(isFreeTrailCompany, projectPaymentPackageDetails, companyCurrentUsage)) { if (companyPaymentPackage != null) { popupCheckProjectsLimits.ShowPopup(Z_Index); } else { popupCreateNewProjectsDuringFreeTrail.ShowPopup(Z_Index); } isValid = false; } } else { var discountUsage = this.GetBL <FinanceBL>().GetLatestDiscountCodeUsage(CompanyId); ProjectPaymentPackageDetails freeProjectPackage = Utils.GetFreeSystemProjectPackageDetail(); if (companyPaymentPackage != null && (companyPaymentPackage.PaymentMethodCodeId.HasValue || (projectPaymentPackageDetails != null && projectPaymentPackageDetails.ProjectPaymentPackageDetailId == freeProjectPackage.ProjectPaymentPackageDetailId))) { if (GetBL <FinanceBL>().HasExceededProjectLimit(isFreeTrailCompany, projectPaymentPackageDetails, companyCurrentUsage)) { popupCheckProjectsLimits.ShowPopup(Z_Index); isValid = false; } } else if (companyPaymentPackage == null) { if (GetBL <CompanyBL>().IsFreeTrialEndedCompany(this.CompanyId)) { lblProjectLimitFreeTrailEnd.Visible = true; lblProjectLimitNoPackage.Visible = false; popupCreateNewProjectsNoPricingPlan.ShowPopup(Z_Index); isValid = false; } else { lblProjectLimitFreeTrailEnd.Visible = false; lblProjectLimitNoPackage.Visible = true; popupCreateNewProjectsNoPricingPlan.ShowPopup(Z_Index); isValid = false; } } else if (!(companyPaymentPackage != null && (companyPaymentPackage.PaymentMethodCodeId.HasValue || discountUsage != null && discountUsage.DiscountCode.Discount == 100)) && (projectPaymentPackageDetails == null || projectPaymentPackageDetails.ProjectCount > 0)) { lblReActivateProjectsNoPaymentDetails.Visible = true; lblReActivateProjectsNoPricePlan.Visible = false; lblReActivateProjectsNoPaymentDetails.Text = "To create a new Project you will need to setup your payment details."; popupProjectsNoPricePlan.ShowPopup(Z_Index); isValid = false; break; } } break; case ViewMode.ReactivateProjects: List <int> mustIncludeProjectIds = new List <int>(); mustIncludeProjectIds.Add(this.ProjectId); companyCurrentUsage = GetBL <FinanceBL>().GetCompanyCurrentUsage(CompanyId, mustIncludeProjectIds); if (!isFreeTrailCompany) { var discountUsage = this.GetBL <FinanceBL>().GetLatestDiscountCodeUsage(CompanyId); if (!(companyPaymentPackage != null && (companyPaymentPackage.PaymentMethodCodeId.HasValue || discountUsage != null && discountUsage.DiscountCode.Discount == 100)) && (projectPaymentPackageDetails == null || projectPaymentPackageDetails.ProjectCount > 0)) { lblReActivateProjectsNoPaymentDetails.Visible = companyPaymentPackage != null && !companyPaymentPackage.PaymentMethodCodeId.HasValue; lblReActivateProjectsNoPricePlan.Visible = companyPaymentPackage == null; popupProjectsNoPricePlan.ShowPopup(Z_Index); isValid = false; break; } } if (GetBL <FinanceBL>().HasExceededProjectLimit(isFreeTrailCompany, projectPaymentPackageDetails, companyCurrentUsage)) { popupCheckProjectsLimits.ShowPopup(Z_Index); isValid = false; } else { if (GetBL <FinanceBL>().HasExceededUserLimit(CompanyId, string.Empty, isFreeTrailCompany, companyPaymentPackage, projectPaymentPackageDetails, companyCurrentUsage, true)) { lblPackageUserCount.Text = projectPaymentPackageDetails.HeadCount.ToString(CultureInfo.InvariantCulture); lnkPricingPlan.NavigateUrl = string.Format("~/Company/CompanyPricingPlans.aspx?companyId={0}", CompanyId); lnkManageProjectTeam.NavigateUrl = string.Format("~/Project/ProjectTeam.aspx?projectid={0}", this.ProjectId); popupReActivateProjectsUserLimitExceeded.ShowPopup(Z_Index); isValid = false; } } break; case ViewMode.InventoryLimit: if (isFreeTrailCompany) { if (GetBL <FinanceBL>().HasExceededInventoryLimit(isFreeTrailCompany, inventoryPaymentPackageDetails, companyCurrentUsage, bulkUploadCount)) { if (companyPaymentPackage != null) { if (IsCompanyAdmin) { popupInventoryLimitCompanyAdmin.ShowPopup(Z_Index); lblInventoryLimitCompanyAdmin.Visible = true; lblInventoryLimitCompanyAdminFreeTrailEndNoPackage.Visible = false; } else { popupInventoryLimitInventoryManager.ShowPopup(Z_Index); lblInventoryLimitInventoryManager.Visible = true; lblInventoryLimitInventoryManagerFreeTrailEndNoPackage.Visible = false; } } else { if (IsCompanyAdmin) { popupFreeTrailInventoryLimitCompanyAdmin.ShowPopup(Z_Index); } else { popupFreeTrailInventoryLimitInventoryManager.ShowPopup(Z_Index); } } isValid = false; } } else { if (companyPaymentPackage != null) { if (GetBL <FinanceBL>().HasExceededInventoryLimit(isFreeTrailCompany, inventoryPaymentPackageDetails, companyCurrentUsage, bulkUploadCount)) { if (IsCompanyAdmin) { popupInventoryLimitCompanyAdmin.ShowPopup(Z_Index); lblInventoryLimitCompanyAdmin.Visible = true; lblInventoryLimitCompanyAdminFreeTrailEndNoPackage.Visible = false; } else { popupInventoryLimitInventoryManager.ShowPopup(Z_Index); lblInventoryLimitInventoryManager.Visible = true; lblInventoryLimitInventoryManagerFreeTrailEndNoPackage.Visible = false; } isValid = false; } } else { if (GetBL <CompanyBL>().IsFreeTrialEndedCompany(this.CompanyId)) { if (IsCompanyAdmin) { popupInventoryLimitCompanyAdmin.ShowPopup(Z_Index); lblInventoryLimitCompanyAdmin.Visible = false; lblInventoryLimitCompanyAdminFreeTrailEndNoPackage.Visible = true; lblInventoryLimitCompanyAdminNoPackage.Visible = false; } else { popupInventoryLimitInventoryManager.ShowPopup(Z_Index); lblInventoryLimitInventoryManager.Visible = false; lblInventoryLimitInventoryManagerFreeTrailEndNoPackage.Visible = true; lblInventoryLimitInventoryManagerNoPackage.Visible = false; } isValid = false; } else { if (IsCompanyAdmin) { popupInventoryLimitCompanyAdmin.ShowPopup(Z_Index); lblInventoryLimitCompanyAdmin.Visible = false; lblInventoryLimitCompanyAdminFreeTrailEndNoPackage.Visible = false; lblInventoryLimitCompanyAdminNoPackage.Visible = true; } else { popupInventoryLimitInventoryManager.ShowPopup(Z_Index); lblInventoryLimitInventoryManager.Visible = false; lblInventoryLimitInventoryManagerFreeTrailEndNoPackage.Visible = false; lblInventoryLimitInventoryManagerNoPackage.Visible = true; } isValid = false; } } } break; case ViewMode.UserLimit: if (isFreeTrailCompany) { if (GetBL <FinanceBL>().HasExceededUserLimit(CompanyId, InvitedUserEmail, isFreeTrailCompany, companyPaymentPackage, projectPaymentPackageDetails, companyCurrentUsage)) { if (companyPaymentPackage != null) { if (IsCompanyAdmin) { popupUserLimitCompanyAdmin.ShowPopup(Z_Index); lblUserLimitCompanyAdmin.Visible = true; lblUserLimitCompanyAdminFreeTrailEndNoPackage.Visible = false; } else { popupUserLimitProjectAdmin.ShowPopup(Z_Index); lblUserLimitProjectAdmin.Visible = true; lblUserLimitProjectAdminFreeTrailEndNoPackage.Visible = false; } } else { if (IsCompanyAdmin) { popupFreeTrailUserLimitCompanyAdmin.ShowPopup(Z_Index); } else { popupFreeTrailUserLimitProjectAdmin.ShowPopup(Z_Index); } } isValid = false; } } else { if (companyPaymentPackage != null) { if (GetBL <FinanceBL>().HasExceededUserLimit(CompanyId, InvitedUserEmail, isFreeTrailCompany, companyPaymentPackage, projectPaymentPackageDetails, companyCurrentUsage)) { if (IsCompanyAdmin) { popupUserLimitCompanyAdmin.ShowPopup(Z_Index); lblUserLimitCompanyAdmin.Visible = true; lblUserLimitCompanyAdminFreeTrailEndNoPackage.Visible = false; } else { popupUserLimitProjectAdmin.ShowPopup(Z_Index); lblUserLimitProjectAdmin.Visible = true; lblUserLimitProjectAdminFreeTrailEndNoPackage.Visible = false; } isValid = false; } } else { if (GetBL <CompanyBL>().IsFreeTrialEndedCompany(this.CompanyId)) { if (IsCompanyAdmin) { popupUserLimitCompanyAdmin.ShowPopup(Z_Index); lblUserLimitCompanyAdmin.Visible = false; lblUserLimitCompanyAdminFreeTrailEndNoPackage.Visible = true; lblUserLimitCompanyAdminNoPackage.Visible = false; } else { popupUserLimitProjectAdmin.ShowPopup(Z_Index); lblUserLimitProjectAdmin.Visible = false; lblUserLimitProjectAdminFreeTrailEndNoPackage.Visible = true; lblUserLimitProjectAdminNoPackage.Visible = false; } isValid = false; } else { if (IsCompanyAdmin) { popupUserLimitCompanyAdmin.ShowPopup(Z_Index); lblUserLimitCompanyAdmin.Visible = false; lblUserLimitCompanyAdminFreeTrailEndNoPackage.Visible = false; lblUserLimitCompanyAdminNoPackage.Visible = true; } else { popupUserLimitProjectAdmin.ShowPopup(Z_Index); lblUserLimitProjectAdmin.Visible = false; lblUserLimitProjectAdminFreeTrailEndNoPackage.Visible = false; lblUserLimitProjectAdminNoPackage.Visible = true; } isValid = false; } } } break; } return(isValid); }
public ItemResult SyncItem(MobileItem mobileItem) { string status = string.Empty; string message = string.Empty; ItemResult itemResult = new ItemResult(); bool isValidVersion = true; try { using (StageBitzDB dataContext = new StageBitzDB()) { isValidVersion = Helper.IsValidAppVersion(mobileItem.Version, out status); if (isValidVersion) { if (mobileItem != null) { //Check if this Item has already been created in MobileItem table //If not create InventoryMobileItem inventoryMobileItem = dataContext.InventoryMobileItems.Where(imi => imi.MobileItemId == mobileItem.DeviceItemId).FirstOrDefault(); if (inventoryMobileItem == null) { int userId = int.Parse(Utils.DecryptStringAES(mobileItem.Token)); //Check if the user can Create the Item CompanyBL companyBL = new CompanyBL(dataContext); FinanceBL financeBL = new FinanceBL(dataContext); InventoryBL inventoryBL = new InventoryBL(dataContext); if (companyBL.HasEditPermissionForInventoryStaff(mobileItem.CompanyId, userId, null)) { //New Creation of Item if (mobileItem.ItemId == 0) { //To create items in the hidden mode, if the limits have reached. bool isFreeTrailCompany = companyBL.IsFreeTrialCompany(mobileItem.CompanyId); CompanyPaymentPackage companyPaymentPackage = financeBL.GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(mobileItem.CompanyId); InventoryPaymentPackageDetails inventoryPaymentPackageDetails = null; if (companyPaymentPackage != null) { inventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(companyPaymentPackage.InventoryPaymentPackageTypeId); } CompanyCurrentUsage companyCurrentUsage = financeBL.GetCompanyCurrentUsage(mobileItem.CompanyId, null); if (!financeBL.HasExceededInventoryLimit(isFreeTrailCompany, inventoryPaymentPackageDetails, companyCurrentUsage)) { inventoryMobileItem = new InventoryMobileItem(); inventoryMobileItem.MobileItemId = mobileItem.DeviceItemId; inventoryMobileItem.CreatedBy = userId; inventoryMobileItem.CreatedDate = Utils.Now; dataContext.InventoryMobileItems.AddObject(inventoryMobileItem); Item item = new Item(); item.Name = mobileItem.Name; item.IsManuallyAdded = true; item.ItemTypeId = mobileItem.ItemTypeId; item.Quantity = mobileItem.Quantity; item.Description = mobileItem.Description; item.CompanyId = mobileItem.CompanyId; item.IsActive = true; item.CreatedByUserId = item.LastUpdatedByUserId = userId; item.CreatedDate = item.LastUpdatedDate = Utils.Now; item.VisibilityLevelCodeId = Utils.GetCodeIdByCodeValue("InventoryVisibilityLevel", "ABOVE_SHAREDINVENTORY"); dataContext.Items.AddObject(item); dataContext.SaveChanges(); itemResult.Id = item.ItemId; status = "OK"; } else { status = "LIMITREACHED"; message = "Inventory plan limit reached."; } } else { //Edit existing one Item exItem = inventoryBL.GetItem(mobileItem.ItemId); if (exItem != null && exItem.IsActive) { Code userVisibilityCode = inventoryBL.GetUserInventoryVisibilityLevel(mobileItem.CompanyId, userId, null, false); if (!inventoryBL.GetItemStatusInformationForUser(exItem, mobileItem.CompanyId, userId).IsReadOnly&& exItem.Code.SortOrder >= userVisibilityCode.SortOrder) { if (mobileItem.LastUpdateDate == exItem.LastUpdatedDate) { exItem.Name = mobileItem.Name; exItem.ItemTypeId = mobileItem.ItemTypeId; exItem.Description = mobileItem.Description; exItem.Quantity = mobileItem.Quantity; exItem.LastUpdatedByUserId = userId; exItem.LastUpdatedDate = Utils.Now; dataContext.SaveChanges(); status = "OK"; itemResult.Id = mobileItem.ItemId; } else { status = "ITEMEDITED"; message = "Item already edited."; } } else { status = "NORIGHTS"; message = "Check settings with Company Administrator."; } } else { status = "ITEMDELETED"; message = "Item no longer exists."; } } } else { status = "NOACCESS"; message = "Check settings with Company Administrator."; } } else { itemResult.Id = inventoryMobileItem.ItemId; status = "ITEMEXIST"; message = "Item already synced."; } } } else { status = "INVALIDAPP"; message = "Please update App."; } } } catch (Exception ex) { AgentErrorLog.HandleException(ex); status = "ERROR"; message = "Oops! Unkown error. Sorry..."; } itemResult.MobileId = mobileItem.DeviceItemId; itemResult.Status = status; itemResult.Message = message; return(itemResult); }