public dynamic GetPageData(string id)
        {
            var masterService = new MES_MaterialPickMainService();
            var pQuery        = ParamQuery.Instance().AndWhere("ID", id);
            var mainData      = masterService.GetModel(pQuery);

            if (mainData != null)
            {
                var pQuery2 = ParamQuery.Instance().AndWhere("MainID", mainData.ID).AndWhere("IsEnable", 1);
                var result  = new
                {
                    //主表数据
                    form       = mainData,
                    scrollKeys = masterService.ScrollKeys("ID", id),

                    //明细数据
                    tab0 = new MES_MaterialPickDetailService().GetDynamicList(pQuery2)
                };
                return(result);
            }
            else
            {
                var result = new
                {
                    //主表数据
                    form       = mainData,
                    scrollKeys = masterService.ScrollKeys("ID", id),

                    //明细数据
                    tab0 = ""
                };
                return(result);
            }
        }
        public void Edit(dynamic data)
        {
            var service = new MES_MaterialPickMainService();

            if (data.form["BillCode"] != "系统生成")
            {
                var pQuery = ParamQuery.Instance().Select("*").AndWhere("ID", data.form["ID"]);
                MES_MaterialPickMain model = service.GetModel(pQuery);
                if (model.BillState != null && model.BillState == 2)
                {
                    MmsHelper.ThrowHttpExceptionWhen(true, "已发布的不能修改!");
                    return;
                }
            }
            var ids = "(";

            foreach (JToken tab in data["tabs"].Children())
            {
                foreach (JProperty item in tab.Children())
                {
                    if (item.Name == "deleted")
                    {
                        foreach (var row in item.Value.Children())
                        {
                            ids += "'" + row["ID"] + "',";
                        }
                        item.Value = "[]";
                    }
                }
            }
            if (ids != "(")
            {
                ids  = ids.Remove(ids.Length - 1, 1);
                ids += ")";
                using (var db = Db.Context("Mms"))
                {
                    string sql1 = string.Format("update MES_MaterialPickDetail set IsEnable=0 where ID in {0} ", ids);
                    db.Sql(sql1).Execute();
                }
            }

            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        MES_MaterialPickMain
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");



            var tabsWrapper = new List <RequestWrapper>();

            tabsWrapper.Add(RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>MES_MaterialPickDetail</table>
    <where>
        <field name='ID' cp='equal'></field>      
    </where>
</settings>"));

            if (data.form["BillCode"] == "系统生成")
            {
                string documentNo = MmsHelper.GetOrderNumber("MES_MaterialPickMain", "BillCode", "CJLL", "", "");
                data.form["BillCode"] = documentNo;
            }
            var result = service.EditPage(data, formWrapper, tabsWrapper);
        }