public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
<settings defaultOrderBy='BillNo'>
    <select>
        A.*,B.Name as WarehouseName,C.Name as CustomerName
    </select>
    <from>
        psi_picking A
        left join psi_warehouse B on B.Id = A.Warehouse
        left join psi_customer  C on C.Id = A.CustomNo
        left join psi_customerContract D on D.ContractNo = A.Contract
    </from>
    <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
        <field name='BillNo'            cp='equal'      ></field>
        <field name='Warehouse'         cp='equal'       ></field>
        <field name='PickingPerson'     cp='like'       ></field>
        <field name='PickingDate'       cp='daterange'       ></field>
        <field name='C.Name'            cp='like' variable='CustomerName'></field>
        <field name='Contract'          cp='like'       ></field>
    </where>
</settings>");

            var PickingService = new psi_pickingService();
            var pQuery         = query.ToParamQuery();
            var result         = PickingService.GetDynamicListWithPaging(pQuery);

            return(result);
        }
        public dynamic GetDetail(string id)
        {
            var query = RequestWrapper
                        .InstanceFromRequest()
                        .SetRequestData("BillNo", id)
                        .LoadSettingXmlString(@"
<settings defaultOrderBy='RowId'>
    <select>
        A.*, B.Name,B.Catagory,B.Brand,B.Model,B.Unit
    </select>
    <from>
        psi_pickingGoods A
        left join psi_goods B on B.Id = A.GoodNo
    </from>
    <where>
        <field name='BillNo' cp='equal'></field>
    </where>
</settings>");

            var pQuery         = query.ToParamQuery();
            var PickingService = new psi_pickingService();
            var result         = PickingService.GetDynamicListWithPaging(pQuery);

            return(result);
        }
        public void Edit(dynamic data)
        {
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        psi_picking
    </table>
    <where>
        <field name='BillNo' cp='equal'></field>
    </where>
</settings>");

            var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        psi_pickingGoods
    </table>
    <where>
        <field name='BillNo' cp='equal'></field>
        <field name='RowId'  cp='equal'></field>
    </where>
</settings>");

            var service = new psi_pickingService();
            var result  = service.Edit(formWrapper, listWrapper, data);
        }
        public dynamic GetEditMaster(string id)
        {
            dynamic result        = new ExpandoObject();
            var     masterService = new psi_pickingService();

            result.form        = masterService.GetModel(ParamQuery.Instance().AndWhere("BillNo", id));
            result.form.BillNo = id; //如果没有数据,返回一条空数据,BillNo=id; 对应新增的情况
            result.scrollKeys  = masterService.ScrollKeys("BillNo", id);
            return(result);
        }
        public void Delete(string id)
        {
            var service = new psi_pickingService();
            var result  = service.Delete(ParamDelete.Instance().AndWhere("BillNo", id));

            if (result <= 0)
            {
                throw new HttpResponseException(new HttpResponseMessage()
                {
                    Content = new StringContent("领货单删除失败{BillNo=" + id + "},请重试或联系管理员!")
                });
            }
        }
        public void Audit(string id, dynamic data)
        {
            var service = new psi_pickingService();
            var result  = service.Update(ParamUpdate.Instance()
                                         .Column("AuditState", data.status)
                                         .Column("AuditReason", data.comment)
                                         .Column("AuditPerson", FormsAuth.GetUserData().UserName)
                                         .Column("AuditDate", DateTime.Now)
                                         .AndWhere("BillNo", id));

            if (result <= 0)
            {
                throw new HttpResponseException(new HttpResponseMessage()
                {
                    Content = new StringContent("审核领货单失败{BillNo=" + id + "},请重试或联系管理员!")
                });
            }
        }
        public string GetNewBillNo()
        {
            var service = new psi_pickingService();

            return(service.GetNewKey("BillNo", "dateplus"));
        }
        public void Edit(dynamic data)
        {
            var formWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        psi_picking
    </table>
    <where>
        <field name='BillNo' cp='equal'></field>
    </where>
</settings>");

            var listWrapper = RequestWrapper.Instance().LoadSettingXmlString(@"
<settings>
    <table>
        psi_pickingGoods
    </table>
    <where>
        <field name='BillNo' cp='equal'></field>
        <field name='RowId'  cp='equal'></field>
    </where>
</settings>");
             
            var service = new psi_pickingService();
            var result = service.Edit(formWrapper, listWrapper, data);
        }
        public dynamic Get(RequestWrapper query)
        {
            query.LoadSettingXmlString(@"
<settings defaultOrderBy='BillNo'>
    <select>
        A.*,B.Name as WarehouseName,C.Name as CustomerName
    </select>
    <from>
        psi_picking A
        left join psi_warehouse B on B.Id = A.Warehouse
        left join psi_customer  C on C.Id = A.CustomNo
        left join psi_customerContract D on D.ContractNo = A.Contract
    </from>
    <where defaultForAll='true' defaultCp='equal' defaultIgnoreEmpty='true' >
        <field name='BillNo'            cp='equal'      ></field>
        <field name='Warehouse'         cp='equal'       ></field>
        <field name='PickingPerson'     cp='like'       ></field>
        <field name='PickingDate'       cp='daterange'       ></field>
        <field name='C.Name'            cp='like' variable='CustomerName'></field>
        <field name='Contract'          cp='like'       ></field>
    </where>
</settings>");  

            var PickingService = new psi_pickingService();
            var pQuery = query.ToParamQuery();
            var result = PickingService.GetDynamicListWithPaging(pQuery);
            return result;
        }
        public dynamic GetDetail(string id)
        {
            var query = RequestWrapper
                .InstanceFromRequest()
                .SetRequestData("BillNo",id)
                .LoadSettingXmlString(@"
<settings defaultOrderBy='RowId'>
    <select>
        A.*, B.Name,B.Catagory,B.Brand,B.Model,B.Unit
    </select>
    <from>
        psi_pickingGoods A
        left join psi_goods B on B.Id = A.GoodNo
    </from>
    <where>
        <field name='BillNo' cp='equal'></field>
    </where>
</settings>");

            var pQuery = query.ToParamQuery();
            var PickingService = new psi_pickingService();
            var result = PickingService.GetDynamicListWithPaging(pQuery);
            return result;
        }
 public dynamic GetEditMaster(string id) {
     dynamic result = new ExpandoObject();
     var masterService = new psi_pickingService();
     result.form = masterService.GetModel(ParamQuery.Instance().AndWhere("BillNo", id));
     result.form.BillNo = id; //如果没有数据,返回一条空数据,BillNo=id; 对应新增的情况
     result.scrollKeys = masterService.ScrollKeys("BillNo", id);
     return result;
 }
        public void Audit(string id, dynamic data)
        {
            var service = new psi_pickingService();
            var result = service.Update(ParamUpdate.Instance()
                .Column("AuditState", data.status)
                .Column("AuditReason", data.comment)
                .Column("AuditPerson", FormsAuth.GetUserData().UserName)
                .Column("AuditDate", DateTime.Now)
                .AndWhere("BillNo", id));

            if (result <= 0)
                throw new HttpResponseException(new HttpResponseMessage() { Content = new StringContent("审核领货单失败{BillNo=" + id + "},请重试或联系管理员!") });
        }
 public void Delete(string id)
 {
     var service = new psi_pickingService();
     var result = service.Delete(ParamDelete.Instance().AndWhere("BillNo", id));
     if (result <= 0)
         throw new HttpResponseException(new HttpResponseMessage() { Content = new StringContent("领货单删除失败{BillNo=" + id + "},请重试或联系管理员!") });
 }
 public string GetNewBillNo()
 {
     var service = new psi_pickingService();
     return service.GetNewKey("BillNo", "dateplus");
 }