protected void btnComplete_Click(object sender, EventArgs e) { string key = hfSelections.Value; bool completeAll = true; ISelectionService srv = SelectionServiceRequest.GetSelectionService(); ISelectionContext selectionContext = srv.GetSelectionContext(key); List <string> ids = selectionContext.GetSelectedIds(); foreach (string id in ids) { ILitRequest lit = EntityFactory.GetById <ILitRequest>(id); if (UserCalendar.CurrentUserCanEdit(lit.CreateUser)) { lit.CompleteLitRequest(); } else { completeAll = false; } } // this has to occur after the fulfillment is completed. The status needs to be updated before refresh is called. ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "refreshList", "RefreshList();", true); if (!completeAll) { DialogService.ShowMessage(GetLocalResourceObject("Err_Complete").ToString(), 70, 400); } }
private void FulfillRequestLocally(ILitRequest lr) { // build client script with values StringBuilder sb = new StringBuilder(); sb.AppendFormat("fulfillLitRequestLocally('{0}');", lr.Id); ScriptManager.RegisterClientScriptBlock(this, typeof(SmartParts_LitRequest_LiteratureRequest), "fulfillRequest", sb.ToString(), true); }
private void UpdateFulfillStatus(string litRequestId) { // call business rule to update the entity properties ILitRequest lr = EntityFactory.GetById <ILitRequest>(litRequestId); lr.FulfillLitRequest(); Response.Redirect(string.Format("Contact.aspx?entityId={0}", lr.Contact.Id)); }
private void FulfillRequestLocally(ILitRequest lr) { // build client script with values StringBuilder sb = new StringBuilder(); sb.AppendFormat("fulfillLitRequestLocally('{0}');", lr.Id); ScriptManager.RegisterClientScriptBlock(this, typeof(SmartParts_LitRequest_LiteratureRequest), "fulfillRequest", sb.ToString(), true); }
protected void Save(object sender, EventArgs e) { if (SendBy.DateTimeValue < DateTime.Now.AddDays(-1)) { return; } if (RequestedFor.LookupResultValue != null) { IContextService conserv = ApplicationContext.Current.Services.Get <IContextService>(true); Sage.Platform.TimeZone tz = (Sage.Platform.TimeZone)conserv.GetContext("TimeZone"); ILitRequest lr = EntityFactory.Create <ILitRequest>(); SLXUserService slxUserService = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService; if (slxUserService != null) { lr.RequestUser = slxUserService.GetUser(); } String[] arClientData = clientdata.Value.ToString().Split('|'); lr.RequestDate = DateTime.Now.AddMinutes(tz.BiasForGivenDate(DateTime.Now)); lr.CoverId = arClientData[0]; lr.Contact = (IContact)RequestedFor.LookupResultValue; lr.ContactName = lr.Contact.LastName + ", " + lr.Contact.FirstName; lr.Description = Description.Text; lr.SendDate = SendBy.DateTimeValue; lr.SendVia = SendVia.PickListValue; lr.Priority = Priority.PickListValue; lr.Options = PrintLiteratureList.SelectedIndex; lr.Save(); Activity act = new Activity(); act.Type = ActivityType.atLiterature; act.AccountId = lr.Contact.Account.Id.ToString(); act.AccountName = lr.Contact.Account.AccountName; act.ContactId = lr.Contact.Id.ToString(); act.ContactName = lr.ContactName; act.PhoneNumber = lr.Contact.WorkPhone; act.StartDate = (DateTime)lr.RequestDate; act.Duration = 0; act.Description = lr.Description; act.Alarm = false; act.Timeless = true; act.Rollover = false; act.UserId = lr.RequestUser.Id.ToString(); act.OriginalDate = (DateTime)lr.RequestDate; act.Save(); // save litRequest item double totalCost = 0.0; string coverId = arClientData[0]; // get cover name for (int i = 1; i < arClientData.Length; i++) { string[] clientData = arClientData[i].Split('='); string litItemId = clientData[0]; int qty = Int32.Parse(clientData[1]); // get literature item cost ILiteratureItem litItem = EntityFactory.GetById <ILiteratureItem>(litItemId); totalCost += (double)qty * (litItem.Cost.HasValue ? (double)litItem.Cost.Value : (double)0.0); // add the literature request item ILitRequestItem lrItem = EntityFactory.Create <ILitRequestItem>(); lrItem.Qty = qty; lrItem.LitRequest = lr; lrItem.LiteratureItem = litItem; lr.LitRequestItems.Add(lrItem); } lr.TotalCost = totalCost; // get cover name string coverName = GetCoverName(coverId); lr.CoverName = coverName; lr.Save(); //must make ids match, and id prop is read only, so.... SynchronizeLitRequestId(act.Id, lr.Id.ToString()); // re-get entity with new activity id lr = EntityFactory.GetById <ILitRequest>(act.Id); // process the lit request if handle fulfillment locally is checked if (chkHandleLocal.Checked) { // show printer dialog for fulfillment FulfillRequestLocally(lr); // call business rule to update the entity properties lr.FulfillLitRequest(); } else { Response.Redirect("Contact.aspx?entityId=" + lr.Contact.Id.ToString()); } } }