示例#1
0
        /// <summary>
        /// 2012.1.31 增加
        /// 目的:增加了成组控件后需要递归给其子控件的赋值
        /// </summary>
        /// <param name="Aim">子控件集合</param>
        /// <returns>返回处理结果</returns>
        private int SetChildrenValue(Control.ControlCollection Aim)
        {
            int result = 0;

            if (Aim == null)
            {
                return(result);
            }
            foreach (Control cmp in Aim)
            {
                if (cmp is TextBoxEx)
                {
                    TextBoxEx pTB = (TextBoxEx)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];
                        if (pd.fieldName == pTB.RField)
                        {
                            if (pd.fieldValue != null)
                            {
                                pTB.Text = pd.fieldValue.ToString();
                            }

                            break;
                        }
                    }
                }
                else if (cmp is ComboBoxEx)
                {
                    ComboBoxEx pTB = (ComboBoxEx)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];//ElementAt(i);
                        if (pd.fieldName == pTB.RField)
                        {
                            string strValue = "";
                            if (pd.fieldValue != null)
                            {
                                strValue = pd.fieldValue.ToString();
                            }
                            for (int iPos = 0; iPos < pTB.Items.Count; iPos++)
                            {
                                string strItem = (string)pTB.Items[iPos];
                                int    nPos    = strItem.IndexOf(" -> ");
                                if (nPos < 0)
                                {
                                    pTB.Text = strValue;
                                    goto ComboBoxEnd;
                                }
                                strItem = strItem.Substring(0, nPos);
                                if (strItem == strValue)
                                {
                                    pTB.SelectedIndex = iPos;
                                    goto ComboBoxEnd;
                                }
                            }
                            pTB.Text = strValue;
                            break;
                        }
                    }
                }
                else if (cmp is ForeignKeyCtrlEx)
                {
                    ForeignKeyCtrlEx pTB = (ForeignKeyCtrlEx)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];//ElementAt(i);
                        if (pd.fieldName == pTB.RField)
                        {
                            if (this._runPageData.BReplace)
                            {
                                pTB.Tag = pd.fieldValue1;
                            }
                            else
                            {
                                pTB.Tag = pd.fieldValue;
                            }

                            if (pd.fieldValue != null)
                            {
                                pTB.Text = pd.fieldValue.ToString();
                            }

                            pTB.tag1 = pd.fieldValue2;
                            break;
                        }
                    }
                }
                else if (cmp is CheckBoxEx)
                {
                    CheckBoxEx pTB = (CheckBoxEx)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];//ElementAt(i);
                        if (pd.fieldName == pTB.RField)
                        {
                            try
                            {
                                pTB.Checked = Convert.ToBoolean(pd.fieldValue);
                            }
                            catch
                            {
                                pTB.Checked = false;
                            }
                            break;
                        }
                    }
                }
                else if (cmp is RadioButtonEx)
                {
                    RadioButtonEx pTB = (RadioButtonEx)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];//ElementAt(i);
                        if (pd.fieldName == pTB.RField)
                        {
                            try
                            {
                                pTB.Checked = Convert.ToBoolean(pd.fieldValue);
                            }
                            catch
                            {
                                pTB.Checked = false;
                            }
                            break;
                        }
                    }
                }
                else if (cmp is GroupBoxEx)
                {
                    GroupBoxEx pTB = (GroupBoxEx)cmp;
                    if (pTB.Controls != null)
                    {
                        SetChildrenValue(pTB.Controls);
                    }
                }
                if (cmp is NumericUpDownEx)
                {
                    NumericUpDownEx pTB = (NumericUpDownEx)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];
                        if (pd.fieldName == pTB.RField)
                        {
                            if (pd.fieldValue != null)
                            {
                                try
                                {
                                    pTB.Value = Convert.ToDecimal(pd.fieldValue);
                                }
                                catch (System.Exception ex)
                                {
                                    PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(ex.Message);
                                }
                            }

                            break;
                        }
                    }
                }
                else if (cmp is FileDisplay)
                {
                    FileDisplay pTB = (FileDisplay)cmp;
                    for (int i = 0; i < _displayList.Count; i++)
                    {
                        PmsDisplay pd = _displayList[i];//ElementAt(i);
                        if (pd.fieldName == pTB.RField)
                        {
                            pTB.Url = pd.fileName;
                        }
                    }
                }
