private static ChargePriceRange[] GetPriceRangeList(ViewImportFeeDetail2 self) { var list = new List <ChargePriceRange>(); if (PriceRangeList == null || PriceRangeList.Length == 0) { PriceRangeList = ChargePriceRange.GetChargePriceRangeList(); } if (PriceFeeRangeList == null) { PriceFeeRangeList = ChargeFeePriceRange.GetAllActiveChargeFeePriceRangeList(); } if (self.RoomFeeID > 0) { if (PriceFeeRangeList != null && PriceFeeRangeList.Length > 0) { var my_pricefee_list = PriceFeeRangeList.Where(p => p.RoomFeeID == self.RoomFeeID && p.SummaryID == self.ChargeID).ToArray(); foreach (var item in my_pricefee_list) { var data = new ChargePriceRange(); data.SummaryID = item.SummaryID; data.MinValue = item.MinValue; data.MaxValue = item.MaxValue; data.BasePrice = item.BasePrice; data.BaseType = item.BaseType; data.IsActive = item.IsActive; list.Add(data); } } return(list.OrderBy(p => { decimal minvalue = 0; decimal.TryParse(p.MinValue, out minvalue); return minvalue; }).ToArray()); } else { if (PriceRangeList != null && PriceRangeList.Length > 0) { list = PriceRangeList.Where(p => p.SummaryID == self.ChargeID).OrderBy(p => { decimal minvalue = 0; decimal.TryParse(p.MinValue, out minvalue); return(minvalue); }).ToList(); } return(list.ToArray()); } }
public static List <Utility.ChargeFeePriceRangeModel> GetAllActiveChargeFeePriceRangeObjectList() { var PriceFeeRangeList = ChargeFeePriceRange.GetAllActiveChargeFeePriceRangeList(); var rangelist = PriceFeeRangeList.Select(p => { decimal MinValue = 0; decimal.TryParse(p.MinValue, out MinValue); decimal MaxValue = 0; decimal.TryParse(p.MaxValue, out MaxValue); var data = new Utility.ChargeFeePriceRangeModel { RoomFeeID = p.RoomFeeID, SummaryID = p.SummaryID, MinValue = MinValue, MaxValue = MaxValue, BasePrice = p.BasePrice, BaseType = p.BaseType, IsActive = p.IsActive }; return(data); }).ToList(); return(rangelist); }
public static RoomFee SetInfo_RoomFee(int RoomID, DateTime StartTime, DateTime EndTime, decimal Cost, decimal RealCost, decimal UnitPrice, int ChargeID, RoomFee data = null, decimal UseCount = 0, string Remark = "", bool IsCharged = false, int ChargeFeeID = 0, bool IsStart = true, decimal Discount = 0, decimal ChargeFee = 0, decimal TotalRealCost = 0, decimal TotalDiscountCost = 0, decimal RestCost = 0, int ContractID = 0, int RelatedFeeID = 0, int DefaultChargeManID = 0, string DefaultChargeManName = "", int Contract_RoomChargeID = 0, int ContractDivideID = 0, bool cansave = false, DateTime?NewEndTime = null, bool OnlyOnceCharge = false, int OutDays = 0, int DiscountID = 0, DateTime?CuiShouStartTime = null, DateTime?CuiShouEndTime = null, int ChongDiChargeID = 0, string TradeNo = "", int OrderID = 0, bool IsTempFee = false, bool IsMeterFee = false, bool IsImportFee = false, bool IsCycleFee = false, int ImportFeeID = 0, decimal RoomFeeCoefficient = 0, DateTime?RoomFeeWriteDate = null, int ChargeMeterProjectFeeID = 0, decimal RoomFeeStartPoint = 0, decimal RoomFeeEndPoint = 0, SqlHelper helper = null, int HistoryRoomFeeID = 0) { if (data == null) { data = new RoomFee(); data.AddTime = DateTime.Now; data.AddUserName = User.GetCurrentUserName(); } data.RoomID = RoomID; data.UseCount = UseCount; data.StartTime = StartTime; data.EndTime = EndTime; data.Cost = Cost; data.RealCost = RealCost; data.Remark = Remark; data.IsCharged = IsCharged; data.ChargeFeeID = 0; data.ChargeID = ChargeID; data.IsStart = IsStart; data.UnitPrice = UnitPrice; data.Discount = Discount; data.ChargeFee = ChargeFee; data.TotalRealCost = TotalRealCost; data.TotalDiscountCost = TotalDiscountCost; data.RestCost = RestCost; data.ContractID = ContractID; data.RelatedFeeID = RelatedFeeID; if (DefaultChargeManID <= 0) { RoomPhoneRelation default_relation = null; if (helper == null) { default_relation = RoomPhoneRelation.GetDefaultInChargeFeeRoomPhoneRelation(data.RoomID, data.ContractID); } else { default_relation = RoomPhoneRelation.GetDefaultInChargeFeeRoomPhoneRelation(data.RoomID, data.ContractID, helper); } if (default_relation != null) { DefaultChargeManID = default_relation.ID; DefaultChargeManName = default_relation.RelationName; } } data.DefaultChargeManID = DefaultChargeManID; data.DefaultChargeManName = DefaultChargeManName; data.Contract_RoomChargeID = Contract_RoomChargeID; data.ContractDivideID = ContractDivideID; if (NewEndTime != null && NewEndTime.HasValue) { data.NewEndTime = Convert.ToDateTime(NewEndTime); } data.OnlyOnceCharge = OnlyOnceCharge; data.OutDays = OutDays; data.DiscountID = DiscountID; if (CuiShouStartTime != null && CuiShouStartTime.HasValue) { data.CuiShouStartTime = Convert.ToDateTime(CuiShouStartTime); } if (CuiShouEndTime != null && CuiShouEndTime.HasValue) { data.CuiShouEndTime = Convert.ToDateTime(CuiShouEndTime); } data.ChongDiChargeID = ChongDiChargeID; data.TradeNo = TradeNo; data.OrderID = OrderID; data.IsTempFee = IsTempFee; data.IsMeterFee = IsMeterFee; data.IsImportFee = IsImportFee; data.IsCycleFee = IsCycleFee; data.ImportFeeID = ImportFeeID; data.RoomFeeCoefficient = RoomFeeCoefficient; data.ChargeMeterProjectFeeID = ChargeMeterProjectFeeID; data.RoomFeeStartPoint = RoomFeeStartPoint; data.RoomFeeEndPoint = RoomFeeEndPoint; if (RoomFeeWriteDate != null && RoomFeeWriteDate.HasValue) { data.RoomFeeWriteDate = Convert.ToDateTime(RoomFeeWriteDate); } if (cansave) { if (helper == null) { using (helper = new SqlHelper()) { try { helper.BeginTransaction(); data.Save(helper); ChargeFeePriceRange.CreateChargeFeePriceRangeByImportFeeIDList(helper, RoomFeeID: data.ID, HistoryRoomFeeID: HistoryRoomFeeID); helper.Commit(); } catch (Exception) { helper.Rollback(); } } } else { data.Save(helper); ChargeFeePriceRange.CreateChargeFeePriceRangeByImportFeeIDList(helper, RoomFeeID: data.ID, HistoryRoomFeeID: HistoryRoomFeeID); } } return(data); }
public static bool Save_ChargeMeter_ProjectFee(int[] MeterProjectIDList, DateTime WriteDate, decimal Coefficient, decimal SummaryUnitPrice, DateTime StartTime, DateTime EndTime, string AddUserName, out string errormsg, List <int> ChargeIDList) { errormsg = string.Empty; var meter_project_list = ChargeMeter_ProjectDetail.GetChargeMeter_ProjectDetailListByIDList(MeterProjectIDList); if (meter_project_list.FirstOrDefault(p => p.RoomOwnerCount <= 0) != null && new Utility.SiteConfig().CheckOwnerInStatus) { errormsg = "选中的房间尚未有业主入住"; return(false); } if (meter_project_list.Length == 0) { errormsg = "请选择一条数据,操作取消"; return(false); } using (SqlHelper helper = new SqlHelper()) { try { helper.BeginTransaction(); List <int> RoomFeeIDList = new List <int>(); foreach (var ChargeID in ChargeIDList) { foreach (var item in meter_project_list) { string cmdtext = "update [ChargeMeter_Project] set [WriteStatus]=1,[FeeStatus]=1 where ID=" + item.ID + ";"; helper.Execute(cmdtext, CommandType.Text, new List <SqlParameter>()); var data = new ChargeMeter_ProjectFee(); data.MeterProjectID = item.ID; data.MeterID = item.MeterID; data.ProjectID = item.ProjectID; data.MeterName = item.MeterName; data.MeterNumber = item.MeterNumber; data.MeterCategoryID = item.MeterCategoryID; data.MeterType = item.MeterType; data.MeterSpec = item.MeterSpec; data.MeterCoefficient = Coefficient; data.MeterRemark = item.MeterRemark; data.MeterChargeID = ChargeID; data.MeterHouseNo = item.MeterHouseNo; data.MeterLocation = item.MeterLocation; data.SortOrder = item.SortOrder; data.MeterStartPoint = item.FinalFeeStartPoint; data.MeterEndPoint = item.FinalFeeEndPoint; data.MeterTotalPoint = item.FinalFeeTotalPoint; data.AddTime = DateTime.Now; data.AddUserName = AddUserName; data.MeterStartTime = StartTime; data.MeterEndTime = EndTime; data.MeterWriteDate = WriteDate; data.WriteDate = item.WriteDate; data.WriteUserName = item.WriteUserName; var room_fee = RoomFee.SetInfo_RoomFee(data.ProjectID, data.MeterStartTime, data.MeterEndTime, 0, 0, SummaryUnitPrice, ChargeID, IsMeterFee: true, RoomFeeCoefficient: data.MeterCoefficient, RoomFeeWriteDate: WriteDate, UseCount: data.MeterTotalPoint, RoomFeeStartPoint: data.MeterStartPoint, RoomFeeEndPoint: data.MeterEndPoint, cansave: true, helper: helper); data.RoomFeeID = room_fee.ID; data.Save(helper); room_fee.ChargeMeterProjectFeeID = data.ID; room_fee.Save(helper); RoomFeeIDList.Add(room_fee.ID); } } ChargeFeePriceRange.CreateChargeFeePriceRangeByImportFeeIDList(helper, RoomFeeIDList: RoomFeeIDList); helper.Commit(); } catch (Exception ex) { Utility.LogHelper.WriteError("ChargeMeter_ProjectFee.cs", "Save_ChargeMeter_ProjectFee", ex); helper.Rollback(); errormsg = ex.Message; return(false); } } return(true); }