public List <ReservationVo> GetReservations(uint recentResNum) //추가적인 예약정보를 가져옴
        {
            List <ReservationVo> list = new List <ReservationVo>();

            _conn.Msc.Open();
            _sql = $"SELECT * FROM RESERVATION WHERE isPaid = 0 AND resNum > {recentResNum} ";
            MySqlCommand    cmd = new MySqlCommand(_sql, _conn.Msc);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                ReservationVo rv = new ReservationVo();
                rv.ResNum       = (uint)rdr["resNum"];
                rv.EndAt        = (DateTime)rdr["endAt"];
                rv.Gender       = (bool)rdr["gender"] ? 1 : 0;
                rv.IsPaid       = (bool)rdr["isPaid"];
                rv.Note         = rdr["note"] as string;
                rv.StartAt      = (DateTime)rdr["startAt"];
                rv.StylistId    = (uint)rdr["stylistId"];
                rv.UserBirthday = rdr["userBirthday"] as DateTime?;
                rv.UserName     = rdr["userName"] as string;
                rv.UserTel      = rdr["userTel"] as string;
                list.Add(rv);
            }
            _conn.Msc.Close();
            return(list);
        }
        public uint InsertReservation(ReservationVo rv) //예약 추가
        {
            _conn.Msc.Open();
            _sql = "INSERT INTO reservation(stylistId,note,gender,userBirthday,startAt,endAt,userName,userTel) VALUES(@stylistId,@note,@gender,@userBirthday,@startAt,@endAt,@userName,@userTel)";

            MySqlCommand cmd = new MySqlCommand(_sql, _conn.Msc);

            cmd.Parameters.AddWithValue("@stylistId", rv.StylistId);
            cmd.Parameters.AddWithValue("@userTel", rv.UserTel);
            cmd.Parameters.AddWithValue("@note", rv.Note);
            cmd.Parameters.AddWithValue("@gender", rv.Gender);
            cmd.Parameters.AddWithValue("@userBirthday", rv.UserBirthday);
            cmd.Parameters.AddWithValue("@startAt", rv.StartAt);
            cmd.Parameters.AddWithValue("@endAt", rv.EndAt);
            cmd.Parameters.AddWithValue("@userName", rv.UserName);

            if (cmd.ExecuteNonQuery() == -1) //실패시
            {
                _conn.Msc.Close();
                return(0);
            }

            uint recentId = (uint)cmd.LastInsertedId;

            _conn.Msc.Close();
            return(recentId); //성공시
        }
        public bool UpdateReservation(ReservationVo rv) //예약 수정
        {
            _conn.Msc.Open();
            _sql = "UPDATE reservation SET stylistId = @stylistId, userTel = @userTel, " +
                   "note = @note, gender = @gender, userBirthday = @userBirthday, startAt = @startAt, endAt = @endAt, userName = @userName, isPaid = @isPaid WHERE resNum = @resNum";

            MySqlCommand cmd = new MySqlCommand(_sql, _conn.Msc);

            cmd.Parameters.AddWithValue("@resNum", rv.ResNum);
            cmd.Parameters.AddWithValue("@stylistId", rv.StylistId);
            cmd.Parameters.AddWithValue("@userTel", rv.UserTel);
            cmd.Parameters.AddWithValue("@note", rv.Note);
            cmd.Parameters.AddWithValue("@gender", rv.Gender);
            cmd.Parameters.AddWithValue("@userBirthday", rv.UserBirthday);
            cmd.Parameters.AddWithValue("@startAt", rv.StartAt);
            cmd.Parameters.AddWithValue("@endAt", rv.EndAt);
            cmd.Parameters.AddWithValue("@userName", rv.UserName);
            cmd.Parameters.AddWithValue("@isPaid", rv.IsPaid);

            if (cmd.ExecuteNonQuery() == -1) //실패시
            {
                _conn.Msc.Close();
                return(false);
            }
            _conn.Msc.Close();
            return(true); //성공시
        }
示例#4
0
 private void ExecuteDeleteMethod(object obj)
 {
     _reservationRepository.RemoveReservation(SelectedRes.ResNum);
     ResList.Remove(SelectedRes);
     SelectedRes         = new ReservationVo(); //삭제되면 SelectedRes도 삭제 됨으로 다시 생성
     SelectedRes.StartAt = DateTime.Today;
 }
