コード例 #1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            //
            Dictionary <string, string> lst = new Dictionary <string, string>();

            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                string name = VPLUtil.ObjectToString(dataGridView1.Rows[i].Cells[0].Value);
                string val  = VPLUtil.ObjectToString(dataGridView1.Rows[i].Cells[1].Value);
                if (!string.IsNullOrEmpty(name) || !string.IsNullOrEmpty(val))
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        name = val;
                    }
                    if (string.IsNullOrEmpty(val))
                    {
                        val = name;
                    }
                }
                if (!string.IsNullOrEmpty(name))
                {
                    lst.Add(name, val);
                }
            }
            WebDataEditorLookup de = this.SelectedEditor as WebDataEditorLookup;

            if (de == null)
            {
                de = new WebDataEditorLookup();
                this.SetSelection(de);
            }
            de.values         = lst;
            this.DialogResult = DialogResult.OK;
        }
コード例 #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            //
            List <string> lst = new List <string>();

            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                string name = VPLUtil.ObjectToString(dataGridView1.Rows[i].Cells[0].Value);
                if (!string.IsNullOrEmpty(name))
                {
                    lst.Add(name);
                }
            }
            string[] valueList = new string[lst.Count];
            lst.CopyTo(valueList, 0);
            DataEditorLookup de = this.SelectedEditor as DataEditorLookup;

            if (de == null)
            {
                de = new DataEditorLookup();
                this.SetSelection(de);
            }
            de.values         = valueList;
            this.DialogResult = DialogResult.OK;
        }
