Esempio n. 1
0
        private StringBuilder Sub3_init_DB()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("/// <summary>").Append(HssStr.WinNextLine);
            sb.Append("/// Initialize object from DB").Append(HssStr.WinNextLine);
            sb.Append("/// </summary>").Append(HssStr.WinNextLine);

            sb.Append("public bool Init_from_DB(").Append(this.Get_DBname(0)).Append(")").Append(HssStr.WinNextLine);
            sb.Append("{").Append(HssStr.WinNextLine);

            ColumnSchema pk_cs      = this.col_list[0];
            string       dataTP_str = pk_cs.DATA_TYPE.ToLower();

            if (dataTP_str.Contains("int"))
            {
                sb.Append("if (this.").Append(pk_cs.COLUMN_NAME).Append(" < 0) return false;").Append(HssStr.WinNextLine);
            }
            else if (dataTP_str.Contains("char"))
            {
                sb.Append("if (string.IsNullOrEmpty(this.").Append(pk_cs.COLUMN_NAME).Append(")) return false;").Append(HssStr.WinNextLine);
            }

            sb.Append(HssStr.WinNextLine);
            sb.Append(SQL_lib).Append("DB_select db_sel = new ").Append(SQL_lib).Append("DB_select(").Append(this.className).Append(".Get_cmdTP());").Append(HssStr.WinNextLine);
            sb.Append("db_sel.tableName = \"").Append(this.tableName).Append("\";").Append(HssStr.WinNextLine);

            sb.Append(SQL_lib).Append("SQL_relation rela = new ").Append(SQL_lib).Append("SQL_relation(\"");
            sb.Append(pk_cs.COLUMN_NAME).Append("\", ").Append(General_lib).Append("RelationalOperator.Equals, this.");
            sb.Append(pk_cs.COLUMN_NAME).Append(");").Append(HssStr.WinNextLine);

            sb.Append("db_sel.SetCondition(rela);").Append(HssStr.WinNextLine);
            sb.Append(HssStr.WinNextLine);
            sb.Append("bool res_flag = false;").Append(HssStr.WinNextLine);
            sb.Append(SQL_lib).Append("DB_reader reader = new ").Append(SQL_lib).Append("DB_reader(db_sel, ").Append(this.hDB_name).Append(");").Append(HssStr.WinNextLine);
            sb.Append("if (reader.Read())").Append(HssStr.WinNextLine);
            sb.Append("{").Append(HssStr.WinNextLine);
            sb.Append("this.Init_from_reader(reader);").Append(HssStr.WinNextLine);
            sb.Append("res_flag = true;").Append(HssStr.WinNextLine);
            sb.Append("}").Append(HssStr.WinNextLine);
            sb.Append("reader.Close();").Append(HssStr.WinNextLine);
            sb.Append("return res_flag;").Append(HssStr.WinNextLine);
            sb.Append("}").Append(HssStr.WinNextLine);
            return(sb);
        }
Esempio n. 2
0
        private StringBuilder Sub1_constructor()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("public ").Append(this.className).Append("() { }").Append(HssStr.WinNextLine);

            ColumnSchema pk_col = this.col_list[0];

            if (pk_col.DATA_TYPE.ToLower().Contains("int"))
            {
                sb.Append("public ").Append(this.className).Append("(int id) { this.pk_ID = id; }").Append(HssStr.WinNextLine);
            }
            else
            {
                sb.Append("public ").Append(this.className).Append("(string id) { this.pk_ID = id; }").Append(HssStr.WinNextLine);
            }
            return(sb);
        }
Esempio n. 3
0
        private StringBuilder Sub11_copy()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("public ").Append(this.className).Append(" GetCopy()").Append(HssStr.WinNextLine);
            sb.Append("{").Append(HssStr.WinNextLine);
            sb.Append(this.className).Append(" newEntity = new ").Append(this.className).Append("();").Append(HssStr.WinNextLine);

            for (int i = 1; i < this.col_list.Count; ++i)
            {
                ColumnSchema cs = this.col_list[i];
                sb.Append("if (!this.").Append(cs.attr_name).Append(".IsNull_flag)");
                sb.Append("newEntity.").Append(cs.attr_name).Append(".Value = this.");
                sb.Append(cs.attr_name).Append(".Value;").Append(HssStr.WinNextLine);
            }

            sb.Append("return newEntity;").Append(HssStr.WinNextLine);
            sb.Append("}").Append(HssStr.WinNextLine);
            return(sb);
        }
