/// <summary>
        /// 获取品牌列表
        /// </summary>
        /// <returns></returns>
        public List <TB_BrandModel> GetBrandList(hn.Core.Model.User loginUser)
        {
            try
            {
                var brandlist = TB_BrandDal.Instance.GetAll().ToList();
                if (loginUser.IsAdmin != 1)
                {
                    List <TB_BrandModel> list = new List <TB_BrandModel>();

                    var userbrand = TB_USERBRANDDal.Instance.GetWhere(new { FUSERID = loginUser.FID });
                    foreach (var model in brandlist)
                    {
                        var count = userbrand.Where(m => m.FBRANDID == model.FID).Count();
                        if (count > 0)
                        {
                            list.Add(model);
                        }
                    }

                    return(list);
                }
                else
                {
                    return(brandlist);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取承运公司列表
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <returns></returns>
        //public List<TB_EXPRESSCOMPANYModel> GetExpressCompanyList(string keyword)
        //{
        //    try
        //    {


        //        return TB_EXPRESSCOMPANYDal.Instance.GetAll().ToList();
        //    }
        //    catch (Exception ex)
        //    {
        //        LogHelper.WriteLog(ex);
        //        throw ex;
        //    }
        //}

        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public List <ProductViewModel> GetProductList(hn.Core.Model.User loginUser, string keywords)
        {
            try
            {
                StringBuilder query = new StringBuilder();
                if (!keywords.IsNullOrEmpty())
                {
                    query.Append(" and ( ");

                    query.AppendFormat("  FPRODUCTNAME like '%{0}%' ", keywords);
                    query.AppendFormat(" OR FPRODUCTTYPE like '%{0}%' ", keywords);
                    query.AppendFormat(" OR FPRODUCTCODE like '%{0}%' ", keywords);
                    query.AppendFormat(" OR FMODEL like '%{0}%' ", keywords);

                    query.Append(" ) ");
                }
                if (loginUser.IsAdmin != 1)
                {
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat(" AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }
                return(ProductViewDal.Instance.GetWhereStr(query.ToStr()).ToList());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        public List <V_ICPRBILLMODEL> GetPurchasePlanImport3(
            hn.Core.Model.User loginUser,
            hn.Common.Cls_query.P_QueryOrder queryCls
            )
        {
            try
            {
                StringBuilder query = new StringBuilder();


                if (loginUser.IsAdmin != 1)
                {
                    query.AppendFormat("  AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }

                query.AppendFormat(" and FBRANDID ='{0}'", queryCls.brand);

                if (!string.IsNullOrEmpty(queryCls.address))
                {
                    query.AppendFormat(" and FRECEIVINGADDR like '%{0}%'", queryCls.address);
                }
                if (!string.IsNullOrEmpty(queryCls.P_BillNo))
                {
                    query.AppendFormat(" and FBILLNO like '%{0}%'", queryCls.P_BillNo);
                }
                if (queryCls.startTime != DateTime.MinValue)
                {
                    //query.AppendFormat(" and FBILLDATE >= to_date('{0}','yyyyMMdd')", queryCls.startTime);
                }

                if (queryCls.endTime != DateTime.MinValue)
                {
                    //query.AppendFormat(" and FBILLDATE <= to_date('{0}','yyyyMMdd')", queryCls.endTime);
                }

                // query.AppendFormat(" and FSTATUS='7' and FID not in (select FPLANID from icprbillentry where FID in (select FPLANID from ICPOBILLENTRY))", "");

                query.AppendFormat(" and FSTATUS='7' and FID in (select FPLANID from icprbillentry where ICPOBILLENTRYID is null or ICPOBILLENTRYID='')", "");

                LogHelper.WriteLog(query.ToString());

                return(V_ICPRBILLDAL.Instance.GetWhereStr(query.ToString(), "FBILLDATE DESC").ToList());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        public List <V_ICPRBILLMODEL> GetPurchasePlanImport2(
            hn.Core.Model.User loginUser,
            string strQuery, string brandid
            )
        {
            try
            {
                StringBuilder query = new StringBuilder();

                // query.AppendLine(" and FStatus = 3 ");


                if (!strQuery.IsNullOrEmpty())
                {
                    query.AppendFormat(" and (FCLASSAREA2NAME like '%{0}%' or FBILLNO like '%{1}%')", strQuery, strQuery);
                }


                if (loginUser.IsAdmin != 1)
                {
                    //  query.AppendFormat("  AND FPREMISEID IN (SELECT FPREMISEID FROM TB_USERPREMISE WHERE FUSERID = '{0}') ", loginUser.FID);
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat("  AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }

                query.AppendFormat(" and FBRANDID ='{0}'", brandid);

                LogHelper.WriteLog(query.ToString());

                return(V_ICPRBILLDAL.Instance.GetWhereStr(query.ToString(), "FBILLDATE DESC").ToList());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        /// <summary>
        /// 获取请购计划列表
        /// </summary>
        /// <param name="classarea2name">销区</param>
        /// <param name="brand">品牌</param>
        /// <param name="status">状态</param>
        /// <param name="premiseid">经营场所</param>
        /// <returns></returns>
        public List <V_ICPRBILLMODEL> GetPurchasePlanList(
            hn.Core.Model.User loginUser,
            string classarea2name,
            string brand,
            int status,
            string premiseid,
            string billno,
            string startdate,
            string enddate,
            bool searchclose = false
            )
        {
            try
            {
                StringBuilder query = new StringBuilder();

                if (!premiseid.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPREMISEID = '{0}' ", premiseid);
                }

                if (status > 0)
                {
                    query.AppendFormat(" and FStatus = {0} ", status);
                }

                if (!searchclose)
                {
                    query.AppendLine(" and FStatus <> 5 ");
                }

                if (!classarea2name.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FCLASSAREA2NAME like '%{0}%' ", classarea2name);
                }

                if (!billno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FBILLNO like '%{0}%' ", billno);
                }

                if (!brand.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FBRANDID = '{0}' ", brand);
                }

                if (!startdate.IsNullOrEmpty() && startdate != "0001/01/01")
                {
                    query.AppendFormat(" and to_char(FBILLDATE,'yyyy/MM/dd')  >= '{0}' ", startdate);
                }

                if (!enddate.IsNullOrEmpty() && enddate != "0001/01/01")
                {
                    query.AppendFormat(" and to_char(FBILLDATE,'yyyy/MM/dd') <= '{0}' ", enddate);
                }

                if (loginUser.IsAdmin != 1)
                {
                    //  query.AppendFormat("  AND FPREMISEID IN (SELECT FPREMISEID FROM TB_USERPREMISE WHERE FUSERID = '{0}') ", loginUser.FID);
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat("  AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }

                LogHelper.WriteLog(query.ToString());

                return(V_ICPRBILLDAL.Instance.GetWhereStr(query.ToString(), "FBILLDATE DESC").ToList());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        /// <summary>
        /// 获取请购计划明细列表(组柜用)
        /// </summary>
        /// <param name="productinfo">商品信息</param>
        /// <param name="classarea2name">销区</param>
        /// <param name="premiseid">经营场所</param>
        /// <param name="brand">品牌部</param>
        /// <param name="deliveryaddr">发货地点</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public List <V_ICPRBILLENTRYMODEL> GetPurchasePlanEntryByDeliveryList(
            hn.Core.Model.User loginUser,
            string productinfo,
            string classarea2name,
            string premiseid,
            string brand,
            string deliveryaddr,
            string typename,
            string billno,
            int status)
        {
            try
            {
                StringBuilder query = new StringBuilder();

                if (!productinfo.IsNullOrEmpty())
                {
                    query.Append(" and ( ");

                    query.AppendFormat("  FPRODUCTCODE like '%{0}%' ", productinfo);
                    query.AppendFormat(" OR FPRODUCTNAME like '%{0}%' ", productinfo);
                    query.AppendFormat(" OR FMODEL like '%{0}%' ", productinfo);

                    query.Append(" ) ");
                }

                if (!premiseid.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPREMISEID = '{0}' ", premiseid);
                }

                if (!classarea2name.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FCLASSAREA2NAME LIKE '%{0}%' ", classarea2name);
                }

                if (!brand.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPREMISEBRANDNAME LIKE '%{0}%' ", brand);
                }

                if (!deliveryaddr.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FDELIVERYADDR LIKE '%{0}%' ", deliveryaddr);
                }

                if (!typename.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FTYPENAME LIKE '%{0}%' ", typename);
                }

                if (!billno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and ICPRBILLNO LIKE '%{0}%' ", billno);
                }

                if (status > 0)
                {
                    query.AppendFormat(" and FSTATUS = {0} ", status);
                }

                if (loginUser.IsAdmin != 1)
                {
                    //  query.AppendFormat("  AND FPREMISEID IN (SELECT FPREMISEID FROM TB_USERPREMISE WHERE FUSERID = '{0}') ", loginUser.FID);
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat("  AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }

                return(V_ICPRBILLENTRYDAL.Instance.GetWhereStr(query.ToString()).ToList());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        public List <ICPO_BOLentryModel> GeICPO_BOLList(
            hn.Core.Model.User loginUser,
            string FPObillno,
            string Ficbolno,
            int FSYNCSTATUS,
            string FACCOUNT,
            string FITEMID,
            string startdate,
            string enddate, bool searchclose = false)
        {
            try
            {
                StringBuilder query = new StringBuilder();

                if (!FPObillno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPObillno = '{0}' ", FPObillno);
                }

                if (!Ficbolno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and Ficbolno = '{0}' ", Ficbolno);
                }

                if (FSYNCSTATUS > 0)
                {
                    query.AppendFormat(" and FSYNCSTATUS = {0} ", FSYNCSTATUS);
                }

                if (!FACCOUNT.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FACCOUNT = '{0}' ", FACCOUNT);
                }

                if (!FITEMID.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FITEMID = '{0}' ", FITEMID);
                }


                if (!startdate.IsNullOrEmpty() && startdate != "0001/01/01")
                {
                    query.AppendFormat(" and  FDATE >= to_date('{0}','yyyy-MM-dd HH24:mi:ss') ", startdate);
                }

                if (!enddate.IsNullOrEmpty() && enddate != "0001/01/01")
                {
                    query.AppendFormat(" and  FDATE <= to_date('{0}','yyyy-MM-dd HH24:mi:ss') ", enddate);
                }

                if (loginUser.IsAdmin != 1)
                {
                    //  query.AppendFormat("  AND FPREMISEID IN (SELECT FPREMISEID FROM TB_USERPREMISE WHERE FUSERID = '{0}') ", loginUser.FID);
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat("  AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }

                LogHelper.WriteLog(query.ToString());

                return(ICPO_BOLentryDAL.Instance.GetWhereStr(query.ToString(), "FDATE DESC").ToList());
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        /// <summary>
        /// 获取请购计划明细列表(组柜用)
        /// </summary>
        /// <param name="productinfo">商品信息</param>
        /// <param name="classarea2name">销区</param>
        /// <param name="premiseid">经营场所</param>
        /// <param name="brand">品牌部</param>
        /// <param name="deliveryaddr">发货地点</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public List <V_ICPRBILLENTRYMODEL> GetPurchasePlanEntryByDeliveryList(
            hn.Core.Model.User loginUser,
            string yjfsid,
            string classarea2name,
            string premiseid,
            string brand,
            string deliveryaddr,
            string typename,
            string billno,
            int status, bool bHaveSL)
        {
            try
            {
                StringBuilder query = new StringBuilder();

                if (!yjfsid.IsNullOrEmpty())
                {
                    query.AppendFormat(" and fplanid in(select fid from icprbill where ftransname='{0}') ", yjfsid);
                }

                if (!premiseid.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPREMISEID = '{0}' ", premiseid);
                }

                if (!classarea2name.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FCLASSAREA2NAME LIKE '%{0}%' ", classarea2name);
                }

                if (!brand.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPREMISEBRANDNAME LIKE '%{0}%' ", brand);
                }

                //FPREMISEBRANDID
                //query.AppendFormat(" and FPREMISEBRANDID='01' ", "");

                if (!deliveryaddr.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FDELIVERYADDR LIKE '%{0}%' ", deliveryaddr);
                }

                if (!typename.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FTYPENAME LIKE '%{0}%' ", typename);
                }

                if (!billno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and ICPRBILLNO LIKE '%{0}%' ", billno);
                }

                if (status > 0)
                {
                    query.AppendFormat(" and FSTATUS = {0} ", status);
                }

                if (bHaveSL)
                {
                    query.AppendFormat(" and fid in (select icprbillentryid from v_icpr_icpo_icseout_thd where (leftsl>0 or leftsl is null) and autoid is not null and fdesbillno is not null) ", "");
                }

                if (loginUser.IsAdmin != 1)
                {
                    //  query.AppendFormat("  AND FPREMISEID IN (SELECT FPREMISEID FROM TB_USERPREMISE WHERE FUSERID = '{0}') ", loginUser.FID);
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat("  AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }
                LogHelper.WriteLog(query.ToStr());



                List <V_ICPRBILLENTRYMODEL> list = V_ICPRBILLENTRYDAL.Instance.GetWhereStr(query.ToString()).ToList();
                return(list);

                /*
                 * List<V_ICPRBILLENTRYMODEL> list1 = new List<V_ICPRBILLENTRYMODEL>();
                 * foreach (var sub in list)
                 * {
                 *  if (Get_CountTHD(sub.FID) > 0)
                 *  {
                 *      list1.Add(sub);
                 *  }
                 * }
                 *
                 *
                 * return list1;
                 */
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
        /// <summary>
        /// 获取发货计划列表
        /// </summary>
        /// <param name="brand">品牌</param>
        /// <param name="classarea2name">销区</param>
        /// <param name="premiseid">经营场所</param>
        /// <param name="status">状态</param>
        /// <param name="car">车辆</param>
        /// <param name="stock">仓库</param>
        /// <param name="account">厂家账户</param>
        /// <param name="expresscompany">承运公司</param>
        /// <param name="factotryno">厂家单号</param>
        /// <param name="billno">发货计划单号</param>
        /// <param name="groupno">组柜单号</param>
        /// <param name="projectname">工程名称</param>
        /// <param name="searchclose">是否查询已关闭的数据</param>
        /// <returns></returns>
        public List <V_ICSEOUTBILLMODEL> GetDeliveryList(
            hn.Core.Model.User loginUser,
            string brand,
            string classarea2name,
            string premiseid,
            int status,
            string car,
            string stock,
            string account,
            string expresscompany,
            string factotryno,
            string billno,
            string groupno,
            string projectname,
            string startdate,
            string enddate,
            bool searchclose = false)
        {
            try
            {
                StringBuilder query = new StringBuilder();

                if (!premiseid.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPREMISEID = '{0}' ", premiseid);
                }

                if (!brand.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FBRANDID = '{0}' ", brand);
                }

                if (!account.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FCLIENTID = '{0}' ", account);
                }

                if (!expresscompany.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FEXPRESSCOMPANYID = '{0}' ", expresscompany);
                }

                if (!classarea2name.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FCLASSAREA2NAME LIKE '%{0}%' ", classarea2name);
                }

                if (!car.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FCARNUMBER LIKE '%{0}%' ", car);
                }

                if (!factotryno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FSRCBILLNO LIKE '%{0}%' ", factotryno);
                }

                if (!billno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FBILLNO LIKE '%{0}%' ", billno);
                }

                if (!groupno.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FGROUP_NO LIKE '%{0}%' ", groupno);
                }

                if (!projectname.IsNullOrEmpty())
                {
                    query.AppendFormat(" and FPROJECTNAME LIKE '%{0}%' ", projectname);
                }

                if (status > 0)
                {
                    query.AppendFormat(" and FSTATUS = {0} ", status);
                }

                if (!searchclose)
                {
                    query.AppendLine(" and FStatus <> 5 ");
                }

                if (!startdate.IsNullOrEmpty())
                {
                    query.AppendFormat(" and to_char(FBILLDATE,'yyyy/MM/dd')  >= '{0}' ", startdate);
                }

                if (!enddate.IsNullOrEmpty())
                {
                    query.AppendFormat(" and to_char(FBILLDATE,'yyyy/MM/dd') <= '{0}' ", enddate);
                }


                if (loginUser.IsAdmin != 1)
                {
                    //品牌/厂家进行数据权限控制
                    query.AppendFormat(" AND FBRANDID IN (SELECT FBRANDID FROM TB_USERBRAND WHERE FUSERID = '{0}') ", loginUser.FID);
                }

                hn.Common.LogHelper.WriteLog(query.ToString());

                return(V_ICSEOUTBILLDAL.Instance.GetWhereStr(query.ToString(), "FBILLDATE DESC").ToList());
            }
            catch (Exception ex)
            {
                hn.Common.LogHelper.WriteLog(ex);
                throw ex;
            }
        }