示例#1
0
        public void ChangeRecord(RoomRecord data, int oldRoomIndex, DateTime oldCheckInDate,
                                 DateTime oldCheckOutDate, List <PayRecord> oldPayRecords)
        {
            if (oldRoomIndex != data.RoomIndex)
            {
                if (oldRoomIndex < Rooms.Count)
                {
                    Rooms[oldRoomIndex].RemoveRecord(data);
                }
                Rooms[data.RoomIndex].AddRecord(data);
            }

            if (oldCheckInDate.GetDays() != data.CheckInDate.GetDays() ||
                oldCheckOutDate.GetDays() != data.CheckOutDate.GetDays())
            {
                _dataCollectHandler.ChangeDate(data, oldCheckInDate, oldCheckOutDate);
            }

            if (oldPayRecords != data.PayRecords)
            {
                _dataCollectHandler.ChangePayRecord(data, oldPayRecords);
            }

            _dataLoadHandler.ChangeRecord(data);
        }
示例#2
0
        public void AddData(RoomRecord roomRecord)
        {
            var endDays = roomRecord.CheckOutDate.GetDays();
            var date    = roomRecord.CheckInDate;

            while (date.GetDays() <= endDays)
            {
                var month = date.GetMonths();
                if (month == CurMonth)
                {
                    AddDay(date.Day);
                }

                date = date.AddDays(1);
            }

            var payRecords = roomRecord.PayRecords;

            foreach (var payRecord in payRecords)
            {
                if (payRecord.PayTime.GetMonths() == CurMonth)
                {
                    TotalIncome += payRecord.PayNum;
                }
            }
        }
示例#3
0
 public void RemoveRecord(RoomRecord data)
 {
     _records.Remove(data);
     _id2Record.Remove(data.Id);
     _recordsData.RoomRecords.Remove(_recordsData.RoomRecords.Find(record => record.Id == data.Id));
     SaveRecordsData();
 }
示例#4
0
        private void AddMonthData(RoomRecord data, int month)
        {
            var monthData = _monthRoomRecord.GetOrCreateValue(month);

            if (!monthData.Contains(data))
            {
                monthData.Add(data);
            }
        }
示例#5
0
 public void AddRecord(RoomRecord data)
 {
     data.RecordPhase = ERecordPhase.Valid;
     _records.Add(data);
     _id2Record.Add(data.Id, data);
     _recordsData.RoomRecords.Add(data.GetData());
     _recordsData.RecordIndex++;
     SaveRecordsData();
 }
示例#6
0
        public void RemoveRecord(RoomRecord data)
        {
            _records.Remove(data);
            var index = _unFinishRecords.IndexOf(data);

            if (index >= 0)
            {
                _unFinishRecords.RemoveAt(index);
            }
        }
示例#7
0
        public void ChangePayRecord(RoomRecord data, List <PayRecord> oldPayRecords)
        {
            _isDirty = true;
            foreach (var payRecord in oldPayRecords)
            {
                RemovePayRecord(payRecord);
            }

            foreach (var payRecord in data.PayRecords)
            {
                AddPayRecord(payRecord);
            }
        }
示例#8
0
 public void ChangeRecord(RoomRecord data)
 {
     for (int i = _recordsData.RoomRecords.Count - 1; i >= 0; i--)
     {
         var recordData = _recordsData.RoomRecords[i];
         if (recordData.Id == data.Id)
         {
             data.GetData(_recordsData.RoomRecords[i]);
             SaveRecordsData();
             return;
         }
     }
 }
示例#9
0
        public void RemoveRecord(RoomRecord data)
        {
            _isDirty = true;
            var startMonth = data.CheckInDate.GetMonths();
            var endMonth   = data.CheckOutDate.GetMonths();

            for (int i = startMonth; i <= endMonth; i++)
            {
                _monthRoomRecord[i].Remove(data);
            }

            foreach (var payRecord in data.PayRecords)
            {
                RemovePayRecord(payRecord);
            }
        }
