public void AddOrUpdateReview(ReviewData reviewData)
        {
            var existReview = GetReviewList()
                              .Where(x => x.UserNumber == reviewData.UserNumber)
                              .Where(x => x.PaymentNumber == reviewData.PaymentNumber)
                              .Where(x => x.RoomNumber == reviewData.RoomNumber)
                              .FirstOrDefault();

            if (existReview != null)
            {
                reviewData.Row          = existReview.Row;
                reviewData.ReviewNumber = existReview.ReviewNumber;
            }
            else
            {
                reviewData.Row          = UsedRange.Row + UsedRange.Rows.Count;
                reviewData.ReviewNumber = GetReviewList().Any() ? GetReviewList().Max(x => x.ReviewNumber) + 1 : 1;
            }

            this.GetCell(reviewData.Row, 1).Value2 = reviewData.ReviewNumber;
            this.GetCell(reviewData.Row, 2).Value2 = reviewData.PaymentNumber;
            this.GetCell(reviewData.Row, 3).Value2 = reviewData.UserNumber;
            this.GetCell(reviewData.Row, 4).Value2 = reviewData.Public;
            this.GetCell(reviewData.Row, 5).Value2 = reviewData.RoomNumber;
            this.GetCell(reviewData.Row, 6).Value2 = reviewData.Grade;
            this.GetCell(reviewData.Row, 7).Value2 = reviewData.Comment;

            Globals.ReviewSheet.Activate();
        }
Beispiel #2
0
        private void AddOrUpdateButton_Click(object sender, EventArgs e)
        {
            var reviewData = new ReviewData
            {
                PaymentNumber = _paymentData.PaymentNumber,
                RoomNumber    = _roomData.RoomNumber,
                UserNumber    = _paymentData.UserNumber,
                Public        = PublicOption.Checked,
                Grade         = (double)RoomGradeNumber.Value,
                Comment       = ReviewText.Text,
            };

            Globals.ReviewSheet.AddOrUpdateReview(reviewData);

            if (ExistReview)
            {
                MessageBox.Show("수정되었습니다.");
            }
            else
            {
                MessageBox.Show("리뷰를 등록했습니다.");
            }
        }