ComboBoxEnd:
                cmp.Invalidate();

                if (cmp is ComboBoxEx)
                {
                    ComboBoxEx pTB = (ComboBoxEx)cmp;
                    if (pTB.Items.Count > 0 && pTB.SelectedIndex < 0)
                    {
                        pTB.SelectedIndex = 0;
                    }
                }
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 2012.1.31 增加
        /// 目的:增加了成组控件后需要递归获取其子控件的值
        /// </summary>
        /// <param name="Aim">子控件集合</param>
        /// <returns>返回处理结果</returns>
        private int GetChildrenValue(Control.ControlCollection Aim)
        {
            int result = 0;

            if (Aim == null)
            {
                return(result);
            }
            if (_displayList == null)
            {
                return(result);
            }
            for (int i = 0; i < _displayList.Count; i++)
            {
                _displayList[i].bInEditList = false;
            }
            for (int i = 0; i < _displayList.Count; i++)
            {
                PmsDisplay pf    = _displayList[i];
                bool       bFind = false;
                foreach (Control cmp in Aim)
                {
                    if (cmp is TextBoxEx)
                    {
                        TextBoxEx pTB = (TextBoxEx)cmp;
                        if (pf.fieldName == pTB.RField)
                        {
                            pf.fieldValue = pTB.Text;
                            bFind         = true;
                        }
                    }
                    else if (cmp is FileDisplay)
                    {
                        FileDisplay pTB = (FileDisplay)cmp;
                        if (pf.fieldName == pTB.RField)
                        {
                            pf.fieldValue = pTB.Url;
                            bFind         = true;
                        }
                    }
                    else if (cmp is ComboBoxEx)
                    {
                        ComboBoxEx pTB = (ComboBoxEx)cmp;
                        if (pf.fieldName == pTB.RField)
                        {
                            string strValue1 = "";
                            int    nPos      = pTB.Text.IndexOf(" -> ");
                            if (nPos < 0)
                            {
                                strValue1 = pTB.Text;
                            }
                            else
                            {
                                strValue1 = pTB.Text.Substring(0, nPos);
                            }

                            pf.fieldValue = strValue1;
                            bFind         = true;
                        }
                    }
                    else if (cmp is ForeignKeyCtrlEx)
                    {
                        ForeignKeyCtrlEx pTB = (ForeignKeyCtrlEx)cmp;

                        if (pf.fieldName == pTB.RField)
                        {
                            pf.fieldValue = pTB.Tag;
                            bFind         = true;
                        }
                    }
                    else if (cmp is CheckBoxEx)
                    {
                        CheckBoxEx pTB = (CheckBoxEx)cmp;
                        if (pf.fieldName == pTB.RField)
                        {
                            string strValue1 = string.Format("{0}", pTB.Checked);
                            pf.fieldValue = strValue1;
                            bFind         = true;
                        }
                    }
                    else if (cmp is RadioButtonEx)
                    {
                        RadioButtonEx pTB = (RadioButtonEx)cmp;
                        if (pf.fieldName == pTB.RField)
                        {
                            string strValue1 = string.Format("{0}", pTB.Checked);
                            pf.fieldValue = strValue1;
                            bFind         = true;
                        }
                    }
                    else if (cmp is GroupBoxEx)
                    {
                        GroupBoxEx pTB = (GroupBoxEx)cmp;
                        if (pTB.Controls != null)
                        {
                            GetChildrenValue(pTB.Controls);
                        }
                    }
                    else if (cmp is NumericUpDownEx)
                    {
                        NumericUpDownEx pTB = (NumericUpDownEx)cmp;
                        if (pf.fieldName == pTB.RField)
                        {
                            pf.fieldValue = pTB.Value;
                            bFind         = true;
                            break;
                        }
                    }
                }
                if (bFind == true)
                {
                    pf.bInEditList = true;
                }
            }
            return(result);
        }
