示例#1
0
        private TableFieldType GetFieldType(string field_type_string)
        {
            int            exc_idx          = field_type_string.IndexOf('!');
            TableFieldType table_field_type = TableFieldType.INVALID;

            if (exc_idx == 0)
            {
                if (!Enum.TryParse <TableFieldType>(field_type_string.Substring(1), out table_field_type))
                {
                    if (field_type_string.Substring(1, 2) == TableFieldType.ID.ToString())
                    {
                        return(TableFieldType.ID);
                    }
                    else if (field_type_string.Substring(1, 7) == TableFieldType.ENUM_ID.ToString())
                    {
                        return(TableFieldType.ENUM_ID);
                    }
                    else if (field_type_string.Substring(1, 8) == TableFieldType.KEY_ENUM.ToString())
                    {
                        return(TableFieldType.KEY_ENUM);
                    }
                    else
                    {
                        throw new ApplicationException("필드 타입 문자열 오류: " + field_type_string);
                    }
                }
            }
            else
            {
                throw new ApplicationException("필드 타입 문자열 오류: " + field_type_string);
            }

            return(table_field_type);
        }
示例#2
0
        public static string AsString(this TableFieldType value)
        {
            switch (value)
            {
            case TableFieldType.Guid:
                return("GUID");

            default:
                return(value.ToString());
            }
        }
示例#3
0
 public void RegisterTableField(string tableName, string fieldName, TableFieldType fieldType)
 {
     if (!_mapping.ContainsKey(tableName))
     {
         _mapping.Add(tableName, new Dictionary <string, TableFieldType>());
     }
     if (!_mapping[tableName].ContainsKey(fieldName))
     {
         _mapping[tableName].Add(fieldName, fieldType);
     }
 }
示例#4
0
 public void OnBeginTableField(int fieldNo, bool?fieldEnabled, string fieldName, TableFieldType fieldType, int fieldLength)
 {
 }
示例#5
0
 public override void OnBeginTableField(int fieldNo, bool?fieldEnabled, string fieldName, TableFieldType fieldType, int fieldLength) => InvokeCBreezeParser.OnBeginTableField?.Invoke(fieldNo, fieldEnabled, fieldName, fieldType, fieldLength);
示例#6
0
        private void bt_Save_Click(object sender, EventArgs e)
        {
            if (tb_Caption.Text == "")
            {
                MessageBox.Show("请输入字段名");
                return;
            }
            if (tb_Caption.Text[0] <= 64)
            {
                MessageBox.Show("不能字母或汉字以外的字符做为字段开头!");
                return;
            }
            TableField tf = new TableField()
            {
                Name       = tb_Caption.Text,
                Type       = TableField.FieldTypeList[(TableFieldType)Enum.Parse(typeof(TableFieldType), cbox_Mode.Text)],
                IsSearched = cb_IsSearched.Checked,
                NoNull     = cb_NoNull.Checked
            };

            if (AddCol.Any(c => c.Name == tf.Name))
            {
                AddCol = AddCol.Where(c => c.Name != tf.Name).ToList();
                //MessageBox.Show("此列已存在!");
                //tb_Caption.Text = "";
                //tb_Caption.Text = "";
                //cbox_Mode.SelectedIndex = 0;
                //cb_NoNull.Checked = false;
                //cb_IsSearched.Checked = false;
                //return;
            }
            AddCol.Add(tf);
            DataGridViewColumn col = new DataGridViewColumn();

            Type           colType   = typeof(string);
            TableFieldType fieldType = (TableFieldType)Enum.Parse(typeof(TableFieldType), cbox_Mode.Text);

            switch (fieldType)
            {
            case TableFieldType.整型:
                colType = typeof(int);
                break;

            case  TableFieldType.小数:
                colType = typeof(float);
                break;

            case  TableFieldType.日期时间:
                colType = typeof(DateTime);
                break;

            case  TableFieldType.文档:
                colType = typeof(object);
                break;

            case TableFieldType.布尔:
                colType = typeof(bool);
                break;

            default:
                colType = typeof(string);
                break;
            }


            col.HeaderText = tb_Caption.Text;
            col.Name       = tb_Caption.Text;
            col.ValueType  = colType;
            col.Tag        = tf;
            if (dataGridView1.Columns.Contains(tb_Caption.Text))
            {
                TableField field = new TableField()
                {
                    Name   = dataGridView1.SelectedColumns[0].Name,
                    Type   = dataGridView1.SelectedColumns[0].ValueType.ToString(),
                    NoNull = false,
                };
                DelCol.Add(field);
                int index = dataGridView1.Columns[tb_Caption.Text].Index;
                dataGridView1.Columns.RemoveAt(index);
                dataGridView1.Columns.Insert(index, col);
            }
            else
            {
                dataGridView1.Columns.Add(col);
            }
            tb_Caption.Text         = "";
            tb_Caption.Text         = "";
            cbox_Mode.SelectedIndex = 0;
            cb_NoNull.Checked       = false;
        }