Esempio n. 1
0
        internal string GetUpdateSql(string tableName)
        {
            PropertyInfo[] plist = DObjectHelper.GetInsertablePropertyList(PropertyList);
            if (plist == null)
            {
                return("");
            }

            PropertyInfo key = MainKey;

            if (key == null)
            {
                return("");
            }
            string val = GetProperty(key);

            StringBuilder sb = new StringBuilder();

            sb.Append("UPDATE ");
            sb.Append(tableName);
            sb.Append(" SET ");

            foreach (PropertyInfo p in plist)
            {
                string fname = DObjectHelper.GetFieldName(p);
                sb.Append(fname + "=" + GetProperty(p) + ",");
            }

            string str   = sb.ToString();
            string kname = DObjectHelper.GetFieldName(key);
            string ostr  = str.TrimEnd(',') + " WHERE " + kname + "=" + val;

            return(ostr);
        }
Esempio n. 2
0
        internal string GetSelectSql(string tableName)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(" WHERE ");

//			foreach( PropertyInfo p in PropertyList )
//			{
//				string str = GetProperty(p);
//				if( str != null && str.Length > 0 )
//					sb.Append( p.Name + "=" + GetProperty(p) + "," );
//			}

            PropertyInfo key = MainKey;

            if (key == null)
            {
                return("");
            }
            string fname = DObjectHelper.GetFieldName(key);

            sb.Append(fname + "=" + GetProperty(key));

            string sql = sb.ToString();

            sql = sql.TrimEnd(',').Replace(",", " AND ");
            sql = GetSelectAllSql(tableName) + sql;

            return(sql);
        }
Esempio n. 3
0
        internal string GetMaxAutoIDSql(string tableName)
        {
            PropertyInfo key = MainKey;

            if (key == null || !DObjectHelper.IsAutoIncrementing(key))
            {
                return("");
            }

            string kname = DObjectHelper.GetFieldName(key);
            string sql   = "SELECT MAX(" + kname + ") FROM " + tableName;

            return(sql);
        }
Esempio n. 4
0
        internal string GetDeleteSql(string tableName)
        {
            PropertyInfo key = MainKey;

            if (key == null)
            {
                return("");
            }
            string val   = GetProperty(key);
            string fname = DObjectHelper.GetFieldName(key);
            string sql   = "DELETE FROM " + tableName + " WHERE " + fname + "=" + val;

            return(sql);
        }
Esempio n. 5
0
        internal bool LoadData(DbDataRecord dbData)
        {
            if (dbData == null)
            {
                return(false);
            }

            PropertyInfo[] plist = PropertyList;
            if (plist == null)
            {
                return(false);
            }

            foreach (PropertyInfo p in plist)
            {
                string fname = DObjectHelper.GetFieldName(p);
                SetProperty(p, dbData[fname]);
            }

            return(true);
        }
Esempio n. 6
0
        internal string GetSelectAllSql(string tableName)
        {
            PropertyInfo[] plist = PropertyList;
            if (plist == null)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("SELECT ");

            foreach (PropertyInfo p in plist)
            {
                string fname = DObjectHelper.GetFieldName(p);
                sb.Append(fname + ",");
            }

            string str = sb.ToString().TrimEnd(',');

            str = str + " FROM " + tableName;
            return(str);
        }
Esempio n. 7
0
        internal string GetInsertSql(string tableName)
        {
            PropertyInfo[] plist = DObjectHelper.GetInsertablePropertyList(PropertyList);
            if (plist == null)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("INSERT INTO ");
            sb.Append(tableName);
            sb.Append(" (");

            foreach (PropertyInfo p in plist)
            {
                string fname = DObjectHelper.GetFieldName(p);
                sb.Append(fname + ",");
            }

            string str = sb.ToString().TrimEnd(',');

            str = str + ") VALUES (";

            sb = new StringBuilder();
            sb.Append(str);

            foreach (PropertyInfo p in plist)
            {
                sb.Append(GetProperty(p) + ",");
            }

            str = sb.ToString().TrimEnd(',');
            str = str + ")";

            return(str);
        }