예제 #1
0
 public static List <int> GetMyUserProjectIDList(RoomPhoneRelation[] phone_list, int UserID)
 {
     if (UserID <= 0)
     {
         return(new List <int>());
     }
     Mall_UserProject[] user_project_list = new Mall_UserProject[] { };
     if (phone_list.Length > 0)
     {
         user_project_list = Mall_UserProject.GetMall_UserProjectListByProjectIDList(phone_list.Select(p => p.RoomID).ToList());
     }
     return(user_project_list.Where(p => p.UserID == UserID).Select(p => p.ProjectID).ToList());
 }
예제 #2
0
        public static Ui.DataGrid GetMall_RoomOwnerBalanceDetailApplicationGridByKeywords(string Keywords, long startRowIndex, int pageSize, List <int> RoomIDList, List <int> ProjectIDList, DateTime StartTime, DateTime EndTime, int UserID = 0)
        {
            var room_list = ViewRoomBasic.GetRoomBasicListByKeywords(RoomIDList, ProjectIDList, Keywords, HavingOrder: true);

            if (room_list.Length == 0)
            {
                return(new Ui.DataGrid());
            }
            var order_analysis_list = Mall_OrderAnalysis.GetMall_OrderAnalysisList(StartTime, EndTime);
            var user_project_list   = Mall_UserProject.GetMall_UserProjectListHavingOrders();
            var balance_list        = Mall_RoomOwnerBalanceAnalysis.GetMall_RoomOwnerBalanceAnalysisList();
            List <Mall_RoomOwnerBalanceApplicationDetail> list = new List <Mall_RoomOwnerBalanceApplicationDetail>();

            foreach (var item in room_list)
            {
                var my_user_project_list = user_project_list.Where(p => p.ProjectID == item.RoomID).ToArray();
                if (my_user_project_list.Length == 0)
                {
                    continue;
                }
                var my_useridlist          = my_user_project_list.Select(p => p.UserID).ToArray();
                var my_order_analysis_list = order_analysis_list.Where(p => my_useridlist.Contains(p.UserID)).ToArray();
                if (my_order_analysis_list.Length == 0)
                {
                    continue;
                }
                var data = new Mall_RoomOwnerBalanceApplicationDetail();
                data.RoomID    = item.RoomID;
                data.FullName  = item.FullName;
                data.RoomName  = item.Name;
                data.TotalCost = my_order_analysis_list.Sum(p => p.TotalCost);
                var my_balance_list = balance_list.Where(p => p.ProjectID == item.RoomID).ToArray();
                data.TotalBalanceAmount = my_balance_list.Sum(p => p.TotalCost);
                if (data.TotalCost > 0)
                {
                    list.Add(data);
                }
            }
            var finallist = list.Skip(Convert.ToInt32(startRowIndex)).Take(pageSize).ToArray();

            DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
            dg.rows  = finallist;
            dg.total = list.Count;
            dg.page  = pageSize;
            return(dg);
        }
예제 #3
0
        public static ViewRoomBasic[] GetViewRoomBasicListByUserID(User user, bool IncludeRelation = true, string PhoneNumber = "")
        {
            var phone_list = RoomPhoneRelation.GetRoomPhoneRelationsByPhone(PhoneNumber, uid: user.FinalUserID);

            Mall_UserProject.Insert_UserProjectList(phone_list, user);
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("[isParent]=0");
            List <string> cmdlist  = new List <string>();
            string        cmdwhere = " and [UserID]=@UserID and isnull([IsDisable],0)=0";

            cmdlist.Add("[RoomID] in (select [ProjectID] from [Mall_UserProject] where 1=1 " + cmdwhere + ")");
            if (IncludeRelation)
            {
                cmdlist.Add("[RoomID] in (select [RoomID] from [RoomRelation] where [GUID] in (select [GUID] from [RoomRelation] where [RoomID] in (select [ProjectID] from [Mall_UserProject] where 1=1 " + cmdwhere + ")))");
            }
            conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            parameters.Add(new SqlParameter("@UserID", user.FinalUserID));
            ViewRoomBasic[] list = new ViewRoomBasic[] { };
            list = GetList <ViewRoomBasic>("select * from [ViewRoomBasic] where  " + string.Join(" and ", conditions.ToArray()) + " order by [DefaultOrder] asc", parameters).ToArray();
            return(list);
        }
예제 #4
0
        public static void Insert_UserProjectList(RoomPhoneRelation[] phone_list, User user, SqlHelper helper)
        {
            var parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@UserID", user.FinalUserID));
            helper.Execute("delete from [Mall_UserProject] where [UserID]=@UserID and isnull([IsManualAdd],0)=0 and isnull([IsDisable],0)=0", CommandType.Text, parameters);
            foreach (var item in phone_list)
            {
                if (item.RelatePhoneNumber.Equals(user.LoginName))
                {
                    item.UserID = user.UserID;
                    item.Save(helper);
                }
                var my_user_project = Mall_UserProject.GetMall_UserProject(user.FinalUserID, item.RoomID, helper);
                if (my_user_project == null)
                {
                    my_user_project = new Mall_UserProject();
                }
                my_user_project.IsManualAdd = false;
                my_user_project.UserID      = user.FinalUserID;
                my_user_project.ProjectID   = item.RoomID;
                my_user_project.Save(helper);
            }
        }
예제 #5
0
        public static Ui.DataGrid GetMall_UserBalanceDetailGridByKeywords(string Keywords, DateTime StartTime, DateTime EndTime, int AmountType, long startRowIndex, int pageSize, int IncomingType, int OutcomingType)
        {
            long   totalRows = 0;
            string OrderBy   = " order by AddTime desc";
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("1=1");
            if (AmountType > 0)
            {
                conditions.Add("[BalanceType]=@BalanceType");
                parameters.Add(new SqlParameter("@BalanceType", AmountType));
            }
            if (IncomingType > 0)
            {
                conditions.Add("[CategoryType]=@IncomingType");
                parameters.Add(new SqlParameter("@IncomingType", IncomingType));
            }
            if (OutcomingType > 0)
            {
                conditions.Add("[CategoryType]=@OutcomingType");
                parameters.Add(new SqlParameter("@OutcomingType", OutcomingType));
            }
            if (StartTime > DateTime.MinValue)
            {
                conditions.Add("Convert(varchar(100),[AddTime],23)>=@StartTime");
                parameters.Add(new SqlParameter("@StartTime", StartTime));
            }
            if (EndTime > DateTime.MinValue)
            {
                conditions.Add("Convert(varchar(100),[AddTime],23)<=@EndTime");
                parameters.Add(new SqlParameter("@EndTime", EndTime));
            }
            if (!string.IsNullOrEmpty(Keywords))
            {
                conditions.Add("[UserID] in (select [UserID] from [User] where [LoginName] like @keywords)");
                parameters.Add(new SqlParameter("@keywords", "%" + Keywords + "%"));
            }
            string fieldList = "A.*";
            string Statement = " from (select [Mall_UserBalance].*,(select LoginName from [User] where [UserID]=Mall_UserBalance.UserID) as CustomerName from [Mall_UserBalance])A where  " + string.Join(" and ", conditions.ToArray());

            Mall_UserBalanceDetail[] list = GetList <Mall_UserBalanceDetail>(fieldList, Statement, parameters, OrderBy, startRowIndex, pageSize, out totalRows).ToArray();
            if (list.Length > 0)
            {
                int MinUserID       = list.Min(p => p.UserID);
                int MaxUserID       = list.Max(p => p.UserID);
                var userList        = User.GetAPPCustomerUserList(MinUserID: MinUserID, MaxUserID: MaxUserID);
                var userProjectList = Mall_UserProject.GetMall_UserProjectListByMinMaxUserID(MinUserID, MaxUserID);
                int MinRoomID       = 0;
                int MaxRoomID       = 0;
                if (userProjectList.Length > 0)
                {
                    MinRoomID = userProjectList.Min(p => p.ProjectID);
                    MaxRoomID = userProjectList.Max(p => p.ProjectID);
                }
                var projectList = Project.GetProjectListByMinMaxID(MinRoomID, MaxRoomID);
                foreach (var item in list)
                {
                    var myUser = userList.FirstOrDefault(p => p.UserID == item.UserID);
                    if (myUser != null)
                    {
                        item.CustomerInfo = myUser.FinalRealName;
                        var myUserProjectList = userProjectList.Where(p => p.UserID == item.UserID).ToArray();
                        var myProjectList     = projectList.Where(p => myUserProjectList.Select(q => q.ProjectID).ToList().Contains(p.ID)).ToArray();
                        if (myProjectList.Length > 0)
                        {
                            item.CustomerInfo += "【" + myProjectList[0].FullName + "-" + myProjectList[0].Name + "】";
                        }
                    }
                }
            }
            DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
            dg.rows  = list;
            dg.total = totalRows;
            dg.page  = pageSize;
            return(dg);
        }