Example #1
0
        private void getQueryValue(ref List <QueryResultObj> qList)
        {
            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;

                        QueryResultObj qr = new QueryResultObj();
                        qr.UniqueID = pTB.RNode;
                        qr.value    = pTB.Text;
                        qList.Add(qr);
                    }
                    else if (cmp is ComboBoxEx)
                    {
                        ComboBoxEx     pTB = (ComboBoxEx)cmp;
                        QueryResultObj qr  = new QueryResultObj();
                        qr.UniqueID = pTB.RNode;
                        qr.value    = pTB.Text;
                        qList.Add(qr);
                    }
                    else if (cmp is CheckBoxEx)
                    {
                        CheckBoxEx     pTB = (CheckBoxEx)cmp;
                        QueryResultObj qr  = new QueryResultObj();
                        qr.UniqueID = pTB.RNode;
                        qr.value    = pTB.Checked;
                        qList.Add(qr);
                    }
                    #endregion
                }
            }
        }
Example #2
0
        /// <summary>
        /// 鼠标双击事件
        /// </summary>
        /// <param name="e">双击类型,左键上传,右建下载</param>
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                OpenFileDialog fd = new OpenFileDialog();
                if (fd.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        FileStream fileStream = new FileStream(fd.FileName, FileMode.Open);//文件大小限制?
                        long       abc        = fileStream.Length;
                        _ImageByte = new byte[(int)fileStream.Length];
                        fileStream.Read(_ImageByte, 0, (int)fileStream.Length);
                        fileStream.Close();
                    }
                    catch
                    {
                        MessageBox.Show("文件不存在或被占用!");
                        return;
                    }
                    MemoryStream ms = new MemoryStream(_ImageByte);
                    try
                    {
                        this.Image = Image.FromStream(ms);
                    }
                    catch
                    {
                        this.Image = (Image)Properties.Resources.ResourceManager.GetObject("file");
                        WebBrowser axWebBrowser1;
                        if (this.Tag == null)
                        {
                            axWebBrowser1 = new WebBrowser();
                            this.Tag      = axWebBrowser1;
                            this.Parent.Controls.Add(axWebBrowser1);
                        }
                        else
                        {
                            axWebBrowser1 = (WebBrowser)this.Tag;
                        }
                        axWebBrowser1.Visible = true;
                        axWebBrowser1.BringToFront();
                        System.Drawing.Point pt = this.Location;
                        pt.X += 20;
                        axWebBrowser1.Location = pt;
                        axWebBrowser1.Size     = new Size(this.Size.Width, this.Size.Height);
                        axWebBrowser1.Navigate(fd.FileName);
                    }

                    //更新文件后缀名字段
                    int dotPos = fd.FileName.LastIndexOf('.');
                    if (dotPos >= 0)
                    {
                        strFileType = fd.FileName.Substring(dotPos + 1);
                        if (pParentWin != null)
                        {
                            TabControl tc = (TabControl)(pParentWin.Parent);
                            foreach (TabPage tp in tc.TabPages)
                            {
                                IEnumerator enumerator = tp.Controls.GetEnumerator();
                                while (enumerator.MoveNext())
                                {
                                    Control cmp = (Control)enumerator.Current;
                                    if (cmp is TextBoxEx)
                                    {
                                        TextBoxEx pTB = (TextBoxEx)cmp;
                                        if (pTB.RField == RName)
                                        {
                                            pTB.Text = strFileType;
                                        }
                                    }
                                    else if (cmp is ComboBoxEx)
                                    {
                                        ComboBoxEx pTB = (ComboBoxEx)cmp;
                                        if (pTB.RField == RName)
                                        {
                                            pTB.Text = strFileType;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    this.Invalidate();
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                SaveFileDialog fd = new SaveFileDialog();

                if (strFileType.Length > 0)
                {
                    fd.DefaultExt = strFileType;
                    fd.Filter     = strFileType + "文件|*." + strFileType;
                }
                if (fd.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        string     filename = fd.FileName;
                        FileStream stream   = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Write);
                        stream.SetLength(this.ImageByte.LongLength);
                        stream.Write(this.ImageByte, 0, this.ImageByte.Length);  //将二进制文件写到指定目录
                        stream.Close();
                        MessageBox.Show("保存成功!");
                    }
                    catch
                    {
                        MessageBox.Show("保存失败!");
                    }
                }
            }
        }
Example #3
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);
        }
Example #4
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);
            }
        }
Example #5
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);
        }
Example #6
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;
                    }
                }
            }
        }
Example #7
0
        private void setQueryValue(List <QueryResultObj> qList)
        {
            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;

                        foreach (QueryResultObj qr in qList)
                        {
                            if (qr.UniqueID == pTB.RNode)
                            {
                                pTB.Text = qr.value.ToString();
                                break;
                            }
                        }
                    }
                    else if (cmp is ComboBoxEx)
                    {
                        ComboBoxEx pTB = (ComboBoxEx)cmp;
                        foreach (QueryResultObj qr in qList)
                        {
                            if (qr.UniqueID == pTB.RNode)
                            {
                                pTB.Text = qr.value.ToString();
                                break;
                            }
                        }
                        if (pTB.Items.Count > 0)
                        {
                            pTB.SelectedIndex = 0;
                        }
                    }
                    else if (cmp is CheckBoxEx)
                    {
                        CheckBoxEx pTB = (CheckBoxEx)cmp;
                        foreach (QueryResultObj qr in qList)
                        {
                            if (qr.UniqueID == pTB.RNode)
                            {
                                try
                                {
                                    pTB.Checked = Convert.ToBoolean(qr.value);
                                }
                                catch
                                {
                                    pTB.Checked = false;
                                }

                                break;
                            }
                        }
                    }
                    #endregion
                }
            }
        }