Beispiel #1
0
        private bool SaveDialogAnswers(string dialogStatus, bool pOnPressButtonSave)
        {
            /**
             * commented as per https://brightvision.jira.com/browse/PLATFORM-1358
             * but will be needed later.
             * this function is for the validation checking of the required fields.
             */
            /** /
            if (!ValidateDialog(true)) {
                MessageBox.Show("Please supply the required fields first before saving. Required fields are indicated in red background.",
                    "Save Dialog", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }
            /**/

            //if ((dialogStatus != null && dialogStatus.ToLower() != "none") ||
            //    (string.IsNullOrEmpty(dialogStatus))) {
            //if (SelectedContact != null &&
            //    ((dialogStatus != null && dialogStatus.ToLower() == "none") || (string.IsNullOrEmpty(dialogStatus))))
            //SavingEventArgs savingArgs = new SavingEventArgs{ Status=dialogStatus, Cancel = false};
            //if (OnSaving != null)
            //    OnSaving(this, ref savingArgs);

            //if (SelectedContact != null && ((dialogStatus != null && dialogStatus.ToLower() == "none")) || savingArgs.Cancel)
            //if (SelectedContact != null && ((dialogStatus != null && dialogStatus.ToLower() == "none"))) {
            //    MessageBox.Show("Please set status in dropdown for contact and company.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    return false;
            //}

            //WaitDialog.Show(ParentForm, "Saving...");

            IQuestionnaire iQuestion = null;
            var objGroupItems = this.layoutControlGroupQuestionnaire.Items;
            foreach (BaseLayoutItem item in objGroupItems) {
                if (item.IsGroup) {
                    if (item.Tag != null) {
                        iQuestion = item.Tag as IQuestionnaire;

                        /**
                         * if questionnaire is contact level and there are no contacts,
                         * just by pass saving.
                         */
                        if (!iQuestion.Questionnaire.Form.Settings.DataBindings.account_level && m_BrightSalesProperty.CampaignBooking.ContactCount < 1)
                            continue;

                        iQuestion.Save();
                        if (!iQuestion.Questionnaire.Form.Settings.DataBindings.same_contact_binding && iQuestion.HasChanged)
                            BusinessAnswer.SaveAnswer(iQuestion.Questionnaire);
                        else if (pOnPressButtonSave && iQuestion.HasMustSaveDefaultValues)
                            BusinessAnswer.SaveAnswer(iQuestion.Questionnaire);

                        //if ((!iQuestion.Questionnaire.Form.Settings.DataBindings.same_contact_binding && iQuestion.HasChanged) || iQuestion.HasMustSaveDefaultValues)
                        //    BusinessAnswer.SaveAnswer(iQuestion.Questionnaire);

                        //if (!iQuestion.Questionnaire.Form.Settings.DataBindings.same_contact_binding && iQuestion.HasChanged)
                        //    BusinessAnswer.SaveAnswer(iQuestion.Questionnaire);
                    }
                }
            }

            DialogEditorEvents.OnSaveCompletedArgs _args = new DialogEditorEvents.OnSaveCompletedArgs() {
                DialogId = m_oDialog.id,
                Status = string.IsNullOrEmpty(dialogStatus) ? "None" : dialogStatus,
                ContactId = SelectedContact != null ? SelectedContact.id : 0
            };

            if (m_CurrentStatus.ToLower() != dialogStatus.ToLower() && !string.IsNullOrEmpty(dialogStatus)) {
                m_CurrentStatus = dialogStatus;
                _args.EventLog = new DialogEditorEvents.EventLog() {
                    EventType = BrightVision.Common.Classes.EventLog.EventTypes.CHANGE_DIALOG_SAVE_EVENT,
                    Parameters = new string[] {
                        m_oDialog.id.ToString(),
                        m_CurrentStatus,
                        string.IsNullOrEmpty(dialogStatus) ? "None" : dialogStatus
                    }
                };
            }

            m_EventBus.Notify(new DialogEditorEvents.OnSaveCompleted() {
                OnSaveCompletedArgs = _args,
                TransactionSource = DialogEditorEvents.eTransactionSource.OnSaveButtonClick
            });

            //this.RaiseSaveCompletedEvent(this, _args);

            //this.RaiseSaveCompletedEvent(this, new SaveCompletedEventArgs() {
            //    DialogID = m_oDialog.id,
            //    Status = dialogStatus,
            //    ContactId = SelectedContact.id
            //});
            //WaitDialog.Close();
            //***NOTE: Move this to the exposed handler OnSaveCompleted
            //string curStatus = string.Empty;
            //if (m_oContactView != null) {
            //    try {
            //        if (m_oContactView.SelectedContact != null)
            //            curStatus = m_oContactView.SelectedContact.status;
            //        m_oContactView.SaveSubCampaignContactAppointmentStatus(
            //            status,
            //            oAppointment.FinalListId,
            //            oAppointment.AccountId,
            //            oAppointment.SubCampaignId);
            //    } catch { }
            //    oMode = SaveMode.Unspecified;
            //    CloseDialogEditor(false);
            //}
            //WaitDialog.Close();

            //if (string.IsNullOrEmpty(m_CurrentStatus)) m_CurrentStatus = "None";
            //string newStatus = "None";
            //switch (status)
            //{
            //    case ContactView.eDialogStatus.InterviewCompleted: newStatus = "Interview Completed"; break;
            //    case ContactView.eDialogStatus.ArticleCompleted: newStatus = "Article Completed"; break;
            //    case ContactView.eDialogStatus.InProgress: newStatus = "In Progress"; break;
            //}
            //Log only if current status has changed to new status. Don't log if both are in the same status
            //if (m_CurrentStatus.ToLower() != dialogStatus.ToLower())
            //{
            //    LogAnEvent(
            //        BrightVision.EventLog.EventTypes.CHANGE_DIALOG_SAVE_EVENT,
            //        m_oDialog.id.ToString(),
            //        m_CurrentStatus,
            //        dialogStatus);
            //}
            return true;
        }
