protected override void UpdateValues()
		{
            Business.RenewalTerm renewalTerm = Term as Business.RenewalTerm;
			if (renewalTerm == null)
                throw new Exception(string.Format("Unable to cast _term \"{0}\" to a Business.RenewalTerm object.", TermName));

			TermName = txtTermName.Text;

            if (!IsComplexListField)
            {
                if (_template.SecurityModel == Business.SecurityModel.Advanced)
                    renewalTerm.TermGroupID = new Guid(ddlTermGroup.SelectedValue);
                else
                    renewalTerm.TermGroupID = _template.BasicSecurityTermGroupID;
            }
			renewalTerm.IsHeader = chkHeaderTerm.Checked;
			renewalTerm.ValidateOnSave = this.vos.Validate;
            renewalTerm.ValidationStatuses = this.vos.SelectedStatuses;

			renewalTerm.Required = true;
			renewalTerm.AllowBackDating = chkbxAllowBackdating.Checked;
			//DEG_20071026  Made the switch - no longer looking at chkbxEditable, but instead looking at chkbxEditableRenewalDurationUnit
			//renewalTerm.Editable = chkbxEditable.Checked;
			renewalTerm.Editable = chkbxEditableRenewalDurationUnit.Checked;
			renewalTerm.KeywordSearchable = chkbxKeywordSearchable.Checked;
			renewalTerm.EffectiveDateFormat = ddlEffectiveDateFormat.SelectedValue;
			renewalTerm.ExpirationDateFormat = ddlExpirationDateFormat.SelectedValue;
			renewalTerm.SendNotification = chkbxSendNotification.Checked;

			renewalTerm.Name = txtTermName.Text;
			renewalTerm.AllowBackDating = chkbxAllowBackdating.Checked;
			renewalTerm.PopUpText = textbxRenewalPopup.Text;
			
			if (renewalTerm.InitialDurationUnits != null)
			{
				renewalTerm.InitialDurationUnits.Clear();
				foreach (ListItem li in listbxInitialDurationUnit.Items)
				{
					if (li.Selected)
					{
						Business.DurationUnit durationUnit = new Kindred.Knect.ITAT.Business.DurationUnit();
						durationUnit.Display = li.Text;
						durationUnit.Value = li.Value;
						durationUnit.Selected = (ddlDefaultInitialDurationUnit.SelectedValue == li.Value);
						durationUnit.Default = (ddlDefaultInitialDurationUnit.SelectedValue == li.Value);
						renewalTerm.InitialDurationUnits.Add(durationUnit);
					}
				}
			}

			renewalTerm.InitialDurationUnitCountDefault = int.Parse(textbxDefaultInitialDuration.Text);
			renewalTerm.InitialDurationUnitPopUpIfNot = chkbxInitialPopUpIfNot.Checked;
			renewalTerm.InitialDurationUnitPopUpText = textbxInitialDurationPopup.Text;

			Business.Event renewalEvent = _template.RenewalEvent;
			Business.Message message = _template.RenewalTermMessage;
			if (renewalEvent != null && message != null)
			{
				message.NotificationStatuses.Clear();
				message.NotificationStatuses.Add(ddlSendNotificationStatus.SelectedValue);
				message.Subject = textbxSubject.Text;
				if (string.IsNullOrEmpty(ddlOffsetTerm.SelectedValue))
					renewalEvent.OffsetTermID = Guid.Empty;
				else
					renewalEvent.OffsetTermID = _template.FindTerm(ddlOffsetTerm.SelectedValue).ID;
				renewalEvent.OffsetDefaultValue = int.Parse(txtOffsetDefault.Text);
				renewalEvent.BaseDateOffset = textbxOffsetDays.Text;
				message.Text = Business.Term.SubstituteTermNames(_template, edt.Html);

				message.Recipients.Clear();
				foreach (ListItem li in listbxRecipients.Items)
					if (li.Selected)
						message.Recipients.Add(li.Text);

                if (ddlFilterFacility.SelectedIndex > 0)
                {
                    string storedFilterFacility = string.Empty;
                    if (message.FilterFacilityTermID.HasValue)
                    {
                        storedFilterFacility = _template.FindTerm(message.FilterFacilityTermID.Value).Name;
                    }
                    if (storedFilterFacility != ddlFilterFacility.SelectedValue)
                    {
                        message.FilterFacilityTermID = _template.FindTerm(ddlFilterFacility.SelectedValue).ID;
                    }
                }
                else
                {
                    message.FilterFacilityTermID = null;
                }
			}

			renewalTerm.RenewalTermType = (Business.RenewalTermType)Enum.Parse(typeof(Business.RenewalTermType), ddlRenewalType.SelectedValue);

			if (renewalTerm.RenewerRoles != null)
			{
				renewalTerm.RenewerRoles.Clear();
				if (renewalTerm.RenewalTermType != Business.RenewalTermType.None)
					foreach (ListItem li in listbxRenewers.Items)
						if (li.Selected)
							renewalTerm.RenewerRoles.Add(new Business.Role(li.Text));
			}

			renewalTerm.RenewalDurationEditable = chkbxEditableRenewalDurationUnit.Checked;

			if (renewalTerm.RenewalDurationUnits != null)
			{
				renewalTerm.RenewalDurationUnits.Clear();
				foreach (ListItem li in listbxRenewalDurationUnit.Items)
				{
					if (li.Selected)
					{
						Business.DurationUnit durationUnit = new Kindred.Knect.ITAT.Business.DurationUnit();
						durationUnit.Display = li.Text;
						durationUnit.Value = li.Value;
						durationUnit.Selected =  (ddlDefaultRenewalDurationUnit.SelectedValue == li.Value);
						durationUnit.Default = (ddlDefaultRenewalDurationUnit.SelectedValue == li.Value);
						renewalTerm.RenewalDurationUnits.Add(durationUnit);
					}
				}
			}

			renewalTerm.RenewalDurationUnitCountDefault = int.Parse(textbxDefaultRenewalDuration.Text);
			renewalTerm.RenewalDurationUnitPopUpIfNot = chkbxRenewalPopUpIfNot.Checked;
			renewalTerm.RenewalDurationUnitPopUpText = textbxRenewalDurationPopup.Text;
		}
