/// <summary> /// called when combo box value for publication status is changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PublicationStatusChanged(object sender, EventArgs e) { if ((FSubscriptionDR == null) || FInitializationRunning) { /* don't do this check while a new record is being displayed */ return; } if (this.cmbPSubscriptionSubscriptionStatus.GetSelectedString() == MPartnerConstants.SUBSCRIPTIONS_STATUS_GIFT) { /* GIFT */ /* enable Gift From partner key text box */ this.txtPSubscriptionGiftFromKey.Enabled = true; /* clear any previously supplied reason for cancellation */ FSubscriptionDR.SetReasonSubsCancelledCodeNull(); this.cmbPSubscriptionReasonSubsCancelledCode.cmbCombobox.SelectedValue = ""; this.cmbPSubscriptionReasonSubsCancelledCode.Enabled = false; /* clear any previously supplied Date Ended */ this.dtpPSubscriptionDateCancelled.Enabled = false; this.dtpPSubscriptionDateCancelled.Text = ""; if (!FSubscriptionDR.IsDateCancelledNull()) { FSubscriptionDR.SetDateCancelledNull(); } } else if ((this.cmbPSubscriptionSubscriptionStatus.GetSelectedString() == MPartnerConstants.SUBSCRIPTIONS_STATUS_CANCELLED) || (this.cmbPSubscriptionSubscriptionStatus.GetSelectedString() == MPartnerConstants.SUBSCRIPTIONS_STATUS_EXPIRED)) { /* CANCELLED or EXPIRED */ /* Set the DateEnded field to todays date: */ this.dtpPSubscriptionDateCancelled.Enabled = true; if (dtpPSubscriptionDateCancelled.Text.Length == 0) { // only initialize date if value is not set yet dtpPSubscriptionDateCancelled.Text = StringHelper.DateToLocalizedString(DateTime.Now, false); FSubscriptionDR.DateCancelled = DateTime.Now.Date; } /* clear any previously supplied partner key */ if (!FSubscriptionDR.IsGiftFromKeyNull()) { FSubscriptionDR.SetGiftFromKeyNull(); } // following check prevents save button to be wrongly enabled during initialization of tab if (txtPSubscriptionGiftFromKey.Text != "0000000000") { txtPSubscriptionGiftFromKey.Text = "0"; } this.txtPSubscriptionGiftFromKey.Enabled = false; /* allow them to enter a reason ended */ this.cmbPSubscriptionReasonSubsCancelledCode.Enabled = true; // don't open drop down box during initialization if (!FInitializationRunning) { this.cmbPSubscriptionReasonSubsCancelledCode.DropDown(); } } else { /* All other Cases */ /* clear any previously supplied partner key */ if (!FSubscriptionDR.IsGiftFromKeyNull()) { FSubscriptionDR.SetGiftFromKeyNull(); } // following check prevents save button to be wrongly enabled during initialization of tab if (txtPSubscriptionGiftFromKey.Text != "0000000000") { txtPSubscriptionGiftFromKey.Text = "0"; } this.txtPSubscriptionGiftFromKey.Enabled = false; /* clear any previously supplied Date Ended */ if (!FSubscriptionDR.IsDateCancelledNull()) { FSubscriptionDR.SetDateCancelledNull(); } this.dtpPSubscriptionDateCancelled.Text = ""; this.dtpPSubscriptionDateCancelled.Enabled = false; /* clear any previously supplied reason for cancellation */ FSubscriptionDR.ReasonSubsCancelledCode = ""; this.cmbPSubscriptionReasonSubsCancelledCode.cmbCombobox.SelectedValue = ""; this.cmbPSubscriptionReasonSubsCancelledCode.Enabled = false; } }