public static void Save_ChargeMeter_Project_Point(ChargeMeter_Project data, SqlHelper helper)
        {
            var data_detail = ChargeMeter_ProjectDetail.GetChargeMeter_ProjectDetailByID(data.ID, helper);
            var point       = new ChargeMeter_Project_Point();

            point.MeterFullName         = data_detail.FinalName;
            point.ChargeMeter_ProjectID = data.ID;
            point.ProjectID             = data.ProjectID;
            point.MeterID          = data.MeterID;
            point.MeterName        = data.MeterName;
            point.MeterNumber      = data.MeterNumber;
            point.MeterCategoryID  = data.MeterCategoryID;
            point.MeterType        = data.MeterType;
            point.MeterSpec        = data.MeterSpec;
            point.MeterCoefficient = data.MeterCoefficient;
            point.MeterRemark      = data.MeterRemark;
            point.MeterChargeID    = data.MeterChargeID;
            point.MeterHouseNo     = data.MeterHouseNo;
            point.MeterLocation    = data.MeterLocation;
            point.SortOrder        = data.SortOrder;
            point.MeterStartPoint  = data.MeterStartPoint;
            point.MeterEndPoint    = data.MeterEndPoint;
            point.MeterTotalPoint  = data.MeterTotalPoint;
            point.AddTime          = data.AddTime;
            point.AddUserName      = data.AddUserName;
            point.WriteStatus      = data.WriteStatus;
            point.FeeStatus        = data.FeeStatus;
            point.WriteDate        = data.WriteDate;
            point.WriteUserName    = data.WriteUserName;
            point.IsAPPWriteEnable = data.IsAPPWriteEnable;
            point.UpdateTime       = DateTime.Now;
            point.UpdateUserName   = User.GetCurrentUserName();
            point.Save(helper);
        }
