/// <summary> /// Handles the UpdateCommand event of the gvLocations control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> protected void gvLocations_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (!PageBase.StopProcessing && Page.IsValid) { //Get the GridEditableItem of the RadGrid GridEditableItem editedItem = e.Item as GridEditableItem; //string name = (editedItem["Name"].Controls[0] as TextBox).Text; //string location = (editedItem["Location"].Controls[0] as TextBox).Text; TextBox name = (TextBox)editedItem.FindControl("tbName"); TextBox location = (TextBox)editedItem.FindControl("tbLocation"); if (name.Text.Trim() != string.Empty || location.Text.Trim() != string.Empty) { if (ProjectID == 0) { ProjectLocation projectLocation = LocationList[editedItem.ItemIndex]; projectLocation.Location = location.Text.Trim(); projectLocation.Name = name.Text.Trim(); projectLocation.LastUpdatedByUserId = UserID; projectLocation.LastUpdatedDate = Now; } else { int projectLocationID = (int)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ProjectLocationId"]; DateTime originalLastUpdatedDate = (DateTime)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["LastUpdatedDate"]; ProjectLocation projectLocation = (from pl in DataContext.ProjectLocations where pl.ProjectLocationId == projectLocationID && pl.LastUpdatedDate == originalLastUpdatedDate select pl).FirstOrDefault(); if (projectLocation == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ProjectDetails, ProjectID)); } #region Project Notification if (projectLocation.Location != location.Text.Trim() || projectLocation.Name != name.Text.Trim()) { DataContext.Notifications.AddObject(CreateNotification(Support.GetCodeIdByCodeValue("OperationType", "EDIT"), string.Format("{0} edited a Project Location.", Support.UserFullName))); } #endregion Project Notification projectLocation.Location = location.Text.Trim(); projectLocation.Name = name.Text.Trim(); projectLocation.LastUpdatedByUserId = UserID; projectLocation.LastUpdatedDate = Now; DataContext.SaveChanges(); } gvLocations.EditIndexes.Clear(); gvLocations.MasterTableView.IsItemInserted = false; gvLocations.Rebind(); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.Exception">project not found</exception> /// <exception cref="System.ApplicationException">Permission denied for this project </exception> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["projectid"] != null) { ProjectID = Convert.ToInt32(Request.QueryString["projectid"].ToString()); ucProjectEvents.ProjectID = ProjectID; } StageBitz.Data.Project project = (from p in DataContext.Projects where p.ProjectId == ProjectID select p).FirstOrDefault(); if (project == null) { throw new Exception("project not found"); } if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project "); } this.CompanyId = project.CompanyId; projectWarningPopup.ProjectId = ProjectID; warningDisplay.ProjectID = ProjectID; warningDisplay.LoadData(); //Set last updated date for concurrency handling OriginalLastUpdatedDate = project.LastUpdatedDate.Value; btnCancel.PostBackUrl = string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", ProjectID); DisplayTitle = "Manage Schedule";//string.Format("{0}'s Dashboard", Support.TruncateString(project.ProjectName, 32)); bool isReadOnlyRightsForProject = Support.IsReadOnlyRightsForProject(ProjectID); btnCancel.Visible = !isReadOnlyRightsForProject; #region SET LINKS lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", project.CompanyId, (int)BookingTypes.Project, ProjectID); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectID); linkTaskManager.HRef = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectID); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectID), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectID), ProjectID); projectUpdatesLink.ProjectID = ProjectID; projectUpdatesLink.LoadData(); #endregion SET LINKS LoadBreadCrumbs(project); } ucProjectEvents.SetEventsGridLength(900);//to fix the events grid issue in chrome set the lengh of the grid manually. }
/// <summary> /// Gets the item brief task. /// </summary> /// <param name="itemBriefTaskId">The item brief task identifier.</param> /// <param name="originalLastUpdatedDate">The original last updated date.</param> /// <returns></returns> private ItemBriefTask GetItemBriefTask(int itemBriefTaskId, DateTime originalLastUpdatedDate) { ItemBriefTask itemBriefTask = this.GetBL <ItemBriefBL>().GetItemBriefTask(itemBriefTaskId, originalLastUpdatedDate); if (itemBriefTask == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ItemBriefTasks, ProjectId)); } return(itemBriefTask); }
/// <summary> /// Handles the Click event of the btnConfirmFreeInventory control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnConfirmFreeInventory_Click(object sender, EventArgs e) { popupFreeInventoryOnly.HidePopup(); if (!IsCompanyValidToSave()) { return; } CompanyPaymentPackage oldCompanyPaymentPackage = this.GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(CompanyId); bool isInventoryPackageOrDurationChanged = GetBL <FinanceBL>().HasInventryProjectOrDurationChanged(PricePlanDetails, oldCompanyPaymentPackage); //Handling concurrency (another admin changed the package concurrently) if (oldCompanyPaymentPackage != null && oldCompanyPaymentPackage.LastUpdateDate > OriginalLastUpdatedDate) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.CompanyPaymentPackage, CompanyId)); } else { if (CompanyId == 0) { //Add to the Context DataContext.Companies.AddObject(NewCompany); } this.GetBL <FinanceBL>().SaveCompanyPackage(UserID, oldCompanyPaymentPackage, PricePlanDetails, false); //First check whether the applied Discount is valid. Because it can be either deleted, some one else being used, etc.. if (PricePlanDetails.DiscountCode != null) { string errorMsg = string.Empty; bool isValid = GetBL <FinanceBL>().IsDiscountCodeValidToUse(PricePlanDetails.DiscountCode.Code, CompanyId, out errorMsg, PricePlanDetails.DiscountCode == null ? null : PricePlanDetails.DiscountCode); if (isValid) { SaveDiscountCode(); } } this.GetBL <CompanyBL>().SaveChanges(); var globalizationSection = WebConfigurationManager.GetSection("system.web/globalization") as GlobalizationSection; string cultureName = globalizationSection.Culture; string authText = string.Format("They have selected {0} Inventory level and {1} Project level.", Utils.GetSystemInventoryPackageDetailByPaymentPackageTypeId(PricePlanDetails.InventoryPaymentPackageTypeId).PackageDisplayName, Utils.GetSystemProjectPackageDetailByPaymentPackageTypeId(PricePlanDetails.ProjectPaymentPackageTypeId).PackageDisplayName); if (chkAcceptTermsFreeInventory.Visible) { this.GetBL <FinanceBL>().SendStageBitzAdminEmail(CompanyId == 0 ? NewCompany.CompanyId : CompanyId, UserID, PricePlanDetails, cultureName, string.Empty, authText, isInventoryPackageOrDurationChanged); } //Save the Company Profile image if (CompanyId == 0 && Media != null) { Media.RelatedId = NewCompany.CompanyId; DataContext.DocumentMedias.AddObject(Media); this.GetBL <CompanyBL>().SaveChanges(); } } btnChangesSaved.CommandArgument = "FreeInventory"; popupSaveChangesConfirm.ShowPopup(); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.Exception">project not found</exception> /// <exception cref="System.ApplicationException"> /// Permission denied for this project /// or /// Invalid request. /// </exception> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["projectid"] != null) { ProjectID = Convert.ToInt32(Request.QueryString["projectid"].ToString()); projectWarningPopup.ProjectId = ProjectID; StageBitz.Data.Project project = (from p in DataContext.Projects where p.ProjectId == ProjectID && p.IsActive == true select p).FirstOrDefault(); if (project == null) { throw new Exception("project not found"); } this.CompanyId = project.CompanyId; DisplayTitle = string.Format("{0}'s Updates Report", Support.TruncateString(project.ProjectName, 32)); if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project "); } warningDisplay.ProjectID = ProjectID; warningDisplay.LoadData(); LoadConfigurationSettings(); #region SET LINKS lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", project.CompanyId, (int)BookingTypes.Project, ProjectID); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectID); linkTaskManager.HRef = ResolveUrl(string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectID)); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectID), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectID), ProjectID); projectUpdatesLink.ProjectID = ProjectID; projectUpdatesLink.LoadData(false); #endregion SET LINKS LoadBreadCrumbs(project); } else //UNCOMMENT this { throw new ApplicationException("Invalid request."); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.Exception">project not found</exception> /// <exception cref="System.ApplicationException"> /// Permission denied for this project /// or /// Permission denied to this page /// </exception> protected void Page_Load(object sender, EventArgs e) { //IsLargeContentArea = true; if (!IsPostBack) { StageBitz.Data.Project project = (from p in DataContext.Projects where p.ProjectId == ProjectId && p.IsActive == true select p).FirstOrDefault(); if (project == null) { throw new Exception("project not found"); } if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "Permission denied for this project.")); } throw new ApplicationException("Permission denied for this project "); } if (Support.IsReadOnlyRightsForProject(ProjectId, UserID, false)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "Permission denied for this page.")); } throw new ApplicationException("Permission denied to this page "); } Data.Booking booking = this.GetBL <InventoryBL>().GetBooking(ProjectId, GlobalConstants.RelatedTables.Bookings.Project); editBookingDetails.ItemTypeId = ItemTypeId; editBookingDetails.IsToDateChange = IsToDateChange; editBookingDetails.BookingId = booking.BookingId; editBookingDetails.IsInventoryManager = false; editBookingDetails.CallBackURL = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); DisplayTitle = "Bookings"; LoadBreadCrumbs(project); lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", project.CompanyId, (int)BookingTypes.Project, ProjectId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); linkTaskManager.HRef = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); } }
/// <summary> /// Handles the Click event of the btnSavePersonalDetails control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnSavePersonalDetails_Click(object sender, EventArgs e) { if (!StopProcessing) { User user = DataContext.Users.Where(u => u.UserId == ViewUserId && u.LastUpdatedDate == OriginalLastUpdatedDate).FirstOrDefault(); if (user == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.UserDetails, ViewUserId)); } if (this.IsValid) { if (this.IsPageDirty) { user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); user.Position = txtPosition.Text.Trim(); user.Company = txtCompany.Text.Trim(); user.Email2 = txtEmail2.Text.Trim(); user.IsEmailVisible = chkEmailVisible.Checked; user.Phone1 = txtPhone1.Text.Trim(); user.Phone2 = txtPhone2.Text.Trim(); user.AddressLine1 = txtAddressLine1.Text.Trim(); user.AddressLine2 = txtAddressLine2.Text.Trim(); user.City = txtCity.Text.Trim(); user.State = txtState.Text.Trim(); user.PostCode = txtPostCode.Text.Trim(); user.CountryId = countryList.CountryID; DataContext.SaveChanges(); LoadBasicDetails(user); Support.SetUserSessionData(user); ((Content)Master).UpdateUserNameDisplay(); //Save skills userSkills.SaveChanges(); this.IsPageDirty = false; } ShowNotification("personalDetailsSavedNotice"); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.ApplicationException">Permission denied for this project.</exception> protected void Page_Load(object sender, EventArgs e) { this.ExportData1.PDFExportClick += new EventHandler(ExportData1_PDFExportClick); this.ExportData1.ExcelExportClick += new EventHandler(ExportData1_ExcelExportClick); taskList.SetTasksGridWidth(930); if (!IsPostBack) { StageBitz.Data.Project project = GetBL <Logic.Business.Project.ProjectBL>().GetProject(ProjectId); if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project."); } this.CompanyId = project.CompanyId; warningDisplay.ProjectID = ProjectId; warningDisplay.LoadData(); projectWarningPopup.ProjectId = ProjectId; bool isReadOnly = Support.IsReadOnlyRightsForProject(ProjectId); LoadList(); if (ProjectId > 0) { LoadBreadCrumbs(); //For observers, do not allow delete list if (isReadOnly) { btnDeleteList.Enabled = false; } } //Set links lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}&ItemTypeId={3}", project.CompanyId, (int)BookingTypes.Project, ProjectId, ItemTypeId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); hyperLinkTaskManager.NavigateUrl = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}&ItemTypeId={1}", ProjectId, ItemTypeId); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); } }
/// <summary> /// Gets the company payment package for updating. /// </summary> /// <returns></returns> private CompanyPaymentPackage GetCompanyPaymentPackageForUpdating() { if (CompanyId > 0 && OriginalLastUpdatedDate.HasValue) { var companyPaymentPackage = GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrialForConcurrency(CompanyId, OriginalLastUpdatedDate.Value); if (companyPaymentPackage == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.CompanyPaymentPackage, CompanyId)); } return(companyPaymentPackage); } else { return(null); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.Exception">project not found</exception> /// <exception cref="System.ApplicationException">Permission denied for this project </exception> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StageBitz.Data.Project project = (from p in DataContext.Projects where p.ProjectId == ProjectId && p.IsActive == true select p).FirstOrDefault(); if (project == null) { throw new Exception("project not found"); } if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project "); } bookingDetails.CanEditBookingDates = !GetBL <ProjectBL>().IsReadOnlyRightsForProject(ProjectId, UserID, false); //bookingDetails.RelatedId = ProjectId; //bookingDetails.RelatedTableName = "Project"; bookingDetails.BookingId = GetBL <InventoryBL>().GetBooking(ProjectId, "Project").BookingId; bookingDetails.DisplayMode = UserWeb.Controls.Inventory.BookingDetails.ViewMode.Project; bookingDetails.OnlyShowMyBookings = this.OnlyShowMyBookings; DisplayTitle = "Bookings"; LoadBreadCrumbs(project); lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", project.CompanyId, (int)BookingTypes.Project, ProjectId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); linkTaskManager.HRef = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.ApplicationException">Permission denied for this project.</exception> protected void Page_Load(object sender, EventArgs e) { this.ExportData1.PDFExportClick += new EventHandler(ExportData1_PDFExportClick); this.ExportData1.ExcelExportClick += new EventHandler(ExportData1_ExcelExportClick); projectItemTypes.ProjectID = ProjectId; if (!IsPostBack) { StageBitz.Data.Project project = this.GetBL <ProjectBL>().GetProject(ProjectId); if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project."); } this.CompanyId = project.CompanyId; projectWarningPopup.ProjectId = ProjectId; warningDisplay.ProjectID = ProjectId; warningDisplay.LoadData(); if (Support.IsReadOnlyRightsForProject(ProjectId) || projectItemTypes.SelectedItemTypeId == 0) { IsReadOnly = true; //Can not create lists, can not add tasks to lists, can view lists //Set visibility and enabling txtListName.Enabled = false; btnAddList.Enabled = false; gridviewTaskList.Enabled = false; } #region SET Links lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}&ItemTypeId={3}", project.CompanyId, (int)BookingTypes.Project, ProjectId, projectItemTypes.SelectedItemTypeId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); hyperLinkTaskManager.NavigateUrl = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); #endregion SET Links LoadData(); if (projectItemTypes.SelectedItemTypeId != 0) { string itemTypename = Utils.GetItemTypeById(projectItemTypes.SelectedItemTypeId).Name; litTitleAT.Text = string.Concat("All Active " + itemTypename + " Tasks"); litItemtype1.Text = litItemtype2.Text = itemTypename; DisplayTitle = "Task Manager - " + Utils.GetItemTypeById(projectItemTypes.SelectedItemTypeId).Name; } else { litTitleAT.Text = "All Active Tasks"; DisplayTitle = "Task Manager"; } } projectItemTypes.InformParentToReload += delegate() { //Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); ReloadByItemType(); }; }
protected void gvDiscountCodes_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (Page.IsValid) { ClearUI(); uplAddDisCode.Update(); //Get the GridEditableItem of the RadGrid GridEditableItem editedItem = e.Item as GridEditableItem; TextBox txtDiscountCode = (TextBox)editedItem.FindControl("txtDiscountCode"); RadNumericTextBox txtDuration = (RadNumericTextBox)editedItem.FindControl("txtDuration"); RadNumericTextBox txtInstanceCount = (RadNumericTextBox)editedItem.FindControl("txtInstanceCount"); RadNumericTextBox txtDiscountPercentage = (RadNumericTextBox)editedItem.FindControl("txtDiscountPercentage"); RadDatePicker dtExpireDate = (RadDatePicker)editedItem.FindControl("dtExpireDate"); int discountCodeID = (int)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["DiscountCode.DiscountCodeID"]; int discountCodeUsageCount = GetDiscountUsageCount(discountCodeID); DateTime originalLastUpdatedDate = (DateTime)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["DiscountCode.LastUpdatedDate"]; DiscountCode discountCode = (from dc in DataContext.DiscountCodes where dc.DiscountCodeID == discountCodeID select dc).FirstOrDefault(); if (dtExpireDate.SelectedDate.HasValue && dtExpireDate.SelectedDate.Value < Today) { Image imgExpireDate = (Image)editedItem.FindControl("imgExpireDate"); imgExpireDate.Visible = true; imgExpireDate.ToolTip = string.Format("Expiry date cannot be a past date."); e.Canceled = true; return; } if (discountCode == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ManageDiscounts, discountCodeID)); } if (discountCodeUsageCount > 0) { if (discountCodeUsageCount > txtInstanceCount.Value.Value) { Image imgInstanceCountError = (Image)editedItem.FindControl("imgInstanceCountError"); imgInstanceCountError.Visible = true; imgInstanceCountError.ToolTip = string.Format("Instance count cannot be reduced below the used count {0}.", discountCodeUsageCount); e.Canceled = true; return; } discountCode.InstanceCount = (int)txtInstanceCount.Value.Value; } else { if (!IsValidtoSave(txtDiscountCode.Text, discountCodeID, false)) { Image imgDiscountCodeError = (Image)editedItem.FindControl("imgDiscountCodeError"); imgDiscountCodeError.Visible = true; imgDiscountCodeError.ToolTip = "Please choose a different Discount Code."; e.Canceled = true; return; } discountCode.Code = txtDiscountCode.Text.Trim(); discountCode.Discount = (decimal)txtDiscountPercentage.Value.Value; discountCode.InstanceCount = (int)txtInstanceCount.Value.Value; discountCode.Duration = (int)txtDuration.Value.Value; discountCode.ExpireDate = dtExpireDate.SelectedDate.Value; } discountCode.LastUpdatedByUserId = UserID; discountCode.LastUpdatedDate = Now; DataContext.SaveChanges(); IsPageDirty = false;//Clear the page dirty gvDiscountCodes.EditIndexes.Clear(); gvDiscountCodes.MasterTableView.IsItemInserted = false; gvDiscountCodes.Rebind(); } }
/// <summary> /// Handles the UpdateCommand event of the gvItemList control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> protected void gvItemList_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (!StopProcessing) { if (Page.IsValid) { //Get the GridEditableItem of the RadGrid GridEditableItem editedItem = e.Item as GridEditableItem; int itemBriefId = (int)editedItem.GetDataKeyValue("ItemBrief.ItemBriefId");// (int)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ItemBrief.ItemBriefId"]; DateTime localLastUpdatedDate = (DateTime)editedItem.GetDataKeyValue("ItemBrief.LastUpdatedDate"); Data.ItemBrief itemBrief = GetBL <ItemBriefBL>().GetItemBrief(itemBriefId, localLastUpdatedDate); if (itemBrief == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ItemBriefList, ProjectId)); } TextBox tbItemBriefName = (TextBox)editedItem.FindControl("tbItemBriefName"); if (!IsValidtoSave(tbItemBriefName.Text, itemBriefId, false)) { Label lblErrorMsgForDuplicateItemBriefs = (Label)editedItem.FindControl("lblErrorMsgForDuplicateItemBriefs"); lblErrorMsgForDuplicateItemBriefs.Visible = true; lblErrorMsgForDuplicateItemBriefs.ToolTip = string.Format("'{0}' already exists in this Project.", tbItemBriefName.Text.Trim()); e.Canceled = true; return; } TextBox tbDescription = (TextBox)editedItem.FindControl("tbDescription"); TextBox tbCategory = (TextBox)editedItem.FindControl("tbCategory"); TextBox tbAct = (TextBox)editedItem.FindControl("tbAct"); TextBox tbScene = (TextBox)editedItem.FindControl("tbScene"); TextBox tbPage = (TextBox)editedItem.FindControl("tbPage"); TextBox tbCharacter = (TextBox)editedItem.FindControl("tbCharacter"); TextBox tbPreset = (TextBox)editedItem.FindControl("tbPreset"); TextBox tbRehearsal = (TextBox)editedItem.FindControl("tbRehearsal"); RadNumericTextBox tbItemQuantity = (RadNumericTextBox)editedItem.FindControl("tbItemQuantity"); if (itemBrief != null) { StageBitz.Data.ItemBrief tmpItemBrief = new Data.ItemBrief(); #region Assign input values to the temporary item brief object tmpItemBrief.Name = tbItemBriefName.Text.Trim(); if (tbItemQuantity.Value.HasValue) { tmpItemBrief.Quantity = (int)tbItemQuantity.Value; } else { tmpItemBrief.Quantity = null; } tmpItemBrief.Description = tbDescription.Text.Trim(); tmpItemBrief.Act = tbAct.Text.Trim(); tmpItemBrief.Scene = tbScene.Text.Trim(); tmpItemBrief.Page = tbPage.Text.Trim(); tmpItemBrief.Category = tbCategory.Text.Trim(); tmpItemBrief.Character = tbCharacter.Text.Trim(); tmpItemBrief.Preset = tbPreset.Text.Trim(); tmpItemBrief.RehearsalItem = tbRehearsal.Text.Trim(); //Added since the Grid does not contains these fields. tmpItemBrief.Budget = itemBrief.Budget; tmpItemBrief.DueDate = itemBrief.DueDate; #endregion Assign input values to the temporary item brief object //Compare and generate the edited field list. string editedFieldList = this.GetBL <ItemBriefBL>().GenerateEditedFieldListForItemBrief(itemBrief, tmpItemBrief); #region Generate 'Edit' Notification if (editedFieldList != string.Empty) { Notification nf = new Notification(); nf.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "ITEMBRIEF"); nf.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "EDIT"); nf.RelatedId = itemBrief.ItemBriefId; nf.ProjectId = ProjectId; nf.Message = string.Format("{0} edited the Item Brief - {1}.", Support.UserFullName, editedFieldList); nf.CreatedByUserId = nf.LastUpdatedByUserId = UserID; nf.CreatedDate = nf.LastUpdatedDate = Now; DataContext.Notifications.AddObject(nf); } #endregion Generate 'Edit' Notification #region Update the existing ItemBrief itemBrief.Name = tbItemBriefName.Text.Trim(); itemBrief.Description = tbDescription.Text.Trim(); itemBrief.Category = tbCategory.Text.Trim(); itemBrief.Act = tbAct.Text.Trim(); itemBrief.Scene = tbScene.Text.Trim(); itemBrief.Page = tbPage.Text.Trim(); itemBrief.Character = tbCharacter.Text.Trim(); itemBrief.Preset = tbPreset.Text.Trim(); itemBrief.RehearsalItem = tbRehearsal.Text.Trim(); if (tbItemQuantity.Value != null) { itemBrief.Quantity = (int)tbItemQuantity.Value; } else { itemBrief.Quantity = null; } itemBrief.LastUpdatedDate = Now; itemBrief.LastUpdatedByUserId = UserID; #endregion Update the existing ItemBrief GetBL <ItemBriefBL>().SaveChanges(); } gvItemList.EditIndexes.Clear(); gvItemList.MasterTableView.IsItemInserted = false; gvItemList.Rebind(); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.ApplicationException"> /// Item type not found /// or /// Project not found /// or /// Permission denied for this project /// </exception> /// <exception cref="System.Exception">Item Type not found</exception> protected void Page_Load(object sender, EventArgs e) { projectItemTypes.ProjectID = ProjectId; if (!IsPostBack) { LoadItemBriefSorting(); StageBitz.Data.Project project = GetBL <ProjectBL>().GetProject(ProjectId); #region concurrentScenarios projectWarningPopup.ProjectId = ProjectId; if (isItemRmoved()) { throw new ApplicationException("Item type not found"); } #endregion concurrentScenarios #region Check access security if (project == null) { throw new ApplicationException("Project not found"); } if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project "); } //Check the validity of the ItemType if (Utils.GetItemTypeById(ItemTypeId) == null) { throw new Exception("Item Type not found"); } #endregion Check access security this.CompanyId = project.CompanyId; warningDisplay.ProjectID = ProjectId; warningDisplay.LoadData(); //Set the page read only status if the user is project "Observer" IsReadOnly = Support.IsReadOnlyRightsForProject(ProjectId); pnlAddItem.Visible = !IsReadOnly; displaySettings.Module = ListViewDisplaySettings.ViewSettingModule.ProjectItemBriefList; displaySettings.LoadControl(); txtName.Focus(); #region SET LINKS lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}&ItemTypeId={3}", project.CompanyId, (int)BookingTypes.Project, ProjectId, ItemTypeId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); hyperLinkTaskManager.NavigateUrl = ResolveUrl(string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}&ItemTypeId={1}", ProjectId, ItemTypeId)); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}&ItemTypeId={1}", ProjectId, ItemTypeId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}&ItemTypeId={1}", ProjectId, ItemTypeId), ProjectId); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); #endregion SET LINKS var itemType = Utils.GetItemTypeById(ItemTypeId); string searchDefaultText = string.Concat("Find ", itemType.Name, " Briefs..."); wmeFindName.WatermarkText = searchDefaultText; DisplayTitle = string.Format("{0} Brief List", string.Concat(Utils.GetItemTypeById(ItemTypeId).Name)); LoadBreadCrumbs(project); ImportbulkItemsControl.ProjectID = ProjectId; ImportbulkItemsControl.ItemTypeId = ItemTypeId; ImportbulkItemsControl.IsReadOnly = IsReadOnly; //Security - Hide editing deleting for Observers if (IsReadOnly) { foreach (GridColumn col in gvItemList.MasterTableView.RenderColumns) { if (col.UniqueName == "EditCommandColumn") { col.Visible = false; } } } } projectItemTypes.InformParentToReload += delegate() { //Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); ReloadByItemType(); }; ImportbulkItemsControl.InformItemListToLoad += delegate()//Subscribe to the Informparent to get updated { displaySettings.LoadControl(); }; }
/// <summary> /// Handles the UpdateCommand event of the gvEvents control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> protected void gvEvents_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (!PageBase.StopProcessing) { if (Page.IsValid) { //Get the GridEditableItem of the RadGrid GridEditableItem editedItem = e.Item as GridEditableItem; TextBox tbEventName = (TextBox)editedItem.FindControl("tbEventName"); RadDatePicker tbEventDate = (RadDatePicker)editedItem.FindControl("tbEventDate"); if (ProjectID == 0) //Update viewState { ProjectEvent projectEvent = EventList[editedItem.ItemIndex]; projectEvent.EventName = tbEventName.Text.Trim(); projectEvent.LastUpdatedByUserId = UserID; projectEvent.LastUpdatedDate = Now; projectEvent.EventDate = tbEventDate.SelectedDate; } else { //Get the primary key value using the DataKeyValue. int projectEventId = (int)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ProjectEventId"]; DateTime originalLastUpdatedDate = (DateTime)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["LastUpdatedDate"]; ProjectEvent projectEvent = (from pe in DataContext.ProjectEvents where pe.ProjectEventId == projectEventId && pe.LastUpdatedDate == originalLastUpdatedDate select pe).FirstOrDefault(); if (projectEvent == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ProjectDetails, ProjectID)); } //Create Notification for edit project events #region Project Notification if (projectEvent.EventName != tbEventName.Text || projectEvent.EventDate != tbEventDate.SelectedDate) { #region Project Notification DataContext.Notifications.AddObject(CreateNotification(Support.GetCodeIdByCodeValue("OperationType", "EDIT"), string.Format("{0} edited a Project Schedule.", Support.UserFullName))); #endregion Project Notification } #endregion Project Notification projectEvent.EventName = tbEventName.Text; projectEvent.EventDate = tbEventDate.SelectedDate; projectEvent.LastUpdatedByUserId = UserID; projectEvent.LastUpdatedDate = Now; DataContext.SaveChanges(); } gvEvents.EditIndexes.Clear(); gvEvents.MasterTableView.IsItemInserted = false; gvEvents.Rebind(); } } }
/// <summary> /// Saves the schedule. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void SaveSchedule(object sender, EventArgs e) { if (!StopProcessing) { bool isReadOnlyRightsForProject = Support.IsReadOnlyRightsForProject(ProjectID); if (Page.IsValid && !isReadOnlyRightsForProject) { StageBitz.Data.Project project = (from p in DataContext.Projects where p.ProjectId == ProjectID && p.LastUpdatedDate == OriginalLastUpdatedDate select p).FirstOrDefault(); if (project == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ProjectDetails, ProjectID)); } #region Notification string message = string.Empty; //Build the message if ((ucProjectEvents.ProjectStartDate != project.StartDate && ucProjectEvents.ProjectStartDate != DateTime.MinValue || ucProjectEvents.ProjectStartDate == DateTime.MinValue && project.StartDate != null) && (ucProjectEvents.ProjectEndDate != project.EndDate && ucProjectEvents.ProjectEndDate != DateTime.MinValue || ucProjectEvents.ProjectEndDate == DateTime.MinValue && project.EndDate != null)) { message = string.Format("{0} changed Project Start date and End date.", Support.UserFullName); } else if (ucProjectEvents.ProjectStartDate != project.StartDate && ucProjectEvents.ProjectStartDate != DateTime.MinValue || ucProjectEvents.ProjectStartDate == DateTime.MinValue && project.StartDate != null) { message = string.Format("{0} changed the Project Start date.", Support.UserFullName); } else if (ucProjectEvents.ProjectEndDate != project.EndDate && ucProjectEvents.ProjectEndDate != DateTime.MinValue || ucProjectEvents.ProjectEndDate == DateTime.MinValue && project.EndDate != null) { message = string.Format("{0} changed the Project End date.", Support.UserFullName); } if (message != string.Empty) { Notification nf = new Notification(); nf.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "SCHEDULE"); nf.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "EDIT"); nf.RelatedId = ProjectID; nf.ProjectId = ProjectID; nf.Message = message; nf.CreatedByUserId = nf.LastUpdatedByUserId = UserID; nf.CreatedDate = nf.LastUpdatedDate = Now; DataContext.Notifications.AddObject(nf); } #endregion Notification if (ucProjectEvents.ProjectStartDate != DateTime.MinValue) { project.StartDate = ucProjectEvents.ProjectStartDate; } else { project.StartDate = null; } if (ucProjectEvents.ProjectEndDate != DateTime.MinValue) { project.EndDate = ucProjectEvents.ProjectEndDate; } else { project.EndDate = null; } project.LastUpdatedByUserId = UserID; project.LastUpdatedDate = Now; DataContext.SaveChanges(); } Response.Redirect(string.Format("~/Project/ProjectDashboard.aspx?projectid={0}", ProjectID)); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.ApplicationException"> /// Permission denied for Itemised Purchase Report. /// or /// You don't have permission to view data in this project. /// </exception> protected void Page_Load(object sender, EventArgs e) { this.ExportData1.PDFExportClick += new EventHandler(ExportData1_PDFExportClick); this.ExportData1.ExcelExportClick += new EventHandler(ExportData1_ExcelExportClick); projectItemTypes.ProjectID = ProjectId; projectWarningPopup.ProjectId = ProjectId; if (!IsPostBack) { var project = GetBL <ProjectBL>().GetProject(ProjectId); if (Support.CanAccessProject(project)) { if (!Support.CanSeeBudgetSummary(UserID, ProjectId)) { throw new ApplicationException("Permission denied for Itemised Purchase Report."); } this.CompanyId = project.CompanyId; warningDisplay.ProjectID = ProjectId; warningDisplay.LoadData(); CultureName = Support.GetCultureName(project.Country.CountryCode); //Set links lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}&ItemTypeId={3}", project.CompanyId, (int)BookingTypes.Project, ProjectId, projectItemTypes.SelectedItemTypeId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); hyperLinkTaskManager.NavigateUrl = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); reportList.ApplyReportLinkStyle("ItemisedPurchaseReport"); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); LoadBreadCrumbs(); LoadData(); if (projectItemTypes.SelectedItemTypeId != 0) { DisplayTitle = "Itemised Purchase Report - " + Utils.GetItemTypeById(projectItemTypes.SelectedItemTypeId).Name; } else { DisplayTitle = "Itemised Purchase Report"; } } else { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("You don't have permission to view data in this project."); } } projectItemTypes.InformParentToReload += delegate() { //Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); ReloadByItemType(); }; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.Exception">User does not have permission to access the project team</exception> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StageBitz.Data.Project project = DataContext.Projects.Where(p => p.ProjectId == ProjectId && p.IsActive == true).SingleOrDefault(); if (!Support.CanAccessProject(project)) { if (IsProjectClosed) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new Exception("User does not have permission to access the project team"); } this.CompanyId = project.CompanyId; projectWarningPopup.ProjectId = ProjectId; warningDisplay.ProjectID = ProjectId; warningDisplay.LoadData(); sbPackageLimitsValidation.CompanyId = CompanyId; sbPackageLimitsValidation.DisplayMode = UserWeb.Controls.Company.PackageLimitsValidation.ViewMode.UserLimit; sbPackageLimitsValidation.LoadData(); LoadBreadCrumbs(); SetReadOnlyMode(project); if (!IsReadOnly) { searchUsers.DisplayMode = SearchUsers.ViewMode.ProjectTeam; searchUsers.ProjectId = ProjectId; searchUsers.LoadControl(); } else { searchUsers.Visible = false; } LoadProjectTeam(); #region SET LINKS lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", project.CompanyId, (int)BookingTypes.Project, ProjectId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); linkTaskManager.HRef = ResolveUrl(string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId)); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); #endregion SET LINKS #region SetValidationGroup string validationGroup = string.Concat(ucUserInvitationPopup.ClientID, "ValidationGroup"); btnApplyUserPermission.ValidationGroup = validationGroup; ucUserInvitationPopup.InitializeValidationGroup(validationGroup); #endregion SetValidationGroup } }
/// <summary> /// Handles the Click event of the btnConfirmHundredPercentDiscount control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnConfirmHundredPercentDiscount_Click(object sender, EventArgs e) { if (!IsCompanyValidToSave()) { popupHundredPercentDiscount.HidePopup(); return; } this.DisplayMode = ViewMode.HundredPercentDiscount; //concurrent discount chaged popups come on top of payment details popup. view mode set accordingly. if (HandleConcurrentDiscountChanges()) { this.PricePlanDetails.DiscountCodeUsage = this.DiscountCodeUsage; this.PricePlanDetails.DiscountCode = (this.DiscountCodeUsage != null ? this.DiscountCodeUsage.DiscountCode : null); } else { CompanyPaymentPackage oldCompanyPaymentPackage = this.GetBL <FinanceBL>().GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(CompanyId); bool isInventoryPackageOrDurationChanged = GetBL <FinanceBL>().HasInventryProjectOrDurationChanged(PricePlanDetails, oldCompanyPaymentPackage); //Handling concurrency (another admin changed the package concurrently) if (oldCompanyPaymentPackage != null && oldCompanyPaymentPackage.LastUpdateDate > OriginalLastUpdatedDate) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.CompanyPaymentPackage, CompanyId)); } else { if (CompanyId == 0) { DataContext.Companies.AddObject(NewCompany); } this.GetBL <FinanceBL>().SaveCompanyPackage(UserID, oldCompanyPaymentPackage, PricePlanDetails, false); //First check whether the applied Discount is valid. Because it can be either deleted, some one else being used, etc.. string errorMsg = string.Empty; bool isValid = GetBL <FinanceBL>().IsDiscountCodeValidToUse(PricePlanDetails.DiscountCodeUsage.DiscountCode.Code, CompanyId, out errorMsg, PricePlanDetails.DiscountCodeUsage.DiscountCode); if (isValid) { SaveDiscountCode(); } this.GetBL <CompanyBL>().SaveChanges(); var globalizationSection = WebConfigurationManager.GetSection("system.web/globalization") as GlobalizationSection; string cultureName = globalizationSection.Culture; string authText = string.Concat(String.Format("{0:P}", PricePlanDetails.DiscountCodeUsage.DiscountCode.Discount / 100), " discount code is applied."); if (chkAcceptTermsDiscount.Visible) { this.GetBL <FinanceBL>().SendStageBitzAdminEmail(CompanyId == 0 ? NewCompany.CompanyId : CompanyId, UserID, PricePlanDetails, cultureName, string.Empty, authText, isInventoryPackageOrDurationChanged); } //Save the Company Profile image. First you need to save the Company to get the CompanyId. if (CompanyId == 0 && Media != null) { Media.RelatedId = NewCompany.CompanyId; DataContext.DocumentMedias.AddObject(Media); this.GetBL <CompanyBL>().SaveChanges(); } } popupHundredPercentDiscount.HidePopup(); btnChangesSaved.CommandArgument = "HundredDiscount"; popupSaveChangesConfirm.ShowPopup(); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.ApplicationException"> /// Permission denied for this project. /// or /// Permission denied for Budget Summary Page. /// </exception> protected void Page_Load(object sender, EventArgs e) { this.ExportData1.PDFExportClick += new EventHandler(ExportData1_PDFExportClick); this.ExportData1.ExcelExportClick += new EventHandler(ExportData1_ExcelExportClick); projectItemTypes.ProjectID = ProjectId; projectItemTypes.ShouldShowAllItemTypeText = true; if (!IsPostBack) { StageBitz.Data.Project project = GetBL <Logic.Business.Project.ProjectBL>().GetProject(ProjectId); this.CompanyId = project.CompanyId; if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project."); } if (!Support.CanSeeBudgetSummary(UserID, ProjectId)) { throw new ApplicationException("Permission denied for Budget Summary Page."); } if (project != null) { CultureName = Support.GetCultureName(project.Country.CountryCode); } warningDisplay.ProjectID = ProjectId; warningDisplay.LoadData(); //Set links lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}&ItemTypeId={3}", project.CompanyId, (int)BookingTypes.Project, ProjectId, projectItemTypes.SelectedItemTypeId); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectId); hyperLinkTaskManager.NavigateUrl = string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectId); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectId), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectId), ProjectId); reportList.ApplyReportLinkStyle("BudgetSummaryReport"); projectUpdatesLink.ProjectID = ProjectId; projectUpdatesLink.LoadData(); LoadData(); projectWarningPopup.ProjectId = ProjectId; budgetList.ProjectID = ProjectId; budgetList.ItemTypeID = projectItemTypes.SelectedItemTypeId; budgetList.BudgetListViewMode = UserWeb.Controls.ItemBrief.BudgetList.ViewMode.BudgetSummary; LoadBreadCrumbs(); if (projectItemTypes.SelectedItemTypeId > 0) { DisplayTitle = "Budget Summary Report - " + Utils.GetItemTypeById(projectItemTypes.SelectedItemTypeId).Name; } else { DisplayTitle = "Budget Summary Report"; } } projectItemTypes.InformParentToReload += delegate() { //Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri); ReloadByItemType(); }; bool IsItemTypeColVisible = true; foreach (GridColumn col in gvItems.MasterTableView.RenderColumns) { if (col.UniqueName == "ItemType" && projectItemTypes.SelectedItemTypeId != -1) { col.Visible = false; IsItemTypeColVisible = false; } else if (IsItemTypeColVisible) { switch (col.UniqueName) { case "Budget": { col.HeaderStyle.Width = 110; break; } case "Expended": { col.HeaderStyle.Width = 110; break; } case "Remaining": { col.HeaderStyle.Width = 110; break; } case "Balance": { col.HeaderStyle.Width = 110; break; } } } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="System.Exception">project not found</exception> /// <exception cref="System.ApplicationException">Permission denied for this project.</exception> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["projectid"] != null) { ProjectID = Convert.ToInt32(Request.QueryString["projectid"].ToString()); ucLocation.ProjectID = ProjectID; attachments.RelatedId = ProjectID; attachments.ProjectId = ProjectID; attachments.Mode = ItemAttachments.DisplayMode.Project; attachments.IsReadOnly = Support.IsReadOnlyRightsForProject(ProjectID); } string tabId = Request.QueryString["tabId"]; if (tabId != null) { int tabIndex = Convert.ToInt16(tabId); projectDetailsTabs.SelectedIndex = tabIndex; projectDetailsPages.SelectedIndex = tabIndex; } projectWarningPopup.ProjectId = ProjectID; var project = GetBL <ProjectBL>().GetProject(ProjectID); if (project == null) { throw new Exception("project not found"); } CompanyID = project.CompanyId; ProjectName = project.ProjectName; DisplayTitle = string.Format("{0}'s Details", Support.TruncateString(project.ProjectName, 32)); txtName.Text = project.ProjectName; if (!Support.CanAccessProject(project)) { if (GetBL <ProjectBL>().IsProjectClosed(project.ProjectId)) { StageBitzException.ThrowException(new StageBitzException(ExceptionOrigin.ProjectClose, project.ProjectId, "This Project Is Closed.")); } throw new ApplicationException("Permission denied for this project."); } warningDisplay.ProjectID = ProjectID; warningDisplay.LoadData(); bool isReadOnlyRightsForProject = Support.IsReadOnlyRightsForProject(ProjectID); //Set last updated date for concurrency handling OriginalLastUpdatedDate = project.LastUpdatedDate.Value; btnCancel.PostBackUrl = String.Format("~/Project/ProjectDashboard.aspx?projectid={0}&companyid={1}", ProjectID, CompanyID); btnCancel.Visible = !isReadOnlyRightsForProject; txtName.ReadOnly = isReadOnlyRightsForProject; #region SET LINKS lnkCompanyInventory.HRef = string.Format("~/Inventory/CompanyInventory.aspx?companyid={0}&relatedtable={1}&relatedid={2}", CompanyID, (int)BookingTypes.Project, ProjectID); lnkBookings.HRef = string.Format("~/Project/ProjectBookingDetails.aspx?projectid={0}", ProjectID); linkTaskManager.HRef = ResolveUrl(string.Format("~/ItemBrief/TaskManager.aspx?projectid={0}", ProjectID)); reportList.ShowReportLinks(string.Format("~/ItemBrief/ItemisedPurchaseReport.aspx?projectid={0}", ProjectID), string.Format("~/ItemBrief/BudgetSummaryReport.aspx?projectid={0}", ProjectID), ProjectID); projectUpdatesLink.ProjectID = ProjectID; projectUpdatesLink.LoadData(); #endregion SET LINKS LoadBreadCrumbs(project); LoadProjectWarpupTab(); } ucLocation.SetLocationsGridLength(880);//to fix the grid issue in chrome set the lengh of the grid manually. ucLocation.UpdateLocationTabCount += delegate(int count) { UpdateLocationsTabCount(count); }; attachments.UpdateAttachmentsCount += delegate(int count) { UpdateAttachmentsTabCount(count); }; }
/// <summary> /// Saves the project details. /// </summary> private void SaveProjectDetails() { bool isReadOnlyRightsForProject = Support.IsReadOnlyRightsForProject(ProjectID); if (txtName.Text.Trim() != string.Empty && ProjectName != txtName.Text.Trim() && !isReadOnlyRightsForProject) { StageBitz.Data.Project project = GetBL <ProjectBL>().GetProjectByLastUpdatedDateTime(ProjectID, OriginalLastUpdatedDate); if (project == null) { StageBitzException.ThrowException(new ConcurrencyException(ExceptionOrigin.ProjectDetails, ProjectID)); } ////Check whether the same project name exist in the company. if (!IsValidToSave()) { errormsg.InnerText = "Project Name cannot be duplicated within the company."; return; } bool shouldChangeCreatedForTag = false; string oldProjectName = project.ProjectName; string newProjectName = txtName.Text.Trim(); // Create notifications, if the project name is being changed. // Change Item's CreatedFor field.(if item is created from this project) if (project.ProjectName != newProjectName) { Notification nf = new Notification(); nf.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "PROJECT"); nf.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "EDIT"); nf.RelatedId = project.ProjectId; nf.ProjectId = project.ProjectId; nf.Message = string.Format("{0} edited Project Name.", Support.UserFullName); nf.CreatedByUserId = nf.LastUpdatedByUserId = UserID; nf.CreatedDate = nf.LastUpdatedDate = Now; GetBL <NotificationBL>().AddNotification(nf); #region Initialize Update CreatedFor field shouldChangeCreatedForTag = true; #endregion Initialize Update CreatedFor field } project.ProjectName = newProjectName; project.LastUpdatedByUserId = UserID; project.LastUpdatedDate = Now; GetBL <ProjectBL>().SaveChanges(); #region Update CreatedFor field if (shouldChangeCreatedForTag) { DataContext.UpdateCreatedForField(project.ProjectId, newProjectName, oldProjectName); } #endregion Update CreatedFor field } }