Пример #1
0
 internal static DataTable GetUserFavCompany(List<int> favCmps, SysAreaMansion mansion, char cbMyCompany)
 {
     var query = DB.Select(Utilities.GetTableColumns(SysCompany.Schema))
                   .From<SysCompany>( )
                   .InnerJoin(SysCompanyMansion.CompanyIDColumn, SysCompany.IdColumn)
                   .Where(SysCompany.CompanyTypeColumn).IsEqualTo((int)CompanyType.MealCompany)
                   .And(SysCompany.CompanyStatusColumn).IsEqualTo(1)
                   .And(SysCompanyMansion.MansionIDColumn).IsEqualTo(mansion.Id)
                   .And(SysCompany.IdColumn).In(favCmps)
                   .OrderDesc(SysCompany.Columns.SetTopDate, SysCompany.Columns.IsOnSale, SysCompany.Columns.IsPoint);
     if (cbMyCompany == '1') //营业中
         query.And(SysCompany.IsSuspendColumn).IsNotEqualTo(true)
              .ConstraintExpression(CompanyBLL.FuncCheckIsWorkingTime(1));
     else if (cbMyCompany == '2') //免费送餐
         query.AndEx(SysCompany.ServiceSumColumn).IsEqualTo(0)
              .Or(SysCompany.ServiceSumColumn).IsNull( )
              .CloseEx( );
     //using (var dr = query.ExecuteReader( ))
     //{
     //    while (dr.Read( ))
     //    {
     //        SysCompany cmp = new SysCompany( );
     //        cmp.Load(dr);
     //        yield return cmp;
     //    }
     //}
     return query.ExecuteDataTable( );
 }
Пример #2
0
 public static SysAreaMansion GetAreaMansion(string areaName, string mansionName)
 {
     var areaDict = AreaBLL.AreaNameMapping;
     if (!areaDict.ContainsKey(areaName))
         return null;
     var area = areaDict[areaName];
     var query = DB.Select( ).Top("1").From<SysAreaMansion>( )
                   .Where(SysAreaMansion.AreaIDColumn).IsEqualTo(area.Id)
                   .And(SysAreaMansion.NameColumn).IsEqualTo(mansionName);
     SysAreaMansion mansion = null;
     using (var dr = query.ExecuteReader( ))
     {
         if (dr.Read( ))
         {
             mansion = new SysAreaMansion( );
             mansion.Load(dr);
         }
     }
     if (mansion == null)
     {
         mansion = new SysAreaMansion
         {
             AreaID = area.Id,
             Name = mansionName,
             Address = null,
             Code = null,
             AreaDepth = area.Depth,
         };
         mansion.Save( );
     }
     return mansion;
 }
Пример #3
0
 public static IEnumerable<SysAreaMansion> LoadCompanyMansions(int companyId)
 {
     var query = DB.Select(Utilities.GetTableColumns(SysAreaMansion.Schema)).From<SysAreaMansion>( )
                             .InnerJoin(SysCompanyMansion.MansionIDColumn, SysAreaMansion.IdColumn)
                             .Where(SysCompanyMansion.CompanyIDColumn).IsEqualTo(companyId);
     using (var rdr = query.ExecuteReader( ))
     {
         while (rdr.Read( ))
         {
             SysAreaMansion companyMansion = new SysAreaMansion( );
             companyMansion.Load(rdr);
             yield return companyMansion;
         }
     }
 }
Пример #4
0
 public static IEnumerable<SysAreaMansion> LoadAreaMansions( )
 {
     var rdr = DB.Select( ).From<SysAreaMansion>( ).ExecuteReader( );
     using (rdr)
     {
         while (rdr.Read( ))
         {
             SysAreaMansion mansion = new SysAreaMansion( );
             mansion.Load(rdr);
             yield return mansion;
         }
     }
 }
Пример #5
0
        public static bool ImportAreaMansion(DataTable dt, out string message)
        {
            bool result = false;
            message = string.Empty;
            var dcAreaName = (DataColumn)null;
            var dcName = (DataColumn)null;
            var dcAddr = (DataColumn)null;
            if (dt.Columns.Contains("所属片区"))
                dcAreaName = dt.Columns["所属片区"];
            if (dt.Columns.Contains("派送范围"))
                dcName = dt.Columns["派送范围"];
            if (dt.Columns.Contains("大厦地址"))
                dcAddr = dt.Columns["大厦地址"];
            if (dcAreaName == null || dcName == null)
            {
                message = "上传的excel 文档必须包含有 所属片区 和 派送范围两列信息";
                goto lbl_return;
            }

            var areaDict = AreaBLL.AreaNameMapping;
            string areaName, mansionName;
            SysArea area;
            MansionAreaId mansionAreaId;
            foreach (DataRow dr in dt.Rows)
            {
                if (string.IsNullOrEmpty(areaName = Convert.ToString(dr[dcAreaName]).Trim( )))
                    continue;
                if (string.IsNullOrEmpty(mansionName = Convert.ToString(dr[dcName]).Trim( )))
                    continue;
                if (!areaDict.ContainsKey(areaName))
                    continue;
                area = areaDict[areaName];
                mansionAreaId = MansionAreaId.GetMansionAreaId(area.Id, mansionName);
                if (AreaMansionMapping.ContainsKey(mansionAreaId))
                    continue;
                SysAreaMansion mansion = new SysAreaMansion
                {
                    AreaID = area.Id,
                    Name = mansionName,
                    Address = dcAddr != null ? Convert.ToString(dr[dcAddr]).Trim( ) : null,
                    Code = null,
                    AreaDepth = area.Depth,
                };
                mansion.Save( );
                AreaMansionMapping.Add(mansionAreaId, mansion);
            }
            result = true;
            lbl_return:
            return result;
        }
