Exemple #1
0
        private void InitValues()
        {
            // Populate datasets combos
            object[] datasets = _Draw.DataSetNames;
            this.cbDefaultDataSets.Items.AddRange(datasets);
            this.cbValidDataSets.Items.AddRange(datasets);

            XmlNode rNode   = _Draw.GetReportNode();
            XmlNode rpsNode = _Draw.GetNamedChildNode(rNode, "ReportParameters");

            if (rpsNode == null)
            {
                return;
            }
            foreach (XmlNode repNode in rpsNode)
            {
                XmlAttribute nAttr = repNode.Attributes["Name"];
                if (nAttr == null)                      // shouldn't really happen
                {
                    continue;
                }
                ReportParm repParm = new ReportParm(nAttr.Value);
                repParm.DataType = _Draw.GetElementValue(repNode, "DataType", "String");
                // Get default values
                InitDefaultValues(repNode, repParm);

                string nullable = _Draw.GetElementValue(repNode, "Nullable", "false");
                repParm.AllowNull = (nullable.ToLower() == "true");
                string allowBlank = _Draw.GetElementValue(repNode, "AllowBlank", "false");
                repParm.AllowBlank = (allowBlank.ToLower() == "true");
                string mvalue = _Draw.GetElementValue(repNode, "MultiValue", "false");
                repParm.MultiValue = (mvalue.ToLower() == "true");
                repParm.Prompt     = _Draw.GetElementValue(repNode, "Prompt", "");

                InitValidValues(repNode, repParm);

                this.lbParameters.Items.Add(repParm);
            }
            if (lbParameters.Items.Count > 0)
            {
                lbParameters.SelectedIndex = 0;
            }
        }
        private void ApplyValidValues(XmlNode repNode, ReportParm repParm)
        {
            _Draw.RemoveElement(repNode, "ValidValues");
            if (repParm.Valid)
            {
                if (repParm.ValidValues == null || repParm.ValidValues.Count == 0)
                {
                    return;
                }

                XmlNode vvNode = _Draw.GetCreateNamedChildNode(repNode, "ValidValues");
                XmlNode vNodes = _Draw.GetCreateNamedChildNode(vvNode, "ParameterValues");
                // put out the parameter values
                foreach (ParameterValueItem dvi in repParm.ValidValues)
                {
                    XmlNode pvNode = _Draw.CreateElement(vNodes, "ParameterValue", null);
                    _Draw.CreateElement(pvNode, "Value", dvi.Value);
                    if (dvi.Label != null)
                    {
                        _Draw.CreateElement(pvNode, "Label", dvi.Label);
                    }
                }
            }
            else
            {
                if (repParm.ValidValuesDSRDataSetName == null || repParm.ValidValuesDSRDataSetName.Length == 0 ||
                    repParm.ValidValuesDSRValueField == null || repParm.ValidValuesDSRValueField.Length == 0)
                {
                    return;
                }
                XmlNode defNode = _Draw.GetCreateNamedChildNode(repNode, "ValidValues");
                XmlNode dsrNode = _Draw.GetCreateNamedChildNode(defNode, "DataSetReference");
                _Draw.CreateElement(dsrNode, "DataSetName", repParm.ValidValuesDSRDataSetName);
                _Draw.CreateElement(dsrNode, "ValueField", repParm.ValidValuesDSRValueField);
                if (repParm.ValidValuesDSRLabelField != null && repParm.ValidValuesDSRLabelField.Length > 0)
                {
                    _Draw.CreateElement(dsrNode, "LabelField", repParm.ValidValuesDSRLabelField);
                }
            }
        }
        private void rbDataSet_CheckedChanged(object sender, System.EventArgs e)
        {
            int cur = lbParameters.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            ReportParm rp = lbParameters.Items[cur] as ReportParm;

            if (rp == null)
            {
                return;
            }

            rp.Valid = !rbDataSet.Checked;
            this.tbParmValidValues.Enabled       = bValidValues.Enabled = !rbDataSet.Checked;
            this.cbValidDisplayField.Enabled     =
                this.cbValidFields.Enabled       =
                    this.cbValidDataSets.Enabled = rbDataSet.Checked;
        }
        private void rbDefaultDataSetName_CheckedChanged(object sender, System.EventArgs e)
        {
            int cur = lbParameters.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            ReportParm rp = lbParameters.Items[cur] as ReportParm;

            if (rp == null)
            {
                return;
            }

            rp.Default = !rbDefaultDataSetName.Checked;

            tbParmDefaultValue.Enabled           = bDefaultValues.Enabled = !rbDefaultDataSetName.Checked;
            this.cbDefaultDataSets.Enabled       =
                this.cbDefaultValueField.Enabled = rbDefaultDataSetName.Checked;
        }
        private void cbDefaultDataSets_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int cur = lbParameters.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            ReportParm rp = lbParameters.Items[cur] as ReportParm;

            if (rp == null)
            {
                return;
            }

            rp.DefaultDSRDataSetName = cbDefaultDataSets.Text;

            // Populate the fields from the selected dataset
            this.cbDefaultValueField.Items.Clear();
            string[] fields = _Draw.GetFields(cbDefaultDataSets.Text, false);
            this.cbDefaultValueField.Items.AddRange(fields);
        }
        void InitDefaultValues(XmlNode reportParameterNode, ReportParm repParm)
        {
            repParm.Default = true;
            XmlNode dfNode = _Draw.GetNamedChildNode(reportParameterNode, "DefaultValue");

            if (dfNode == null)
            {
                return;
            }

            XmlNode vNodes = _Draw.GetNamedChildNode(dfNode, "Values");

            if (vNodes != null)
            {
                List <string> al = new List <string>();
                foreach (XmlNode v in vNodes.ChildNodes)
                {
                    if (v.InnerText.Length <= 0)
                    {
                        continue;
                    }
                    al.Add(v.InnerText);
                }
                if (al.Count >= 1)
                {
                    repParm.DefaultValue = al;
                }
            }
            XmlNode dsNodes = _Draw.GetNamedChildNode(dfNode, "DataSetReference");

            if (dsNodes != null)
            {
                repParm.Default = false;
                repParm.DefaultDSRDataSetName = _Draw.GetElementValue(dsNodes, "DataSetName", "");
                repParm.DefaultDSRValueField  = _Draw.GetElementValue(dsNodes, "ValueField", "");
            }
        }