示例#3
0
        private void setNewValue()
        {
            if (_displayList == null)
            {
                return;
            }

            DownFile();
            try
            {
                foreach (TabPage tabPage in tabControl1.TabPages)
                {
                    foreach (Control cmp in tabPage.Controls)
                    {
                        #region textbox
                        if (cmp is TextBoxEx)
                        {
                            TextBoxEx pTB = (TextBoxEx)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];
                                if (pd.fieldName == pTB.RField)
                                {
                                    if (pd.fieldValue != null)
                                    {
                                        pTB.Text = pd.fieldValue.ToString();
                                    }

                                    break;
                                }
                            }
                        }
                        else if (cmp is ComboBoxEx)
                        {
                            ComboBoxEx pTB = (ComboBoxEx)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];//ElementAt(i);
                                if (pd.fieldName == pTB.RField)
                                {
                                    string strValue = "";
                                    if (pd.fieldValue != null)
                                    {
                                        strValue = pd.fieldValue.ToString();
                                    }
                                    for (int iPos = 0; iPos < pTB.Items.Count; iPos++)
                                    {
                                        string strItem = (string)pTB.Items[iPos];
                                        int    nPos    = strItem.IndexOf(" -> ");
                                        if (nPos < 0)
                                        {
                                            pTB.Text = strValue;
                                            goto ComboBoxEnd;
                                        }
                                        strItem = strItem.Substring(0, nPos);
                                        if (strItem == strValue)
                                        {
                                            pTB.SelectedIndex = iPos;
                                            goto ComboBoxEnd;
                                        }
                                    }
                                    pTB.Text = strValue;
                                    break;
                                }
                            }
                        }
                        else if (cmp is ForeignKeyCtrlEx)
                        {
                            ForeignKeyCtrlEx pTB = (ForeignKeyCtrlEx)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];//ElementAt(i);
                                if (pd.fieldName == pTB.RField)
                                {
                                    if (this._runPageData.BReplace)
                                    {
                                        pTB.Tag = pd.fieldValue1;
                                    }
                                    else
                                    {
                                        pTB.Tag = pd.fieldValue;
                                    }

                                    if (pd.fieldValue != null)
                                    {
                                        pTB.Text = pd.fieldValue.ToString();
                                    }

                                    pTB.tag1 = pd.fieldValue2;
                                    break;
                                }
                            }
                        }
                        else if (cmp is CheckBoxEx)
                        {
                            CheckBoxEx pTB = (CheckBoxEx)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];//ElementAt(i);
                                if (pd.fieldName == pTB.RField)
                                {
                                    try
                                    {
                                        pTB.Checked = Convert.ToBoolean(pd.fieldValue);
                                    }
                                    catch
                                    {
                                        pTB.Checked = false;
                                    }
                                    break;
                                }
                            }
                        }
                        else if (cmp is RadioButtonEx)
                        {
                            RadioButtonEx pTB = (RadioButtonEx)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];//ElementAt(i);
                                if (pd.fieldName == pTB.RField)
                                {
                                    try
                                    {
                                        pTB.Checked = Convert.ToBoolean(pd.fieldValue);
                                    }
                                    catch
                                    {
                                        pTB.Checked = false;
                                    }
                                    break;
                                }
                            }
                        }
                        else if (cmp is GroupBoxEx)
                        {
                            GroupBoxEx pTB = (GroupBoxEx)cmp;
                            if (pTB.Controls != null)
                            {
                                SetChildrenValue(pTB.Controls);
                            }
                        }
                        else if (cmp is NumericUpDownEx)
                        {
                            NumericUpDownEx pTB = (NumericUpDownEx)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];
                                if (pd.fieldName == pTB.RField)
                                {
                                    if (pd.fieldValue != null)
                                    {
                                        try
                                        {
                                            pTB.Value = Convert.ToDecimal(pd.fieldValue);
                                        }
                                        catch (System.Exception ex)
                                        {
                                            PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(ex.Message);
                                        }
                                    }

                                    break;
                                }
                            }
                        }
                        else if (cmp is FileDisplay)
                        {
                            FileDisplay pTB = (FileDisplay)cmp;
                            for (int i = 0; i < _displayList.Count; i++)
                            {
                                PmsDisplay pd = _displayList[i];//ElementAt(i);
                                if (pd.fieldName == pTB.RField)
                                {
                                    pTB.Url = pd.fileName;
                                }
                            }
                        }