Esempio n. 4
0
        private StringBuilder Sub6_createAttrDic()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("private void Create_attrDic()").Append(HssStr.WinNextLine);
            sb.Append("{").Append(HssStr.WinNextLine);
            sb.Append("if (this.attr_dic != null) return;").Append(HssStr.WinNextLine);
            sb.Append(HssStr.WinNextLine);
            sb.Append("this.attr_dic = new Dictionary<string, ").Append(Attr_lib).Append("I_modelAttr>(StringComparer.OrdinalIgnoreCase);").Append(HssStr.WinNextLine);

            for (int i = 1; i < this.col_list.Count; ++i)
            {
                ColumnSchema cs = this.col_list[i];
                sb.Append("this.attr_dic.Add(\"").Append(cs.COLUMN_NAME).Append("\", this.").Append(cs.attr_name).Append(");");
                sb.Append(this.Get_optional_sb(cs)).Append(HssStr.WinNextLine);
            }

            sb.Append("}").Append(HssStr.WinNextLine);
            return(sb);
        }
Esempio n. 5
0
        private StringBuilder Sub12_toXML()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("public string ToXML()").Append(HssStr.WinNextLine);
            sb.Append("{").Append(HssStr.WinNextLine);

            sb.Append("StringBuilder sb = new StringBuilder();").Append(HssStr.WinNextLine);
            sb.Append("sb.Append(\"<").Append(this.className).Append(">\").Append(HssUtility.General.HssStr.WinNextLine);").Append(HssStr.WinNextLine);

            ColumnSchema pk_cs = this.col_list[0];

            sb.Append("sb.Append(\"<").Append(pk_cs.COLUMN_NAME).Append(">\").Append(this.").Append(pk_cs.attr_name).Append(").Append(\"</");
            sb.Append(pk_cs.COLUMN_NAME).Append(">\").Append(HssUtility.General.HssStr.WinNextLine);").Append(HssStr.WinNextLine);

            for (int i = 1; i < this.col_list.Count; ++i)
            {
                ColumnSchema cs = this.col_list[i];

                string        type_str   = cs.DATA_TYPE.ToLower();
                StringBuilder replace_sb = new StringBuilder();
                if (type_str.Contains("char") || type_str.Contains("xml"))
                {
                    replace_sb.Append("HssUtility.General.HssStr.ToSafeXML_str(this.").Append(cs.attr_name).Append(".Value)");
                }
                else
                {
                    replace_sb.Append("this.").Append(cs.attr_name).Append(".Value");
                }

                sb.Append("sb.Append(\"<").Append(cs.COLUMN_NAME).Append(">\").Append(").Append(replace_sb).Append(").Append(\"</");
                sb.Append(cs.COLUMN_NAME).Append(">\").Append(HssUtility.General.HssStr.WinNextLine);").Append(HssStr.WinNextLine);
            }

            sb.Append("sb.Append(\"</").Append(this.className).Append(">\").Append(HssUtility.General.HssStr.WinNextLine);").Append(HssStr.WinNextLine);
            sb.Append("return sb.ToString();").Append(HssStr.WinNextLine);
            sb.Append("}").Append(HssStr.WinNextLine);

            return(sb);
        }
Esempio n. 6
0
        private StringBuilder GetAttrs(ColumnSchema cs)
        {
            StringBuilder sb       = new StringBuilder();
            string        type_str = cs.DATA_TYPE.ToLower();

            if (type_str.Contains("bigint"))
            {
                sb.Append("public readonly ").Append(Attr_lib).Append("Long_attr").Append(" ").Append(cs.attr_name);
                sb.Append(" = new ").Append(Attr_lib).Append("Long_attr").Append("();");
            }
            else if (type_str.Contains("int"))
            {
                sb.Append("public readonly ").Append(Attr_lib).Append("Int_attr").Append(" ").Append(cs.attr_name);
                sb.Append(" = new ").Append(Attr_lib).Append("Int_attr").Append("();");
            }
            else if (type_str.Contains("char") || type_str.Contains("xml"))
            {
                sb.Append("public readonly ").Append(Attr_lib).Append("String_attr").Append(" ").Append(cs.attr_name);
                sb.Append(" = new ").Append(Attr_lib).Append("String_attr").Append("();");
            }
            else if (type_str.Contains("numeric") || type_str.Contains("decimal") || type_str.Contains("float"))
            {
                sb.Append("public readonly ").Append(Attr_lib).Append("Decimal_attr").Append(" ").Append(cs.attr_name);
                sb.Append(" = new ").Append(Attr_lib).Append("Decimal_attr").Append("();");
            }
            else if (type_str.Contains("date"))
            {
                sb.Append("public readonly ").Append(Attr_lib).Append("DateTime_attr").Append(" ").Append(cs.attr_name);
                sb.Append(" = new ").Append(Attr_lib).Append("DateTime_attr").Append("();");
            }
            else if (type_str.Contains("bit"))
            {
                sb.Append("public readonly ").Append(Attr_lib).Append("Bool_attr").Append(" ").Append(cs.attr_name);
                sb.Append(" = new ").Append(Attr_lib).Append("Bool_attr").Append("();");
            }

            sb.Append(this.Get_optional_sb(cs));
            return(sb);
        }