コード例 #3
0
        public void CreateHtmlContent(XmlNode node, EnumWebElementPositionType positionType, int groupId)
        {
            XmlUtil.SetAttribute(node, "tabindex", this.TabIndex);
            WebPageCompilerUtility.SetWebControlAttributes(this, node);
            for (int i = 0; i < Items.Count; i++)
            {
                string v;
                string s = VPLUtil.ObjectToString(Items[i]);
                if (!string.IsNullOrEmpty(s))
                {
                    int n = s.IndexOf('|');
                    if (n >= 0)
                    {
                        v = s.Substring(n + 1).Trim();
                        s = s.Substring(0, n).Trim();
                    }
                    else
                    {
                        v = s;
                    }
                }
                else
                {
                    v = string.Empty;
                }
                XmlElement oNode = node.OwnerDocument.CreateElement("option");
                node.AppendChild(oNode);
                XmlUtil.SetAttribute(oNode, "value", v);
                oNode.InnerText = s;
                oNode.IsEmpty   = false;
            }
            //
            StringBuilder sb = new StringBuilder();

            //
            sb.Append("background-color:");
            sb.Append(ObjectCreationCodeGen.GetColorString(this.BackColor));
            sb.Append("; ");
            //
            sb.Append("color:");
            sb.Append(ObjectCreationCodeGen.GetColorString(this.ForeColor));
            sb.Append("; ");
            //
            WebPageCompilerUtility.CreateWebElementZOrder(this.zOrder, sb);
            WebPageCompilerUtility.CreateElementPosition(this, sb, positionType);
            WebPageCompilerUtility.CreateWebElementCursor(cursor, sb, false);
            //
            if (_dataNode != null)
            {
                XmlNode pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                         "{0}[@name='Visible']", XmlTags.XML_PROPERTY));
                if (pNode != null)
                {
                    string s = pNode.InnerText;
                    if (!string.IsNullOrEmpty(s))
                    {
                        try
                        {
                            bool b = Convert.ToBoolean(s, CultureInfo.InvariantCulture);
                            if (!b)
                            {
                                sb.Append("display:none; ");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                sb.Append(ObjectCreationCodeGen.GetFontStyleString(this.Font));
                //
                pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                 "{0}[@name='disabled']", XmlTags.XML_PROPERTY));
                if (pNode != null)
                {
                    string s = pNode.InnerText;
                    if (!string.IsNullOrEmpty(s))
                    {
                        try
                        {
                            bool b = Convert.ToBoolean(s, CultureInfo.InvariantCulture);
                            if (b)
                            {
                                XmlUtil.SetAttribute(node, "disabled", "disabled");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            XmlUtil.SetAttribute(node, "style", sb.ToString());
            StringBuilder dbs = new StringBuilder();

            if (this.DataBindings != null && this.DataBindings.Count > 0)
            {
                string tbl2    = null;
                string sIdx    = string.Empty;
                string slItem  = string.Empty;
                string slValue = string.Empty;
                for (int i = 0; i < DataBindings.Count; i++)
                {
                    if (DataBindings[i].DataSource != null)
                    {
                        if (string.Compare(DataBindings[i].PropertyName, "SelectedIndex", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(DataBindings[i].PropertyName, "selectedIndex", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            sIdx = string.Format(CultureInfo.InvariantCulture, "{0}:{1}:SelectedIndex",
                                                 DataBindings[i].BindingMemberInfo.BindingPath, DataBindings[i].BindingMemberInfo.BindingMember);
                        }
                        else if (string.Compare(DataBindings[i].PropertyName, "SelectedItem", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            tbl2   = DataBindings[i].BindingMemberInfo.BindingPath;
                            slItem = DataBindings[i].BindingMemberInfo.BindingField;
                        }
                        else if (string.Compare(DataBindings[i].PropertyName, "SelectedValue", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            tbl2    = DataBindings[i].BindingMemberInfo.BindingPath;
                            slValue = DataBindings[i].BindingMemberInfo.BindingField;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(sIdx))
                {
                    dbs.Append(sIdx);
                }
                if (!string.IsNullOrEmpty(tbl2))
                {
                    if (dbs.Length > 0)
                    {
                        dbs.Append(";");
                    }
                    dbs.Append(tbl2);
                    dbs.Append(":");
                    dbs.Append(slItem);
                    dbs.Append(":");
                    dbs.Append(slValue);
                }
                if (dbs.Length > 0)
                {
                    XmlUtil.SetAttribute(node, "jsdb", dbs.ToString());
                }
                if (this.AddBlankOnDataBinding)
                {
                    XmlUtil.SetAttribute(node, "useblank", "true");
                }
            }
            //
            if (this.Items.Count == 0)
            {
                node.InnerText = "";
            }
            XmlElement xe = (XmlElement)node;

            xe.IsEmpty = false;
        }
コード例 #4
0
        public void CreateHtmlContent(XmlNode node, EnumWebElementPositionType positionType, int groupId)
        {
            XmlUtil.SetAttribute(node, "tabindex", this.TabIndex);
            WebPageCompilerUtility.SetWebControlAttributes(this, node);
            XmlNode okNode = node.OwnerDocument.CreateElement("img");

            if (this.HideButtons)
            {
                XmlUtil.SetAttribute(okNode, "style", "display:none;cursor:pointer;");
            }
            else
            {
                XmlUtil.SetAttribute(okNode, "style", "display:inline;cursor:pointer;");
            }
            XmlUtil.SetAttribute(okNode, "onclick", string.Format(CultureInfo.InvariantCulture, "document.getElementById('{0}').jsData.onOK();", CodeName));
            node.AppendChild(okNode);
            bool            b;
            string          imgFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ok.png");
            WebResourceFile wf      = new WebResourceFile(imgFile, WebResourceFile.WEBFOLDER_Images, out b);

            _resourceFiles.Add(wf);
            if (b)
            {
                imgFile = wf.ResourceFile;
            }
            XmlUtil.SetAttribute(okNode, "src", string.Format(CultureInfo.InvariantCulture, "{0}/{1}", WebResourceFile.WEBFOLDER_Images, Path.GetFileName(imgFile)));
            //
            XmlNode spaceNode = node.OwnerDocument.CreateElement("span");

            spaceNode.InnerText = " ";
            node.AppendChild(spaceNode);
            //
            XmlNode cancelNode = node.OwnerDocument.CreateElement("img");

            if (this.HideButtons)
            {
                XmlUtil.SetAttribute(cancelNode, "style", "display:none;cursor:pointer;");
            }
            else
            {
                XmlUtil.SetAttribute(cancelNode, "style", "display:inline;cursor:pointer;");
            }
            XmlUtil.SetAttribute(cancelNode, "onclick", string.Format(CultureInfo.InvariantCulture, "document.getElementById('{0}').jsData.onCancel();", CodeName));
            imgFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "cancel.png");
            wf      = new WebResourceFile(imgFile, WebResourceFile.WEBFOLDER_Images, out b);
            _resourceFiles.Add(wf);
            if (b)
            {
                imgFile = wf.ResourceFile;
            }
            XmlUtil.SetAttribute(cancelNode, "src", string.Format(CultureInfo.InvariantCulture, "{0}/{1}", WebResourceFile.WEBFOLDER_Images, Path.GetFileName(imgFile)));
            node.AppendChild(cancelNode);
            //
            spaceNode           = node.OwnerDocument.CreateElement("span");
            spaceNode.InnerText = "  ";
            node.AppendChild(spaceNode);
            //
            XmlNode chkAllNode = node.OwnerDocument.CreateElement("img");

            if (this.HideButtons)
            {
                XmlUtil.SetAttribute(chkAllNode, "style", "display:none;cursor:pointer;");
            }
            else
            {
                XmlUtil.SetAttribute(chkAllNode, "style", "display:inline;cursor:pointer;");
            }
            XmlUtil.SetAttribute(chkAllNode, "onclick", string.Format(CultureInfo.InvariantCulture, "document.getElementById('{0}').jsData.selectAll();", CodeName));
            imgFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "checkbox.png");
            wf      = new WebResourceFile(imgFile, WebResourceFile.WEBFOLDER_Images, out b);
            _resourceFiles.Add(wf);
            if (b)
            {
                imgFile = wf.ResourceFile;
            }
            XmlUtil.SetAttribute(chkAllNode, "src", string.Format(CultureInfo.InvariantCulture, "{0}/{1}", WebResourceFile.WEBFOLDER_Images, Path.GetFileName(imgFile)));
            node.AppendChild(chkAllNode);
            //
            spaceNode           = node.OwnerDocument.CreateElement("span");
            spaceNode.InnerText = "  ";
            node.AppendChild(spaceNode);
            //
            chkAllNode = node.OwnerDocument.CreateElement("img");
            if (this.HideButtons)
            {
                XmlUtil.SetAttribute(chkAllNode, "style", "display:none;cursor:pointer;");
            }
            else
            {
                XmlUtil.SetAttribute(chkAllNode, "style", "display:inline;cursor:pointer;");
            }
            XmlUtil.SetAttribute(chkAllNode, "onclick", string.Format(CultureInfo.InvariantCulture, "document.getElementById('{0}').jsData.selectNone();", CodeName));
            imgFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "box.png");
            wf      = new WebResourceFile(imgFile, WebResourceFile.WEBFOLDER_Images, out b);
            _resourceFiles.Add(wf);
            if (b)
            {
                imgFile = wf.ResourceFile;
            }
            XmlUtil.SetAttribute(chkAllNode, "src", string.Format(CultureInfo.InvariantCulture, "{0}/{1}", WebResourceFile.WEBFOLDER_Images, Path.GetFileName(imgFile)));
            node.AppendChild(chkAllNode);
            //
            XmlNode brNode = node.OwnerDocument.CreateElement("br");

            node.AppendChild(brNode);
            XmlNode lstNode = node.OwnerDocument.CreateElement("select");

            node.AppendChild(lstNode);
            XmlUtil.SetAttribute(lstNode, "id", string.Format(CultureInfo.InvariantCulture, "{0}_sel", CodeName));
            for (int i = 0; i < _listBox.Items.Count; i++)
            {
                string v;
                string s = VPLUtil.ObjectToString(_listBox.Items[i]);
                if (!string.IsNullOrEmpty(s))
                {
                    int n = s.IndexOf('|');
                    if (n >= 0)
                    {
                        v = s.Substring(n + 1).Trim();
                        s = s.Substring(0, n).Trim();
                    }
                    else
                    {
                        v = s;
                    }
                }
                else
                {
                    v = string.Empty;
                }
                XmlElement oNode = node.OwnerDocument.CreateElement("option");
                lstNode.AppendChild(oNode);
                XmlUtil.SetAttribute(oNode, "value", v);
                oNode.InnerText = s;
                oNode.IsEmpty   = false;
            }
            Graphics g  = this.CreateGraphics();
            SizeF    sf = g.MeasureString("H", this.Font);
            float    h  = (float)this.Height / sf.Height;

            XmlUtil.SetAttribute(lstNode, "size", Convert.ToInt32(h + 1));
            XmlUtil.SetAttribute(lstNode, "multiple", "multiple");
            //
            StringBuilder sblst = new StringBuilder();
            StringBuilder sb    = new StringBuilder();

            //
            sb.Append("background-color:");
            sb.Append(ObjectCreationCodeGen.GetColorString(this.BackColor));
            sb.Append("; ");
            //
            sb.Append("color:");
            sb.Append(ObjectCreationCodeGen.GetColorString(this.ForeColor));
            sb.Append("; ");
            //
            sblst.Append(sb.ToString());
            sblst.Append(ObjectCreationCodeGen.GetFontStyleString(this.Font));
            XmlUtil.SetAttribute(lstNode, "style", sblst.ToString());
            //
            WebPageCompilerUtility.CreateWebElementZOrder(this.zOrder, sb);
            WebPageCompilerUtility.CreateElementPosition(this, sb, positionType);
            WebPageCompilerUtility.CreateWebElementCursor(cursor, sb, false);
            //
            if (_dataNode != null)
            {
                XmlNode pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                         "{0}[@name='Visible']", XmlTags.XML_PROPERTY));
                if (pNode != null)
                {
                    string s = pNode.InnerText;
                    if (!string.IsNullOrEmpty(s))
                    {
                        try
                        {
                            b = Convert.ToBoolean(s, CultureInfo.InvariantCulture);
                            if (!b)
                            {
                                sb.Append("display:none; ");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                sb.Append(ObjectCreationCodeGen.GetFontStyleString(this.Font));
                //
                pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                 "{0}[@name='disabled']", XmlTags.XML_PROPERTY));
                if (pNode != null)
                {
                    string s = pNode.InnerText;
                    if (!string.IsNullOrEmpty(s))
                    {
                        try
                        {
                            b = Convert.ToBoolean(s, CultureInfo.InvariantCulture);
                            if (b)
                            {
                                XmlUtil.SetAttribute(node, "disabled", "disabled");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            XmlUtil.SetAttribute(node, "style", sb.ToString());
            //
            StringBuilder dbs = new StringBuilder();

            if (this.DataBindings != null && this.DataBindings.Count > 0)
            {
                string tbl2    = null;
                string sIdx    = string.Empty;
                string slItem  = string.Empty;
                string slValue = string.Empty;
                for (int i = 0; i < DataBindings.Count; i++)
                {
                    if (DataBindings[i].DataSource != null)
                    {
                        if (string.Compare(DataBindings[i].PropertyName, "SelectedIndex", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            sIdx = string.Format(CultureInfo.InvariantCulture, "{0}:{1}:SelectedIndex",
                                                 DataBindings[i].BindingMemberInfo.BindingPath, DataBindings[i].BindingMemberInfo.BindingMember);
                        }
                        else if (string.Compare(DataBindings[i].PropertyName, "SelectedItem", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            tbl2   = DataBindings[i].BindingMemberInfo.BindingPath;
                            slItem = DataBindings[i].BindingMemberInfo.BindingField;
                        }
                        else if (string.Compare(DataBindings[i].PropertyName, "SelectedValue", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            tbl2    = DataBindings[i].BindingMemberInfo.BindingPath;
                            slValue = DataBindings[i].BindingMemberInfo.BindingField;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(sIdx))
                {
                    dbs.Append(sIdx);
                }
                if (!string.IsNullOrEmpty(tbl2))
                {
                    if (dbs.Length > 0)
                    {
                        dbs.Append(";");
                    }
                    dbs.Append(tbl2);
                    dbs.Append(":");
                    dbs.Append(slItem);
                    dbs.Append(":");
                    dbs.Append(slValue);
                }
                if (dbs.Length > 0)
                {
                    XmlUtil.SetAttribute(lstNode, "jsdb", dbs.ToString());
                }
            }
            if (_listBox.Items.Count == 0)
            {
                lstNode.InnerText = "";
            }
            XmlElement xe = (XmlElement)lstNode;

            xe.IsEmpty = false;
        }
コード例 #5
0
        public FieldList GetFields(string tbl)
        {
            FieldList flds = null;

            if (_columns == null)
            {
                _columns = new Dictionary <string, FieldList>();
            }
            if (!_columns.TryGetValue(tbl, out flds))
            {
                if (bOpened)
                {
                    DbDataReader dr = null;

                    string sSQL;
                    sSQL = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                         "select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,COLUMN_KEY,COLUMN_TYPE, EXTRA from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '{0}' and TABLE_SCHEMA = '{1}'  order by ORDINAL_POSITION", tbl, Schema);

                    DbCommand cmd = _connection.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = sSQL;
                    try
                    {
                        if (_connection.State == System.Data.ConnectionState.Closed)
                        {
                            _connection.Open();
                        }
                        dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                        flds = new FieldList();
                        int n = 0;
                        while (dr.Read())
                        {
                            EPField fld = new EPField();
                            fld.Name          = (string)dr[0];
                            fld.Indexed       = (string.CompareOrdinal("PRI", VPLUtil.ObjectToString(dr[3])) == 0);
                            fld.Index         = n;
                            fld.FromTableName = tbl;
                            bool bUnsigned = (VPLUtil.ObjectToString(dr[4]).IndexOf("unsigned", StringComparison.OrdinalIgnoreCase) >= 0);
                            fld.OleDbType = stringToOleDbType(VPLUtil.ObjectToString(dr[1]), bUnsigned);

                            if (dr[2] != null && dr[2] != DBNull.Value)
                            {
                                fld.DataSize = VPLUtil.ObjectToInt(dr[2]);
                            }
                            fld.IsIdentity = (string.Compare("auto_increment", VPLUtil.ObjectToString(dr[5]), StringComparison.OrdinalIgnoreCase) == 0);
                            flds.Add(fld);
                            n++;
                        }
                        _columns.Add(tbl, flds);
                    }
                    finally
                    {
                        if (dr != null)
                        {
                            dr.Close();
                            dr = null;
                        }
                        if (_connection.State != System.Data.ConnectionState.Closed)
                        {
                            _connection.Close();
                        }
                    }
                }
            }
            if (flds == null)
            {
                flds = new FieldList();
            }
            return(flds);
        }
コード例 #6
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection ps   = TypeDescriptor.GetProperties(this, attributes, true);
            List <PropertyDescriptor>    list = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor p in ps)
            {
                if (IsDataOnly)
                {
                    PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), p.Name, VPLUtil.ObjectToString(p.GetValue(this)), attributes);
                    list.Add(p0);
                }
                else
                {
                    list.Add(p);
                }
            }

            ps = new PropertyDescriptorCollection(list.ToArray());
            return(ps);
        }
コード例 #7
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection ps   = TypeDescriptor.GetProperties(this, attributes, true);
            List <PropertyDescriptor>    list = new List <PropertyDescriptor>();
            bool isString = typeof(string).Equals(_type);

            if (IsDataOnly)
            {
                foreach (PropertyDescriptor p in ps)
                {
                    if ((string.CompareOrdinal(p.Name, "DefaultData") == 0) || (string.CompareOrdinal(p.Name, "DataType") == 0))
                    {
                        PropertyDescriptorForDisplay p0 = new PropertyDescriptorForDisplay(this.GetType(), p.Name, VPLUtil.ObjectToString(p.GetValue(this)), attributes);
                        list.Add(p0);
                    }
                }
            }
            else
            {
                if (isString)
                {
                    PropertyDescriptor[] a = new PropertyDescriptor[ps.Count];
                    ps.CopyTo(a, 0);
                    list.AddRange(a);
                }
                else
                {
                    //remove Encrypted if not a string value
                    foreach (PropertyDescriptor p in ps)
                    {
                        if (string.CompareOrdinal(p.Name, "Encrypted") != 0)
                        {
                            list.Add(p);
                        }
                    }
                }
            }

            PropertyInfo            pif = typeof(ConfigProperty).GetProperty("DefaultData");
            PropertyDescriptorValue pv  = new PropertyDescriptorValue("Data", attributes, pif, _type, typeof(ConfigProperty));

            list.Add(pv);
            ps = new PropertyDescriptorCollection(list.ToArray());
            return(ps);
        }