Beispiel #1
0
        /// <summary>
        /// Binds the inner attribute group.
        /// </summary>
        /// <param name="saveSearchDoc">The save search doc.</param>
        /// <param name="SaveSearchXPATH">The save search XPATH.</param>
        private void BindInnerAttributeGroup(XmlDocument saveSearchDoc, string saveSearchXPATH)
        {
            RadioButtonList objRadioButtonList = new RadioButtonList();
            RadioButton objRadioButton = new RadioButton();
            TextBox objTextBox = new TextBox();
            ListBox objListBox = new ListBox();
            XmlNodeList xmlnodelistAttrGrp = saveSearchDoc.SelectNodes(saveSearchXPATH);
            foreach(XmlNode xmlnodeAttrGrp in xmlnodelistAttrGrp)
            {
                string strLabel;
                try
                {
                    strLabel = xmlnodeAttrGrp.Attributes.GetNamedItem(LABEL).Value.ToString();
                }
                catch(Exception)
                {
                    strLabel = string.Empty;
                }

                if(strLabel.Length > 0)
                {
                    //Loop through the page controls.
                    foreach(Control objControl in this.Controls)
                    {
                        //Loop through the page's panel control.
                        foreach(Control objChildControl in objControl.Controls)
                        {
                            //Checks for Control of RadioButton Type.
                            if(string.Equals(objChildControl.GetType().ToString(), objRadioButton.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    if((string.Equals(objChildControl.ID, "rdoLatLong")) || (string.Equals(objChildControl.ID, "rdoCRS")))
                                    {
                                        chbGeographicalSearch.Checked = true;
                                    }
                                    ((RadioButton)(objChildControl)).Checked = true;
                                    break;
                                }
                            }
                            //Checks for Control of TextBox Type.
                            if(string.Equals(objChildControl.GetType().ToString(), objTextBox.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    if(xmlnodeAttrGrp.HasChildNodes)
                                    {
                                        if(string.Equals(xmlnodeAttrGrp.FirstChild.Name, VALUE))
                                        {
                                            ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                        break;
                                    }
                                }
                            }
                            //Checks for Control of ListBox Type.
                            if(string.Equals(objChildControl.GetType().ToString(), objListBox.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    /// Set the respective check box checked and populate related listbox
                                    BindCheckBoxControl(objChildControl.ID);

                                    ((ListBox)(objChildControl)).ClearSelection();
                                    XmlNodeList xmlnodelistValue = saveSearchDoc.SelectNodes(saveSearchXPATH + "/value");
                                    //ListBox selection based on the save search XML.
                                    foreach(ListItem lstItems in ((ListBox)(objChildControl)).Items)
                                    {
                                        foreach(XmlNode xmlnodeListBoxItem in xmlnodelistValue)
                                        {
                                            if(string.Equals(xmlnodeListBoxItem.ParentNode.Attributes.GetNamedItem(LABEL).Value.ToString(), strLabel))
                                            {
                                                if(string.Equals(lstItems.Value, xmlnodeListBoxItem.InnerText))
                                                {
                                                    lstItems.Selected = true;
                                                }
                                            }
                                        }
                                    }
                                    ////if any country is selected, respective state / field needs to be loaded.
                                    //if(string.Equals(((ListBox)(objChildControl)).ID, "lstCountry"))
                                    //{
                                    //    lstCountry_SelectedIndexChanged(null, EventArgs.Empty);
                                    //    break;
                                    //}
                                    //if any state is selected, respective county needs to be loaded.
                                    if(string.Equals(((ListBox)(objChildControl)).ID, "lstState_Or_Province"))
                                    {
                                        lstState_Or_Province_SelectedIndexChanged(null, EventArgs.Empty);
                                        break;
                                    }

                                }
                            }
                            //DREAM 4.0 coutry listbox change
                            //Checks for Control of dropdownlistbox Type.
                            if(string.Equals(objChildControl.GetType().ToString(), typeof(DropDownList).ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    /// Set the respective check box checked and populate related listbox
                                    BindCheckBoxControl(objChildControl.ID);

                                    ((DropDownList)(objChildControl)).ClearSelection();
                                    XmlNodeList xmlnodelistValue = saveSearchDoc.SelectNodes(saveSearchXPATH + "/value");
                                    //ListBox selection based on the save search XML.
                                    foreach(ListItem lstItems in ((DropDownList)(objChildControl)).Items)
                                    {
                                        foreach(XmlNode xmlnodeListBoxItem in xmlnodelistValue)
                                        {
                                            if(string.Equals(xmlnodeListBoxItem.ParentNode.Attributes.GetNamedItem(LABEL).Value.ToString(), strLabel))
                                            {
                                                if(string.Equals(lstItems.Value, xmlnodeListBoxItem.InnerText))
                                                {
                                                    lstItems.Selected = true;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    //if any country is selected, respective state / field needs to be loaded.
                                    if(string.Equals(((DropDownList)(objChildControl)).ID, "lstCountry"))
                                    {
                                        lstCountry_SelectedIndexChanged(null, EventArgs.Empty);
                                    }
                                }
                            }
                            //Checks for Control of RadioButtonList Type.
                            if(string.Equals(objChildControl.GetType().ToString(), objRadioButtonList.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    int intIndex = CheckRadioButtonGroup(((RadioButtonList)(objChildControl)).ID.ToString(), saveSearchDoc, saveSearchXPATH);
                                    ((RadioButtonList)(objChildControl)).Items[intIndex].Selected = true;
                                    break;
                                }
                            }
                        }
                    }

                }
                if(xmlnodeAttrGrp.HasChildNodes)
                {
                    if(string.Equals(xmlnodeAttrGrp.FirstChild.Name.ToString(), "parameter"))
                    {
                        saveSearchXPATH = saveSearchXPATH.ToString() + "/parameter";
                        BindInnerAttributeGroup(saveSearchDoc, saveSearchXPATH);
                    }
                }
            }
        }
 /// <summary>
 /// Create attribute and funtion for textbox
 /// </summary>
 /// <param name="textBox">Textbox to set client attribute</param>
 /// <param name="Event">Event set for textbox</param>
 /// <param name="Funtion">Value of event - funtion javascript</param>
 /// <param name="ScriptFuntion">String funtion script return</param>
 public static void CreateClientScriptAttributes(TextBox textBox, string Event, string Funtion, string ScriptFuntion)
 {
     textBox.Page.ClientScript.RegisterClientScriptBlock(textBox.GetType(), textBox.ID.ToString() + "_" + Event, ScriptFuntion);
     textBox.Attributes.Add(Event, Funtion);
 }
 /// <summary>
 /// Clears the UI controls.
 /// </summary>
 protected new void ClearUIControls()
 {
     foreach (Control objControl in this.Controls)
     {
         foreach (Control objChildControl in objControl.Controls)
         {
             RadioButtonList objRadioButtonList = new RadioButtonList();
             RadioButton objRadioButton = new RadioButton();
             TextBox objTextBox = new TextBox();
             ListBox objListBox = new ListBox();
             CheckBox objCheckBox = new CheckBox();
             RadComboBox objRadCombo = new RadComboBox();
             DropDownList objDropDownList = new DropDownList();
             if (string.Equals(objChildControl.GetType().ToString(), objRadioButtonList.GetType().ToString()))
             {
                 ((RadioButtonList)(objChildControl)).SelectedIndex = 0;
             }
             if (string.Equals(objChildControl.GetType().ToString(), objRadioButton.GetType().ToString()))
             {
                 ((RadioButton)(objChildControl)).Checked = false;
             }
             if (string.Equals(objChildControl.GetType().ToString(), objTextBox.GetType().ToString()))
             {
                 ((TextBox)(objChildControl)).Text = string.Empty;
             }
             if (string.Equals(objChildControl.GetType().ToString(), objListBox.GetType().ToString()))
             {
                 ((ListBox)(objChildControl)).Items.Clear();
             }
             if (string.Equals(objChildControl.GetType().ToString(), objRadCombo.GetType().ToString()))
             {
                 //    On changing the selected Save Search, all RadCombo items are removed. Only Reset them to selected index = 0.
                 ((RadComboBox)(objChildControl)).SelectedIndex = 0;
                 // Clear only Lithology Secondary RadCombo if Lithology Main selected index = 0;
                 if (((RadComboBox)(objChildControl)).ID.Equals(radCboLithologySecondary.ID))
                 {
                     if (radCboLithologyMain.SelectedIndex == 0)
                     {
                         radCboLithologySecondary.Items.Clear();
                     }
                 }
             }
             if (string.Equals(objChildControl.GetType().ToString(), objCheckBox.GetType().ToString()))
             {
                 ((CheckBox)(objChildControl)).Checked = false;
             }
             /// All DropDown Controls set only selected index = 0, should not clear items
             if (string.Equals(objChildControl.GetType().ToString(), objDropDownList.GetType().ToString()))
             {
                 ((DropDownList)(objChildControl)).SelectedIndex = 0;
             }
         }
     }
 }
Beispiel #4
0
        /// <summary>
        /// 取得Control对应的xml
        /// </summary>
        /// <param name="item">blockfielditem</param>
        /// <param name="tableName">tablename</param>
        /// <param name="id">控件的id</param>
        /// <returns>xml</returns>
        private string GetControlXml(TBlockFieldItem item, string tableName, ref string id)
        {
            WebControl control = null;
            PropertyInfo info = null;

            #region DropDownList
            if (string.Compare(item.ControlType, "combobox", true) == 0)
            {
                control = new WebDropDownList();
                control.ID = string.Format("{0}DropDownList", item.DataField);
                control.Width = new Unit(130, UnitType.Pixel);
                (control as WebDropDownList).DataSourceID = GenWebDataSource(item, tableName, "ComboBox", string.Empty);
                (control as WebDropDownList).DataMember = item.ComboEntityName;
                (control as WebDropDownList).DataTextField = item.ComboTextField;
                (control as WebDropDownList).DataValueField = item.ComboValueField;
                info = control.GetType().GetProperty("SelectedValue");
            }
            #endregion

            #region RefVal
            else if (string.Compare(item.ControlType, "refvalbox", true) == 0)
            {
            #warning GenWebDataSource未完成FSYS_REFVAL部分
                control = new WebRefVal();
                control.ID = string.Format("{0}RefVal", item.DataField);
                if (!string.IsNullOrEmpty(item.RefValNo) || (item.RefField != null))
                {
                    (control as WebRefVal).DataSourceID = GenWebDataSource(item, tableName, "RefVal", string.Empty);
                    (control as WebRefVal).DataBindingField = item.DataField;
                    (control as WebRefVal).DataTextField = FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
                    (control as WebRefVal).DataValueField = FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
                    if (!string.IsNullOrEmpty(item.RefValNo))
                    {
                        IDbConnection conn = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, false);
                        InfoCommand command = new InfoCommand(FClientData.DatabaseType);
                        command.Connection = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, true);
                        //command.Connection = conn;
                        command.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", item.RefValNo);
                        IDbDataAdapter adapter = WzdUtils.AllocateDataAdapter(FClientData.DatabaseType);
                        adapter.SelectCommand = command.GetInternalCommand();
                        DataSet dataset = new DataSet();
                        WzdUtils.FillDataAdapter(FClientData.DatabaseType, adapter, dataset, item.RefValNo);
                        if (dataset != null && dataset.Tables.Count > 0 && dataset.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow DR in dataset.Tables[0].Rows)
                            {
                                WebRefColumn refcolumn = new WebRefColumn();
                                refcolumn.ColumnName = DR["FIELD_NAME"].ToString();
                                refcolumn.HeadText = DR["HEADER_TEXT"].ToString();
                                refcolumn.Width = 100;
                                (control as WebRefVal).Columns.Add(refcolumn);
                            }
                        }
                    }
                    info = control.GetType().GetProperty("BindingValue");
                }
                else
                {
                    control = new TextBox();
                    control.ID = string.Format("{0}TextBox", item.DataField);
                    (control as TextBox).MaxLength = item.Length;
                    info = control.GetType().GetProperty("Text");
                }

            }
            #endregion

            #region DateTimePicker
            else if (string.Compare(item.ControlType, "datetimebox", true) == 0)
            {
                control = new WebDateTimePicker();
                control.ID = string.Format("{0}DateTimePicker", item.DataField);
                (control as WebDateTimePicker).MaxLength = item.Length;
                if (string.IsNullOrEmpty(item.EditMask))
                {
                    (control as WebDateTimePicker).DateFormat = dateFormat.ShortDate;
                }
                if (item.DataType == typeof(DateTime))
                {
                    info = control.GetType().GetProperty("Text");
                }
                else if (item.DataType == typeof(string))
                {
                    (control as WebDateTimePicker).DateTimeType = dateTimeType.VarChar;
                    info = control.GetType().GetProperty("DataString");
                }
            }
            #endregion

            #region ValidateBox
            else if (string.Compare(item.ControlType, "validatebox", true) == 0)
            {
                control = new WebValidateBox();
                control.ID = string.Format("{0}ValidateBox", item.DataField);
                (control as WebValidateBox).WebValidateID = string.Format("wv{0}", tableName);
                (control as WebValidateBox).ValidateField = item.DataField;
                (control as WebValidateBox).MaxLength = item.Length;
                info = control.GetType().GetProperty("Text");
            }
            #endregion

            #region CheckBox
            else if (string.Compare(item.ControlType, "checkbox", true) == 0)
            {
                control = new CheckBox();
                control.ID = string.Format("{0}CheckBox", item.DataField);
                info = control.GetType().GetProperty("Checked");
            }
            #endregion

            #region TextBox
            else
            {
                control = new TextBox();
                control.ID = string.Format("{0}TextBox", item.DataField);
                (control as TextBox).MaxLength = item.Length;
                info = control.GetType().GetProperty("Text");
            }
            #endregion

            control.ID = string.Format("{0}{1}", control.ID, id);
            id = control.ID;
            item.EditMask = FormatEditMask(item.EditMask);
            return GetControlXml(control, info, item.DataField, item.EditMask);
        }
Beispiel #5
0
        /// <summary>
        /// Clears the UI controls.
        /// </summary>
        protected void ClearUIControls()
        {
            foreach(Control objControl in this.Controls)
            {
                foreach(Control objChildControl in objControl.Controls)
                {
                    RadioButtonList objRadioButtonList = new RadioButtonList();
                    RadioButton objRadioButton = new RadioButton();
                    TextBox objTextBox = new TextBox();
                    ListBox objListBox = new ListBox();
                    CheckBox objCheckBox = new CheckBox();
                    RadComboBox objRadComboBox = new RadComboBox();
                    DropDownList objDropDownList = new DropDownList();
                    if(string.Equals(objChildControl.GetType().ToString(), objRadioButtonList.GetType().ToString()))
                    {
                        foreach(ListItem lstRadioItem in ((RadioButtonList)(objChildControl)).Items)
                        {
                            lstRadioItem.Selected = false;
                        }
                    }
                    if(string.Equals(objChildControl.GetType().ToString(), objRadioButton.GetType().ToString()))
                    {
                        ((RadioButton)(objChildControl)).Checked = false;
                    }
                    if(string.Equals(objChildControl.GetType().ToString(), objTextBox.GetType().ToString()))
                    {
                        ((TextBox)(objChildControl)).Text = string.Empty;
                    }
                    if(string.Equals(objChildControl.GetType().ToString(), objListBox.GetType().ToString()))
                    {
                        ((ListBox)(objChildControl)).Items.Clear();
                    }
                    if(string.Equals(objChildControl.GetType().ToString(), objCheckBox.GetType().ToString()))
                    {
                        ((CheckBox)(objChildControl)).Checked = false;
                    }

                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Binds the attribute group.
        /// </summary>
        /// <param name="saveSearchDoc">The save search doc.</param>
        /// <param name="SaveSearchXPATH">The save search XPATH.</param>
        private void BindAttributeGroup(XmlDocument saveSearchDoc, string saveSearchXPATH)
        {
            string strLabel;
            TextBox objTextBox = new TextBox();
            ListBox objListBox = new ListBox();
            RadioButton objRadioButton = new RadioButton();
            #region  SRP Code
            DropDownList objDropdownList = new DropDownList();
            RadComboBox objRadComboBox = new RadComboBox();
            RadioButtonList objRadioButtonList = new RadioButtonList();
            HiddenField objHiddenField = new HiddenField();
            #endregion
            XmlNodeList xmlnodelistAttrGrp = saveSearchDoc.SelectNodes(saveSearchXPATH);
            //loop through the save search XML.
            foreach(XmlNode xmlnodeAttrGrp in xmlnodelistAttrGrp)
            {
                try
                {
                    //Get the Control label.
                    strLabel = xmlnodeAttrGrp.Attributes.GetNamedItem(LABEL).Value.ToString();
                }
                catch(Exception)
                {
                    strLabel = string.Empty;
                }
                if(strLabel.Length > 0)
                {
                    //Loop through the controls in page.
                    foreach(Control objControl in this.Controls)
                    {
                        //Loop through the controls in the page's panel.
                        foreach(Control objChildControl in objControl.Controls)
                        {
                            #region RadioButton Control
                            //Checks whether the control is a radio button or not.
                            if(string.Compare(objChildControl.GetType().ToString(), objRadioButton.GetType().ToString()) == 0)
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    ((RadioButton)(objChildControl)).Checked = true;
                                }
                            }
                            #endregion RadioButton Control

                            #region TextBox Control
                            //Check for TextBox controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objTextBox.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                }
                            }
                            #endregion TextBox Control

                            #region ListBox Control
                            //Checks whether the control is a List Box or not.
                            if(string.Compare(objChildControl.GetType().ToString(), objListBox.GetType().ToString()) == 0)
                            {
                                //Checks whether the Id matches with the Label.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    ((ListBox)(objChildControl)).ClearSelection();
                                    XmlNodeList xmlnodelistValue = saveSearchDoc.SelectNodes(saveSearchXPATH + "/value");
                                    //Modification done for Field Issue.
                                    if(!string.Equals(xmlnodeAttrGrp.Attributes.GetNamedItem(CHECKED).Value.ToString(), FALSE))
                                    {
                                        //Loop through the items in the list.
                                        foreach(ListItem lstItems in ((ListBox)(objChildControl)).Items)
                                        {
                                            foreach(XmlNode xmlnodeListBoxItem in xmlnodelistValue)
                                            {
                                                if(string.Compare(xmlnodeListBoxItem.ParentNode.Attributes.GetNamedItem(LABEL).Value.ToString(), strLabel) == 0)
                                                {
                                                    //check for the item text and if the value matches then that item will be selected.
                                                    if(string.Compare(lstItems.Value, xmlnodeListBoxItem.InnerText) == 0)
                                                    {
                                                        lstItems.Selected = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion ListBox Control

                            #region DropDownList Control

                            //Check for Drop controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objDropdownList.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    //Loop through the items in the list.
                                    foreach(ListItem lstItem in ((DropDownList)(objChildControl)).Items)
                                    {
                                        if(string.Compare(lstItem.Value, objvalue) == 0)
                                        {
                                            ((DropDownList)(objChildControl)).SelectedValue = lstItem.Value;
                                        }

                                    }
                                }
                            }
                            #endregion DropDownList Control

                            #region RadioButtonList Control
                            //check for readio button list
                            if(string.Compare(objChildControl.GetType().ToString(), objRadioButtonList.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    //Loop through the items in the list.
                                    foreach(ListItem lstItem in ((RadioButtonList)(objChildControl)).Items)
                                    {
                                        if(string.Compare(lstItem.Value, objvalue) == 0)
                                        {
                                            ((RadioButtonList)(objChildControl)).SelectedValue = lstItem.Value;
                                        }

                                    }
                                }
                            }

                            #endregion RadioButtonList Control

                            #region RadComboBox Control
                            //Check for RadComboBox in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objRadComboBox.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    if(!string.IsNullOrEmpty(objvalue) && objvalue.Contains(";"))
                                    {
                                        RadComboBoxItem item = new RadComboBoxItem(objvalue.Split(";".ToCharArray())[0], objvalue.Split(";".ToCharArray())[1]);
                                        ((RadComboBox)(objChildControl)).Items.Add(item);
                                        ((RadComboBox)(objChildControl)).SelectedValue = item.Value;
                                        ((RadComboBox)(objChildControl)).Text = item.Text;
                                    }
                                }
                            }
                            #endregion RadComboBox Control

                            #region Hidden Control
                            //Check for TextBox controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objHiddenField.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        ((HiddenField)(objChildControl)).Value = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        ((HiddenField)(objChildControl)).Value = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                }
                            }
                            #endregion Hidden Control
                        }
                    }
                }
                //If the xmlnode has childnodes then process repeats for childnodes also.
                if(xmlnodeAttrGrp.HasChildNodes)
                {
                    //This will change the XPATH by adding Attributegroup.
                    if(string.Equals(xmlnodeAttrGrp.FirstChild.Name.ToString(), ATTRIBUTEGROUP))
                    {
                        saveSearchXPATH = saveSearchXPATH.ToString() + SINGLEATTRIBUTEGROUPXPATH;
                        BindAttributeGroup(saveSearchDoc, saveSearchXPATH);
                    }
                    //This will change the XPATH by adding Attribute.
                    else if(string.Equals(xmlnodeAttrGrp.FirstChild.Name.ToString(), ATTRIBUTE))
                    {
                        if(string.Equals(xmlnodeAttrGrp.FirstChild.FirstChild.Name.ToString(), VALUE))
                        {
                            saveSearchXPATH = saveSearchXPATH.ToString() + ATTRIBUTEXPATH;
                            BindInnerAttributeGroup(saveSearchDoc, saveSearchXPATH);
                            saveSearchXPATH = ATTRIBUTEGROUPXPATH;
                        }
                        else if(string.Equals(xmlnodeAttrGrp.FirstChild.FirstChild.Name.ToString(), PARAMETER))
                        {
                            saveSearchXPATH = saveSearchXPATH.ToString() + ATTRIBUTEXPATH;
                            BindInnerAttributeGroup(saveSearchDoc, saveSearchXPATH);
                            saveSearchXPATH = ATTRIBUTEGROUPXPATH;
                        }
                    }
                }
            }
            //Checks whether the XmlnodeList do not have any xmlNode.
            if(xmlnodelistAttrGrp.Count == 0)
            {
                XmlNodeList xmlnodelistAttrGrps = saveSearchDoc.SelectNodes(ATTRIBUTEXPATH);
                XmlNode xmlnodeAttrGrp = xmlnodelistAttrGrps.Item(0);
                strLabel = xmlnodeAttrGrp.Attributes.GetNamedItem(LABEL).Value.ToString();
                if(strLabel.Length > 0)
                {
                    foreach(Control objControl in this.Controls)
                    {
                        foreach(Control objChildControl in objControl.Controls)
                        {
                            #region Radio Button
                            if(string.Compare(objChildControl.GetType().ToString(), objRadioButton.GetType().ToString()) == 0)
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    ((RadioButton)(objChildControl)).Checked = true;
                                }
                            }
                            #endregion Radio Button

                            #region TextBox Control
                            //Check for TextBox controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objTextBox.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                }
                            }
                            #endregion TextBox Control

                            #region ListBox Control
                            //Check for ListBox type controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objListBox.GetType().ToString()) == 0)
                            {
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    ((ListBox)(objChildControl)).ClearSelection();
                                    XmlNodeList xmlnodelistValue = saveSearchDoc.SelectNodes(saveSearchXPATH + "/value");
                                    if(!string.Equals(xmlnodeAttrGrp.Attributes.GetNamedItem(CHECKED).Value.ToString(), FALSE))
                                    {
                                        //Loop through the items in the list.
                                        foreach(ListItem lstItems in ((ListBox)(objChildControl)).Items)
                                        {
                                            foreach(XmlNode xmlnodeListBoxItem in xmlnodelistValue)
                                            {
                                                //check for the item text and if the value matches then that item will be selected.
                                                if(string.Compare(xmlnodeListBoxItem.ParentNode.Attributes.GetNamedItem(LABEL).Value.ToString(), strLabel) == 0)
                                                {
                                                    if(string.Compare(lstItems.Value, xmlnodeListBoxItem.InnerText) == 0)
                                                    {
                                                        lstItems.Selected = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion ListBox Control

                            #region DropDownList Control

                            //Check for Drop controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objDropdownList.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    //Loop through the items in the list.
                                    foreach(ListItem lstItem in ((DropDownList)(objChildControl)).Items)
                                    {
                                        if(string.Compare(lstItem.Value, objvalue) == 0)
                                        {
                                            ((DropDownList)(objChildControl)).SelectedValue = lstItem.Value;
                                        }

                                    }
                                }
                            }
                            #endregion DropDownList Control

                            #region RadioButtonList Control
                            //check for readio button list
                            if(string.Compare(objChildControl.GetType().ToString(), objRadioButtonList.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    //Loop through the items in the list.
                                    foreach(ListItem lstItem in ((RadioButtonList)(objChildControl)).Items)
                                    {
                                        if(string.Compare(lstItem.Value, objvalue) == 0)
                                        {
                                            ((RadioButtonList)(objChildControl)).SelectedValue = lstItem.Value;
                                        }

                                    }
                                }
                            }
                            #endregion RadioButtonList Control

                            #region RadComboBox Control
                            //Check for RadComboBox in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objRadComboBox.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    if(!string.IsNullOrEmpty(objvalue) && objvalue.Contains(";"))
                                    {
                                        RadComboBoxItem item = new RadComboBoxItem(objvalue.Split(";".ToCharArray())[0], objvalue.Split(";".ToCharArray())[1]);
                                        ((RadComboBox)(objChildControl)).Items.Add(item);
                                        ((RadComboBox)(objChildControl)).SelectedValue = item.Value;
                                        ((RadComboBox)(objChildControl)).Text = item.Text;
                                    }
                                }
                            }

                            #endregion RadComboBox Control

                            #region Hidden Control
                            //Check for TextBox controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objHiddenField.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        ((HiddenField)(objChildControl)).Value = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        ((HiddenField)(objChildControl)).Value = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                }
                            }
                            #endregion Hidden Control

                        }
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Binds the inner attribute group.
        /// </summary>
        /// <param name="saveSearchDoc">The save search doc.</param>
        /// <param name="SaveSearchXPATH">The save search XPATH.</param>
        private void BindInnerAttributeGroup(XmlDocument saveSearchDoc, string saveSearchXPATH)
        {
            XmlNodeList xmlnodelistAttrGrp = saveSearchDoc.SelectNodes(saveSearchXPATH);
            foreach(XmlNode xmlnodeAttrGrp in xmlnodelistAttrGrp)
            {
                string strLabel = string.Empty;
                try
                {
                    strLabel = xmlnodeAttrGrp.Attributes.GetNamedItem(LABEL).Value.ToString();
                }
                catch(Exception)
                {
                    strLabel = string.Empty;
                }
                if(strLabel.Length > 0)
                {
                    foreach(Control objControl in this.Controls)
                    {
                        foreach(Control objChildControl in objControl.Controls)
                        {
                            RadioButton objRadioButton = new RadioButton();
                            TextBox objTextBox = new TextBox();
                            ListBox objListBox = new ListBox();
                            // SRP Code
                            DropDownList objDropdownList = new DropDownList();
                            RadComboBox objRadComboBox = new RadComboBox();
                            RadioButtonList objRadioButtonList = new RadioButtonList();
                            HiddenField objHiddenField = new HiddenField();
                            if(objChildControl.ID != null)
                            {
                                //Checks whether the ID is Equal to trDates row.
                                if(string.Equals(objChildControl.ID.ToString(), "trDates"))
                                {
                                    foreach(Control objDateControl in objChildControl.Controls)
                                    {
                                        foreach(Control objDatesControl in objDateControl.Controls)
                                        {
                                            #region TextBox Control
                                            //Checks for control type as TextBox.
                                            if(string.Equals(objDatesControl.GetType().ToString(), objTextBox.GetType().ToString()))
                                            {
                                                if(string.Equals(objDatesControl.ID, strLabel))
                                                {
                                                    if(xmlnodeAttrGrp.HasChildNodes)
                                                    {
                                                        if(string.Equals(xmlnodeAttrGrp.FirstChild.Name, VALUE))
                                                        {
                                                            ((TextBox)(objDatesControl)).Text = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ((TextBox)(objDatesControl)).Text = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                                    }
                                                }
                                            }
                                            #endregion TextBox Control
                                        }
                                    }
                                }
                            }
                            #region RadioButton Control
                            //Checks for control type as RadioButton.
                            if(string.Equals(objChildControl.GetType().ToString(), objRadioButton.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    ((RadioButton)(objChildControl)).Checked = true;
                                }
                            }
                            #endregion RadioButton Control

                            #region ListBox Control
                            //Check for ListBox type controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objListBox.GetType().ToString()) == 0)
                            {
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    ((ListBox)(objChildControl)).ClearSelection();
                                    XmlNodeList xmlnodelistValue = saveSearchDoc.SelectNodes(saveSearchXPATH + "/value");
                                    if(!string.Equals(xmlnodeAttrGrp.Attributes.GetNamedItem(CHECKED).Value.ToString(), FALSE))
                                    {
                                        //Loop through the items in the list.
                                        foreach(ListItem lstItems in ((ListBox)(objChildControl)).Items)
                                        {
                                            foreach(XmlNode xmlnodeListBoxItem in xmlnodelistValue)
                                            {
                                                //check for the item text and if the value matches then that item will be selected.
                                                if(string.Compare(xmlnodeListBoxItem.ParentNode.Attributes.GetNamedItem(LABEL).Value.ToString(), strLabel) == 0)
                                                {
                                                    if(string.Compare(lstItems.Value, xmlnodeListBoxItem.InnerText) == 0)
                                                    {
                                                        lstItems.Selected = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion ListBox Control

                            #region TextBox Control
                            //Checks for control type as TextBox.
                            if(string.Equals(objChildControl.GetType().ToString(), objTextBox.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    if(xmlnodeAttrGrp.HasChildNodes)
                                    {
                                        if(string.Equals(xmlnodeAttrGrp.FirstChild.Name, VALUE))
                                        {
                                            ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                        }
                                    }
                                    else
                                    {
                                        ((TextBox)(objChildControl)).Text = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }

                                }
                            }
                            #endregion TextBox Control

                            #region DropDownList Control

                            //Check for Drop controls in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objDropdownList.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    //Loop through the items in the list.
                                    foreach(ListItem lstItem in ((DropDownList)(objChildControl)).Items)
                                    {
                                        //Added in DREAM 4.0 for changing country listbox to  ddl
                                        if(objChildControl.ID.Equals("lstCountry"))
                                        {
                                            ((DropDownList)(objChildControl)).SelectedValue = objvalue;
                                        }
                                        if(string.Compare(lstItem.Text, objvalue) == 0)
                                        {
                                            ///<TODO>
                                            /// Change this code by modifying as below
                                            /// Use FindByText and FindByValue function to find and set selected item
                                            /// </TODO>

                                            /// This if Condition for SRP Controls. The below dropdowns are having different value for "Text" and "Value".
                                            /// Selected Text is saved in "Saved Search". Should be set based on Text
                                            if(strLabel.Equals("cboReserveMagOil") || strLabel.Equals("cboReserveMagGas") || strLabel.Equals("cboTectonicSetting") || strLabel.Equals("cboTectonicSettingKle") || strLabel.Equals("cboHydrocarbonMain"))
                                            {
                                                ((DropDownList)(objChildControl)).ClearSelection();
                                                ((DropDownList)(objChildControl)).Items.FindByText(lstItem.Text).Selected = true;
                                            }
                                            else
                                            {
                                                ((DropDownList)(objChildControl)).SelectedValue = lstItem.Text;
                                            }
                                        }

                                    }
                                }
                            }
                            #endregion DropDownList Control

                            #region RadioButtonList Control
                            //check for readio button list
                            if(string.Compare(objChildControl.GetType().ToString(), objRadioButtonList.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    //Loop through the items in the list.
                                    foreach(ListItem lstItem in ((RadioButtonList)(objChildControl)).Items)
                                    {
                                        if(string.Compare(lstItem.Value, objvalue) == 0)
                                        {
                                            ((RadioButtonList)(objChildControl)).SelectedValue = lstItem.Value;
                                        }

                                    }
                                }
                            }
                            #endregion RadioButtonList Control

                            #region RadComboBox Control
                            //Check for RadComboBox in the list.
                            if(string.Compare(objChildControl.GetType().ToString(), objRadComboBox.GetType().ToString()) == 0)
                            {
                                //if the Control ID matches then it will assign the value.
                                if(string.Compare(objChildControl.ID, strLabel) == 0)
                                {
                                    string objvalue = string.Empty;

                                    if(string.Compare(xmlnodeAttrGrp.FirstChild.Name, VALUE) == 0)
                                    {
                                        objvalue = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                    }
                                    else
                                    {
                                        objvalue = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }
                                    if(!string.IsNullOrEmpty(objvalue) && objvalue.Contains(";"))
                                    {

                                        RadComboBoxItem item = new RadComboBoxItem(objvalue.Split(";".ToCharArray())[0], objvalue.Split(";".ToCharArray())[1]);

                                        ((RadComboBox)(objChildControl)).Items.Add(item);

                                        ((RadComboBox)(objChildControl)).SelectedValue = item.Value;
                                        ((RadComboBox)(objChildControl)).Text = item.Text;

                                    }
                                    else
                                    {
                                        RadComboBoxItem item = new RadComboBoxItem(objvalue);

                                        ((RadComboBox)(objChildControl)).Items.Add(item);
                                        if(((RadComboBox)(objChildControl)).FindItemByText(objvalue) != null)
                                        {
                                            ((RadComboBox)(objChildControl)).FindItemByText(objvalue).Selected = true;
                                        }
                                        ((RadComboBox)(objChildControl)).Text = item.Text;
                                    }

                                }
                            }
                            #endregion RadComboBox Control

                            #region Hidden Control
                            //Checks for control type as TextBox.
                            if(string.Equals(objChildControl.GetType().ToString(), objHiddenField.GetType().ToString()))
                            {
                                if(string.Equals(objChildControl.ID, strLabel))
                                {
                                    if(xmlnodeAttrGrp.HasChildNodes)
                                    {
                                        if(string.Equals(xmlnodeAttrGrp.FirstChild.Name, VALUE))
                                        {
                                            ((HiddenField)(objChildControl)).Value = xmlnodeAttrGrp.FirstChild.InnerText.ToString();
                                        }
                                    }
                                    else
                                    {
                                        ((HiddenField)(objChildControl)).Value = xmlnodeAttrGrp.Attributes.GetNamedItem(VALUE).Value.ToString();
                                    }

                                }
                            }
                            #endregion Hidden Control
                        }
                    }
                }
                //Checks whether the Xml node has some more Child nodes or not.
                if(xmlnodeAttrGrp.HasChildNodes)
                {
                    if(string.Equals(xmlnodeAttrGrp.FirstChild.Name.ToString(), PARAMETER))
                    {
                        saveSearchXPATH = saveSearchXPATH.ToString() + PARAMETERXPATH;
                        BindInnerAttributeGroup(saveSearchDoc, saveSearchXPATH);
                    }
                }
            }
        }
Beispiel #8
0
        private static TextBox getTextControl(FormField param, string currentValue, string defaultCssClass)
        {
            TextBox ctrl = new TextBox();
            ctrl.ID = ctrl.GetType().Name + param.Name;
            ctrl.ToolTip = param.Description;
            ctrl.Style.Value = param.CssStyle;
            ctrl.CssClass = defaultCssClass + " " + param.CssClass;
            if (string.IsNullOrEmpty(currentValue))
                ctrl.Text = param.DefaultValue;
            else
                ctrl.Text = currentValue;
            if (param.Rows > 0) //textarea
            {
                ctrl.TextMode = TextBoxMode.MultiLine;
                ctrl.Rows = param.Rows;
                if (param.Cols > 0) ctrl.Columns = param.Cols;

            }
            //txt1.MaxLength = 50;
            //txt1.Width = new Unit(255);
            return ctrl;
        }
Beispiel #9
0
        private static string getControlValue(FormField currField, Control container)
        {
            string res = "";
            switch (currField.Type)
            {
                case FormFieldTypeEnum.Text:
                case FormFieldTypeEnum.Numeric:
                {
                    var t1 = new TextBox();
                    t1 = Utility.FindControlRecursive<TextBox>(container, t1.GetType().Name + currField.Name);
                    if (t1 != null)
                        res = t1.Text;
                }
                break;

                case FormFieldTypeEnum.Html:
                {
                    //var t1 = new FCKeditor();
                    var t1 = new TextBox();
                    t1 = Utility.FindControlRecursive<TextBox /*FCKeditor*/>(container, t1.GetType().Name + currField.Name);
                    if (t1 != null)
                        res = t1.Text;
                }
                break;

                case FormFieldTypeEnum.Combo:
                {
                    var t1 = new DropDownList();
                    t1 = Utility.FindControlRecursive<DropDownList>(container, t1.GetType().Name + currField.Name);
                    if (t1 != null)
                        res = t1.SelectedValue;
                }
                break;

                case FormFieldTypeEnum.Hidden:
                case FormFieldTypeEnum.Error:
                {
                    var t1 = new HiddenField();
                    t1 = Utility.FindControlRecursive<HiddenField>(container, t1.GetType().Name + currField.Name);
                    if (t1 != null)
                        res = t1.Value;
                }
                break;
            }
            return res;
        }