Exemple #1
0
        private void updateLvItem(ListViewItem lvItem)
        {
            MysqlCreateStruct mStr = (MysqlCreateStruct)lvItem.Tag;


            if (lvItem.SubItems.Count < 6)
            {
                lvItem.SubItems.Clear();
                lvItem.SubItems.Add(mStr.dataType);
                lvItem.SubItems.Add(mStr.length.ToString());
                lvItem.SubItems.Add(mStr.defaultValue);
                lvItem.SubItems.Add("");
                lvItem.SubItems.Add(mStr.comments);
            }
            else
            {
                lvItem.SubItems[1].Text = mStr.dataType;
                lvItem.SubItems[2].Text = mStr.length.ToString();
                lvItem.SubItems[3].Text = mStr.defaultValue;
                lvItem.SubItems[4].Text = "";
                lvItem.SubItems[5].Text = mStr.comments;
            }
            lvItem.Text = mStr.name;
            if (mStr.isPrimary)
            {
                lvItem.BackColor = Color.LightGreen;
            }
            else
            {
                lvItem.BackColor = Color.Transparent;
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MysqlCreateStruct addStruct = new MysqlCreateStruct();

            addStruct.autoIncrement = colAutoInc.Checked;
            addStruct.name          = colName.Text;
            addStruct.defaultValue  = colDefault.Text;
            addStruct.dataType      = colType.Text;
            addStruct.isPrimary     = colPrim.Checked;
            addStruct.length        = (ulong)colLength.Value;
            addStruct.notNull       = colNotNull.Checked;
            addStruct.comments      = "";

            ListViewItem addLvItem = new ListViewItem();

            addStruct.refObject = addLvItem;

            addLvItem.Tag = addStruct;

            if (CreateStructCont.addStruct(addStruct))
            {
                listView1.Items.Add(addLvItem);
                updateLvItem(addLvItem);
                updateSql();
            }
            else
            {
                MessageBox.Show("Fieldname Allready in use");
            }
        }
Exemple #3
0
        /**
         * add index by the name of keys
         */
        public void addIndex(string name, List <string> keys)
        {
            if (null == this.getIndexbyName(name))
            {
                MysqlIndexType newIndex = new MysqlIndexType(name);

                for (int i = 0; i < keys.Count; i++)
                {
                    MysqlCreateStruct getStruct = this.getStructByName(keys[i]);
                    if (getStruct != null)
                    {
                        newIndex.addRefererStruct(getStruct);
                    }
                    else
                    {
                        throw new Exception("key " + keys[i] + " not exists");
                    }

                    this.crIndizies.Add(newIndex);
                }
            }
            else
            {
                throw new Exception("Index with name " + name + " allready exists");
            }
        }
Exemple #4
0
 public bool addStruct(MysqlCreateStruct mStruct)
 {
     if (mStruct.name.Length > 0 && getStructByName(mStruct.name) == null)
     {
         this.crList.Add(mStruct);
         return(true);
     }
     return(false);
 }
Exemple #5
0
        private void updateFormByListItem(ListViewItem lvItem)
        {
            MysqlCreateStruct mStr = (MysqlCreateStruct)lvItem.Tag;

            colAutoInc.Checked = mStr.autoIncrement;
            colName.Text       = mStr.name;
            colDefault.Text    = mStr.defaultValue;
            colType.Text       = mStr.dataType;
            colPrim.Checked    = mStr.isPrimary;
            colLength.Value    = mStr.length;
            colNotNull.Checked = mStr.notNull;
        }
Exemple #6
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count == 1)
     {
         MysqlCreateStruct addStruct = (MysqlCreateStruct)listView1.SelectedItems[0].Tag;
         addStruct.autoIncrement = colAutoInc.Checked;
         addStruct.name          = colName.Text;
         addStruct.defaultValue  = colDefault.Text;
         addStruct.dataType      = colType.Text;
         addStruct.isPrimary     = colPrim.Checked;
         addStruct.length        = (ulong)colLength.Value;
         addStruct.notNull       = colNotNull.Checked;
         addStruct.comments      = "";
         updateLvItem(listView1.SelectedItems[0]);
     }
     updateSql();
 }
Exemple #7
0
        public void addFieldToIndex(string name, string fieldName)
        {
            MysqlIndexType editIndex = this.getIndexbyName(name);

            if (null != editIndex)
            {
                MysqlCreateStruct getStruct = this.getStructByName(fieldName);
                if (getStruct != null)
                {
                    editIndex.addRefererStruct(getStruct);
                }
                else
                {
                    throw new Exception("key " + fieldName + " not exists");
                }
            }
        }
Exemple #8
0
 public void addRefererStruct(MysqlCreateStruct refStruct)
 {
     this.refers.Add(refStruct);
 }