Пример #1
0
        /// <summary>
        /// 返回一个地区下的所有子地区
        /// </summary>
        /// <param name="tid"></param>
        /// <returns></returns>
        public static string Area_ids(int tid)
        {
            string           ids = tid.ToString();
            List <Lebi_Area> ts  = B_Lebi_Area.GetList("Parentid=" + tid + "", "");

            foreach (Lebi_Area t in ts)
            {
                ids += "," + Area_ids(t.id);
            }
            return(ids);
        }
Пример #2
0
        /// <summary>
        /// 返回一个AREA的所有父id(不含自己)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string Parentids_Get(int area_id)
        {
            string    ids  = "";
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area != null)
            {
                ids = area.Parentid.ToString();
                if (area.Parentid > 0)
                {
                    ids += "," + Parentids_Get(area.Parentid);
                }
            }
            return(ids);
        }
Пример #3
0
        /// <summary>
        /// 返回地区名称目录
        /// </summary>
        /// <param name="area_id"></param>
        /// <param name="deep">目录深度 0</param>
        /// <param name="loop">显示层级</param>
        /// <returns></returns>
        public static string GetAreaName(int area_id, int deep, int loop)
        {
            string res = "";

            loop++;
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area == null)
            {
                return(res);
            }
            res = area.Name;
            if (area.Parentid > 0 && loop < 5)
            {
                res = GetAreaName(area.Parentid, deep, loop);
            }
            return(res);
        }
Пример #4
0
        /// <summary>
        /// 返回地区名称目录
        /// </summary>
        /// <param name="area_id"></param>
        /// <param name="deep">目录深度</param>
        /// <returns></returns>
        public static string GetAreaName(int area_id, int deep)
        {
            string res = "";

            deep--;
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area == null)
            {
                return(res);
            }
            res = area.Name;
            if (deep > 0)
            {
                res = GetAreaName(area.Parentid, deep) + " " + res;
            }
            return(res);
        }
Пример #5
0
        /// <summary>
        /// 查询对于的代理资格设置
        /// </summary>
        /// <param name="areaid"></param>
        /// <returns></returns>
        private Lebi_Agent_Area GetAgentArea(int areaid)
        {
            Lebi_Agent_Area agentarea = B_Lebi_Agent_Area.GetModel("Area_id=" + areaid + " and IsFailure=0");

            if (agentarea != null)
            {
                return(agentarea);
            }
            else
            {
                Lebi_Area area = B_Lebi_Area.GetModel(areaid);
                if (area != null)
                {
                    return(GetAgentArea(area.Parentid));
                }
            }
            return(null);
        }
Пример #6
0
        /// <summary>
        /// 返回一个AREA的最后一个父id(不含自己)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static int Parentids_Get(int area_id, int path)
        {
            int       id   = 0;
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area == null)
            {
                return(area_id);
            }
            else
            {
                id = area.Parentid;
                if (area.Parentid > 0)
                {
                    id = Parentids_Get(area.Parentid, path);
                }
            }
            return(id);
        }
Пример #7
0
        /// <summary>
        /// 获取指定运输公司,指定区域的价格
        /// </summary>
        /// <returns></returns>
        public static Lebi_Transport_Price GetAreaPrice(int transport_id, int area_id, int supplierid)
        {
            Lebi_Transport_Price price = B_Lebi_Transport_Price.GetModel("Transport_id=" + transport_id + " and Area_id=" + area_id + " and Supplier_id=" + supplierid + "");

            if (price == null)
            {
                Lebi_Area area = B_Lebi_Area.GetModel(area_id);
                if (area != null)
                {
                    if (area.Parentid > 0)
                    {
                        return(GetAreaPrice(transport_id, area.Parentid, supplierid));
                    }
                    return(null);
                }
                return(null);
            }
            return(price);
        }
Пример #8
0
        public static string GetAreaNameNoPath(int area_id, int deep)
        {
            string res = "";

            deep--;
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area == null)
            {
                return(res);
            }
            res = area.Name;
            if (area.Parentid > 0 && deep > 0)
            {
                res = GetAreaNameNoPath(area.Parentid, deep);
                return(res);
            }
            DateTime dt = System.DateTime.Now.Date.AddDays(0 - System.DateTime.Now.Day);

            return(res);
        }
Пример #9
0
 /// <summary>
 /// 递归处理运费价格
 /// </summary>
 /// <param name="area"></param>
 /// <param name="trans"></param>
 /// <returns></returns>
 private static List <Lebi_Transport_Price> TransportPrice(Lebi_Area area, List <Lebi_Transport_Price> trans, int supplierid)
 {
     if (trans == null)
     {
         trans = B_Lebi_Transport_Price.GetList("Area_id=" + area.id + " and Supplier_id=" + supplierid + "", "");
     }
     else
     {
         string pids = "";
         List <Lebi_Transport_Price> models = B_Lebi_Transport_Price.GetList("Area_id=" + area.id + " and Supplier_id=" + supplierid + "", "");
         foreach (Lebi_Transport_Price model in models)
         {
             //排除包含的关系
             //跳过儿子,孙子在列表中的情况
             bool flag = false;
             foreach (Lebi_Transport_Price tran in trans)
             {
                 pids = EX_Area.Parentids_Get(tran.Area_id);
                 pids = "," + pids + ",";
                 if (pids.Contains("," + model.Area_id + ",") && model.Transport_id == tran.Transport_id)
                 {
                     flag = true;
                 }
             }
             if (!flag)
             {
                 trans.Add(model);
             }
         }
     }
     if (area.Parentid > 0)
     {
         area = B_Lebi_Area.GetModel(area.Parentid);
         if (area != null)
         {
             trans = TransportPrice(area, trans, supplierid);
         }
     }
     return(trans);
 }
Пример #10
0
        /// <summary>
        /// 根据配送地区取出运输公司并计算相应运费
        /// </summary>
        public static List <Lebi_Transport_Price> TransportPrices_Get(int area_id, int supplierid)
        {
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area == null)
            {
                return(new List <Lebi_Transport_Price>());
            }
            List <Lebi_Transport_Price> trans = null;//配送地区含当前地区的运输公司以及价格

            trans = TransportPrice(area, trans, supplierid);
            foreach (Lebi_Transport_Price p in trans)
            {
                Lebi_Transport t = B_Lebi_Transport.GetModel(p.Transport_id);
                if (t != null)
                {
                    p.Sort = t.Sort;
                }
            }
            trans = trans.OrderByDescending(a => a.Sort).ToList();
            return(trans);
        }
Пример #11
0
        public static string GetAreaNameDesc(int area_id, int deep)
        {
            string res = "";

            deep--;
            Lebi_Area area = B_Lebi_Area.GetModel(area_id);

            if (area == null)
            {
                return(res);
            }
            res = area.Name;
            if (deep > 0)
            {
                Lebi_Area areacheck = B_Lebi_Area.GetModel(area.Parentid);
                if (areacheck != null)
                {
                    res = res + ",";
                }
                res = res + GetAreaNameDesc(area.Parentid, deep);
            }
            return(res);
        }