예제 #1
0
 /// <summary>
 /// 取得欄位值後轉型成bool
 /// </summary>
 /// <param name="fieldName">欄位名稱</param>
 /// <returns></returns>
 public bool ValueAsBool(string fieldName)
 {
     if (this.HasField(fieldName))
     {
         return(BaseFunc.CBool(this[fieldName]));
     }
     return(false);
 }
예제 #2
0
        public void DoCreateProgramDefine()
        {
            var helper = new InitDataHelper();

            var progDefine = new GProgramDefine();

            Console.WriteLine("ProgID:");
            progDefine.ProgID = Console.ReadLine();
            Console.WriteLine("DisplayName:");
            progDefine.DisplayName = Console.ReadLine();
            Console.WriteLine("Start Create Table");
            var tableDefine = new GTableDefine();

            tableDefine.PrimaryKey = progDefine.ProgID + "Id";
            progDefine.Tables.Add(tableDefine);
            Console.WriteLine("TableName:");
            tableDefine.TableName = Console.ReadLine();
            Console.WriteLine("DbTableName:");
            tableDefine.DbTableName = Console.ReadLine();
            Console.WriteLine("Table DisplayName:");
            tableDefine.DisplayName = Console.ReadLine();
            var createField = true;

            while (createField)
            {
                Console.WriteLine("Start Create Field Define");
                var fieldDefine = new GFieldDefine();
                tableDefine.Fields.Add(fieldDefine);
                Console.WriteLine("FieldName:");
                fieldDefine.FieldName = Console.ReadLine();
                Console.WriteLine("DisplayName:");
                fieldDefine.DisplayName = Console.ReadLine();
                Console.WriteLine("DbType:");
                Console.WriteLine("(0:String, 1:Text, 2:Boolean, 3:Integer, 4:Double, 5:Currency, 6:DateTime, 7:GUID, 8:Binary)");
                var dbType = int.Parse(Console.ReadLine());
                fieldDefine.DbType = BaseFunc.CEnum <EFieldDbType>(dbType, 0);
                Console.WriteLine("MaxLength:");
                fieldDefine.MaxLength = int.Parse(Console.ReadLine());
                Console.WriteLine("AllowNull:(0: false, 1: true)");
                fieldDefine.AllowNull = BaseFunc.CBool(Console.ReadLine());
                Console.WriteLine("LinkFieldName:");
                fieldDefine.LinkFieldName = Console.ReadLine();
                Console.WriteLine("LinkProgID:");
                fieldDefine.LinkProgID = Console.ReadLine();
                Console.WriteLine("Continue Create Field Define? 1:Yes? 0:No?");
                var ans = Console.ReadLine();
                if (ans.SameTextOr("No", "0"))
                {
                    createField = false;
                }
                Console.WriteLine("================================================");
            }

            helper.ProgDefineToJson(progDefine);
            Console.WriteLine($"已產生程式定義檔案:{progDefine.ProgID}/{progDefine.DisplayName}");
            Console.ReadKey();
        }