Пример #6
0
        public void Insert(int? AreaID,string Name,string AreaDepth,string Code,string Address)
        {
            SysAreaMansion item = new SysAreaMansion();

            item.AreaID = AreaID;

            item.Name = Name;

            item.AreaDepth = AreaDepth;

            item.Code = Code;

            item.Address = Address;

            item.Save(UserName);
        }
Пример #7
0
        public void Update(int Id,int? AreaID,string Name,string AreaDepth,string Code,string Address)
        {
            SysAreaMansion item = new SysAreaMansion();
            item.MarkOld();
            item.IsLoaded = true;

            item.Id = Id;

            item.AreaID = AreaID;

            item.Name = Name;

            item.AreaDepth = AreaDepth;

            item.Code = Code;

            item.Address = Address;

            item.Save(UserName);
        }
Пример #8
0
        private static DataTable GetMealCompanyItems(bool isLogin, SysAreaMansion mansion, char cbJf)
        {
            var userLastOrderSum = UserBLL.GetUserAvgOrderSum(AppContext.Context.User.Id);
            var query = DB.Select(Utilities.GetTableColumns(SysCompanyItem.Schema), CompanyBLL.FuncIsWorkingTime( ))
                //.Top("3")
                          .From<SysCompanyItem>( )
                          .InnerJoin(SysCompany.IdColumn, SysCompanyItem.CompanyIDColumn)
                          .InnerJoin(SysCompanyMansion.CompanyIDColumn, SysCompany.IdColumn)
                          .Where(SysCompanyItem.IsDeletedColumn).IsEqualTo(false)
                          .And(SysCompanyItem.ItemEndDateColumn).IsGreaterThanOrEqualTo(DateTime.Today)
                          .And(SysCompanyItem.IsPassColumn).IsEqualTo(true)
                          .And(SysCompany.CompanyStatusColumn).IsEqualTo(1)
                          .And(SysCompany.CompanyTypeColumn).IsEqualTo((int)CompanyType.MealCompany)
                          .And(SysCompanyMansion.MansionIDColumn).IsEqualTo(mansion.Id)
                          .And(SysCompanyItem.ItemStatusColumn).IsEqualTo(1)
                //.ConstraintExpression(string.Format(" AND({0} - {1} > 0) ", Utilities.GetTableColumn(SysCompanyItem.ItemAmountColumn), Utilities.GetTableColumn(SysCompanyItem.ItemClickedColumn)))
                          .ConstraintExpression("AND({0} = {1})", AreaBLL.RenderCheckAreaDepthFunc(SysCompanyItem.AreaDepthColumn, mansion.AreaDepth, true), 1)
                          .OrderDesc(Utilities.GetTableColumn(SysCompanyItem.ItemIDColumn));
            //if (isLogin)
            //    query.ConstraintExpression(CompanyItemBLL.RenderCheckItemFuncInVals(AppContext.Context.User.Id, userLastOrderSum, "1", "-20","-19"));
            if (cbJf == '1') //营业中
                query.And(SysCompany.IsSuspendColumn).IsNotEqualTo(true)
                     .ConstraintExpression(CompanyBLL.FuncCheckIsWorkingTime(SysCompanyItem.WorkingHoursColumn.QualifiedName, SysCompany.CompanyTypeColumn.QualifiedName, 1))
                     .ConstraintExpression(string.Format(" AND({0} - {1} > 0) ", Utilities.GetTableColumn(SysCompanyItem.ItemAmountColumn), Utilities.GetTableColumn(SysCompanyItem.ItemClickedColumn)));
            else if (cbJf == '2')
                query.AndEx(SysCompany.ServiceSumColumn).IsEqualTo(0)
                     .Or(SysCompany.ServiceSumColumn).IsNull( )
                     .CloseEx( );

            //Logging.Log("test->GetMealCompanyItems", query.ToString( ), string.Empty);
            return query.ExecuteDataTable( );
            //using (var dr = query.ExecuteReader( ))
            //{
            //    while (dr.Read( ))
            //    {
            //        SysCompanyItem item = new SysCompanyItem( );
            //        item.Load(dr);
            //        yield return item;
            //    }
            //}
        }
Пример #9
0
 private static DataTable GetMealCompany(SysAreaMansion mansion, List<int> favCmps, char cbCompany)
 {
     var query = DB.Select(Utilities.GetTableColumns(SysCompany.Schema)).Top("200")
                   .From<SysCompany>( )
                   .InnerJoin(SysCompanyMansion.CompanyIDColumn, SysCompany.IdColumn)
                   .Where(SysCompany.CompanyTypeColumn).IsEqualTo((int)CompanyType.MealCompany)
                   .And(SysCompany.CompanyStatusColumn).IsEqualTo(1)
                   .And(SysCompanyMansion.MansionIDColumn).IsEqualTo(mansion.Id)
                   .OrderDesc(SysCompany.Columns.SetTopDate, SysCompany.Columns.IsOnSale, SysCompany.Columns.IsPoint);
     if (favCmps != null && favCmps.Count > 0)
         query.And(SysCompany.IdColumn).NotIn(favCmps);
     if (cbCompany == '1') //营业中
         query.And(SysCompany.IsSuspendColumn).IsNotEqualTo(true)
              .ConstraintExpression(CompanyBLL.FuncCheckIsWorkingTime(1));
     else if (cbCompany == '2')
         query.AndEx(SysCompany.ServiceSumColumn).IsEqualTo(0)
              .Or(SysCompany.ServiceSumColumn).IsNull( )
              .CloseEx( );
     return query.ExecuteDataTable( );
 }