Example #1
0
        protected void JobCorrespondenceSelection_OnItemCheck(Object sender, Telerik.Web.UI.RadListBoxItemEventArgs e)
        {
            InitializeJobDescriptionGrid();

            System.Data.DataTable jobDescriptionTable = (System.Data.DataTable)JobDescriptionGrid.DataSource;


            Client.Core.Reference.Correspondence selectedCorrespondence = MercuryApplication.CorrespondenceGet(Convert.ToInt64(e.Item.Value), true);

            if (selectedCorrespondence != null)
            {
                foreach (Client.Core.Reference.CorrespondenceContent currentContent in selectedCorrespondence.Content.Values)
                {
                    jobDescriptionTable.Rows.Add(

                        selectedCorrespondence.Id,

                        selectedCorrespondence.Name,

                        currentContent.Id,

                        currentContent.ReportNameRaw,

                        String.Empty,

                        String.Empty,

                        String.Empty,

                        String.Empty

                        );
                }
            }


            JobDescriptionGrid.Rebind();

            return;
        }
Example #2
0
        protected void EntityDocumentHistoryGrid_OnNeedDataSource(Object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs eventArgs)
        {
            if (MercuryApplication == null)
            {
                return;
            }

            System.Data.DataTable dataTable = EntityDocumentHistoryGrid_DataTable;


            switch (eventArgs.RebindReason)
            {
            case Telerik.Web.UI.GridRebindReason.InitialLoad:

                #region Initialize Grid

                EntityDocumentHistoryGrid_Count = 0;

                EntityDocumentHistoryGrid_CurrentPage = 0;

                EntityDocumentHistoryGrid_PageSize = 10;


                EntityDocumentHistoryGrid.CurrentPageIndex = EntityDocumentHistoryGrid_CurrentPage;

                EntityDocumentHistoryGrid.PageSize = EntityDocumentHistoryGrid_PageSize;

                EntityDocumentHistoryGrid.VirtualItemCount = EntityDocumentHistoryGrid_Count;

                #endregion

                break;

            case Telerik.Web.UI.GridRebindReason.PostbackViewStateNotPersisted:

                #region Restore Grid State

                if (EntityDocumentHistoryGrid_CurrentPage >= 0)
                {
                    EntityDocumentHistoryGrid.CurrentPageIndex = EntityDocumentHistoryGrid_CurrentPage;
                }

                EntityDocumentHistoryGrid.PageSize = EntityDocumentHistoryGrid_PageSize;

                EntityDocumentHistoryGrid.VirtualItemCount = EntityDocumentHistoryGrid_Count;


                if (EntityDocumentToolbar != null)
                {
                    Telerik.Web.UI.RadToolBarItem toolbarItem = EntityDocumentToolbar.Items.FindItemByValue("EnterReceivedFormToolbarButton");

                    Telerik.Web.UI.RadComboBox FormSelection = (Telerik.Web.UI.RadComboBox)toolbarItem.FindControl("FormSelection");

                    if (FormSelection != null)
                    {
                        FormSelection_SelectedValue = FormSelection.SelectedValue;
                    }
                }

                #endregion

                break;

            case Telerik.Web.UI.GridRebindReason.ExplicitRebind:

            case Telerik.Web.UI.GridRebindReason.PostBackEvent:

                #region Rebind Grid

                if (Entity == null)
                {
                    dataTable.Rows.Clear();
                }

                else
                {
                    if (EntityDocumentHistoryGrid_Count == 0)
                    {
                        EntityDocumentHistoryGrid_Count = Convert.ToInt32(MercuryApplication.EntityDocumentsGetCount(Entity.Id));

                        EntityDocumentHistoryGrid.VirtualItemCount = Convert.ToInt32(EntityDocumentHistoryGrid_Count);
                    }

                    if (!pageSizeChanged)
                    {
                        EntityDocumentHistoryGrid_PageSize = EntityDocumentHistoryGrid.PageSize;
                    }

                    else
                    {
                        EntityDocumentHistoryGrid.PageSize = EntityDocumentHistoryGrid_PageSize;

                        pageSizeChanged = false;
                    }


                    EntityDocumentHistoryGrid_CurrentPage = EntityDocumentHistoryGrid.CurrentPageIndex;

                    dataTable.Rows.Clear();

                    List <Mercury.Server.Application.EntityDocumentDataView> entityDocuments;

                    Int32 initialRow = EntityDocumentHistoryGrid.CurrentPageIndex * EntityDocumentHistoryGrid.PageSize + 1;

                    entityDocuments = MercuryApplication.EntityDocumentsGetByPage(Entity.Id, initialRow, EntityDocumentHistoryGrid.PageSize);

                    foreach (Mercury.Server.Application.EntityDocumentDataView currentDocument in entityDocuments)
                    {
                        #region Create Data Row

                        String detail = String.Empty;

                        String markSent = "&nbsp";

                        String markReceived = "&nbsp";

                        String markReturned = "&nbsp";

                        String automation = "&nbsp";

                        String relatedEntity = String.Empty;


                        if (currentDocument.DocumentType == "Correspondence")
                        {
                            Client.Core.Reference.Correspondence correspondence = MercuryApplication.CorrespondenceGet(currentDocument.DocumentId, true);


                            if ((currentDocument.HasImage) || (correspondence.Content.Count > 0))
                            {
                                detail = "<a href=\"javascript:void(0);\" onclick=\"javascript:window.open ('/Application/Common/Image.aspx?ObjectType=EntityCorrespondence&ObjectId=" + currentDocument.EntityDocumentId.ToString() + "&Render=true', '_blank', 'toolbar=0, location=0, directories=0, status=1, menubar=0, scrollbars=1, resizable=1');\"><img src=\"/Images/Common16/Document.png\" border=\"0\" /></a>";
                            }


                            if (currentDocument.SentDate.HasValue)
                            {
                                markSent = currentDocument.SentDate.Value.ToString("MM/dd/yyyy");

                                if (currentDocument.ReturnedDate.HasValue)
                                {
                                    markReturned = currentDocument.ReturnedDate.Value.ToString("MM/dd/yyyy");
                                }

                                else if ((!currentDocument.ReceivedDate.HasValue) && (correspondence != null))
                                {
                                    markReturned = " <a href=\"javascript:Correspondence_MarkReturned (" + currentDocument.EntityDocumentId.ToString() + ", '" + correspondence.Name + "', '" + currentDocument.SentDate.Value.ToString("MM/dd/yyyy") + "')\" title=\"Mark the correspondence as returned as undeliverable.\">(mark returned)</a>";
                                }
                            }

                            else
                            {
                                markSent = " <a href=\"javascript:Correspondence_MarkSent (" + currentDocument.EntityDocumentId.ToString() + ", '" + correspondence.Name + "', '" + currentDocument.ReadyToSendDate.Value.ToString("MM/dd/yyyy") + "')\">(mark sent)</a>";
                            }


                            // MCM-1175: Received Date was not visible unless the sent date had a value. This was not true for

                            // inbound correspondence only. Moved the received date setter outside.

                            if (currentDocument.ReceivedDate.HasValue)
                            {
                                markReceived = currentDocument.ReceivedDate.Value.ToString("MM/dd/yyyy");
                            }

                            // ALLOW DATA ENTRY ON THOSE OUTBOUND CORRESPONDENCE THAT HAVE BEEN SENT

                            else if ((currentDocument.SentDate.HasValue) && (!currentDocument.ReturnedDate.HasValue) && (correspondence.FormId != 0) && (currentDocument.EntityFormId == 0))
                            {
                                markReceived = " <a href=\"/Application/Forms/FormDataEntry/FormDataEntry.aspx?EntityCorrespondenceId=" + currentDocument.EntityDocumentId.ToString() + "&formid=" + correspondence.FormId.ToString() + "\">(received - data enter)</a>";
                            }


                            // TODO: MOVE AUTOMATION INTO THE DATA VIEW

                            Client.Core.Entity.EntityCorrespondence entityCorrespondence = MercuryApplication.EntityCorrespondenceGet(currentDocument.EntityDocumentId, true);

                            if (entityCorrespondence != null)
                            {
                                String automationTitle = ((entityCorrespondence.AutomationDate.HasValue) ? "[" + entityCorrespondence.AutomationDate.Value.ToString("MM/dd/yyyy") + "] " : String.Empty);

                                automationTitle += entityCorrespondence.AutomationStatus.ToString();

                                automationTitle += (!String.IsNullOrWhiteSpace(entityCorrespondence.AutomationException)) ? ": " + entityCorrespondence.AutomationException : String.Empty;

                                automation = "<span title=\"" + automationTitle + "\"><img src=\"/Images/Common16/Automation" + entityCorrespondence.AutomationStatus.ToString() + ".png\" /></span>";
                            }


                            if (entityCorrespondence.RelatedEntity != null)
                            {
                                relatedEntity = entityCorrespondence.RelatedEntity.Name;

                                switch (entityCorrespondence.RelatedEntity.EntityType)
                                {
                                case Mercury.Server.Application.EntityType.Member:

                                    relatedEntity = CommonFunctions.MemberProfileAnchor(entityCorrespondence.RelatedEntityId, relatedEntity).Replace("MemberId=", "EntityId=");

                                    break;

                                case Mercury.Server.Application.EntityType.Provider:

                                    relatedEntity = CommonFunctions.ProviderProfileAnchor(entityCorrespondence.RelatedEntityId, relatedEntity).Replace("ProviderId=", "EntityId=");

                                    break;
                                }
                            }
                        }

                        dataTable.Rows.Add(

                            detail,

                            currentDocument.DocumentType,

                            currentDocument.EntityDocumentId.ToString(),

                            currentDocument.DocumentId.ToString(),

                            currentDocument.EntityId.ToString(),

                            (currentDocument.DocumentType == "Form") ? CommonFunctions.FormAnchor(currentDocument.EntityDocumentId, currentDocument.Name) : currentDocument.Name,

                            String.Format("{0:0.00######}", currentDocument.Version),

                            ((currentDocument.ContactType != Mercury.Server.Application.EntityContactType.NotSpecified) ? Mercury.Server.CommonFunctions.EnumerationToString(currentDocument.ContactType) : String.Empty),

                            (currentDocument.ReadyToSendDate.HasValue) ? currentDocument.ReadyToSendDate.Value.ToString("MM/dd/yyyy") : "&nbsp",

                            markSent,

                            markReceived,

                            markReturned,

                            relatedEntity,

                            automation,

                            currentDocument.CreateAccountInfo.ActionDate.ToString(),

                            currentDocument.CreateAccountInfo.UserAccountName,

                            currentDocument.ModifiedAccountInfo.ActionDate.ToString(),

                            currentDocument.ModifiedAccountInfo.UserAccountName

                            );

                        #endregion
                    }
                }

                break;

                #endregion

            default:

                System.Diagnostics.Debug.WriteLine(eventArgs.RebindReason + " [" + eventArgs.IsFromDetailTable.ToString() + "]");

                break;
            }


            EntityDocumentHistoryGrid_DataTable = dataTable;

            EntityDocumentHistoryGrid.DataSource = EntityDocumentHistoryGrid_DataTable;

            return;
        }
        protected void ButtonOk_OnClick(Object sender, EventArgs e)
        {
            Telerik.Web.UI.GridDataItem selectedGridItem = (Telerik.Web.UI.GridDataItem)EntitySendCorrespondenceInformationGrid.SelectedItems[0];

            Telerik.Web.UI.DataKey selectedDataKey = selectedGridItem.OwnerTableView.DataKeyValues[selectedGridItem.ItemIndex];


            System.Text.RegularExpressions.Regex expressionValidator;

            Int64 correspondenceId = 0;

            Client.Core.Reference.Correspondence correspondence = null;

            Client.Core.Entity.EntityContactInformation entityContactInformation = null;


            #region Validation

            if (String.IsNullOrEmpty(SendCorrespondenceSelection.SelectedValue))
            {
                ActionResponseLabel.Text = "** No Correspondence selected to send.";

                return;
            }

            if (!Int64.TryParse(SendCorrespondenceSelection.SelectedValue, out correspondenceId))
            {
                ActionResponseLabel.Text = "** No Correspondence Selected.";

                return;
            }

            correspondence = MercuryApplication.CorrespondenceGet(correspondenceId, true);

            if (correspondence == null)
            {
                ActionResponseLabel.Text = "** Unable to retreive correspondence.";

                return;
            }

            if (!SendCorrespondenceDate.SelectedDate.HasValue)
            {
                ActionResponseLabel.Text = "** No valid send date selected.";

                return;
            }

            if (CorrespondenceUseAlternativeFaxNumber.Checked)
            {
                String faxPattern = @"^([\(]{1}[0-9]{3}[\)]{1}[\.| |\-]{0,1}|^[0-9]{3}[\.|\-| ]?)?[0-9]{3}(\.|\-| )?[0-9]{4}$";

                expressionValidator = new System.Text.RegularExpressions.Regex(faxPattern);

                if (!expressionValidator.IsMatch(CorrespondenceAlternateFaxNumber.Text))
                {
                    ActionResponseLabel.Text = "** No valid alternate FAX number provided, or not in correct format.";

                    return;
                }
            }

            if (CorrespondenceUseAlternativeEmail.Checked)
            {
                String emailPattern = @"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$";

                expressionValidator = new System.Text.RegularExpressions.Regex(emailPattern);

                if (!expressionValidator.IsMatch(CorrespondenceAlternateEmail.Text))
                {
                    ActionResponseLabel.Text = "** No valid alternate email provided, or not in correct format.";

                    return;
                }
            }


            #endregion


            ActionResponseLabel.Text = String.Empty;


            entityCorrespondence = new Mercury.Client.Core.Entity.EntityCorrespondence(MercuryApplication);

            entityCorrespondence.EntityId = Int64.Parse(selectedDataKey["EntityId"].ToString());

            entityCorrespondence.RelatedEntityId = (RelatedEntity != null) ? RelatedEntity.Id : 0;


            entityCorrespondence.CorrespondenceId = correspondence.Id;

            entityCorrespondence.CorrespondenceName = correspondence.Name;

            entityCorrespondence.CorrespondenceVersion = correspondence.Version;


            entityCorrespondence.ReadyToSendDate = SendCorrespondenceDate.SelectedDate.Value;

            entityCorrespondence.Attention = SendCorrespondenceAttention.Text;

            entityCorrespondence.Remarks = SendCorrespondenceRemarks.Text;


            Boolean useAlternateInformation = false;

            useAlternateInformation |= CorrespondenceUseAlternativeAddress.Checked;

            useAlternateInformation |= CorrespondenceUseAlternativeFaxNumber.Checked;

            useAlternateInformation |= CorrespondenceUseAlternativeEmail.Checked;


            if (!useAlternateInformation)
            {
                Mercury.Server.Application.EntityContactType contactType;

                contactType = (Mercury.Server.Application.EntityContactType)Convert.ToInt32(selectedDataKey["ContactType"].ToString());

                switch (contactType)
                {
                case Mercury.Server.Application.EntityContactType.ByMail:

                    entityCorrespondence.ContactType = contactType;

                    entityCorrespondence.EntityAddressId = Convert.ToInt64(selectedDataKey["AddressId"].ToString());

                    Client.Core.Entity.EntityAddress entityAddress = MercuryApplication.EntityAddressGet(entityCorrespondence.EntityAddressId, false);

                    if (entityAddress != null)
                    {
                        entityCorrespondence.AddressLine1 = entityAddress.Line1;

                        entityCorrespondence.AddressLine2 = entityAddress.Line2;

                        entityCorrespondence.AddressCity = entityAddress.City;

                        entityCorrespondence.AddressState = entityAddress.State;

                        entityCorrespondence.AddressZipCode = entityAddress.ZipCode;
                    }

                    break;

                case Mercury.Server.Application.EntityContactType.Facsimile:

                    entityCorrespondence.ContactType = contactType;

                    entityCorrespondence.EntityContactInformationId = Convert.ToInt64(selectedDataKey["AddressId"].ToString());

                    entityContactInformation = MercuryApplication.EntityContactInformationGet(entityCorrespondence.EntityContactInformationId, true);

                    if (entityContactInformation != null)
                    {
                        entityCorrespondence.ContactFaxNumber = entityContactInformation.Number;
                    }

                    break;

                case Mercury.Server.Application.EntityContactType.Email:

                    entityCorrespondence.ContactType = contactType;

                    entityCorrespondence.EntityContactInformationId = Convert.ToInt64(selectedDataKey["AddressId"].ToString());

                    entityContactInformation = MercuryApplication.EntityContactInformationGet(entityCorrespondence.EntityContactInformationId, true);

                    if (entityContactInformation != null)
                    {
                        entityCorrespondence.ContactEmail = entityContactInformation.Email;
                    }

                    break;

                case Mercury.Server.Application.EntityContactType.InPerson:

                    entityCorrespondence.ContactType = contactType;

                    break;

                default:

                    ActionResponseLabel.Text = "Check selection. Unknown or unhandled contact type: " + contactType.ToString();

                    return;
                }
            }

            else if (CorrespondenceUseAlternativeAddress.Checked)
            {
                entityCorrespondence.ContactType = Mercury.Server.Application.EntityContactType.ByMail;

                entityCorrespondence.EntityAddressId = 0;

                entityCorrespondence.EntityContactInformationId = 0;

                entityCorrespondence.AddressLine1 = CorrespondenceAlternateAddressLine1.Text;

                entityCorrespondence.AddressLine2 = CorrespondenceAlternateAddressLine2.Text;

                entityCorrespondence.AddressCity = CorrespondenceAlternateAddressCity.Text;

                entityCorrespondence.AddressState = CorrespondenceAlternateAddressState.Text;

                entityCorrespondence.AddressZipCode = CorrespondenceAlternateAddressZipCode.Text;
            }

            else if (CorrespondenceUseAlternativeFaxNumber.Checked)
            {
                entityCorrespondence.ContactType = Mercury.Server.Application.EntityContactType.Facsimile;

                entityCorrespondence.EntityAddressId = 0;

                entityCorrespondence.EntityContactInformationId = 0;

                entityCorrespondence.ContactFaxNumber = CorrespondenceAlternateFaxNumber.Text;
            }

            else if (CorrespondenceUseAlternativeEmail.Checked)
            {
                entityCorrespondence.ContactType = Mercury.Server.Application.EntityContactType.Email;

                entityCorrespondence.EntityAddressId = 0;

                entityCorrespondence.EntityContactInformationId = 0;

                entityCorrespondence.ContactEmail = CorrespondenceAlternateEmail.Text;
            }

            else
            {
                ActionResponseLabel.Text = "Unable to determine method. Please check your selection.";

                return;
            }

            if (SendCorrespondence != null)
            {
                SendCorrespondence(this, new SendCorrespondenceEntityEventArgs(Entity, RelatedEntity, entityCorrespondence));
            }

            return;
        }