Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //查看是否有用户级语言辅助器,没有则用公共的
        LangHelper = FetchData.GetLanguageHelper(Session);


        sEditableInfo = Request["ei"];
        if (sEditableInfo == null)
        {
            sEditableInfo = "_Employee";
        }

        if (sEditableInfo != null)
        {
            EditableInfo selEI = Common.SelectEditableInfo(sEditableInfo);
            if (selEI != null)
            {
                //先为选择编辑字段创建初始的Json列表
                string sJosn = "";
                JsonList = new List <string>();

                //再生成网格上的字段列表
                bool bReadOnlyTable = ((selEI.Option & Option.ReadOnly) != Option.None);

                string sHtml = "";
                FilledFieldList = new List <string>();
                foreach (Field fld in selEI.MasterTable.Fields)
                {
                    CreateJSForColumn(fld, bReadOnlyTable, ref sHtml);
                    GetJson(fld, ref sJosn);
                }

                foreach (EditableTable tbl in selEI.SlaveTables)
                {
                    foreach (Field fld in tbl.Fields)
                    {
                        CreateJSForColumn(fld, bReadOnlyTable, ref sHtml);
                        GetJson(fld, ref sJosn);
                    }
                }
                if ((selEI.Option & Option.ReadOnly) == Option.None)
                {
                    sHtml += "\n,  { display: '" + LangHelper.GetText("Operate") + "', isSort: false, width: 120, render: " + ((selEI.Option & Option.ManualSort) != Option.None ? "f_OperateUpDown" : "f_Operate") + " }";
                }

                ListHolder.Controls.Add(new LiteralControl("<script type=\"text/javascript\">\n var gColumns=[" + sHtml + "];\n"
                                                           + "var gList = {};\n"
                                                           + sJosn
                                                           + "var gUrl= '../FetchData.ashx?fn=TableEdit&rp=get&ei=" + sEditableInfo + "'; \n"
                                                           + "var gUpUrl='../FetchData.ashx?fn=TableEdit&rp=update&ei=" + sEditableInfo + "'; \n"
                                                           + "var gEnabledSort=" + ((selEI.Option & Option.ManualSort) != Option.None ? "false" : "true") + "; \n"
                                                           + "var gEnabledEdit=" + (bReadOnlyTable ? "false" : "true") + "; \n"
                                                           + "var gSelEI= '" + sEditableInfo + "'; \n"
                                                           + "</script>"));
            }
        }
    }
Пример #2
0
    public static void UpdateInfo(HttpContext context, EditableInfo ei)
    {
#if WEB_DEBUG
        EmployeeInfo empInfo = UserMgr.LoadEmployeeInfo("Admin");
#else
        EmployeeInfo empInfo = context.Session["LogonEmployee"] as EmployeeInfo;
        if (empInfo == null)
        {
            throw new Exception("Login session expired!");
        }
#endif
        long nEmployeeID = empInfo._Employee;

        string sJson = context.Request["Changes"];
        if (!string.IsNullOrEmpty(sJson))
        {
            //ArrayList arrayList = sJson.ToArrayList();
            List <Dictionary <string, object> > rows = (new JavaScriptSerializer()).Deserialize <List <Dictionary <string, object> > >(sJson);
            Common.DAL.SubmitEditableChange(empInfo, rows.ToArray(), ei);
        }
    }
Пример #3
0
    private static void GetListInJson(HttpContext context, EditableInfo ei)
    {
        bool bForRender = false, bOnlyArray = false;

        if (!string.IsNullOrEmpty(context.Request["time"]))
        {
            bForRender = true;
        }
        if (!string.IsNullOrEmpty(context.Request["oa"]))
        {
            bOnlyArray = true;
        }

        bool bFirstIsNA = false;

        if (!string.IsNullOrEmpty(context.Request["na"]))
        {
            bFirstIsNA = true;
        }

        // bForRender, bOnlyArray, bFirstIsNA

        DataTable tbl = Common.DAL.GetEditableTable(ei, bOnlyArray, "");

        if (bForRender)
        {
            context.Response.Write(ei.JsonVarName + "=");
        }


        context.Response.Write((new LigerGridRows(tbl, "yyyy-MM-dd HH:mm:ss").ToJson(bFirstIsNA, bOnlyArray)));

        if (bForRender)
        {
            context.Response.Write(";");
        }
    }
Пример #4
0
    private void GetJson(Field fld, ref string sJosn)
    {
        string sName  = Field.AdjustName(fld);
        Editor editor = fld.editor;

        editor &= Editor.MaskNA;       //屏蔽表示是否有<N/A>选项的高位
        editor &= Editor.MaskReadOnly; //屏蔽表示是否只读readOnly选项的高位

        if (editor == Editor.select && (!JsonList.Contains(sName, StringComparer.OrdinalIgnoreCase)))
        {
            JsonList.Add(sName);
            EditableInfo ei = Common.SelectEditableInfo(sName);
            if (ei != null)
            {
                bool bOnlyArray = true;

                DataTable tbl = Common.DAL.GetEditableTable(ei, bOnlyArray, "");

                sName = Field.AdjustName(fld);

                sJosn += "gList['" + sName + "']=" + (new LigerGridRows(tbl, "yyyy-MM-dd HH:mm:ss")).ToJson((fld.editor & Editor.HasNA) != Editor.none, bOnlyArray) + ";\n";
            }
        }
    }