using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using EKETEAM.Data;
using EKETEAM.FrameWork;
using EKETEAM.UserControl;
using System.Xml;
using System.Xml.Serialization;
using LitJson;

namespace eFrameWork.Manage
{
    public partial class setReocrdField : System.Web.UI.Page
    {
        public eUser user;
        public string TemplateID = eParameters.QueryString("TemplateID");
        protected void Page_Load(object sender, EventArgs e)
        {
            user = new eUser("Manage");
            user.Check();
            eTemplate template = new eTemplate(TemplateID);
            StringBuilder sb = new StringBuilder();          


            foreach(JsonData jd in template.RecordItems)
            {
                string asname = jd["asname"].ToString();
                string text = jd["text"].ToString();
                sb.Append("<div class=\"tag\">" + text + ":</div>");
              
                if (template.Records.DataSource.Tables.Contains(asname))
                {
                    DataTable tb = template.Records.DataSource.Tables[asname];
                    sb.Append("<a href=\"javascript:;\" onclick=\"parent.setValue('{" + asname + ":number}');\" class=\"tag\">行号</a>");
                    sb.Append("<a href=\"javascript:;\" onclick=\"parent.setValue('count(" + asname + ")');\" class=\"tag\">记录数</a>");
                    for (int i = 0; i < tb.Columns.Count; i++)
                    {
                        sb.Append("<a href=\"javascript:;\" onclick=\"parent.setValue('{" + asname + ":" + tb.Columns[i].ColumnName + "}');\" class=\"tag\">" + tb.Columns[i].ColumnName + "</a>");
                    }

                    sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('{" + asname + ":循环开始}');\" class=\"tag\">循环开始</a>");
                    sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('{" + asname + ":循环结束}');\" class=\"tag\">循环结束</a>");
                }
            }

            sb.Append("<div class=\"tag\">常用功能:</div>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('sum(',')');\" class=\"tag\">汇总</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('max(',')');\" class=\"tag\">最大值</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('min(',')');\" class=\"tag\">最小值</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('avg(',')');\" class=\"tag\">平均值</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('{interface:eBase.MoneyUpper(',')}');\" class=\"tag\">大写</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('barcode(',',13,150,70)');\" class=\"tag\">条码</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('qrcode(',',3,100,100)');\" class=\"tag\">二维码</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('image(',',100,100)');\" class=\"tag\">图片</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setValue('getdate()');\" class=\"tag\">当前时间</a>");

            sb.Append("<div class=\"tag\">格式化:</div>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:yyyy-MM-dd HH:mm:ss})');\" class=\"tag\">年月日时分秒</a>");
            //sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:yyyy-MM-dd HH:mm})');\" class=\"tag\">年月日时分</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:yyyy-MM-dd})');\" class=\"tag\">年月日</a>");
            //sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:yyyy-MM})');\" class=\"tag\">年月</a>");
            //sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:yyyy})');\" class=\"tag\">年月</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:F2})');\" class=\"tag\">2位小数</a>");
            //sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:F3})');\" class=\"tag\">3位小数</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:N2})');\" class=\"tag\">千分位2位小数</a>");
            //sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:N3})');\" class=\"tag\">千分位3位小数</a>");

            sb.Append("<a href=\"javascript:;\" onclick=\"parent.setFunction('format(',',{0:P0})');\" class=\"tag\">百分比</a>");


            sb.Append("<div class=\"tag\">控制项:</div>");
           

            sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('页眉开始');\" class=\"tag\">页眉开始</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('页眉结束');\" class=\"tag\">页眉结束</a>");

            sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('页脚开始');\" class=\"tag\">页脚开始</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('页脚结束');\" class=\"tag\">页脚结束</a>");
            sb.Append("<a href=\"javascript:;\" onclick=\"parent.appendValue('分页符');\" class=\"tag\">分页符</a>");
            litBody.Text = sb.ToString();
        }

    }
}