Esempio n. 2
0
        public RenewalTerm(XmlNode termNode, bool IsManagedItem, Template template, bool isFilter)
            : base(termNode, template, isFilter)
		{
			_isManagedItem = IsManagedItem;
			TermType = TermType.Renewal;
			NameRequired = true;
	
			if (template != null)
				if (template.RenewalEvent == null)
					template.Events.Add(new Event(EventType.Renewal, IsManagedItem));

			XmlNode nodeEffectiveDate = termNode.SelectSingleNode(XMLNames._E_EffectiveDate);
			XmlNode nodeExpirationDate = termNode.SelectSingleNode(XMLNames._E_ExpirationDate);
			XmlNode nodeInitialDurationUnit = termNode.SelectSingleNode(XMLNames._E_InitialDurationUnit);
			XmlNode nodeInitialDurationUnitCount = termNode.SelectSingleNode(XMLNames._E_InitialDurationUnitCount);
			XmlNode nodeRenewalDurationUnit = termNode.SelectSingleNode(XMLNames._E_RenewalDurationUnit);
			XmlNode nodeRenewalDurationUnitCount = termNode.SelectSingleNode(XMLNames._E_RenewalDurationUnitCount);
			XmlNodeList listInitialDurationUnits = termNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_InitialDurationUnit,XMLNames._E_DurationUnit));
			XmlNodeList listRenewalDurationUnits = termNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_RenewalDurationUnit,XMLNames._E_DurationUnit));

			_renewerRoles = new List<Role>();
			XmlNodeList listRenewers = termNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_Renewers, XMLNames._E_Renewer));
			if (listRenewers != null)
				foreach (XmlNode nodeRenewer in listRenewers)
				{
					_renewerRoles.Add(new Role(Utility.XMLHelper.GetAttributeString(nodeRenewer, XMLNames._A_Role)));
				}
			_renewalType = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_RenewalType);
			_popUpText = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_PopUpText);
			_allowBackDating = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_AllowBackDating);
			_renewalCount = Utility.XMLHelper.GetAttributeInt(termNode, XMLNames._A_RenewalCount);
			_renewalDurationEditable = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_RenewalDurationEditable);
			_effectiveDateFormat = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_EffectiveDateFormat);
			_expirationDateFormat = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_ExpirationDateFormat);

			try
			{
				_displayedDate = (DisplayedDate)Enum.Parse(typeof(DisplayedDate), Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_DisplayedDate));
			}
			catch
			{
				_displayedDate = DisplayedDate.ExpirationDate;
			}

			_sendNotification = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_SendNotification);
			string offsetType = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_DateOffsetType);

			try
			{
				_renewalTermType = (RenewalTermType)Enum.Parse(typeof(RenewalTermType), Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_RenewalTermType));
			}
			catch (ArgumentException)
			{
				_renewalTermType = RenewalTermType.None;
			}
			_popUpText = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_PopUpText);

			//EffectiveDate
			if (nodeEffectiveDate != null)
			{
				_effectiveDate = Utility.XMLHelper.GetValueDate(nodeEffectiveDate);
			}

			//ExpirationDate
			if (nodeExpirationDate != null)
			{
				//_expirationDate = Utility.XMLHelper.GetValueDate(nodeExpirationDate);
				_expirationDate_DBField = Utility.XMLHelper.GetAttributeString(nodeExpirationDate, XMLNames._A_DBFieldName);
			}

			//InitialDurationUnit
			if (nodeInitialDurationUnit != null)
			{
				_initialDurationUnit_PopUpIfNot = Utility.XMLHelper.GetAttributeBool(nodeInitialDurationUnit, XMLNames._A_PopUpIfNot);
				_initialDurationUnit_PopUpText = Utility.XMLHelper.GetAttributeString(nodeInitialDurationUnit, XMLNames._A_PopUpText);

				//Sub element DurationUnit_Value, Display
				if (listInitialDurationUnits != null)
				{
					_initialDurationUnits = new List<DurationUnit>(listInitialDurationUnits.Count);
					foreach (XmlNode nodeInitialDurationUnitDU in listInitialDurationUnits)
					{
						DurationUnit InitialDurationUnit = new DurationUnit(nodeInitialDurationUnitDU);
						_initialDurationUnits.Add(InitialDurationUnit);
					}
				}
			}

			//InitialDurationUnitCount
			if (nodeInitialDurationUnitCount != null)
			{
				_initialDurationUnitCountDefault = Utility.XMLHelper.GetAttributeInt(nodeInitialDurationUnitCount, XMLNames._A_Default);
				_initialDurationUnitCount = Utility.XMLHelper.GetValueInt(nodeInitialDurationUnitCount);
			}

			//RenewalDurationUnit
			if (nodeRenewalDurationUnit != null)
			{
				_renewalDurationUnit_PopUpIfNot = Utility.XMLHelper.GetAttributeBool(nodeRenewalDurationUnit, XMLNames._A_PopUpIfNot);
				_renewalDurationUnit_PopUpText = Utility.XMLHelper.GetAttributeString(nodeRenewalDurationUnit, XMLNames._A_PopUpText);

				//Sub element DurationUnit_Value, Display
				if (listRenewalDurationUnits != null)
				{
					_renewalDurationUnits = new List<DurationUnit>(listRenewalDurationUnits.Count);
					foreach (XmlNode nodeRenewalDurationUnitDU in listRenewalDurationUnits)
					{
						DurationUnit renewalDurationUnit = new DurationUnit(nodeRenewalDurationUnitDU);
						_renewalDurationUnits.Add(renewalDurationUnit);
					}
				}

			}

			//RenewalDurationUnitCount
			if (nodeRenewalDurationUnitCount != null)
			{
				_renewalDurationUnitCountDefault = Utility.XMLHelper.GetAttributeInt(nodeRenewalDurationUnitCount, XMLNames._A_Default);
				_renewalDurationUnitCount = Utility.XMLHelper.GetValueInt(nodeRenewalDurationUnitCount);
			}
		}