ComboBoxEnd:
                        cmp.Invalidate();
                        if (cmp is ComboBoxEx)
                        {
                            ComboBoxEx pTB = (ComboBoxEx)cmp;
                            if (pTB.Items.Count > 0 && pTB.SelectedIndex < 0)
                            {
                                pTB.SelectedIndex = 0;
                            }
                        }
                        #endregion
                    }
                }
            }
            catch (Exception e)
            {
                PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(PMS.Libraries.ToolControls.PMSPublicInfo.CurrentPrjInfo.CurrentLoginUserID, "设置数据异常:" + e.Message.ToString() + "  " + e.GetBaseException().ToString(), true);
            }
        }
示例#4
0
        private void getNewValue()
        {
            if (_displayList == null)
            {
                return;
            }
            for (int i = 0; i < _displayList.Count; i++)
            {
                _displayList[i].bInEditList = false;
            }
            for (int i = 0; i < _displayList.Count; i++)
            {
                PmsDisplay pf    = _displayList[i];
                bool       bFind = false;
                foreach (TabPage tabPage in tabControl1.TabPages)
                {
                    IEnumerator enumerator = tabPage.Controls.GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        #region 取控件值
                        Control cmp = (Control)enumerator.Current;
                        if (cmp is TextBoxEx)
                        {
                            TextBoxEx pTB = (TextBoxEx)cmp;
                            if (pf.fieldName == pTB.RField)
                            {
                                pf.fieldValue = pTB.Text;
                                bFind         = true;
                                break;
                            }
                        }
                        else if (cmp is FileDisplay)
                        {
                            FileDisplay pTB = (FileDisplay)cmp;
                            if (pf.fieldName == pTB.RField)
                            {
                                pf.fieldValue = pTB.Url;
                                bFind         = true;
                                break;
                            }
                        }
                        else if (cmp is ComboBoxEx)
                        {
                            ComboBoxEx pTB = (ComboBoxEx)cmp;
                            if (pf.fieldName == pTB.RField)
                            {
                                string strValue1 = "";
                                int    nPos      = pTB.Text.IndexOf(" -> ");
                                if (nPos < 0)
                                {
                                    strValue1 = pTB.Text;
                                }
                                else
                                {
                                    strValue1 = pTB.Text.Substring(0, nPos);
                                }

                                pf.fieldValue = strValue1;
                                bFind         = true;
                                break;
                            }
                        }
                        else if (cmp is ForeignKeyCtrlEx)
                        {
                            ForeignKeyCtrlEx pTB = (ForeignKeyCtrlEx)cmp;

                            if (pf.fieldName == pTB.RField)
                            {
                                pf.fieldValue = pTB.Tag;
                                bFind         = true;
                                break;
                            }
                        }
                        else if (cmp is CheckBoxEx)
                        {
                            CheckBoxEx pTB = (CheckBoxEx)cmp;
                            if (pf.fieldName == pTB.RField)
                            {
                                string strValue1 = string.Format("{0}", pTB.Checked);
                                pf.fieldValue = strValue1;
                                bFind         = true;
                                break;
                            }
                        }
                        else if (cmp is RadioButtonEx)
                        {
                            RadioButtonEx pTB = (RadioButtonEx)cmp;
                            if (pf.fieldName == pTB.RField)
                            {
                                string strValue1 = string.Format("{0}", pTB.Checked);
                                pf.fieldValue = strValue1;
                                bFind         = true;
                                break;
                            }
                        }
                        else if (cmp is GroupBoxEx)
                        {
                            GroupBoxEx pTB = (GroupBoxEx)cmp;
                            if (pTB.Controls != null)
                            {
                                GetChildrenValue(pTB.Controls);
                            }
                        }
                        else if (cmp is NumericUpDownEx)
                        {
                            NumericUpDownEx pTB = (NumericUpDownEx)cmp;
                            if (pf.fieldName == pTB.RField)
                            {
                                pf.fieldValue = pTB.Value;
                                bFind         = true;
                                break;
                            }
                        }
                        #endregion
                    }
                    if (bFind == true)
                    {
                        pf.bInEditList = true;
                        break;
                    }
                }
            }
        }