Ejemplo n.º 1
0
        protected string MakePagedSql()
        {
            string rlt = "select [pagesize] [fields] from [tables] where [wheres] and [pk] not in (select [pageskip] [pk] from [tables] where [wheres]) [orders]";
            string pageskip = "", curtpage, pagesize, fields, tables, pk, wheres, orders;
            int    nsize, ncurt;
            Node   Root = Queries["select"];

            pagesize = Root["pagesize"]["Content"].Value.ToString();
            curtpage = Root["curtpage"]["Content"].Value.ToString();
            Int32.TryParse(pagesize, out nsize);
            Int32.TryParse(curtpage, out ncurt);
            if (nsize > 0 && ncurt > 0)
            {
                if (ncurt == 1)
                {
                    return(MakeNormalSql());
                }
                pagesize = " top " + nsize;
                pageskip = " top " + ((ncurt - 1) * nsize);
            }
            //pageskip = Root["pageskip"]["Content"].Value.ToString();

            OnMake = MakeFieldsStr;
            pk     = EnumKeys(Root["pk"]);
            fields = EnumKeys(Root["fields"]);
            tables = EnumKeys(Root["tables"]);
            wheres = EnumKeys(Root["wheres"]);
            orders = EnumKeys(Root["orders"]);

            if (string.IsNullOrEmpty(fields))
            {
                fields = "*";
            }
            if (!string.IsNullOrEmpty(orders))
            {
                orders = " order by " + orders + "," + pk;
            }
            rlt = rlt.Replace("[pk]", pk);
            rlt = rlt.Replace("[pagesize]", pagesize);
            rlt = rlt.Replace("[pageskip]", pageskip);
            rlt = rlt.Replace("[fields]", fields);
            rlt = rlt.Replace("[tables]", tables);
            rlt = rlt.Replace("[wheres]", wheres);
            rlt = rlt.Replace("[orders]", orders);
            return(rlt);
        }
Ejemplo n.º 2
0
        //protected string OnMake
        protected string MakeNormalSql()
        {
            string rlt = "select [pagesize] [fields] from [tables] [wheres] [orders]";
            string count, fields, tables, wheres, orders;
            Node   Root = Queries["select"];

            if (Root["pagesize"]["Content"] != null)
            {
                count = Root["pagesize"]["Content"].Value.ToString();
            }
            else
            {
                count = "";
            }
            OnMake    = MakeFieldsStr;
            fields    = EnumKeys(Root["fields"]);
            tables    = EnumKeys(Root["tables"]);
            wheres    = EnumKeys(Root["wheres"]);
            orders    = EnumKeys(Root["orders"]);
            TableName = tables;
            if (!string.IsNullOrEmpty(count))
            {
                count = " top " + count;
            }
            if (string.IsNullOrEmpty(fields))
            {
                fields = "*";
            }
            if (!string.IsNullOrEmpty(wheres))
            {
                wheres = " where " + wheres;
            }
            if (!string.IsNullOrEmpty(orders))
            {
                orders = " order by " + orders;
            }
            rlt = rlt.Replace("[pagesize]", count);
            rlt = rlt.Replace("[fields]", fields);
            rlt = rlt.Replace("[tables]", tables);
            rlt = rlt.Replace("[wheres]", wheres);
            rlt = rlt.Replace("[orders]", orders);
            return(rlt);
        }
Ejemplo n.º 3
0
		protected string MakePagedSql()
		{
			string rlt = "select [pagesize] [fields] from [tables] where [wheres] and [pk] not in (select [pageskip] [pk] from [tables] where [wheres]) [orders]";
			string pageskip = "", curtpage, pagesize, fields, tables, pk, wheres, orders;
			int nsize, ncurt;
			Node Root = Queries["select"];
			pagesize = Root["pagesize"]["Content"].Value.ToString();
			curtpage = Root["curtpage"]["Content"].Value.ToString();
			Int32.TryParse(pagesize, out nsize);
			Int32.TryParse(curtpage, out ncurt);
			if (nsize > 0 && ncurt > 0)
			{
				if (ncurt == 1)
				{
					return MakeNormalSql();
				}
				pagesize = " top " + nsize;
				pageskip = " top " + ((ncurt - 1) * nsize);
			}
			//pageskip = Root["pageskip"]["Content"].Value.ToString();
			
			OnMake = MakeFieldsStr;
			pk = EnumKeys(Root["pk"]);
			fields = EnumKeys(Root["fields"]);
			tables = EnumKeys(Root["tables"]);
			wheres = EnumKeys(Root["wheres"]);
			orders = EnumKeys(Root["orders"]);

			if (string.IsNullOrEmpty(fields))
			{
				fields = "*";
			}
			if (!string.IsNullOrEmpty(orders))
			{
				orders = " order by " + orders + "," + pk;
			}
			rlt = rlt.Replace("[pk]", pk);
			rlt = rlt.Replace("[pagesize]", pagesize);
			rlt = rlt.Replace("[pageskip]", pageskip);
			rlt = rlt.Replace("[fields]", fields);
			rlt = rlt.Replace("[tables]", tables);
			rlt = rlt.Replace("[wheres]", wheres);
			rlt = rlt.Replace("[orders]", orders);
			return rlt;
		}
Ejemplo n.º 4
0
		//protected string OnMake
		protected string MakeNormalSql()
		{
			string rlt = "select [pagesize] [fields] from [tables] [wheres] [orders]";
			string count, fields, tables, wheres, orders;
			Node Root = Queries["select"];
			if (Root["pagesize"]["Content"] != null)
			{
				count = Root["pagesize"]["Content"].Value.ToString();
			}
			else
			{
				count = "";
			}
			OnMake = MakeFieldsStr;
			fields = EnumKeys(Root["fields"]);
			tables = EnumKeys(Root["tables"]);
			wheres = EnumKeys(Root["wheres"]);
			orders = EnumKeys(Root["orders"]);
			TableName = tables;
			if (!string.IsNullOrEmpty(count))
			{
				count = " top " + count;
			}
			if (string.IsNullOrEmpty(fields))
			{
				fields = "*";
			}
			if (!string.IsNullOrEmpty(wheres))
			{
				wheres = " where " + wheres;
			}
			if (!string.IsNullOrEmpty(orders))
			{
				orders = " order by " + orders;
			}
			rlt = rlt.Replace("[pagesize]", count);
			rlt = rlt.Replace("[fields]", fields);
			rlt = rlt.Replace("[tables]", tables);
			rlt = rlt.Replace("[wheres]", wheres);
			rlt = rlt.Replace("[orders]", orders);
			return rlt;
		}