示例#10
0
        public bool CheckDateConflict(RoomRecord checkRecord, DateTime checkInData, DateTime checkOutDate)
        {
            foreach (var record in _unFinishRecords)
            {
                if (record == checkRecord)
                {
                    continue;
                }
                if (SaleTools.IsConflict(checkInData, checkOutDate, record.CheckInDate, record.CheckOutDate))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#11
0
        public void AddRecord(RoomRecord data)
        {
            _isDirty = true;
            var startMonth = data.CheckInDate.GetMonths();
            var endMonth   = data.CheckOutDate.GetMonths();

            for (int i = startMonth; i <= endMonth; i++)
            {
                AddMonthData(data, i);
            }

            foreach (var payRecord in data.PayRecords)
            {
                AddPayRecord(payRecord);
            }
        }
示例#12
0
        protected virtual void RefreshView(object parameter)
        {
            _data = new RoomRecord();
            _recordId.SetContent(SaleDataManager.Instance.RecordIndex.ToString());
            _roomCtrl.SetOptions(_roomNames);
            _roomCtrl.SetCurVal(0);
            OnRoomValChanged(0);
            var now = DateTime.Now;

            _checkInCtrl.SetDate(now);
            _checkOutCtrl.SetDate(now.AddDays(1));
            _roomerCtrl.SetContent(string.Empty);
            _roomerNumCtrl.SetContent(string.Empty);
            _stateCtrl.SetCurVal((int)ERoomerState.入住);
            RefreshPayInfo();
        }
示例#13
0
        public void ChangeDate(RoomRecord data, DateTime oldCheckInDate, DateTime oldCheckOutDate)
        {
            _isDirty = true;
            var oldStartMonth = oldCheckInDate.GetMonths();
            var oldEndMonth   = oldCheckOutDate.GetMonths();
            var newStartMonth = data.CheckInDate.GetMonths();
            var newEndMonth   = data.CheckOutDate.GetMonths();

            if (oldStartMonth != newStartMonth || oldEndMonth != newEndMonth)
            {
                for (int i = oldStartMonth; i <= oldEndMonth; i++)
                {
                    _monthRoomRecord[i].Remove(data);
                }

                for (int i = newStartMonth; i <= newEndMonth; i++)
                {
                    AddMonthData(data, i);
                }
            }
        }
示例#14
0
        public void LoadRecordsData()
        {
            LogHelper.Debug("load sale data");
            _recordsData = DataManager.Instance.LoadData <RecordsData>(_saveFilePath);
            if (_recordsData == null)
            {
                _recordsData             = new RecordsData();
                _recordsData.RecordIndex = 1;
            }

            _records.Clear();
            _id2Record.Clear();
            _recordsData.RoomRecords.Sort((p, q) => p.Id - q.Id);
            for (int i = 0; i < _recordsData.RoomRecords.Count; i++)
            {
                var record = new RoomRecord(_recordsData.RoomRecords[i]);
                foreach (var payRecord in record.PayRecords)
                {
                    payRecord.RecordId = record.Id;
                }
                _records.Add(record);
                _id2Record.Add(record.Id, record);
            }
        }
示例#15
0
 protected override void OnOpen(object parameter)
 {
     base.OnOpen(parameter);
     _data = parameter as RoomRecord;
     RefreshView();
 }
示例#16
0
 public void AddRoomRecord(RoomRecord data)
 {
     Rooms[data.RoomIndex].AddRecord(data);
     _dataCollectHandler.AddRecord(data);
     _dataLoadHandler.AddRecord(data);
 }
示例#17
0
 public void AddRecord(RoomRecord roomRecord)
 {
     _records.Add(roomRecord);
     _unFinishRecords.Add(roomRecord);
 }
示例#18
0
 public void RemoveRoomRecord(RoomRecord data)
 {
     _dataCollectHandler.RemoveRecord(data);
     _dataLoadHandler.RemoveRecord(data);
 }
示例#19
0
 public void Set(object data)
 {
     _record = data as RoomRecord;
     RefreshView();
 }