示例#5
0
 private void ExecuteInitalizeMethod(object obj)
 {
     SelectedRes         = new ReservationVo();
     IsSelected          = true;
     IsSelectedService   = false;
     SelectedRes.StartAt = DateTime.Today;
 }
示例#6
0
 //이벤트
 private void DetectChangedDate(ReservationVo reservation)
 {
     if (reservation != null)
     {
         _timeTable.Clear();
         ShowTimeTable(reservation);
     }
     else
     {
     }
 }
示例#7
0
        private void MakeTimeTable(ReservationVo reservation)
        {
            DataColumn _col;

            for (int i = 0; i < 48; i++)
            {
                _col            = TimeTable.Columns.Add();
                _col.ColumnName = (i / 2).ToString("D2") + " : " + (i % 2 * 30).ToString("D2");
            }

            ShowTimeTable(reservation);
        }
示例#8
0
 private bool Check(ReservationVo rv)
 {
     if (rv.UserName != null && rv.UserTel != null && rv.StylistId != null && rv.Gender != -1)
     {
         if (rv.UserTel.Length > 12)
         {
             MessageBox.Show("번호가 너무 깁니다.");
             return(false);
         }
         return(true);
     }
     MessageBox.Show("빈칸이 존재합니다.");
     return(false);
 }
示例#9
0
        private void RemoveRS(object obj)
        {
            ReservedServiceVo rsv = (ReservedServiceVo)obj;

            _reservedServiceRepository.RemoveReservedService(rsv.ResNum, rsv.SerId);
            ServiceCommands.Remove(ServiceCommands.Single(x => (x.Data == rsv)));

            ServiceVo     s  = ServiceList.Single(x => x.ServiceId == rsv.SerId);
            ReservationVo r  = ResList.Single(x => x.ResNum == rsv.ResNum);
            TimeSpan      ts = new TimeSpan(s.ServiceTime / 60, s.ServiceTime % 60, 0);

            r.EndAt = r.EndAt - ts;
            _reservationRepository.UpdateReservation(r);
        }
示例#10
0
        public MainPageViewModel()
        {
            _reservationRepository     = ReservationRepository.Rr;;
            _reservedServiceRepository = ReservedServiceRepository.RSR;
            _serviceRepository         = ServiceRepository.SR;
            _stylistRepository         = StylistRepository.SR;
            _userRepository            = UserRepository.UR;

            _selectedRes        = new ReservationVo();
            SelectedRes.Gender  = -1;
            SelectedRes.StartAt = DateTime.Today;
            SelectedRes.EndAt   = new DateTime();
            formerDate          = new DateTime(1, 1, 1);
            StartDate           = new DateTime();
            StartDate           = DateTime.Today;

            ResList         = new ObservableCollection <ReservationVo>(_reservationRepository.GetReservations());
            ServiceList     = new ObservableCollection <ServiceVo>(_serviceRepository.GetServicesFromLocal());
            ServiceCommands = new ObservableCollection <DataCommandViewModel <ReservedServiceVo> >();
            StylistList     = new ObservableCollection <StylistVo>(_stylistRepository.GetStylistsFromLocal());

            _availableHour = new List <int>();
            for (int x = 0; x < 24; x++)
            {
                _availableHour.Add(x);
            }
            _availableMinute = new List <int>()
            {
                0, 30
            };

            InsertCommand    = new Command(ExecuteInsertMethod, CanExecuteMethod);
            ModifyCommand    = new Command(ExecuteModifyMethod, CanExecuteMethod);
            DeleteCommand    = new Command(ExecuteDeleteMethod, CanExecuteMethod);
            InsertRSCommand  = new Command(ExecuteInsertRSMethod, CanExecuteMethod);
            InitalizeCommand = new Command(ExecuteInitalizeMethod, CanExecuteMethod);

            _noticeService = NoticeService.NS;


            _timer          = new DispatcherTimer();
            _timer.Interval = new System.TimeSpan(0, 0, 5);
            _timer.Tick    += _timer_Tick;
            _timer.Start();

            MakeTimeTable(_selectedRes);
        }
