/// <summary> /// Handles the OnClick event of the cmdCompleteStep control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void cmdCompleteStep_OnClick(object sender, EventArgs e) { //================================================================ // Templates are Not Completed //================================================================ int rowIndex = Convert.ToInt32(rowContext.Value); string id = grdStages.DataKeys[rowIndex].Value.ToString(); string[] result = id.Split(':'); if (DialogService != null) { if (result[1] == "S") { IOppFulFilStage stage = EntityFactory.GetById <IOppFulFilStage>(result[0]); foreach (IOppFulFilTask tmpTSK in stage.OppFulFilTasks) { if (tmpTSK.Completed == "T") { //if (tmpTSK.Completed == true) { // Do Nothing as it is allready completed } else { tmpTSK.CompleteTask(); } } // Run Complete Stage Business Rule } else if (result[1] == "T") { IOppFulFilTask Task = EntityFactory.GetById <IOppFulFilTask>(result[0]); Task.CompleteTask(); } } IPanelRefreshService refresher = PageWorkItem.Services.Get <IPanelRefreshService>(); refresher.RefreshAll(); LoadView(); }
/// <summary> /// Handles the RowCommand event of the grdStages control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void grdStages_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("AddTask")) { int rowIndex = Convert.ToInt32(e.CommandArgument); string id = grdStages.DataKeys[rowIndex].Value.ToString(); string[] result = id.Split(':'); if (DialogService != null) { if (result[1] == "S") { //DialogService.SetSpecs(200, 200, 550, 700, "AddEditTask", "Add Task", true); //DialogService.EntityType = typeof(ICampaignTask); //DialogService.DialogParameters.Add("StageId", result[0]); //DialogService.DialogParameters.Add("Mode", "Add"); //DialogService.ShowDialog(); // InsertChildDialogActionItem DialogService.SetSpecs(400, 700, "AddEditTask", "Add Task"); DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOppFulFilTask); //DialogService.SetChildIsertInfo( // typeof(Sage.Entity.Interfaces.IFulFilTemplateTask), // typeof(Sage.Entity.Interfaces.IFulFilTemplateStage), // typeof(Sage.Entity.Interfaces.IFulFilTemplateStage).GetProperty("FulFilmentTemplateStage"), // typeof(Sage.Entity.Interfaces.IFulFilTemplateStage).GetProperty("FulFilTemplateTasks")); DialogService.DialogParameters.Add("StageId", result[0]); DialogService.ShowDialog(); } } } if (e.CommandName.Equals("Edit")) { int rowIndex = Convert.ToInt32(e.CommandArgument); string id = grdStages.DataKeys[rowIndex].Value.ToString(); string[] result = id.Split(':'); if (DialogService != null) { if (result[1] == "S") { // QFDataGrid DialogService.SetSpecs(400, 600, "AddEditStage", "Edit Stage"); DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOppFulFilStage); DialogService.EntityID = result[0]; DialogService.ShowDialog(); } else if (result[1] == "T") { // QFDataGrid DialogService.SetSpecs(400, 700, "AddEditTask", "Edit Task"); DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOppFulFilTask); DialogService.EntityID = result[0]; DialogService.ShowDialog(); } } } if (e.CommandName.Equals("Complete")) { //================================================================ // Templates are Not Completed //================================================================ int rowIndex = Convert.ToInt32(e.CommandArgument); string id = grdStages.DataKeys[rowIndex].Value.ToString(); string[] result = id.Split(':'); if (DialogService != null) { if (result[1] == "S") { IOppFulFilStage stage = EntityFactory.GetById <IOppFulFilStage>(result[0]); foreach (IOppFulFilTask tmpTSK in stage.OppFulFilTasks) { if (tmpTSK.Completed == "T") //if (tmpTSK.Completed == true) { // Do Nothing as it is allready completed } else { //Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); //Sage.Entity.Interfaces.IUser user = usersvc.GetUser(); //tmpTSK.Completed = "T"; //tmpTSK.CompletedBy = usersvc.UserId.ToString(); //tmpTSK.CompletedDate = System.DateTime.Now.ToUniversalTime(); //tmpTSK.Status = "Completed"; ////tmpTSK.WeightedPercentage = 1; //tmpTSK.Save(); tmpTSK.CompleteTask(); } } // Run Complete Stage Business Rule //DialogService.SetSpecs(200, 200, 550, 700, "AddEditStage", "Complete Stage", true); //DialogService.EntityType = typeof(ICampaignStage); //DialogService.EntityID = result[0]; //DialogService.DialogParameters.Add("Mode", "Complete"); //DialogService.ShowDialog(); } else if (result[1] == "T") { IOppFulFilTask Task = EntityFactory.GetById <IOppFulFilTask>(result[0]); //Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); //Sage.Entity.Interfaces.IUser user = usersvc.GetUser(); //Task.Completed = "T"; //Task.CompletedBy = usersvc.UserId.ToString(); //Task.CompletedDate = System.DateTime.Now.ToUniversalTime(); //Task.Status = "Completed"; ////Task.PercentageComplete = 1; //Task.Save(); Task.CompleteTask(); //DialogService.SetSpecs(200, 200, 550, 700, "AddEditTask", "Complete Task", true); //DialogService.EntityType = typeof(ICampaignTask); //DialogService.EntityID = result[0]; //DialogService.DialogParameters.Add("Mode", "Complete"); //DialogService.ShowDialog(); } } } if (e.CommandName.Equals("Delete")) { int rowIndex = Convert.ToInt32(e.CommandArgument); string Id = grdStages.DataKeys[rowIndex].Value.ToString(); string[] result = Id.Split(':'); if (result[1] == "S") //Stage { IOppFulFilStage stage = EntityFactory.GetById <IOppFulFilStage>(result[0]); if (stage != null) { //stage.Campaign.CampaignStages.Remove(stage); stage.Delete(); } } else if (result[1] == "T") //Task { IOppFulFilTask task = EntityFactory.GetById <IOppFulFilTask>(result[0]); if (task != null) { //task.CampaignStage.CampaignTasks.Remove(task); //task.Campaign.CampaignTasks.Remove(task); task.Delete(); } } } if (PageWorkItem != null) { IPanelRefreshService refresher = PageWorkItem.Services.Get <IPanelRefreshService>(); if (refresher != null) { refresher.RefreshAll(); } } LoadView(); }