Beispiel #2
0
        private void bbiDialogStatus_EditValueChanged(object sender, EventArgs e)
        {
            if (ContactStatus.ContactStatuses.Count < 1)
                NotificationDialog.Information("Bright Sales", "No values for dropdown defined. Please contact your project manager.");

            string _ContactStat = string.Empty;
            if (bbiDialogStatus.EditValue != null)
                _ContactStat = bbiDialogStatus.EditValue.ToString();

            WaitDialog.Show("Saving changes ...");
            DialogEditorEvents.OnSaveCompletedArgs _args = new DialogEditorEvents.OnSaveCompletedArgs() {
                DialogId = m_oDialog.id,
                Status = string.IsNullOrEmpty(_ContactStat) ? "None" : _ContactStat,
                ContactId = SelectedContact != null ? SelectedContact.id : 0
            };

            if (m_CurrentStatus.ToLower() != _ContactStat.ToLower() && !string.IsNullOrEmpty(_ContactStat)) {
                m_CurrentStatus = _ContactStat;
                _args.EventLog = new DialogEditorEvents.EventLog() {
                    EventType = BrightVision.Common.Classes.EventLog.EventTypes.CHANGE_DIALOG_SAVE_EVENT,
                    Parameters = new string[] {
                        m_oDialog.id.ToString(),
                        m_CurrentStatus,
                        string.IsNullOrEmpty(_ContactStat) ? "None" : _ContactStat
                    }
                };
            }

            m_EventBus.Notify(new DialogEditorEvents.OnSaveCompleted() {
                OnSaveCompletedArgs = _args,
                TransactionSource = DialogEditorEvents.eTransactionSource.OnContactStatusChange
            });

            //DAN: Raise event for campaign list to update contact status as the above code only updates the managecampaignbooking module.
            m_EventBus.Notify(new DialogEditorEvents.OnChangeDialogStatus()
            {
                OnSaveCompletedArgs = _args,
                TransactionSource = DialogEditorEvents.eTransactionSource.OnContactStatusChange
            });
            WaitDialog.Close();

            //if (!m_AnswerBindingOnProgress)
            //    m_EventBus.Notify(new DialogEditorEvents.OnAnswerChange());

            //if (bbiDialogStatus_OnEditValueChange != null && m_AllowEditValueChanged)
            //    bbiDialogStatus_OnEditValueChange();
        }