Пример #1
0
    protected override void OnMyDialogClosing(object from, Sage.Platform.WebPortal.Services.WebDialogClosingEventArgs e)
    {
        base.OnMyDialogClosing(from, e);
        ExpenseEntryForm = null;
        Visible = false;

        this.Page.Form.Attributes.Add("enctype", "multipart/form-data");
        this.Page.Form.Enctype = "multipart/form-data";
    }
Пример #2
0
    /// <summary>
    /// Attempt to load the initial values from the SalesLogix entity.
    /// This is called only  once when the form is initially loaded.
    /// </summary>
    private void InitializeFromSalesLogixEntity()
    {
        ExpenseEntryForm = new ExpenseEntryFormPresenter();
        //ExpenseEntryForm.LoadingForm = true;
        //if (BindingSource.Current is ITicketActivity)
        //    InitializeFromTicketActivity((ITicketActivity)BindingSource.Current);
        //else if (BindingSource.Current is IHistory)
        //    InitializeFromHistory((IHistory)BindingSource.Current);
        //else if (BindingSource.Current is IActivity)
        //    InitializeFromActivity((IActivity)BindingSource.Current);
        if (BindingSource.Current is ITLXProjectExpense)
            InitializeFromTLXExpense((ITLXProjectExpense)BindingSource.Current);

        if (DialogService.DialogParameters.ContainsKey("ParentProjectId"))
        {
            ExpenseData.ProjectID = (String)DialogService.DialogParameters["ParentProjectId"];
            ITLXProject project = EntityFactory.GetById<ITLXProject>(ExpenseData.ProjectID);
            if (project != null)
            {
                ExpenseData.AccountID = project.Account.Id.ToString();
            }
        }

        if (DialogService.DialogParameters.ContainsKey("ParentTaskId"))
        {
            ExpenseData.TaskID = (String)DialogService.DialogParameters["ParentTaskId"];
        }

        if (DialogService.DialogParameters != null && DialogService.DialogParameters.Count() > 0)
        {
            string entity = DialogService.DialogParameters.Keys.Contains("CurrentEntity") == false ? "" : DialogService.DialogParameters["CurrentEntity"].ToString();
            object entityId = DialogService.DialogParameters.Keys.Contains("CurrentEntityId") == false ? null : DialogService.DialogParameters["CurrentEntityId"];

            if (entity == "tlxproject")
            {

            }
            else if (entity == "opportunity")
            {
                IOpportunity oppObj = EntityFactory.GetById<IOpportunity>(entityId);
                ExpenseData.AccountID = oppObj.Account.Id.ToString();
                ExpenseData.OpportunityID = oppObj.Id.ToString();
                ExpenseData.ProjectID = "";
                ExpenseData.TaskID = "";
            }
            else if (entity == "ticket")
            {
                ITicket ticketObj = EntityFactory.GetById<ITicket>(entityId);
                ExpenseData.AccountID = ticketObj.Account.Id.ToString();
                ExpenseData.TicketID = ticketObj.Id.ToString();
                ExpenseData.ProjectID = ticketObj.TLXTicketExt.TLXProject == null ? "" : ticketObj.TLXTicketExt.TLXProject.Id.ToString();
                ExpenseData.TaskID = ticketObj.TLXTicketExt.TLXProjectTask == null ? "" : ticketObj.TLXTicketExt.TLXProjectTask.Id.ToString();
            }
            else if (entity == "tlxprojecttask")
            {
                ITLXProjectTask taskObj = EntityFactory.GetById<ITLXProjectTask>(entityId);
                ExpenseData.AccountID = taskObj.TLXProject == null ? "" : Convert.ToString(taskObj.TLXProject.Accountid);
                ExpenseData.TaskID = taskObj.Id.ToString();
                ExpenseData.ProjectID = taskObj.TLXProject == null ? "" : Convert.ToString(taskObj.TLXProject.Id);
            }

            DialogService.DialogParameters.Clear();
        }

        if (!String.IsNullOrEmpty(ExpenseData.ProjectID))
        {

            if (!String.IsNullOrEmpty(ExpenseData.TaskID))
            {
                if (!String.IsNullOrEmpty(ExpenseData.TaskID.Trim()))
                {
                    if (!String.IsNullOrEmpty(EntityFactory.GetById<ITLXProjectTask>(ExpenseData.TaskID).DefaultSiteID))
                    {
                        TLXProjectAccount projAccountObj = Sage.Platform.EntityFactory.GetByCompositeId<TLXProjectAccount>(new string[] { "AccountID", "Timelink_projectsId" }, new object[] { EntityFactory.GetById<ITLXProjectTask>(ExpenseData.TaskID).DefaultSiteID, ExpenseData.ProjectID });
                        ExpenseData.SiteID = projAccountObj == null ? "" : projAccountObj.Id;
                    }
                }
            }
            else
            {
                TLXProject Projectobj = Sage.Platform.EntityFactory.GetById<TLXProject>(ExpenseData.ProjectID);
                TLXProjectAccount projAccountObj = Sage.Platform.EntityFactory.GetByCompositeId<TLXProjectAccount>(new string[] { "AccountID", "Timelink_projectsId" }, new object[] { Projectobj.ProjectDefaultSiteID, Projectobj.Id });
                ExpenseData.SiteID = projAccountObj == null ? "" : projAccountObj.Id;
            }
            //if Task is selected

            //SiteID.LookupResultValue = Sage.Platform.EntityFactory.GetById<ITLXProjectAccount>(Projectobj.ProjectDefaultSiteID);
        }
    }
Пример #3
0
    private String Save()
    {
        ExpenseData.TimelinkgroupID = (new ServiceTaskDataService()).GetTimelinkGroupID(ExpenseData.ExpenseUser, ExpenseData.ExpenseDate ?? DateTime.Today);

        ExpenseEntryForm.ExpenseData.TLX_RetainerInfoID = Convert.ToString(ExpenseData.TLX_RetainerInfoID);

        ClientMessage msg = ExpenseEntryForm.Save();
        String stId = ExpenseEntryForm.ExpenseData.ID;
        if (msg != null && !String.IsNullOrEmpty(msg.Message))
        {
            if (msg.Type == ClientMessage.MessageType.Information)
            {
                this.MessageBox(msg.Message);
            }
            else
            {
                throw new ValidationException(msg.Message.Replace("\r", "<br/>"));
            }
        }
        // this will clear it from the pageworkitem.. required to release the memory
        ExpenseEntryForm = null;
        return stId;
    }