private void dataGridViewWaitingForReviewOrders_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridViewWaitingForReviewOrders.Columns[e.ColumnIndex].Name == "Review" && e.RowIndex >= 0)
            {
                string OrderId_Value       = dataGridViewWaitingForReviewOrders.Rows[e.RowIndex].Cells["OrderId5"].Value.ToString();
                OrderOfCustomerModel order = _waitingForReviewOrders.FindLast(o => o.Id.ToString().Equals(OrderId_Value));
                string ISBN_Value          = order.Book_ISBN;
                bool   is_reviewed         = ReviewDataAccess.IsReviewed(CustomerInfo.customer.Id, ISBN_Value);
                if (!BookDataAccess.IsBookExisted(ISBN_Value))
                {
                    MessageBox.Show("图书不存在");
                    return;
                }
                if (is_reviewed)
                {
                    DialogResult result = MessageBox.Show("您已对该书做出评价,是否更新评论内容?", "消息", MessageBoxButtons.OKCancel);
                    if (result == DialogResult.Cancel)
                    {
                        CustomerOrderDataAccess.FinishOrder(OrderId_Value);
                        ShowAll();
                        return;
                    }
                }
                var             book            = BookDataAccess.GetFullBookByISBN(ISBN_Value);
                WriteReviewForm writeReviewForm = new WriteReviewForm();
                SendBookInfoEvent += writeReviewForm.ShowDetail;
                SendBookInfoEvent.Invoke(OrderId_Value, book, is_reviewed);
                writeReviewForm.ShowDialog();

                ShowAll();
            }
        }
Esempio n. 2
0
        private void iconButtonOK_Click(object sender, EventArgs e)
        {
            if (textBoxReviewContent.Text.Length > 1000)
            {
                MessageBox.Show("评论内容请不要超过1000字");
                return;
            }

            bool is_review_content_null = false;

            if (textBoxReviewContent.Text.Length == 0)
            {
                is_review_content_null = true;
            }

            GetReviewRate();
            try
            {
                if (_isReviewed)
                {
                    ReviewDataAccess.UpdateReview(CustomerInfo.customer.Id, _book.ISBN, _reviewRate, textBoxReviewContent.Text, DateTime.Now, is_review_content_null);
                    CustomerOrderDataAccess.FinishOrder(_orderId);
                    MessageBox.Show("评论更新成功");
                }
                else
                {
                    ReviewDataAccess.InsertReview(CustomerInfo.customer.Id, _book.ISBN, _reviewRate, textBoxReviewContent.Text, DateTime.Now, is_review_content_null);
                    CustomerOrderDataAccess.FinishOrder(_orderId);
                    MessageBox.Show("评论成功");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }