Exemplo n.º 1
0
        public static void GetFeeListByMonth(int monthnumber, RoomFeeAnalysis[] my_fee_list, ViewRoomFeeHistoryDetail[] my_fee_history_list, ViewRoomFeeHistoryDetail[] my_fee_history_list_chongdi, int Year, out decimal YingShouFee, out decimal YiShouFee, out decimal JianMianFee, out decimal WeiShouFee, out decimal ChongDiFee, out decimal Cycle_WeiShouFee)
        {
            YingShouFee = 0;
            YiShouFee   = 0;
            JianMianFee = 0;
            WeiShouFee  = 0;
            ChongDiFee  = 0;
            decimal Cycle_YiShouFee   = 0;
            decimal Cycle_JianMianFee = 0;

            Cycle_WeiShouFee = 0;
            decimal  Cycle_ChongDiFee = 0;
            DateTime StartTime        = DateTime.MinValue;
            DateTime EndTime          = DateTime.MinValue;

            WebUtil.GetTimeRangeByMonthNumber(monthnumber, Year, out StartTime, out EndTime);
            var     my_fee_history_list1          = ViewRoomFeeHistoryDetail.GetFinalViewRoomFeeHistoryDetailDictionary(my_fee_history_list, StartTime, EndTime).ToArray();
            var     my_fee_history_list_chongdi_1 = ViewRoomFeeHistoryDetail.GetFinalViewRoomFeeHistoryDetailDictionary(my_fee_history_list_chongdi, StartTime, EndTime).ToArray();
            decimal YingShouFee_1 = 0;
            decimal YingShouFee_2 = 0;

            if (my_fee_history_list1.Length > 0)
            {
                decimal RealCost = my_fee_history_list1.Sum(p => Convert.ToDecimal(p["MonthTotalCost"]));
                ChongDiFee  = my_fee_history_list_chongdi_1.Where(p => Convert.ToInt32(p["ChargeState"]) == 4).Sum(p => Convert.ToDecimal(p["MonthTotalCost"]));
                YiShouFee   = RealCost - ChongDiFee;
                JianMianFee = my_fee_history_list1.Sum(p => Convert.ToDecimal(p["MonthDiscountCost"]));
                var     my_fee_history_list2          = my_fee_history_list1.Where(p => (Convert.ToInt32(p["FeeType"]) == 4 && Convert.ToInt32(p["ImportFeeID"]) > 0) || Convert.ToInt32(p["FeeType"]) != 4).ToArray();
                var     my_fee_history_list_chongdi_2 = my_fee_history_list_chongdi_1.Where(p => (Convert.ToInt32(p["FeeType"]) == 4 && Convert.ToInt32(p["ImportFeeID"]) > 0) || Convert.ToInt32(p["FeeType"]) != 4).ToArray();
                decimal Cycle_RealCost = my_fee_history_list2.Sum(p => Convert.ToDecimal(p["MonthTotalCost"]));
                Cycle_ChongDiFee  = my_fee_history_list_chongdi_2.Where(p => Convert.ToInt32(p["ChargeState"]) == 4).Sum(p => Convert.ToDecimal(p["MonthTotalCost"]));
                Cycle_YiShouFee   = Cycle_RealCost - Cycle_ChongDiFee;
                Cycle_JianMianFee = my_fee_history_list2.Sum(p => Convert.ToDecimal(p["MonthDiscountCost"]));
                YingShouFee_1     = my_fee_history_list1.Sum(p => Convert.ToDecimal(p["TotalCost"]));
            }
            var my_fee_list1 = RoomFeeAnalysis.GetRoomFeeAnalysisDictionary(my_fee_list, StartTime, EndTime).ToArray();

            if (my_fee_list1.Length > 0)
            {
                WeiShouFee       = my_fee_list1.Sum(p => Convert.ToDecimal(p["TotalFinalCost"]));
                Cycle_WeiShouFee = my_fee_list1.Where(p => (Convert.ToInt32(p["FeeType"]) == 4 && Convert.ToInt32(p["ImportFeeID"]) <= 0) || Convert.ToInt32(p["FeeType"]) != 4).Sum(p => Convert.ToDecimal(p["TotalFinalCost"]));
                YingShouFee_2    = my_fee_list1.Sum(p => Convert.ToDecimal(p["TotalCost"]));
            }
            YingShouFee = YingShouFee_1 + YingShouFee_2;
        }
Exemplo n.º 2
0
        public static Ui.DataGrid GetViewContractChargeSummaryGrid(int ContractID, string guid, DateTime StartTime, DateTime EndTime, string orderBy, long startRowIndex, int pageSize, bool IsLinShi = false, int UserID = 0, List <int> RoomIDList = null, List <int> ProjectIDList = null, string keywords = "", string ContractStatus = "", bool IsWarning = false, bool includefooter = false, DateTime?ReadyStartTime = null, DateTime?ReadyEndTime = null, int FeeStatus = 0, List <int> ChargeIDList = null, bool canexport = false)
        {
            ReSetParams();
            long totalRows = 0;
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("isnull([ChargeID],0)!=0");
            if (ChargeIDList != null && ChargeIDList.Count > 0)
            {
                conditions.Add("[ChargeID] in (" + string.Join(",", ChargeIDList.ToArray()) + ")");
            }
            if (ReadyStartTime.HasValue)
            {
                DateTime _ReadyStartTime = Convert.ToDateTime(ReadyStartTime);
                if (_ReadyStartTime > DateTime.MinValue)
                {
                    conditions.Add("([ReadyChargeTime]>=@ReadyStartTime or [ReadyChargeTime] is null)");
                    parameters.Add(new SqlParameter("@ReadyStartTime", ReadyStartTime));
                }
            }
            if (ReadyEndTime.HasValue)
            {
                DateTime _ReadyEndTime = Convert.ToDateTime(ReadyEndTime);
                if (_ReadyEndTime > DateTime.MinValue)
                {
                    conditions.Add("([ReadyChargeTime]<=@ReadyEndTime or [ReadyChargeTime] is null)");
                    parameters.Add(new SqlParameter("@ReadyEndTime", ReadyEndTime));
                }
            }
            if (ProjectIDList != null && ProjectIDList.Count > 0)
            {
                List <string> cmdlist = ViewRoomFeeHistory.GetProjectIDListConditions(ProjectIDList, IncludeRelation: false, RoomIDName: "[RoomID]", IsContractFee: true, UserID: UserID);
                conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            }
            if (RoomIDList != null && RoomIDList.Count > 0)
            {
                List <string> cmdlist = ViewRoomFeeHistory.GetRoomIDListConditions(RoomIDList, IncludeRelation: false, RoomIDName: "[RoomID]", IsContractFee: true);
                conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            }
            if (!string.IsNullOrEmpty(keywords))
            {
                conditions.Add("(ContractID in (select ID from Contract where [RentName] like @keywords or [ContractNo] like  @keywords or [ContractName] like @keywords) or [Name] like @keywords)");
                parameters.Add(new SqlParameter("@keywords", "%" + keywords + "%"));
            }
            if (!string.IsNullOrEmpty(ContractStatus))
            {
                conditions.Add("ContractID in (select ID from Contract where [ContractStatus]=@ContractStatus)");
                parameters.Add(new SqlParameter("@ContractStatus", ContractStatus));
            }
            if (IsWarning)
            {
                conditions.Add("([ReadyChargeTime]<=@ReadyChargeTime or [ReadyChargeTime] is null)");
                parameters.Add(new SqlParameter("@ReadyChargeTime", DateTime.Now));
            }
            if (IsLinShi)
            {
                conditions.Add("[ChargeID] in (select ID from ChargeSummary where [FeeType]=4)");
            }
            if (ContractID > 0)
            {
                conditions.Add("[ContractID]=@ContractID");
                parameters.Add(new SqlParameter("@ContractID", ContractID));
            }
            else if (!string.IsNullOrEmpty(guid))
            {
                conditions.Add("[GUID]=@GUID");
                parameters.Add(new SqlParameter("@GUID", guid));
            }
            string fieldList = "[ViewContractChargeSummary].*";
            string Statement = " from [ViewContractChargeSummary] where  " + string.Join(" and ", conditions.ToArray());

            ViewContractChargeSummary[] list = new ViewContractChargeSummary[] { };
            if (FeeStatus == 0)
            {
                if (canexport)
                {
                    list = GetList <ViewContractChargeSummary>("select " + fieldList + Statement + " " + orderBy, parameters).ToArray();
                }
                else
                {
                    list = GetList <ViewContractChargeSummary>(fieldList, Statement, parameters, orderBy, startRowIndex, pageSize, out totalRows).ToArray();
                }

                if (list.Length > 0)
                {
                    var RoomFeeIDList        = list.Where(p => p.RoomFeeID > 0).Select(p => p.RoomFeeID).ToList();
                    var ContractChargeIDList = list.Select(p => p.ID).ToList();
                    ViewRoomFeeHistoryDetailList = ViewRoomFeeHistoryDetail.GetViewRoomFeeHistoryDetailList(new List <int>(), StartTime, EndTime, StartTime, EndTime, new List <int>(), RoomFeeIDList, ContractChargeIDList, UserID: UserID, RequireOrderBy: false).Where(p => p.MonthTotalCost > 0).ToArray();
                }
                DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
                dg.rows  = list;
                dg.total = totalRows;
                dg.page  = pageSize;
                return(dg);
            }
            else
            {
                list = GetList <ViewContractChargeSummary>("select * from [ViewContractChargeSummary] where " + string.Join(" and ", conditions.ToArray()), parameters).ToArray();
                if (list.Length > 0)
                {
                    var RoomFeeIDList        = list.Where(p => p.RoomFeeID > 0).Select(p => p.RoomFeeID).ToList();
                    var ContractChargeIDList = list.Select(p => p.ID).ToList();
                    ViewRoomFeeHistoryDetailList = ViewRoomFeeHistoryDetail.GetViewRoomFeeHistoryDetailList(new List <int>(), StartTime, EndTime, StartTime, EndTime, new List <int>(), RoomFeeIDList, ContractChargeIDList, UserID: UserID, RequireOrderBy: false).Where(p => p.MonthTotalCost > 0).ToArray();
                }
                if (FeeStatus == 1)
                {
                    list = list.Where(p => p.CalcualtePayCost == 0 || p.CalcualteRestCost > 0).ToArray();
                }
                else if (FeeStatus == 2)
                {
                    list = list.Where(p => p.CalcualtePayCost > 0 && p.CalcualteRestCost == 0).ToArray();
                }
                totalRows = list.Length;
                int StartRowIndex         = Convert.ToInt32(startRowIndex);
                var finallist             = list.Skip(StartRowIndex).Take(pageSize).ToArray();
                DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
                dg.rows  = finallist;
                dg.total = totalRows;
                dg.page  = pageSize;
                return(dg);
            }
        }