Exemple #7
0
        private void lbParameters_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int cur = lbParameters.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            ReportParm rp = lbParameters.Items[cur] as ReportParm;

            if (rp == null)
            {
                return;
            }

            tbParmName.Text           = rp.Name;
            cbParmType.Text           = rp.DataType;
            tbParmPrompt.Text         = rp.Prompt;
            tbParmDefaultValue.Text   = rp.DefaultValueDisplay;
            ckbParmAllowBlank.Checked = rp.AllowBlank;
            tbParmValidValues.Text    = rp.ValidValuesDisplay;
            ckbParmAllowNull.Checked  = rp.AllowNull;
        }
        private void bAdd_Click(object sender, System.EventArgs e)
		{
			ReportParm rp = new ReportParm("newparm");
			int cur = this.lbParameters.Items.Add(rp);
			lbParameters.SelectedIndex = cur;
			this.tbParmName.Focus();
		}
		private void ApplyValidValues(XmlNode repNode, ReportParm repParm)
		{
			_Draw.RemoveElement(repNode, "ValidValues");
			if (repParm.Valid)
			{
				if (repParm.ValidValues == null || repParm.ValidValues.Count == 0)
					return;

				XmlNode vvNode = _Draw.GetCreateNamedChildNode(repNode, "ValidValues");
				XmlNode vNodes = _Draw.GetCreateNamedChildNode(vvNode, "ParameterValues");
				// put out the parameter values
				foreach (ParameterValueItem dvi in repParm.ValidValues)
				{
					XmlNode pvNode = _Draw.CreateElement(vNodes, "ParameterValue", null);
					_Draw.CreateElement(pvNode, "Value", dvi.Value);
					if (dvi.Label != null)
						_Draw.CreateElement(pvNode, "Label", dvi.Label);
				}
			}
			else
			{
				if (repParm.ValidValuesDSRDataSetName == null || repParm.ValidValuesDSRDataSetName.Length == 0 ||
					repParm.ValidValuesDSRValueField == null || repParm.ValidValuesDSRValueField.Length == 0)
					return;
				XmlNode defNode = _Draw.GetCreateNamedChildNode(repNode, "ValidValues");
				XmlNode dsrNode = _Draw.GetCreateNamedChildNode(defNode, "DataSetReference");
				_Draw.CreateElement(dsrNode, "DataSetName", repParm.ValidValuesDSRDataSetName);
				_Draw.CreateElement(dsrNode, "ValueField", repParm.ValidValuesDSRValueField);
				if (repParm.ValidValuesDSRLabelField != null && repParm.ValidValuesDSRLabelField.Length > 0)
					_Draw.CreateElement(dsrNode, "LabelField", repParm.ValidValuesDSRLabelField);
			}
		}
		private void ApplyDefaultValues(XmlNode repNode, ReportParm repParm)
		{
			_Draw.RemoveElement(repNode, "DefaultValue");
			if (repParm.Default)
			{
				if (repParm.DefaultValue == null || repParm.DefaultValue.Count == 0)
					return;

				XmlNode defNode = _Draw.GetCreateNamedChildNode(repNode, "DefaultValue");
				XmlNode vNodes = _Draw.GetCreateNamedChildNode(defNode, "Values");
				foreach (string dv in repParm.DefaultValue)
				{
					_Draw.CreateElement(vNodes, "Value", dv);
				}
			}
			else
			{
				if (repParm.DefaultDSRDataSetName == null || repParm.DefaultDSRDataSetName.Length == 0 ||
					repParm.DefaultDSRValueField == null || repParm.DefaultDSRValueField.Length == 0)
					return;
				XmlNode defNode = _Draw.GetCreateNamedChildNode(repNode, "DefaultValue");
				XmlNode dsrNode = _Draw.GetCreateNamedChildNode(defNode, "DataSetReference");
				_Draw.CreateElement(dsrNode, "DataSetName", repParm.DefaultDSRDataSetName);
				_Draw.CreateElement(dsrNode, "ValueField", repParm.DefaultDSRValueField);
			}
		}
		private void InitValidValues(XmlNode reportParameterNode, ReportParm repParm)
		{
			repParm.Valid = true;
			XmlNode vvsNode = _Draw.GetNamedChildNode(reportParameterNode, "ValidValues");
			if (vvsNode == null)
				return;

			XmlNode vNodes = _Draw.GetNamedChildNode(vvsNode, "ParameterValues");
			if (vNodes != null)
			{
                List<ParameterValueItem> pvs = new List<ParameterValueItem>();
				foreach (XmlNode v in vNodes.ChildNodes)
				{
					if (v.Name != "ParameterValue")
						continue;
					XmlNode pv = _Draw.GetNamedChildNode(v, "Value");
					if (pv == null)
						continue;
					if (pv == null || pv.InnerText.Length <= 0)
						continue;
					ParameterValueItem pvi = new ParameterValueItem();
					pvi.Value = pv.InnerText;
					pvi.Label = _Draw.GetElementValue(v, "Label", null);
					pvs.Add(pvi);
				}
				if (pvs.Count > 0)
				{
					repParm.ValidValues = pvs;
				}
			}
			XmlNode dsNodes = _Draw.GetNamedChildNode(vvsNode, "DataSetReference");
			if (dsNodes != null)
			{
				repParm.Valid = false;
				repParm.ValidValuesDSRDataSetName = _Draw.GetElementValue(dsNodes, "DataSetName", "");
				repParm.ValidValuesDSRValueField = _Draw.GetElementValue(dsNodes, "ValueField", "");
				repParm.ValidValuesDSRLabelField = _Draw.GetElementValue(dsNodes, "LabelField", "");
			}
		}				
		private void InitDefaultValues(XmlNode reportParameterNode, ReportParm repParm)
		{
			repParm.Default = true;
			XmlNode dfNode = _Draw.GetNamedChildNode(reportParameterNode, "DefaultValue");
			if (dfNode == null)
				return;

			XmlNode vNodes = _Draw.GetNamedChildNode(dfNode, "Values");
			if (vNodes != null)
			{
				List<string> al = new List<string>();
				foreach (XmlNode v in vNodes.ChildNodes)
				{
					if (v.InnerText.Length <= 0)
						continue;
					al.Add(v.InnerText);
				}
				if (al.Count >= 1)
					repParm.DefaultValue  = al;
			}
			XmlNode dsNodes = _Draw.GetNamedChildNode(dfNode, "DataSetReference");
			if (dsNodes != null)
			{
				repParm.Default = false;
				repParm.DefaultDSRDataSetName = _Draw.GetElementValue(dsNodes, "DataSetName", "");
				repParm.DefaultDSRValueField = _Draw.GetElementValue(dsNodes, "ValueField", "");
			}
		}
        private void InitValues()
		{
			// Populate datasets combos
			object[] datasets = _Draw.DataSetNames;
			this.cbDefaultDataSets.Items.AddRange(datasets);
			this.cbValidDataSets.Items.AddRange(datasets);

			XmlNode rNode = _Draw.GetReportNode();
			XmlNode rpsNode = _Draw.GetNamedChildNode(rNode, "ReportParameters");
			if (rpsNode == null)
				return;
			foreach (XmlNode repNode in rpsNode)
			{	
				XmlAttribute nAttr = repNode.Attributes["Name"];
				if (nAttr == null)	// shouldn't really happen
					continue;
				ReportParm repParm = new ReportParm(nAttr.Value);
				repParm.DataType = _Draw.GetElementValue(repNode, "DataType", "String");
				// Get default values
				InitDefaultValues(repNode, repParm);

				string nullable  = _Draw.GetElementValue(repNode, "Nullable", "false");
				repParm.AllowNull = (nullable.ToLower() == "true"); // fyiReporting.RDL.XmlUtil can do it
				string allowBlank  = _Draw.GetElementValue(repNode, "AllowBlank", "false");
				repParm.AllowBlank = (allowBlank.ToLower() == "true");
                string mvalue = _Draw.GetElementValue(repNode, "MultiValue", "false");
                repParm.MultiValue = (mvalue.ToLower() == "true");
                repParm.Prompt = _Draw.GetElementValue(repNode, "Prompt", "");

				InitValidValues(repNode, repParm);

				this.lbParameters.Items.Add(repParm);
			}
			if (lbParameters.Items.Count > 0)
				lbParameters.SelectedIndex = 0;
		}
        private void lbParameters_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int cur = lbParameters.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            ReportParm rp = lbParameters.Items[cur] as ReportParm;

            if (rp == null)
            {
                return;
            }

            tbParmName.Text           = rp.Name;
            cbParmType.Text           = rp.DataType;
            tbParmPrompt.Text         = rp.Prompt;
            ckbParmAllowBlank.Checked = rp.AllowBlank;
            ckbParmMultiValue.Checked = rp.MultiValue;
            ckbParmAllowNull.Checked  = rp.AllowNull;
            // Handle default values
            if (rp.Default)
            {
                this.rbDefaultValues.Checked = true;
                tbParmDefaultValue.Text      = rp.DefaultValueDisplay;

                tbParmDefaultValue.Enabled             = bDefaultValues.Enabled = true;
                this.cbDefaultDataSets.Enabled         = false;
                this.cbDefaultValueField.Enabled       = false;
                this.cbDefaultDataSets.SelectedIndex   = -1;
                this.cbDefaultValueField.SelectedIndex = -1;
            }
            else
            {
                this.rbDefaultDataSetName.Checked = true;
                this.cbDefaultDataSets.Text       = rp.DefaultDSRDataSetName;
                this.cbDefaultValueField.Text     = rp.DefaultDSRValueField;

                tbParmDefaultValue.Enabled       = bDefaultValues.Enabled = false;
                tbParmDefaultValue.Text          = "";
                this.cbDefaultDataSets.Enabled   = true;
                this.cbDefaultValueField.Enabled = true;
            }
            // Handle Valid Values
            if (rp.Valid)
            {
                this.rbValues.Checked  = true;
                tbParmValidValues.Text = rp.ValidValuesDisplay;

                tbParmValidValues.Enabled                      = bValidValues.Enabled = true;
                this.cbValidDataSets.Enabled                   =
                    this.cbValidFields.Enabled                 =
                        this.cbValidDisplayField.Enabled       = false;
                this.cbValidDataSets.SelectedIndex             =
                    this.cbValidFields.SelectedIndex           =
                        this.cbValidDisplayField.SelectedIndex = -1;
            }
            else
            {
                this.rbDataSet.Checked        = true;
                this.cbValidDataSets.Text     = rp.ValidValuesDSRDataSetName;
                this.cbValidFields.Text       = rp.ValidValuesDSRValueField;
                this.cbValidDisplayField.Text = rp.ValidValuesDSRLabelField == null? "":rp.ValidValuesDSRLabelField;

                this.cbValidDataSets.Enabled             =
                    this.cbValidFields.Enabled           =
                        this.cbValidDisplayField.Enabled = true;
                tbParmValidValues.Enabled = bValidValues.Enabled = false;
                tbParmValidValues.Text    = "";
            }
        }