private void simpleButton6_Click(object sender, EventArgs e)
        {
            var header = new ICPOBILL_PolicyDTO();


            header.Account   = txt厂家账户.Text;
            header.BrandName = comBrand.SelectedItem is TB_BrandModel
                ? ((TB_BrandModel)comBrand.SelectedItem).FNAME
                : "";
            header.OrderType = cmbOrderType.SelectedItem is SYS_SUBDICSMODEL
                ? ((SYS_SUBDICSMODEL)cmbOrderType.SelectedItem).FNUMBER
                : "";

            header.OrderSubType = cmbBusinessType.SelectedItem is SYS_SUBDICSMODEL
                ? ((SYS_SUBDICSMODEL)cmbBusinessType.SelectedItem).FNUMBER
                : "";
            header.Channel = cmbSaleChannel.SelectedItem is SYS_SUBDICSMODEL
                ? ((SYS_SUBDICSMODEL)cmbSaleChannel.SelectedItem).FNUMBER
                : "";
            header.HeadID = cmbPromotionPolicy.SelectedItem is LH_Policy
                ? ((LH_Policy)cmbPromotionPolicy.SelectedItem).Id : "";

            FrmNewQueryProduct queryFrm = new FrmNewQueryProduct();

            queryFrm.header = header;
            if (queryFrm.ShowDialog() == DialogResult.OK)
            {
                var selectRows = queryFrm.SelectRows;

                List <V_ICPOBILLENTRYMODEL> datasource = gridView发货计划明细.DataSource as List <V_ICPOBILLENTRYMODEL>;
                if (datasource == null)
                {
                    datasource = new List <V_ICPOBILLENTRYMODEL>();
                }

                selectRows = selectRows.Where(r => !datasource.Exists(p => p.FSRCCODE == r.PRODCODE)).ToList();
                foreach (var row in selectRows)
                {
                    datasource.Add(PolicyProductToICPOBillEntry(row));
                }

                if (gridControl采购订单明细 != null)
                {
                    gridControl采购订单明细.DataSource = datasource;
                }
                gridView发货计划明细.RefreshData();
            }

            queryFrm.Dispose();
        }
        public PageResult <v_lhproducts_policyModel> GetPolicyProducts(ICPOBILL_PolicyDTO header,
                                                                       v_lhproducts_policyModel where, int index = 1, int size = 35)
        {
            where = ComputeWhere(header, where);
            var helper = new OracleDBHelper();
            var total  = 0;

            string whereStr = helper.GetWhereStr(where);

            List <v_lhproducts_policyModel> resultList = new List <v_lhproducts_policyModel>();

            if (string.IsNullOrEmpty(header.HeadID))
            {
                List <V_LHPRODUCTS_UNPOLICYHEADID> data =
                    helper.GetWithWhereStrByPage <V_LHPRODUCTS_UNPOLICYHEADID>(whereStr, where, index, size);

                total = helper.Count <V_LHPRODUCTS_UNPOLICYHEADID>(whereStr);

                var t = typeof(V_LHPRODUCTS_UNPOLICYHEADID);

                var pis = t.GetProperties().ToList();

                data.ForEach(p =>
                {
                    var item = new v_lhproducts_policyModel();
                    pis.ForEach(pi =>
                    {
                        var value = pi.GetValue(p, null);
                        pi.SetValue(item, value);
                    });
                    resultList.Add(item);
                });
            }
            else
            {
                List <v_lhproducts_policyModel> data =
                    helper.GetWithWhereStrByPage <v_lhproducts_policyModel>(whereStr, where, index, size);

                total      = helper.Count <v_lhproducts_policyModel>(whereStr);
                resultList = data;
            }

            PageResult <v_lhproducts_policyModel> result = new PageResult <v_lhproducts_policyModel>()
            {
                Total = total, Result = resultList
            };

            return(result);
        }
        private v_lhproducts_policyModel ComputeWhere(ICPOBILL_PolicyDTO header, v_lhproducts_policyModel where)
        {
            CheckNull(header);

            where.LHPRODTYPE = header.BrandName;

            switch (header.OrderType)
            {
            //常规订单
            case "Common":
            {
                where.LHPRODSIGN = "成品";
                break;
            }

            //配件订单
            case "Parts":
            {
                where.LHPRODSIGN = "配件";
                break;
            }

            //广告物料申请单
            case "Advertise":
            {
                where.LHPRODSIGN = "广告物料";
                where.LHPRODTYPE = "广告用品";
                break;
            }
            }

            where.HEADID = string.IsNullOrEmpty(header.HeadID) ? null : header.HeadID;

            if (!string.IsNullOrEmpty(header.HeadID))
            {
                where.DEPTNAME     = header.BrandName.Contains("事业部") ? header.BrandName : $"{header.BrandName}事业部";
                where.ORDERTYPE    = header.OrderType;
                where.ORDERSUBTYPE = header.OrderSubType;
                where.ACCTCODES    = header.Account;
            }

            where.LHPRODCHANNEL = header.Channel;

            return(where);
        }
        public List <LH_Policy> GetPolicies(ICPOBILL_PolicyDTO header)
        {
            //检查传入参数是否合法
            CheckNull(header);
            var helper = new OracleDBHelper();
            var sql    =
                @"SELECT DISTINCT HEADID,POLICYNAME,ORDERTYPE,ORDERSUBTYPE,PRODCHANNEL,DEPTNAME from LH_POLICY WHERE 1=1 ";

            //选择订单类型为常规订单的,如果用户要选择促销政策头ID的话则需要同时判断:订单所属公司(事业部)、厂家账号(经销商账号)、销售渠道、业务类型、五项头字段信息来取促销政策头ID信息
            string where = $@"AND ORDERTYPE='{header.OrderType}' AND DEPTNAME LIKE '%{header.BrandName}%' 
                                    AND ORDERSUBTYPE='{header.OrderSubType}' AND PRODCHANNEL='{header.Channel}' AND ACCTCODES LIKE '%{header.Account}%'";

            sql += where;

            var policies = helper.Select <LH_Policy>(sql);

            return(policies);
        }
        private bool CheckNull(ICPOBILL_PolicyDTO header)
        {
            var t   = typeof(ICPOBILL_PolicyDTO);
            var pis = t.GetProperties().ToList();

            //检查传入参数值是否为空
            pis.ForEach(p =>
            {
                var attr = p.GetCustomAttributes(true)
                           .SingleOrDefault(c => c is RequiredAttribute) as RequiredAttribute;
                var value = p.GetValue(header);
                if ((value == null || string.IsNullOrEmpty(value.ToString())) && attr != null)
                {
                    throw new ValidationException(attr.ErrorMessage);
                }
            });

            return(true);
        }
        private void cmbPromotionPolicy_MouseClick(object sender, MouseEventArgs e)
        {
            var header = new ICPOBILL_PolicyDTO();


            header.Account   = txt厂家账户.Text;
            header.BrandName = comBrand.SelectedItem is TB_BrandModel
                ? ((TB_BrandModel)comBrand.SelectedItem).FNAME
                : "";

            header.OrderType = cmbOrderType.SelectedItem is SYS_SUBDICSMODEL
                ? ((SYS_SUBDICSMODEL)cmbOrderType.SelectedItem).FNUMBER
                : "";

            header.OrderSubType = cmbBusinessType.SelectedItem is SYS_SUBDICSMODEL
                ? ((SYS_SUBDICSMODEL)cmbBusinessType.SelectedItem).FNUMBER
                : "";

            header.Channel = cmbSaleChannel.SelectedItem is SYS_SUBDICSMODEL
                ? ((SYS_SUBDICSMODEL)cmbSaleChannel.SelectedItem).FNUMBER
                : "";


            try
            {
                var policies = _service.GetPolicies(header);
                cmbPromotionPolicy.Text = "";
                cmbPromotionPolicy.Properties.Items.Clear();
                cmbPromotionPolicy.Properties.Items.AddRange(policies);

                cmbPromotionPolicy.ShowPopup();
            }
            catch (Exception exception)
            {
                MsgHelper.ShowInformation(exception.Message);
            }
        }
 public PageResult <v_lhproducts_policyModel> GetPolicyProducts(ICPOBILL_PolicyDTO header,
                                                                v_lhproducts_policyModel where, int index = 1, int size = 35)
 {
     return(methods.GetPolicyProducts(header, where, index, size));
 }
 public List <LH_Policy> GetPolicies(ICPOBILL_PolicyDTO header)
 {
     LogHelper.Info($"接收参数 :{JsonConvert.SerializeObject(header)}");
     return(methods.GetPolicies(header));
 }
 public List <LH_Policy> GetPolicies(ICPOBILL_PolicyDTO header)
 {
     return(methods.GetPolicies(header));
 }