Exemplo n.º 2
0
        public static bool InsertRoomFee(List <int> ProjectIDList, List <int> RoomIDList, string StartTime, string EndTime, int ContractID, decimal UnitPrice, string Remark, ViewChargeSummary summary, string NewEndTime, decimal TotalCost = 0, decimal UseCount = 0, int Contract_RoomChargeID = 0, bool includenopeople = true, int IsCycleFee = 0)
        {
            string sqltext = string.Empty;
            List <SqlParameter> parameters = new List <SqlParameter>();

            if (string.IsNullOrEmpty(StartTime))
            {
                StartTime = summary.SummaryStartTime == DateTime.MinValue ? "NULL" : "'" + summary.SummaryStartTime.ToString("yyyy-MM-dd") + "'";
            }
            else
            {
                StartTime = "'" + StartTime + "'";
            }
            if (string.IsNullOrEmpty(EndTime))
            {
                EndTime = "NULL";
            }
            else
            {
                EndTime = "'" + EndTime + "'";
            }
            if (string.IsNullOrEmpty(NewEndTime))
            {
                NewEndTime = "NULL";
            }
            else
            {
                NewEndTime = "'" + NewEndTime + "'";
            }
            TotalCost = TotalCost > 0 ? TotalCost : 0;
            UseCount  = UseCount > 0 ? UseCount : 0;
            string AddUserName = "******" + User.GetCurrentUserName() + "'";

            if (RoomIDList.Contains(0))
            {
                sqltext += @"INSERT INTO [dbo].[RoomFee]
               ([RoomID]
               ,[UseCount]
               ,[StartTime]
               ,[EndTime]
               ,[NewEndTime]
               ,[Cost]
               ,[Remark]
               ,[AddTime]
               ,[IsCharged]
               ,[ChargeFeeID]
               ,[ChargeID]
               ,[IsStart]
               ,[UnitPrice]
               ,[ChargeFee]
               ,[ContractID]
               ,[Contract_RoomChargeID]
               ,[IsCycleFee]
               ,[AddUserName])
                values(
                0," + UseCount + "," + StartTime + "," + EndTime + "," + NewEndTime + "," + TotalCost + ",'" + Remark + @"',getdate(),0,0," + summary.ID + ",1,'" + UnitPrice + "',0," + ContractID + "," + Contract_RoomChargeID + "," + IsCycleFee + "," + AddUserName + ");";
                RoomIDList.Remove(0);
            }
            List <string> conditions = new List <string>();

            conditions.Add("[isParent]=0");
            conditions.Add("isnull([IsLocked],0)=0");
            if (!includenopeople && new Utility.SiteConfig().CheckOwnerInStatus)
            {
                List <string> cmdlist = new List <string>();
                cmdlist.Add("[ID] in (select [RoomID] from [RoomPhoneRelation])");
                cmdlist.Add("[ID] in (select [RoomID] from [RoomRelation] where [GUID] in (select [GUID] from [RoomRelation] where [RoomID] in (select [RoomID] from [RoomPhoneRelation])))");
                conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            }
            if (ProjectIDList.Count > 0)
            {
                List <string> cmdlist = new List <string>();
                cmdlist.Add("[ID] in (" + string.Join(",", ProjectIDList.ToArray()) + ")");
                foreach (var ProjectID in ProjectIDList)
                {
                    cmdlist.Add("[AllParentID] like '%," + ProjectID + ",%'");
                }
                conditions.Add("((" + string.Join(" or ", cmdlist.ToArray()) + "))");
            }
            if (RoomIDList.Count > 0)
            {
                conditions.Add("[ID] in (" + string.Join(",", RoomIDList.ToArray()) + ")");
            }
            string cmdcolumn = ",(select [IsLocked] from [RoomBasic] where [RoomID]=[Project].ID) as IsLocked";

            if (ContractID > 0)
            {
                cmdcolumn += ",(select top 1 ID from [RoomPhoneRelation] where [RoomID]=[Project].ID and [ContractID]=@ContractID) as RelationID,(select top 1 RelationName from [RoomPhoneRelation] where [RoomID]=[Project].ID and [ContractID]=@ContractID) as RelationName";
                parameters.Add(new SqlParameter("@ContractID", ContractID));
            }
            else
            {
                cmdcolumn += ",(select top 1 ID from [RoomPhoneRelation] where [RoomID]=[Project].ID and IsDefault = 1) as RelationID,(select top 1 RelationName from [RoomPhoneRelation] where [RoomID]=[Project].ID and IsDefault = 1) as RelationName";
            }
            if (RoomIDList.Count > 0 || ProjectIDList.Count > 0)
            {
                sqltext += @"INSERT INTO [dbo].[RoomFee]
               ([RoomID]
               ,[UseCount]
               ,[StartTime]
               ,[EndTime]
               ,[NewEndTime]
               ,[Cost]
               ,[Remark]
               ,[AddTime]
               ,[IsCharged]
               ,[ChargeFeeID]
               ,[ChargeID]
               ,[IsStart]
               ,[UnitPrice]
               ,[ChargeFee]
               ,[ContractID]
               ,[Contract_RoomChargeID]
               ,[IsCycleFee]
               ,[AddUserName]
               ,[DefaultChargeManID]
               ,[DefaultChargeManName])
                select [ID]," + UseCount + "," + StartTime + "," + EndTime + "," + NewEndTime + "," + TotalCost + ",'" + Remark + @"',getdate(),0,0," + summary.ID + ",1,'" + UnitPrice + "',0," + ContractID + "," + Contract_RoomChargeID + "," + IsCycleFee + "," + AddUserName + ",A.RelationID,A.RelationName from (select [ID],[AllParentID],[isParent]" + cmdcolumn + " from [Project])A where " + string.Join(" and ", conditions.ToArray()) + ";";
            }
            if (!string.IsNullOrEmpty(sqltext))
            {
                using (SqlHelper helper = new SqlHelper())
                {
                    try
                    {
                        helper.BeginTransaction();
                        helper.Execute(sqltext, CommandType.Text, parameters);
                        helper.Commit();
                        return(true);
                    }
                    catch (Exception)
                    {
                        helper.Rollback();
                        return(false);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
        public static int InsertRoomFeeHistoryByTempHistoryID(int TempHistoryID, string AddMan, int ChargeState, SqlHelper helper, string OpenID = "")
        {
            OpenID = string.IsNullOrEmpty(OpenID) ? "NULL" : "'" + OpenID + "'";
            AddMan = string.IsNullOrEmpty(AddMan) ? "NULL" : "'" + AddMan + "'";
            string AddUserName             = "******" + User.GetCurrentUserName() + "'";
            string commandText             = @"INSERT INTO [dbo].[RoomFeeHistory]
           ([ID]
           ,[RoomID]
           ,[UseCount]
           ,[StartTime]
           ,[EndTime]
           ,[Cost]
           ,[Remark]
           ,[AddTime]
           ,[IsCharged]
           ,[ChargeFeeID]
           ,[ChargeID]
           ,[IsStart]
           ,[NewStartTime]
           ,[ImportFeeID]
           ,[UnitPrice]
           ,[RealCost]
           ,[Discount]
           ,[OutDays]
           ,[ChargeFee]
           ,[TotalRealCost]
           ,[RestCost]
           ,[TotalDiscountCost]
           ,[OnlyOnceCharge]
           ,[NewEndTime]
           ,[ContractID]
           ,[DiscountID]
           ,[CuiShouStartTime]
           ,[CuiShouEndTime]
           ,[RelatedFeeID]
           ,[ChongDiChargeID]
           ,[DefaultChargeManID]
           ,[DefaultChargeManName]
           ,[Contract_RoomChargeID]
           ,[TradeNo]
           ,[ContractDivideID]
           ,[OrderID]
           ,[IsTempFee]
           ,[IsMeterFee]
           ,[IsImportFee]
           ,[IsCycleFee]
           ,[RoomFeeCoefficient]
           ,[ChargeTime]
           ,[ChargeMan]
           ,[ChargeState]
           ,[ReturnGuaranteeFee]
           ,[OpenID]
           ,[AddUserName])
           select [ID]
           ,[RoomID]
           ,[UseCount]
           ,[StartTime]
           ,[EndTime]
           ,[Cost]
           ,[Remark]
           ,getdate()
           ,[IsCharged]
           ,[ChargeFeeID]
           ,[ChargeID]
           ,[IsStart]
           ,[NewStartTime]
           ,[ImportFeeID]
           ,[UnitPrice]
           ,[RealCost]
           ,[Discount]
           ,[OutDays]
           ,[ChargeFee]
           ,[TotalRealCost]
           ,[RestCost]
           ,[TotalDiscountCost]
           ,[OnlyOnceCharge]
           ,[NewEndTime]
           ,[ContractID]
           ,[DiscountID]
           ,[CuiShouStartTime]
           ,[CuiShouEndTime]
           ,[RelatedFeeID]
           ,[ChongDiChargeID]
           ,[DefaultChargeManID]
           ,[DefaultChargeManName]
           ,[Contract_RoomChargeID]
           ,[TradeNo]
           ,[ContractDivideID]
           ,[OrderID]
           ,[IsTempFee]
           ,[IsMeterFee]
           ,[IsImportFee]
           ,[IsCycleFee]
           ,[RoomFeeCoefficient]
           ,GETDATE()," + AddMan + "," + ChargeState + ",0," + OpenID + "," + AddUserName + " from [TempRoomFeeHistory] where TempHistoryID=@ID;SELECT @@IDENTITY";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@ID", TempHistoryID));
            int ID = Convert.ToInt32(helper.ExecuteScalar(commandText, CommandType.Text, parameters));

            return(ID);
        }