示例#11
0
        private void ShowTimeTable(ReservationVo reservation)
        {
            DataRow _row;

            IEnumerable <ReservationVo> necessaryList;

            _row = TimeTable.NewRow(); //DataRow를 생성해서 그 사람의 예약 테이블을 채워야지

            //예약 리스트 중에서 선택한 날짜만 불러오기
            necessaryList = ResList.Where(x => x.StartAt.ToString("d").Equals(SelectedRes.StartAt.ToString("d")));

            //이 목록 중에서 스타일리스트 아이디와 콤보박스에서 셀렉트한 미용사의 아이디 비교
            necessaryList = necessaryList.Where(x => x.StylistId == SelectedRes.StylistId);

            //SaveResInColumn(necessaryList);
            SaveResInColumn.SaveReservationInColumn(necessaryList, TimeTable, _row);
        }
示例#12
0
        public void ExecuteSendMethod(object parameter)
        {
            if (String.IsNullOrWhiteSpace(Name) ||
                String.IsNullOrWhiteSpace(Tel) ||
                !(IsMan || IsWoman) ||
                BirthDay == DateTime.Today ||
                Stylist == null)
            {
                MessageBox.Show("한 개 이상의 입력란이 입력되지 않았습니다.");
                return;
            }

            else
            {
                DateTime StartTime = new DateTime(ResDate.Year, ResDate.Month, ResDate.Day, ResHour, ResMinute, 0);

                if (HasReservations(Stylist.StylistId, StartTime, ResDate, ResHour, ResMinute, _uploadData.UseageTime))
                {
                    MessageBox.Show("이미 예약이 있는 시간대입니다.");
                    return;
                }
                else
                {
                    //입력 내용 Vo로 저장
                    ReservationVo reservation = new ReservationVo();
                    reservation.UserName     = Name;
                    reservation.UserTel      = Tel;
                    reservation.Gender       = IsMan ? 0 : 1;
                    reservation.UserBirthday = BirthDay;
                    reservation.StylistId    = Stylist.StylistId;
                    reservation.StartAt      = StartTime;
                    reservation.Note         = Note;
                    reservation.EndAt        = StartTime.AddMinutes(_uploadData.UseageTime);

                    //Vo를 업로드 클래스에 등록
                    _uploadData.ReservationVo = reservation;

                    //업로드 클래스 데이터 업로드
                    _uploadData.Upload();

                    NavigationServiceProvider.Navigate("/View/Finish.xaml");
                }
            }
        }
示例#13
0
        public PayViewModel()
        {
            _reservationRepository     = ReservationRepository.Rr;
            _reservedServiceRepository = ReservedServiceRepository.RSR;
            _ledgerRepository          = LedgerRepository.LR;
            _userRepository            = UserRepository.UR;
            _stylistRepository         = StylistRepository.SR;
            _resList     = new ObservableCollection <ReservationVo>(_reservationRepository.GetReservations());
            _serviceList = new List <ServiceVo>(ServiceRepository.SR.GetServicesFromLocal());
            _userList    = new List <UserVo>(UserRepository.UR.GetUserList());

            _sum = 0;
            _stylistadditionalCost = 0;
            _consumePoint          = 0;
            _selRes           = new ReservationVo();
            _selRes.StylistId = 0;

            InsertCommand = new Command(ExcuteInsertMethod);
        }
示例#14
0
        private void ExcuteInsertMethod(object obj)
        {
            if (SelRes.StylistId == 0)
            {
                MessageBox.Show("선택된 예약이 없습니다.");
                return;
            }
            LedgerVo l = new LedgerVo();

            if (UserPoint < ConsumePoint)
            {
                MessageBox.Show("적립금이 부족합니다.");
                return;
            }

            if (ConsumePoint > Sum)
            {
                MessageBox.Show("사용할 적립금이 실제 가격보다 더 많습니다.");
                return;
            }
            l.ResNum = SelRes.ResNum;
            l.Sum    = Sum;
            _ledgerRepository.InsertLedger(l);

            UserVo user = _userList.Single(x => x.UserTel == SelRes.UserTel);

            user.Point += Point;
            user.Point -= ConsumePoint;
            _userRepository.UpdateUser(user);

            ReservationVo r = ResList.Single(x => x.ResNum == SelRes.ResNum);

            r.IsPaid = true;
            _reservationRepository.UpdateReservation(r);
            MessageBox.Show("결제 완료");
            // ResList = new ObservableCollection<ReservationVo>(_reservationRepository.GetReservations());
        }