public void CalculatethePackageAmountByPeriodTest() { FinanceBL financeBL = new FinanceBL(DataContext); // Get mega project package List <ProjectPaymentPackageDetails> projectPackageDetails = Utils.GetSystemProjectPackageDetails(); ProjectPaymentPackageDetails projectMegaPackage = projectPackageDetails.Where(ppd => ppd.PackageName == "MEGA").FirstOrDefault(); // Get mega inventory package List <InventoryPaymentPackageDetails> inventoryPackageDetails = Utils.GetSystemInventoryPackageDetails(); InventoryPaymentPackageDetails inventoryMegaPackage = inventoryPackageDetails.Where(ppd => ppd.PackageName == "MEGA").FirstOrDefault(); // get discount code usage DiscountCodeUsage discountCodeUsage = new DiscountCodeUsageMock(DataContext).GetDiscountCodeUsage(true, null); DataContext.SaveChanges(); // get code ids int monthlyPaymentDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "MONTHLY"); int annualPaymentDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "ANUAL"); int projectPackageTypeId = Utils.GetCodeIdByCodeValue("PaymentPackageType", "PROJECT"); int inventoryPackageTypeId = Utils.GetCodeIdByCodeValue("PaymentPackageType", "INVENTORY"); // validate decimal?amount = financeBL.CalculatethePackageAmountByPeriod(inventoryPackageTypeId, inventoryMegaPackage.PackageTypeId, monthlyPaymentDurationCodeId); Assert.IsTrue(inventoryMegaPackage.Amount == amount); amount = financeBL.CalculatethePackageAmountByPeriod(inventoryPackageTypeId, inventoryMegaPackage.PackageTypeId, annualPaymentDurationCodeId); Assert.IsTrue(inventoryMegaPackage.AnualAmount == amount); amount = financeBL.CalculatethePackageAmountByPeriod(projectPackageTypeId, projectMegaPackage.PackageTypeId, monthlyPaymentDurationCodeId); Assert.IsTrue(projectMegaPackage.Amount == amount); amount = financeBL.CalculatethePackageAmountByPeriod(projectPackageTypeId, projectMegaPackage.PackageTypeId, annualPaymentDurationCodeId); Assert.IsTrue(projectMegaPackage.AnualAmount == amount); }
/// <summary> /// Handles the ItemDataBound event of the lvProjectList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ListViewItemEventArgs"/> instance containing the event data.</param> protected void lvProjectList_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { LinkButton lnkProjectPaymentPackage = e.Item.FindControl("lnkProjectPaymentPackage") as LinkButton; if (lnkProjectPaymentPackage != null) { lnkProjectPaymentPackage.Enabled = !IsReadOnly; } int anualPaymentPackageDurationCodeId = Utils.GetCodeByValue("PaymentPackageDuration", "ANUAL").CodeId; ProjectPaymentPackageDetails projectPackageDetail = (ProjectPaymentPackageDetails)e.Item.DataItem; Literal litPackageName = (Literal)e.Item.FindControl("litPackageName"); litPackageName.Text = projectPackageDetail.PackageName; Literal litPackageCharges = (Literal)e.Item.FindControl("litPackageCharges"); StringBuilder textCharhgesBuilder = new StringBuilder(); //eg: $1 per month var globalizationSection = WebConfigurationManager.GetSection("system.web/globalization") as GlobalizationSection; string cultureName = globalizationSection.Culture; decimal?packageAmount = this.GetBL <FinanceBL>().CalculatethePackageAmountByPeriod(Utils.GetCodeByValue("PaymentPackageType", "PROJECT").CodeId, projectPackageDetail.PackageTypeId, PaymentDurationTypeCodeId); if (packageAmount.HasValue && packageAmount > 0) { textCharhgesBuilder.AppendFormat("<p><b>{0}</b> <I>per {1}</I></p>", String.Format("{0:C0}", packageAmount), Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); } else { textCharhgesBuilder.AppendFormat("<p><b>FREE</b></p>"); } litPackageCharges.Text = textCharhgesBuilder.ToString(); if (projectPackageDetail.Amount > 0) { Literal litPackageLimits = (Literal)e.Item.FindControl("litPackageLimits"); StringBuilder textLimitBuilder = new StringBuilder(); textLimitBuilder.AppendFormat("<p>{0} Active {1} </p><p> Up to {2} Active {3} </p> ", projectPackageDetail.ProjectCount.ToString(), projectPackageDetail.ProjectCount == 1 ? "Project" : "Projects", projectPackageDetail.HeadCount, projectPackageDetail.HeadCount == 1 ? "User" : "Users"); litPackageLimits.Text = textLimitBuilder.ToString(); } Literal litPackageDisplayText = (Literal)e.Item.FindControl("litPackageDisplayText"); litPackageDisplayText.Text = projectPackageDetail.PackageDisplayText; Literal litTitleDescription = (Literal)e.Item.FindControl("litTitleDescription"); litTitleDescription.Text = projectPackageDetail.PackageTitleDiscription; //High light the already configured package if (CurrentProjectPaymentPackageTypeId == projectPackageDetail.PackageTypeId) { Panel tblPackage = (Panel)e.Item.FindControl("tblPackage"); tblPackage.CssClass = "PaymentPackageSaved"; } else if (ProjectPaymentPackageTypeId == projectPackageDetail.PackageTypeId) { Panel tblPackage = (Panel)e.Item.FindControl("tblPackage"); tblPackage.CssClass = "PaymentPackageSelected"; } } }
/// <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; } } }
public void CalculateALLPackageAmountsByPeriodTest() { FinanceBL financeBL = new FinanceBL(DataContext); List <ProjectPaymentPackageDetails> projectPackageDetails = Utils.GetSystemProjectPackageDetails(); ProjectPaymentPackageDetails projectMegaPackage = projectPackageDetails.Where(ppd => ppd.PackageName == "MEGA").FirstOrDefault(); List <InventoryPaymentPackageDetails> inventoryPackageDetails = Utils.GetSystemInventoryPackageDetails(); InventoryPaymentPackageDetails inventoryMegaPackage = inventoryPackageDetails.Where(ppd => ppd.PackageName == "MEGA").FirstOrDefault(); // Create a company DiscountCodeUsage discountCodeUsage = new DiscountCodeUsageMock(DataContext).GetDiscountCodeUsage(true, null); DataContext.SaveChanges(); int monthlyPaymentDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "MONTHLY"); int annualPaymentDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "ANUAL"); decimal totalDue = financeBL.CalculateALLPackageAmountsByPeriod(projectMegaPackage.PackageTypeId, inventoryMegaPackage.PackageTypeId, monthlyPaymentDurationCodeId); Assert.IsTrue((projectMegaPackage.Amount + inventoryMegaPackage.Amount) == totalDue); totalDue = financeBL.CalculateALLPackageAmountsByPeriod(projectMegaPackage.PackageTypeId, inventoryMegaPackage.PackageTypeId, annualPaymentDurationCodeId); Assert.IsTrue((projectMegaPackage.AnualAmount + inventoryMegaPackage.AnualAmount) == totalDue); }
public void GetDiscountedAmountTest() { FinanceBL financeBL = new FinanceBL(DataContext); List <ProjectPaymentPackageDetails> projectPackageDetails = Utils.GetSystemProjectPackageDetails(); ProjectPaymentPackageDetails projectMegaPackage = projectPackageDetails.Where(ppd => ppd.PackageName == "MEGA").FirstOrDefault(); List <InventoryPaymentPackageDetails> inventoryPackageDetails = Utils.GetSystemInventoryPackageDetails(); InventoryPaymentPackageDetails inventoryMegaPackage = inventoryPackageDetails.Where(ppd => ppd.PackageName == "MEGA").FirstOrDefault(); // Create a company DiscountCodeUsage discountCodeUsage = new DiscountCodeUsageMock(DataContext).GetDiscountCodeUsage(true, null); DataContext.SaveChanges(); int monthlyPaymentDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "MONTHLY"); int annualPaymentDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "ANUAL"); decimal totalDue = financeBL.CalculateALLPackageAmountsByPeriod(projectMegaPackage.PackageTypeId, inventoryMegaPackage.PackageTypeId, monthlyPaymentDurationCodeId); decimal discountedAmount = financeBL.GetDiscountedAmount(discountCodeUsage.CompanyId, totalDue, monthlyPaymentDurationCodeId, discountCodeUsage, Utils.Today, Utils.Today.AddMonths(1)); Assert.IsTrue((projectMegaPackage.Amount + inventoryMegaPackage.Amount) * (discountCodeUsage.DiscountCode.Discount / 100) == discountedAmount); totalDue = financeBL.CalculateALLPackageAmountsByPeriod(projectMegaPackage.PackageTypeId, inventoryMegaPackage.PackageTypeId, annualPaymentDurationCodeId); discountedAmount = financeBL.GetDiscountedAmount(discountCodeUsage.CompanyId, totalDue, annualPaymentDurationCodeId, discountCodeUsage, Utils.Today, Utils.Today.AddYears(1)); decimal discountedDays = (discountCodeUsage.EndDate - discountCodeUsage.StartDate.Value).Days; decimal totalDays = (Utils.Today.AddYears(1) - Utils.Today).Days; decimal noDiscountedDays = totalDays - discountedDays; decimal testTotalAmount = (((discountedDays / totalDays) * (discountCodeUsage.DiscountCode.Discount / 100)) + (noDiscountedDays / totalDays)) * (projectMegaPackage.AnualAmount + inventoryMegaPackage.AnualAmount); Assert.IsTrue(decimal.Round(testTotalAmount, 2) == discountedAmount); }
/// <summary> /// Updates the payment summary. /// </summary> public void UpdatePaymentSummary() { int anualPaymentPackageDurationCodeId = Utils.GetCodeByValue("PaymentPackageDuration", "ANUAL").CodeId; ProjectPaymentPackageDetails projectPaymentPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(ProjectPaymentPackageDetailId); StringBuilder textCharhgesProjBuilder = new StringBuilder(); if (projectPaymentPackageDetails != null) { litProjectLevelPackage.Text = projectPaymentPackageDetails.PackageDisplayName; textCharhgesProjBuilder.AppendFormat("<b>{0}</b><I>/{1}</I>", Support.FormatCurrency(this.GetBL <FinanceBL>().CalculatethePackageAmountByPeriod(Utils.GetCodeByValue("PaymentPackageType", "PROJECT").CodeId, ProjectPaymentPackageDetailId, PaymentDurationTypeCodeId), CultureName), Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); litProjectLevelAmount.Text = textCharhgesProjBuilder.ToString(); } else { if (CompanyId > 0 && GetBL <CompanyBL>().IsFreeTrialCompany(CompanyId)) { litProjectLevelPackage.Text = Utils.GetSystemValue("DefaultPackageName"); } else { litProjectLevelPackage.Text = "N/A"; } textCharhgesProjBuilder.AppendFormat("<b>{0}</b><I>/{1}</I>", Support.FormatCurrency(0, CultureName), Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); litProjectLevelAmount.Text = textCharhgesProjBuilder.ToString(); } InventoryPaymentPackageDetails inventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(InventoryPaymentPackageDetailId); StringBuilder textCharhgesInvBuilder = new StringBuilder(); if (inventoryPaymentPackageDetails != null) { litInventoryLevelPackage.Text = inventoryPaymentPackageDetails.PackageDisplayName; textCharhgesInvBuilder.AppendFormat("<b>{0}</b><I>/{1}</I>", Support.FormatCurrency(this.GetBL <FinanceBL>().CalculatethePackageAmountByPeriod(Utils.GetCodeByValue("PaymentPackageType", "INVENTORY").CodeId, InventoryPaymentPackageDetailId, PaymentDurationTypeCodeId), CultureName), Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); litInventoryLevelAmount.Text = textCharhgesInvBuilder.ToString(); } else { if (CompanyId > 0 && GetBL <CompanyBL>().IsFreeTrialCompany(CompanyId)) { litInventoryLevelPackage.Text = Utils.GetSystemValue("DefaultPackageName"); } else { litInventoryLevelPackage.Text = "N/A"; } textCharhgesInvBuilder.AppendFormat("<b>{0}</b><I>/{1}</I>", Support.FormatCurrency(0, CultureName), Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); litInventoryLevelAmount.Text = textCharhgesInvBuilder.ToString(); } //Total Amount With No Discount or Educational Package offer //decimal totalAmountForthePeriod = this.GetBL<FinanceBL>().CalculateALLPackageAmountsByPeriod(projectPaymentPackageDetailId, inventoryPaymentPackageDetailId, paymentDurationTypeCodeId); TotalAmountForPeriod = this.GetBL <FinanceBL>().CalculateALLPackageAmountsByPeriod(ProjectPaymentPackageDetailId, InventoryPaymentPackageDetailId, PaymentDurationTypeCodeId); //Just initialization decimal totalAmountWithPromotionalCode = TotalAmountForPeriod; setUpDiscountCode.LoadDiscountCodes(); //Check if there is a Promotional Code. This is to assign to the hidden field DiscountCodeUsage = GetDiscountCodeUsage(); if (DiscountCodeUsage != null) { DateTime packageStartDate = Utils.Today;//For Normal company, the package start date should be Today. if (this.GetBL <CompanyBL>().IsFreeTrialCompany(CompanyId)) { //For Free Trial Companies, Start Date should be FT end Date + 1 packageStartDate = this.GetBL <CompanyBL>().GetFreeTrialProjectEndDate(CompanyId).AddDays(1); } else { packageStartDate = Utils.Today; } DateTime endDate = PaymentDurationTypeCodeId == anualPaymentPackageDurationCodeId?packageStartDate.AddYears(1) : packageStartDate.AddMonths(1); totalAmountWithPromotionalCode = this.GetBL <FinanceBL>().GetDiscountedAmount(CompanyId, TotalAmountForPeriod, PaymentDurationTypeCodeId, DiscountCodeUsage, packageStartDate, endDate); litDiscountMsg.Text = "Promotional Code: "; lblDiscountedAmountText.Text = string.Format("(Including promotional discount of {0}) </br>", Support.FormatCurrency(TotalAmountForPeriod - totalAmountWithPromotionalCode, CultureName)); lblTotalAmountAfterPromotion.Text = string.Concat(Support.FormatCurrency(TotalAmountForPeriod, CultureName), "/", Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description, " after discount expires on ", Support.FormatDate(DiscountCodeUsage.EndDate)); } else { litDiscountMsg.Text = " Do you have a Promotional Code?"; lblTotalAmountAfterPromotion.Text = string.Empty; lblDiscountedAmountText.Text = string.Empty; } //Assign to the hidden field hdnTotalAfterDiscount.Text = string.Concat(Support.FormatCurrency(totalAmountWithPromotionalCode, CultureName), "/", Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); //If there is an Educational discount, what would be the final amount decimal totalAmountWithEducationalPackage = TotalAmountForPeriod; decimal educationalDiscount = decimal.Parse(Utils.GetSystemValue("EducationalDiscount")); totalAmountWithEducationalPackage = TotalAmountForPeriod * (100 - educationalDiscount) / 100; TotalAmountWithEducationalPackage = totalAmountWithEducationalPackage; //Assign to the public variables TotalAmount = TotalAmountForPeriod; //If there is a promotional code or educational discount then get the total out of it. if (chkIsCollege.Checked) { TotalAmountForPeriod = totalAmountWithEducationalPackage; lblTotalAmountAfterPromotion.Style.Add("Display", "None"); //Hide the Promotional Text lblDiscountedAmountText.Style.Add("Display", "None"); trPromotionalCode.Style.Add("Display", "None"); //Hide "Do you have a Promotional Code?" divEducationalDiscount.Style.Add("Display", " "); //Assign to the public variables } else { if (DiscountCodeUsage != null) { lblTotalAmountAfterPromotion.Style.Add("Display", " "); lblDiscountedAmountText.Style.Add("Display", " "); } else { lblTotalAmountAfterPromotion.Style.Add("Display", "None"); lblDiscountedAmountText.Style.Add("Display", "None"); } trPromotionalCode.Style.Add("Display", " "); TotalAmountForPeriod = totalAmountWithPromotionalCode; divEducationalDiscount.Style.Add("Display", "None");//Hide the Educational Discount text } hdnTotalAfterEducationalPackage.Text = string.Concat(Support.FormatCurrency(totalAmountWithEducationalPackage, CultureName), "/", Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); lblTotaltoPay.Text = string.Concat(Support.FormatCurrency(TotalAmountForPeriod, CultureName), "/", Utils.GetCodeByCodeId(PaymentDurationTypeCodeId).Description); upnlSummary.Update(); }
/// <summary> /// Gets the payment package summaries. /// </summary> /// <param name="paymentSummaryDetail">The payment summary detail.</param> /// <param name="dateToConsider">The date to consider.</param> /// <param name="dataContext">The data context.</param> /// <returns></returns> public static List <CompanyPaymentSummary> GetPaymentPackageSummaries(PaymentSummaryDetails paymentSummaryDetail, DateTime dateToConsider, StageBitzDB dataContext) { int anualDurationCodeId = Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "ANUAL"); int invoiceMethodCodeId = Utils.GetCodeIdByCodeValue("PaymentMethod", "INVOICE"); List <CompanyPaymentSummary> summaryList = new List <CompanyPaymentSummary>(); DateTime nextCycleStartDate = Utils.Today; decimal totalDue = 0; decimal educationalDiscount = decimal.Parse(Utils.GetSystemValue("EducationalDiscount")); FinanceBL financeBL = new FinanceBL(dataContext); CompanyBL companyBL = new CompanyBL(dataContext); CompanyPaymentSummary existingCompanyPackageSummary = dataContext.CompanyPaymentSummaries.Where(cps => cps.CompanyId == paymentSummaryDetail.CompanyId).OrderByDescending(cps => cps.CompanyPaymentSummaryId).FirstOrDefault(); CompanyPaymentPackage currentCompanyPaymentPackage = financeBL.GetPaymentPackageForCompanyByDay(dateToConsider, paymentSummaryDetail.CompanyId); if (existingCompanyPackageSummary != null && companyBL.IsFreeTrialCompany(paymentSummaryDetail.CompanyId)) //check whether there is an upgrade/downgrade during the freetrial { existingCompanyPackageSummary = null; } if (existingCompanyPackageSummary == null || currentCompanyPaymentPackage == null) { //This is for the very first time from UI. So return the amount based on promotional and educational discount amount. totalDue = financeBL.CalculateALLPackageAmountsByPeriod(paymentSummaryDetail.ProjectPaymentPackageTypeId, paymentSummaryDetail.InventoryPaymentPackageTypeId, paymentSummaryDetail.PaymentDurationTypeCodeId); if (paymentSummaryDetail.IsEducationPackage) { totalDue = totalDue * (100 - educationalDiscount) / 100; } else if (paymentSummaryDetail.DiscountCodeUsageToApply != null) { DateTime endDate = paymentSummaryDetail.PaymentDurationTypeCodeId == anualDurationCodeId?paymentSummaryDetail.PackageStartDate.AddYears(1) : paymentSummaryDetail.PackageStartDate.AddMonths(1); totalDue = financeBL.GetDiscountedAmount(paymentSummaryDetail.CompanyId, totalDue, paymentSummaryDetail.PaymentDurationTypeCodeId, paymentSummaryDetail.DiscountCodeUsageToApply, paymentSummaryDetail.PackageStartDate, endDate); } nextCycleStartDate = paymentSummaryDetail.PaymentDurationTypeCodeId == anualDurationCodeId?paymentSummaryDetail.PackageStartDate.AddYears(1) : paymentSummaryDetail.PackageStartDate.AddMonths(1); summaryList.Add(CreateCompanyPaymentSummary(totalDue, nextCycleStartDate, paymentSummaryDetail, paymentSummaryDetail.DiscountCodeUsageToApply, paymentSummaryDetail.PackageStartDate, nextCycleStartDate, (paymentSummaryDetail.PaymentMethodCodeId != null && paymentSummaryDetail.PaymentMethodCodeId == invoiceMethodCodeId), paymentSummaryDetail.PaymentMethodCodeId, paymentSummaryDetail.CompanyPaymentPackage)); } else { //This happens when a user upgrades or daily agent makes repeat payments at the end of the Payment Cycle. DateTime endDate = existingCompanyPackageSummary.NextPaymentCycleStartingDate; int dateDifference = 0; InventoryPaymentPackageDetails currentInventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(currentCompanyPaymentPackage.InventoryPaymentPackageTypeId); InventoryPaymentPackageDetails newInventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(paymentSummaryDetail.InventoryPaymentPackageTypeId); ProjectPaymentPackageDetails currentProjectPaymentPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(currentCompanyPaymentPackage.ProjectPaymentPackageTypeId); ProjectPaymentPackageDetails newProjectPaymentPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(paymentSummaryDetail.ProjectPaymentPackageTypeId); decimal currentTotalAmount, newTotalAmount; //Just Get the Amounts from tables if (currentCompanyPaymentPackage.PaymentDurationCodeId == anualDurationCodeId) { currentTotalAmount = currentInventoryPaymentPackageDetails.AnualAmount + currentProjectPaymentPackageDetails.AnualAmount; newTotalAmount = newInventoryPaymentPackageDetails.AnualAmount + newProjectPaymentPackageDetails.AnualAmount; } else { currentTotalAmount = currentInventoryPaymentPackageDetails.Amount + currentProjectPaymentPackageDetails.Amount; newTotalAmount = newInventoryPaymentPackageDetails.Amount + newProjectPaymentPackageDetails.Amount; } if (dateToConsider < endDate && paymentSummaryDetail.HasPackageChanged) //this happens only when a user upgrades during the payment cycle { dateDifference = (int)(endDate - dateToConsider).TotalDays; totalDue = GetProrataAmount(paymentSummaryDetail, currentCompanyPaymentPackage, existingCompanyPackageSummary.DiscountCodeUsage, newTotalAmount, currentTotalAmount, endDate, dateDifference); summaryList.Add(CreateCompanyPaymentSummary(totalDue, endDate, paymentSummaryDetail, paymentSummaryDetail.DiscountCodeUsageToApply, dateToConsider, endDate, (paymentSummaryDetail.PaymentMethodCodeId != null && paymentSummaryDetail.PaymentMethodCodeId == invoiceMethodCodeId), paymentSummaryDetail.PaymentMethodCodeId, paymentSummaryDetail.CompanyPaymentPackage)); } else { //this get executed by a user when changing the package during Agent down or on package virtual end date or during a gap filling execution // currentCompanyPaymentPackage will always be the existing package. DateTime startDate, tempNextCycleDate = endDate; while (tempNextCycleDate <= dateToConsider) { if (tempNextCycleDate == dateToConsider && paymentSummaryDetail.IsUserAction) { break; } //Find the next Package Start Date based on the duration startDate = tempNextCycleDate; tempNextCycleDate = currentCompanyPaymentPackage.PaymentDurationCodeId == anualDurationCodeId?tempNextCycleDate.AddYears(1) : tempNextCycleDate.AddMonths(1); decimal recordTotalAmount = currentTotalAmount; DiscountCodeUsage discountCodeUsage = null; //Get the relavent education or Discount if (currentCompanyPaymentPackage.IsEducationalPackage) { recordTotalAmount = recordTotalAmount * (100 - educationalDiscount) / 100; } else { //Get the DiscountCode Usage for the Day discountCodeUsage = financeBL.GetDiscountCodeUsageByDate(startDate, currentCompanyPaymentPackage.CompanyId); if (discountCodeUsage != null) { recordTotalAmount = financeBL.GetDiscountedAmount(currentCompanyPaymentPackage.CompanyId, recordTotalAmount, currentCompanyPaymentPackage.PaymentDurationCodeId, discountCodeUsage, startDate, tempNextCycleDate); } } if (paymentSummaryDetail.PaymentMethodCodeId != null) { //this will set is monthly agent processed to true for the past records when gap filling if the user has selected the invoice option. summaryList.Add(CreateCompanyPaymentSummary(recordTotalAmount, tempNextCycleDate, paymentSummaryDetail, discountCodeUsage, startDate, tempNextCycleDate, (paymentSummaryDetail.PaymentMethodCodeId == invoiceMethodCodeId), paymentSummaryDetail.PaymentMethodCodeId, currentCompanyPaymentPackage)); } else { summaryList.Add(CreateCompanyPaymentSummary(recordTotalAmount, tempNextCycleDate, paymentSummaryDetail, discountCodeUsage, startDate, tempNextCycleDate, (currentCompanyPaymentPackage.PaymentMethodCodeId != null && currentCompanyPaymentPackage.PaymentMethodCodeId == invoiceMethodCodeId), currentCompanyPaymentPackage.PaymentMethodCodeId, currentCompanyPaymentPackage)); } } if (tempNextCycleDate == dateToConsider && paymentSummaryDetail.IsUserAction) //if the user do any pricing plan change on the same summmnary end date, this will calculate amounts according to the new selections { startDate = tempNextCycleDate; tempNextCycleDate = paymentSummaryDetail.PaymentDurationTypeCodeId == anualDurationCodeId?tempNextCycleDate.AddYears(1) : tempNextCycleDate.AddMonths(1); decimal recordTotalAmount = newTotalAmount; if (paymentSummaryDetail.PaymentDurationTypeCodeId == anualDurationCodeId) { recordTotalAmount = newInventoryPaymentPackageDetails.AnualAmount + newProjectPaymentPackageDetails.AnualAmount; } else { recordTotalAmount = newInventoryPaymentPackageDetails.Amount + newProjectPaymentPackageDetails.Amount; } //Get the relevant education or Discount if (paymentSummaryDetail.IsEducationPackage) { recordTotalAmount = recordTotalAmount * (100 - educationalDiscount) / 100; } else if (paymentSummaryDetail.DiscountCodeUsageToApply != null) { recordTotalAmount = financeBL.GetDiscountedAmount(paymentSummaryDetail.CompanyId, recordTotalAmount, paymentSummaryDetail.PaymentDurationTypeCodeId, paymentSummaryDetail.DiscountCodeUsageToApply, startDate, tempNextCycleDate); } summaryList.Add(CreateCompanyPaymentSummary(recordTotalAmount, tempNextCycleDate, paymentSummaryDetail, paymentSummaryDetail.DiscountCodeUsageToApply, startDate, tempNextCycleDate, paymentSummaryDetail.PaymentMethodCodeId != null && paymentSummaryDetail.PaymentMethodCodeId == invoiceMethodCodeId, paymentSummaryDetail.PaymentMethodCodeId, paymentSummaryDetail.CompanyPaymentPackage)); } if (paymentSummaryDetail.HasPackageChanged && dateToConsider > endDate) // user upgrade after the yearly cycle (Calculcate Pro rata) { dateDifference = (int)(tempNextCycleDate - dateToConsider).TotalDays; totalDue = GetProrataAmount(paymentSummaryDetail, currentCompanyPaymentPackage, summaryList.Count() > 0 ? summaryList.Last().DiscountCodeUsage : null, newTotalAmount, currentTotalAmount, tempNextCycleDate, dateDifference); summaryList.Add(CreateCompanyPaymentSummary(totalDue, tempNextCycleDate, paymentSummaryDetail, paymentSummaryDetail.DiscountCodeUsageToApply, dateToConsider, tempNextCycleDate, paymentSummaryDetail.PaymentMethodCodeId != null && paymentSummaryDetail.PaymentMethodCodeId == invoiceMethodCodeId, paymentSummaryDetail.PaymentMethodCodeId, paymentSummaryDetail.CompanyPaymentPackage)); } } } return(summaryList); }
/// <summary> /// Validates the package configurations. /// </summary> /// <param name="pricePlanDetails">The price plan details.</param> public void ValidatePackageConfigurations(PricePlanDetails pricePlanDetails) { PricePlanDetails = pricePlanDetails; if (!IsCompanyValidToSave()) { return; } if (PricePlanDetails.ProjectPaymentPackageTypeId > 0 && PricePlanDetails.InventoryPaymentPackageTypeId > 0 && PricePlanDetails.PaymentDurationCodeId > 0) { ProjectPaymentPackageDetails projectPackageDetails = Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(PricePlanDetails.ProjectPaymentPackageTypeId); InventoryPaymentPackageDetails inventoryPaymentPackageDetails = Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(PricePlanDetails.InventoryPaymentPackageTypeId); //Get the current usage of the company. If exceeds the package show the error message string errorOnUsage = this.GetBL <FinanceBL>().GettheValidityOfSelectedPlan(CompanyId, pricePlanDetails, projectPackageDetails, inventoryPaymentPackageDetails); this.DisplayMode = ViewMode.PricingPlanPage; //concurrent discount chaged popups come on top of pricing plan page. view mode set accordingly. if (errorOnUsage.Length > 0) { //Show the error message. litError.Text = errorOnUsage; popupError.ShowPopup(); } else { //Assign the InMemory Company object if (CompanyId == 0) { paymentDetails.NewCompany = NewCompany; paymentDetails.Media = Media; } CompanyPaymentPackage oldCompanyPaymentPackage = this.GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(CompanyId); DateTime packageStartDate = Utils.Today;//For Normal company, the package start date should be Today. //Find the package start date if (this.GetBL <CompanyBL>().IsFreeTrialCompany(CompanyId)) { //For Free Trial Companies, Start Date should be FT end Date + 1 packageStartDate = this.GetBL <CompanyBL>().GetFreeTrialProjectEndDate(CompanyId).AddDays(1); } else { if (oldCompanyPaymentPackage != null) { if (oldCompanyPaymentPackage.PaymentDurationCodeId == Utils.GetCodeIdByCodeValue("PaymentPackageDuration", "ANUAL")) { if (oldCompanyPaymentPackage.ProjectPaymentPackageTypeId != PricePlanDetails.ProjectPaymentPackageTypeId || oldCompanyPaymentPackage.InventoryPaymentPackageTypeId != PricePlanDetails.InventoryPaymentPackageTypeId) { packageStartDate = Utils.Today; } else { if (oldCompanyPaymentPackage.EndDate != null) { packageStartDate = oldCompanyPaymentPackage.EndDate.Value.AddDays(1); } else { packageStartDate = oldCompanyPaymentPackage.StartDate.AddYears(1).AddDays(1); } } } else if (oldCompanyPaymentPackage.EndDate != null) { packageStartDate = oldCompanyPaymentPackage.EndDate.Value; } } } PricePlanDetails.PackageStartDate = packageStartDate; OriginalLastUpdatedDate = oldCompanyPaymentPackage != null ? oldCompanyPaymentPackage.LastUpdateDate : null; // No projects selected during free trial period if (!HasRespondedToFreeTrailNoProjectsPopup && this.CompanyId > 0 && projectPackageDetails.Amount == 0 && GetBL <CompanyBL>().IsFreeTrialCompany(this.CompanyId)) { ShowPopupForNoProjectsPackageSelectionDuringFreeTrail(); } // free inventory scenario else if ((projectPackageDetails.Amount + inventoryPaymentPackageDetails.Amount) == 0) { ShowFreeInventoryOnlyPopUp(inventoryPaymentPackageDetails.ItemCount.Value); } else if (HandleConcurrentDiscountChanges()) { this.PricePlanDetails.DiscountCodeUsage = this.DiscountCodeUsage; this.PricePlanDetails.DiscountCode = (this.DiscountCodeUsage != null ? this.DiscountCodeUsage.DiscountCode : null); } else if (!HasRespondedToNoPackageChangesPopup && !this.GetBL <FinanceBL>().IsCompanyPaymentPackageChanged(this.CompanyId, pricePlanDetails)) { ShowPopupNoPackageChanges(); } else if (!PricePlanDetails.IsEducationalPackage && (PricePlanDetails.DiscountCodeUsage != null && PricePlanDetails.DiscountCodeUsage.DiscountCode.Discount == 100 && PricePlanDetails.TotalAmountForPeriod == 0)) { ShowHundredPercentDiscountPopUp(PricePlanDetails.DiscountCodeUsage); } else { ShowAdddetailsPaymentpopUp(); } } } }
/// <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); }