public List<AttributeNode> GetSystemAttr(int pid, int Type)
 {
     string sql = "select * from Detail_SystemAttr where pid = " + pid + " and type =" + Type;
     DataTable dt = dbHelper.ExecuteDataTable(sql, null);
     List<AttributeNode> list = new List<AttributeNode>();
     foreach (DataRow row in dt.Rows)
     {
         AttributeNode kw = new AttributeNode();
         kw.Data = JsonConvert.FromJson<Soomes.Attribute>((string)row["data"]);
         kw.Nodes = JsonConvert.FromJson<List<AttributeNode>>((string)row["nodes"]);
         list.Add(kw);
     }
     return list;
 }
Beispiel #2
0
        private void LoadSystemAttributes(AttributeNode attrNode, ref int height, ref int tabIndex)
        {
            Label label = new System.Windows.Forms.Label();
            label.AutoSize = true;
            label.Location = new System.Drawing.Point(20, height);
            label.Name = attrNode.Data.Id+"-label";
            label.Size = new System.Drawing.Size(65, 12);
            label.TabIndex = 22;
            label.Text = attrNode.Data.Value;
            this.AttrTab.Controls.Add(label);
            if (attrNode.Data.ShowType == ShowType.InputString)
            {
                TextBox textBox = new TextBox();
                textBox.Location = new System.Drawing.Point(100, height-5);
                textBox.Name = attrNode.Data.Id;
                textBox.Size = new System.Drawing.Size(200, 20);
                textBox.Tag = attrNode.Data;
                textBox.TabIndex = tabIndex;
                if (attrNode.Nodes != null && attrNode.Nodes.Count > 0)
                {
                    textBox.Text = attrNode.Nodes[0].Data.Value;
                }
                this.AttrTab.Controls.Add(textBox);
            }
            else if (attrNode.Data.ShowType == ShowType.ListBox)
            {
                int loc = 100;
                ComboBox comboBox = new ComboBox();
                comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                comboBox.FormattingEnabled = true;
                comboBox.Location = new System.Drawing.Point(loc, height - 5);
                comboBox.Name = attrNode.Data.Id;
                comboBox.Tag = attrNode.Data;
                comboBox.Size = new System.Drawing.Size(150, 22);
                loc = loc + 150 + 10;
                comboBox.TabIndex = tabIndex;
                this.AttrTab.Controls.Add(comboBox);
                comboBox.DisplayMember = "Value";
                comboBox.ValueMember = "Id";
                Soomes.Attribute selNode = null;
                foreach (AttributeNode attr in attrNode.Nodes)
                {
                    comboBox.Items.Add(attr.Data);
                    if (attr.Data.Selected)
                    {
                        selNode = attr.Data;
                    }
                    if (attr.Nodes != null && attr.Nodes.Count > 0)
                    {
                        TextBox textBox = new TextBox();
                        textBox.Location = new System.Drawing.Point(loc, height - 5);
                        textBox.Name = attr.Nodes[0].Data.Id;
                        textBox.Size = new System.Drawing.Size(100, 20);
                        loc = loc + 100 + 10;
                        textBox.Tag = attr.Nodes[0].Data;
                        textBox.TabIndex = tabIndex;
                        if (attr.Nodes[0].Nodes.Count > 0)
                        {
                            textBox.Text = attr.Nodes[0].Nodes[0].Data.Value;
                        }
                        this.AttrTab.Controls.Add(textBox);
                    }
                }
                comboBox.SelectedItem = selNode;
            }
            else if (attrNode.Data.ShowType == ShowType.CheckBox)
            {
                int loc = 100;
                int controlCount = 0;
                foreach (AttributeNode attr in attrNode.Nodes)
                {
                    if (controlCount > 5) { controlCount = 0; loc = 100; height = height + 30; }
                    CheckBox checkBox = new CheckBox();
                    checkBox.Location = new System.Drawing.Point(loc, height - 5);
                    checkBox.Name = attr.Data.Id;
                    checkBox.Tag = attr.Data;
                    checkBox.Text = attr.Data.Value;
                    checkBox.Checked = attr.Data.Selected;
                    checkBox.Size = new System.Drawing.Size(70, 22);
                    checkBox.TabIndex = tabIndex;
                    this.AttrTab.Controls.Add(checkBox);
                    loc = loc + 70;
                    if (attr.Nodes != null && attr.Nodes.Count > 0)
                    {
                        TextBox textBox = new TextBox();
                        textBox.Location = new System.Drawing.Point(loc, height - 5);
                        textBox.Name = attr.Nodes[0].Data.Id;
                        textBox.Size = new System.Drawing.Size(100, 20);
                        textBox.Tag = attr.Nodes[0].Data;
                        textBox.TabIndex = tabIndex;
                        if (attr.Nodes[0].Nodes.Count > 0)
                        {
                            textBox.Text = attr.Nodes[0].Nodes[0].Data.Value;
                        }
                        this.AttrTab.Controls.Add(textBox);
                    }
                    controlCount++;
                   
                }
            }

            else if (attrNode.Data.ShowType == ShowType.Country)
            {
                int loc = 100;
                ComboBox comboBox = new ComboBox();
                comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                comboBox.FormattingEnabled = true;
                comboBox.Location = new System.Drawing.Point(loc, height - 5);
                comboBox.Name = attrNode.Data.Id;
                comboBox.Tag = attrNode.Data;
                comboBox.Size = new System.Drawing.Size(150, 22);
                loc = loc + 150 + 10;
                comboBox.TabIndex = tabIndex;
                this.AttrTab.Controls.Add(comboBox);
                comboBox.DisplayMember = "Value";
                comboBox.ValueMember = "Id";
                Soomes.Attribute selNode = null;
                if (attrNode.Nodes != null)
                {
                    foreach (AttributeNode attr in attrNode.Nodes)
                    {
                        comboBox.Items.Add(attr.Data);
                        if (attr.Data.Selected)
                        {
                            selNode = attr.Data;
                        }
                        if (attr.Nodes[0].Nodes != null && attr.Nodes[0].Nodes.Count > 0)
                        {
                            ComboBox subComboBox = new ComboBox();
                            subComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                            subComboBox.FormattingEnabled = true;
                            subComboBox.Location = new System.Drawing.Point(loc, height - 5);
                            subComboBox.Name = attr.Nodes[0].Data.Id;
                            subComboBox.Size = new System.Drawing.Size(150, 20);
                            loc = loc + 150 + 10;
                            subComboBox.Tag = attr.Nodes[0].Data;
                            subComboBox.TabIndex = tabIndex;
                            this.AttrTab.Controls.Add(subComboBox);
                            subComboBox.DisplayMember = "Value";
                            subComboBox.ValueMember = "Id";
                            Soomes.Attribute subSelNode = null;
                            foreach (AttributeNode subAttr in attr.Nodes[0].Nodes)
                            {
                                subComboBox.Items.Add(subAttr.Data);
                                if (subAttr.Data.Selected)
                                {
                                    subSelNode = subAttr.Data;
                                }
                            }
                            subComboBox.SelectedItem = subSelNode;
                        }
                    }
                }
                comboBox.SelectedItem = selNode;
            }
        }