public void Audit(string id, JObject data)
        {
            var pUpdate = ParamUpdate.Instance()
                          .Update("PRS_ProcessRouteModelMain")
                          .Column("ApproveState", data["status"])
                          .Column("ApproveRemark", data["comment"])
                          .Column("ApprovePerson", FormsAuth.GetUserData().UserName)
                          .Column("ApproveDate", DateTime.Now)
                          .AndWhere("ID", id);

            var service      = new PRS_ProcessRouteModelMainService();
            var rowsAffected = service.Update(pUpdate);

            MmsHelper.ThrowHttpExceptionWhen(rowsAffected < 0, "单据审核失败[BillNo={0}],请重试或联系管理员!", id);
        }
        public dynamic GetPageData(string id)
        {
            var masterService = new PRS_ProcessRouteModelMainService();
            var pQuery        = ParamQuery.Instance().AndWhere("ID", id);

            //var pQuery = ParamQuery.Instance();
            if (id == "")
            {
                var result = new
                {
                    tab0 = "",
                    tab1 = ""
                };
                return(result);
            }
            else
            {
                var mainData = masterService.GetModel(pQuery);
                if (mainData != null)
                {
                    var pQuery2 = ParamQuery.Instance().AndWhere("MainID", mainData.ID);

                    var result = new
                    {
                        //主表数据
                        form       = mainData,
                        scrollKeys = masterService.ScrollKeys("ID", id),
                        //明细数据
                        tab0 = new PRS_ProcessRouteModelDetailService().GetDynamicList(pQuery2),
                    };
                    return(result);
                }
                else
                {
                    var result = new
                    {
                        //主表数据
                        form       = mainData,
                        scrollKeys = masterService.ScrollKeys("ID", id),
                        //明细数据
                        tab0 = "", tab1 = ""
                    };
                    return(result);
                }
            }
        }
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
<settings defaultOrderBy='temp.ID'>
    <select>*</select>
    <from>(select t1.*,t2.ProjectName from PRS_ProcessRouteModelMain t1
left join PMS_BN_Project t2 on t1.ContractCode=t2.ContractCode) as temp</from>
    <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
        <field name='temp.ProcessRouteCode'		cp='equal'></field>   
    </where>
</settings>");
            var service = new PRS_ProcessRouteModelMainService();
            var pQuery  = query.ToParamQuery();
            var result  = service.GetDynamicListWithPaging(pQuery.AndWhere("IsEnable", 1));

            return(result);
        }
        public void Edit(dynamic data)
        {
            var id     = data.form["ID"].ToString();
            var pQuery = ParamQuery.Instance().Select("*").AndWhere("ID", id);
            var re     = new PRS_ProcessRouteModelMainService().GetModelList(pQuery);

            if (re.Count > 0 && re[0].BillState == 1)
            {
                MmsHelper.ThrowHttpExceptionWhen(true, "已审核数据不能修改!");
                return;
            }
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        PRS_ProcessRouteModelMain
    </table>
    <where>
        <field name='ID' cp='equal'></field>
    </where>
</settings>
");

            var tabsWrapper = new List <RequestWrapper>();

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

            var service = new PRS_ProcessRouteModelMainService();

            if (data.form["ProcessRouteCode"] == "系统生成")
            {
                string documentNo = MmsHelper.GetLSNumber("PRS_ProcessRouteModelMain", "ProcessRouteCode", "GYMX", "", "");
                data.form["ProcessRouteCode"] = documentNo;
            }


            var result = service.EditPage(data, formWrapper, tabsWrapper);
        }