/// <summary> /// Handles the ItemDataBound event of the rgvItemisedPurchase control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param> protected void rgvItemisedPurchase_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item.ItemType == GridItemType.EditItem || e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; ItemBriefTask itemBriefTask = ((dynamic)(dataItem.DataItem)).ItemBriefTask; HyperLink hyperLinkItem = (HyperLink)dataItem.FindControl("hyperLinkItem"); if (hyperLinkItem != null) { hyperLinkItem.NavigateUrl = ResolveUrl(string.Format("~/ItemBrief/ItemBriefDetails.aspx?ItemBriefId={0}", itemBriefTask.ItemBriefId)); hyperLinkItem.Text = Support.TruncateString(itemBriefTask.ItemBrief.Name, 20); if (itemBriefTask.ItemBrief.Name.Length > 20) { hyperLinkItem.ToolTip = itemBriefTask.ItemBrief.Name; } } //Description dataItem["Description"].Text = Support.TruncateString(itemBriefTask.Description, 30); if (itemBriefTask.Description != null && itemBriefTask.Description.Length > 30) { dataItem["Description"].ToolTip = itemBriefTask.Description; } //Vendor dataItem["Vendor"].Text = Support.TruncateString(itemBriefTask.Vendor, 15); if (itemBriefTask.Vendor != null && itemBriefTask.Vendor.Length > 15) { dataItem["Vendor"].ToolTip = itemBriefTask.Vendor; } } }
/// <summary> /// Changes the task status. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void ChangeTaskStatus(object sender, EventArgs e) { if (!PageBase.StopProcessing) { CheckBox checkBoxStatus = sender as CheckBox; GridDataItem row = checkBoxStatus.NamingContainer as GridDataItem; int itemBriefTaskId = (int)row.GetDataKeyValue("ItemBriefTask.ItemBriefTaskId"); DateTime originalLastUpdatedDate = (DateTime)row.GetDataKeyValue("ItemBriefTask.LastUpdatedDate"); LastUpdateDateForUpdateTask = originalLastUpdatedDate; ItemBriefTask itemBriefTask = GetItemBriefTask(itemBriefTaskId, originalLastUpdatedDate); if (checkBoxStatus.Checked) { if (itemBriefTask != null) { txtVendor.Text = itemBriefTask.Vendor; txtNetCost.Value = (double)itemBriefTask.NetCost; txtTax.Value = (double)itemBriefTask.Tax; txtTotalCost.Value = (double)itemBriefTask.TotalCost; checkBoxStatus.Checked = false; btnSave.CommandArgument = itemBriefTaskId.ToString(); } popupEditTask.ShowPopup(); } } }
/// <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 ItemDeleted event of the gvTasks control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridCommandEventArgs"/> instance containing the event data.</param> protected void gvTasks_ItemDeleted(object sender, GridCommandEventArgs e) { if (!PageBase.StopProcessing) { //Get the GridDataItem of the RadGrid GridDataItem item = (GridDataItem)e.Item; //Get the primary key value using the DataKeyValue. int itemBriefTaskId = (int)item.OwnerTableView.DataKeyValues[item.ItemIndex]["ItemBriefTask.ItemBriefTaskId"]; switch (DisplayMode) { case ViewMode.ItemBriefTaskListView: ItemBriefTask itemBriefTask = this.GetBL <ItemBriefBL>().GetItemBriefTask(itemBriefTaskId); if (itemBriefTask != null) { this.GetBL <ItemBriefBL>().DeleteItemBriefTask(itemBriefTask); #region Generate Task Notification Notification nf = new Notification(); nf.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "TASK"); nf.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "DELETE"); nf.RelatedId = itemBriefTask.ItemBriefId; nf.ProjectId = ProjectId; nf.Message = string.Format("{0} removed the task - '{1}'.", Support.UserFullName, itemBriefTask.Description); nf.CreatedByUserId = nf.LastUpdatedByUserId = UserID; nf.CreatedDate = nf.LastUpdatedDate = Now; this.GetBL <NotificationBL>().AddNotification(nf); #endregion Generate Task Notification if (InformItemBriefDetailToShowBudget != null) { InformItemBriefDetailToShowBudget(); } } break; case ViewMode.TaskListView: this.GetBL <ProjectBL>().RemoveTaskFromList(itemBriefTaskId, TaskListId); break; default: break; } } }
/// <summary> /// Saves the popup. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void SavePopup(object sender, EventArgs e) { if (!PageBase.StopProcessing) { int itemBriefTaskId = int.Parse(btnSave.CommandArgument); ItemBriefTask itemBriefTask = GetItemBriefTask(itemBriefTaskId, LastUpdateDateForUpdateTask); if (itemBriefTask != null) { itemBriefTask.Vendor = txtVendor.Text.Trim(); itemBriefTask.NetCost = (txtNetCost.Value != null) ? (decimal)txtNetCost.Value : 0; itemBriefTask.Tax = (txtTax.Value != null) ? (decimal)txtTax.Value : 0; itemBriefTask.TotalCost = (txtTotalCost.Value != null) ? (decimal)txtTotalCost.Value : 0; itemBriefTask.ItemBriefTaskStatusCodeId = codeComplete.CodeId; itemBriefTask.LastUpdatedByUserId = UserID; itemBriefTask.LastUpdatedDate = LastUpdateDateForUpdateTask = Now; itemBriefTask.CompletedDate = Now; #region Generate Task Notification Notification nf = new Notification(); nf.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "TASK"); nf.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "EDIT"); nf.RelatedId = itemBriefTask.ItemBriefId; nf.ProjectId = ProjectId; nf.Message = string.Format("{0} completed the task '{1}'.", Support.UserFullName, itemBriefTask.Description); nf.CreatedByUserId = nf.LastUpdatedByUserId = UserID; nf.CreatedDate = nf.LastUpdatedDate = Now; this.GetBL <NotificationBL>().AddNotification(nf); #endregion Generate Task Notification LoadTasks(); gvTasks.DataBind(); if (InformItemBriefDetailToShowBudget != null) { InformItemBriefDetailToShowBudget(); } } popupEditTask.HidePopup(); } }
/// <summary> /// Handles the ItemDataBound event of the gvTasks control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridItemEventArgs"/> instance containing the event data.</param> protected void gvTasks_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item.ItemType == GridItemType.EditItem || e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; ItemBriefTask itemBriefTask = ((dynamic)(dataItem.DataItem)).ItemBriefTask; CheckBox chkStatus = (CheckBox)dataItem.FindControl("chkStatus"); HyperLink hyperLinkItem = (HyperLink)dataItem.FindControl("hyperLinkItem"); if (hyperLinkItem != null) { hyperLinkItem.NavigateUrl = ResolveUrl(string.Format("~/ItemBrief/ItemBriefDetails.aspx?ItemBriefId={0}", itemBriefTask.ItemBriefId)); hyperLinkItem.Text = Support.TruncateString(itemBriefTask.ItemBrief.Name, 15); } if (IsReadOnlyRightsForProject) { chkStatus.Enabled = false; } if (chkStatus != null) { if (itemBriefTask.ItemBriefTaskStatusCodeId == codeComplete.CodeId) { chkStatus.Checked = true; chkStatus.Enabled = false; } chkStatus.ToolTip = SetTooltipForStatus(chkStatus.Checked); } if (e.Item.ItemType == GridItemType.EditItem) { TextBox txtDescription = (TextBox)dataItem.FindControl("tbDescription"); TextBox txtVendor = (TextBox)dataItem.FindControl("tbVendor"); RadNumericTextBox tbNetCost = (RadNumericTextBox)dataItem.FindControl("tbNetCost"); RadNumericTextBox tbTax = (RadNumericTextBox)dataItem.FindControl("tbTax"); RadNumericTextBox tbTotal = (RadNumericTextBox)dataItem.FindControl("tbTotal"); RadNumericTextBox tbEstimatedCost = (RadNumericTextBox)dataItem.FindControl("tbEstimatedCost"); tbNetCost.Culture = tbTax.Culture = tbTotal.Culture = tbEstimatedCost.Culture = new System.Globalization.CultureInfo(CultureName); txtDescription.Text = itemBriefTask.Description; txtVendor.Text = itemBriefTask.Vendor; if (chkStatus != null) { chkStatus.Enabled = false; if (itemBriefTask.ItemBriefTaskStatusCodeId == codeInprogress.CodeId) { tbNetCost.Enabled = false; tbTax.Enabled = false; tbTotal.Enabled = false; } } } else if (e.Item is GridDataItem) { HtmlImage imgNoEstimatedCost = (HtmlImage)dataItem.FindControl("imgNoEstimatedCost"); imgNoEstimatedCost.Visible = (itemBriefTask.EstimatedCost == null && itemBriefTask.ItemBriefTaskStatusCodeId == Utils.GetCodeByValue("ItemBriefTaskStatusCode", "INPROGRESS").CodeId); //Description dataItem["Description"].Text = Support.TruncateString(itemBriefTask.Description, 20); if (itemBriefTask.Description != null && itemBriefTask.Description.Length > 20) { dataItem["Description"].ToolTip = itemBriefTask.Description; } //Vendor dataItem["Vendor"].Text = Support.TruncateString(itemBriefTask.Vendor, 10); if (itemBriefTask.Vendor != null && itemBriefTask.Vendor.Length > 10) { dataItem["Vendor"].ToolTip = itemBriefTask.Vendor; } } ImageButton DeleteBtn = (ImageButton)dataItem["DeleteColumn"].Controls[0]; if (DisplayMode == ViewMode.TaskListView) { DeleteBtn.ToolTip = "Remove task from task list"; } else { DeleteBtn.ToolTip = "Remove task"; } } }
/// <summary> /// Adds the task. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void AddTask(object sender, EventArgs e) { if (Page.IsValid && !PageBase.StopProcessing) { #region Create new task object ItemBriefTask itemBriefTask = new ItemBriefTask(); itemBriefTask.Description = txtDescription.Text.Trim(); if (txtEstimatedCost.Value.HasValue) { itemBriefTask.EstimatedCost = (decimal)txtEstimatedCost.Value; } else { itemBriefTask.EstimatedCost = null; } itemBriefTask.Tax = 0; itemBriefTask.NetCost = 0; itemBriefTask.TotalCost = 0; itemBriefTask.ItemBriefId = ItemBriefID; itemBriefTask.ItemBriefTaskStatusCodeId = codeInprogress.CodeId; itemBriefTask.CreatedByUserId = UserID; itemBriefTask.CreatedDate = Now; itemBriefTask.LastUpdatedByUserId = UserID; itemBriefTask.LastUpdatedDate = Now; DataContext.ItemBriefTasks.AddObject(itemBriefTask); #endregion Create new task object #region Generate Task Add Notification Notification nfTask = new Notification(); nfTask.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "TASK"); nfTask.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "ADD"); nfTask.RelatedId = itemBriefTask.ItemBriefId; nfTask.ProjectId = ProjectId; nfTask.Message = string.Format("{0} added a task - '{1}'.", Support.UserFullName, itemBriefTask.Description); nfTask.CreatedByUserId = nfTask.LastUpdatedByUserId = UserID; nfTask.CreatedDate = nfTask.LastUpdatedDate = Now; DataContext.Notifications.AddObject(nfTask); #endregion Generate Task Add Notification #region Update Item Brief status StageBitz.Data.ItemBrief itemBrief = GetItemBrief(ItemBriefID); //Mark the item brief as 'In Progress' if it is not in progress. int ibNotStartedCodeId = Support.GetCodeIdByCodeValue("ItemBriefStatusCode", "NOTSTARTED"); int ibInProgressCodeId = Support.GetCodeIdByCodeValue("ItemBriefStatusCode", "INPROGRESS"); if (!GetBL <ItemBriefBL>().IsItemBriefComplete(itemBrief)) { if (itemBrief.ItemBriefStatusCodeId != ibInProgressCodeId) { string oldStatus = (itemBrief.ItemBriefStatusCodeId == ibNotStartedCodeId) ? "Not Started" : "Completed"; itemBrief.ItemBriefStatusCodeId = ibInProgressCodeId; itemBrief.LastUpdatedByUserId = UserID; //itemBrief.LastUpdatedDate = Now; DataContext.SaveChanges(); #region Generate Item Brief Notification Notification nfItemBrief = new Notification(); nfItemBrief.ModuleTypeCodeId = Support.GetCodeIdByCodeValue("ModuleType", "ITEMBRIEF"); nfItemBrief.OperationTypeCodeId = Support.GetCodeIdByCodeValue("OperationType", "EDIT"); nfItemBrief.RelatedId = itemBrief.ItemBriefId; nfItemBrief.ProjectId = ProjectId; nfItemBrief.Message = string.Format("{0} changed the Item Brief status from '{1}' to 'In Progress'.", Support.UserFullName, oldStatus); nfItemBrief.CreatedByUserId = nfItemBrief.LastUpdatedByUserId = UserID; nfItemBrief.CreatedDate = nfItemBrief.LastUpdatedDate = Now; DataContext.Notifications.AddObject(nfItemBrief); #endregion Generate Item Brief Notification if (InformItemBriefDetail != null) { //Inform parent to show the description as inprogress. InformItemBriefDetail(ibInProgressCodeId, false); } } } #endregion Update Item Brief status DataContext.SaveChanges(); LoadTasks(); gvTasks.DataBind(); txtDescription.Text = string.Empty; txtEstimatedCost.Text = string.Empty; txtDescription.Focus(); if (InformItemBriefDetailToShowBudget != null) { InformItemBriefDetailToShowBudget(); } } }
/// <summary> /// Handles the UpdateCommand event of the gvTasks 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 gvTasks_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { if (Page.IsValid && !PageBase.StopProcessing) { //Get the GridEditableItem of the RadGrid GridEditableItem editedItem = e.Item as GridEditableItem; //Get the primary key value using the DataKeyValue. int itemBriefTaskId = (int)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ItemBriefTask.ItemBriefTaskId"]; DateTime originalLastUpdatedDate = (DateTime)editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ItemBriefTask.LastUpdatedDate"]; //Access the textbox from the edit form template and store the values in string variables. TextBox description = (TextBox)editedItem.FindControl("tbDescription"); TextBox vendor = (TextBox)editedItem.FindControl("tbVendor"); RadNumericTextBox estimatedCost = (RadNumericTextBox)editedItem.FindControl("tbEstimatedCost"); RadNumericTextBox netCost = (RadNumericTextBox)editedItem.FindControl("tbNetCost"); RadNumericTextBox tax = (RadNumericTextBox)editedItem.FindControl("tbTax"); RadNumericTextBox total = (RadNumericTextBox)editedItem.FindControl("tbTotal"); ItemBriefTask itemBriefTask = GetItemBriefTask(itemBriefTaskId, originalLastUpdatedDate); itemBriefTask.Description = description.Text.Trim(); itemBriefTask.Vendor = vendor.Text.Trim(); if (estimatedCost.Value != null) { itemBriefTask.EstimatedCost = (decimal)estimatedCost.Value; } else { itemBriefTask.EstimatedCost = null; } if (netCost.Value != null) { itemBriefTask.NetCost = (decimal)netCost.Value; } else { itemBriefTask.NetCost = 0; } if (tax.Value != null) { itemBriefTask.Tax = (decimal)tax.Value; } else { itemBriefTask.Tax = 0; } if (total.Value != null) { itemBriefTask.TotalCost = (decimal)total.Value; } else { itemBriefTask.TotalCost = 0; } itemBriefTask.LastUpdatedDate = Now; itemBriefTask.LastUpdatedByUserId = UserID; DataContext.SaveChanges(); up.Update(); gvTasks.EditIndexes.Clear(); gvTasks.MasterTableView.IsItemInserted = false; gvTasks.Rebind(); if (InformItemBriefDetailToShowBudget != null) { InformItemBriefDetailToShowBudget(); } } }