public IActionResult Edit(int id, [Bind("ID,Status")] Receipt receipt)
        {
            if (id != receipt.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var updateReceipt = _receiptManager.UpdateReceipt(receipt);
                var receiptStatus = updateReceipt.Status;
                var orderID       = updateReceipt.OrderID;
                var order         = _orderManager.GetOrderByID(orderID);
                if (receiptStatus == ReceiptStatus.Completed)
                {
                    order.Status = OrderStatus.Completed;
                }
                else if (receiptStatus == ReceiptStatus.Cancelled)
                {
                    order.Status = OrderStatus.ReadyToBill;
                }
                _orderManager.OrderUpdates(order);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(receipt));
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //建立資料model及ReceiptManager的物件
            var manager = new ReceiptManager();
            var model   = new ReceiptModel();

            //建立5個變數來存取各個輸入值
            string inputRecNo  = this.txtReceiptNumber.Text.Trim();
            string inputDate   = this.lbDate.Text.Trim();
            string dplCompany  = this.dplCompany.SelectedValue;
            string inputAmount = this.txtAmount.Text.Trim();
            string dplRE       = this.dplRE.SelectedValue;

            //檢查輸入值(發票號碼、日期、金額)
            if (string.IsNullOrEmpty(inputRecNo) || string.IsNullOrEmpty(inputAmount) || string.Equals(inputDate, "請選擇日期"))
            {
                //日期沒輸入會變成紅色
                if (string.Equals(inputDate, "請選擇日期"))
                {
                    this.lbDate.ForeColor = System.Drawing.Color.Red;
                }

                this.lblMsg.Text = "請填入完整的發票資料";
                return;
            }
            else if (ReceiptDetailHelper.checkReceiptNumber(inputRecNo) != string.Empty)
            {
                this.lblMsg.Text = "請填入正確的發票格式";
                return;
            }
            else if (ReceiptDetailHelper.checkAmount(inputAmount) != string.Empty)
            {
                this.lblMsg.Text = "金額只能填入數字";
                return;
            }

            //上面檢查都通過後,將輸入值存入資料model
            model.ReceiptNumber   = inputRecNo;
            model.Date            = DateTime.Parse(inputDate);
            model.Company         = dplCompany;
            model.Amount          = decimal.Parse(inputAmount);
            model.Revenue_Expense = (Revenue_Expense)Enum.Parse(typeof(Revenue_Expense), dplRE);

            //分成更新模式及新增模式
            //更新模式下將資料model更新至資料庫
            //新增模式下將資料model存入資料庫
            if (ReceiptDetailHelper.isUpdateMode())
            {
                manager.UpdateReceipt(model);
                this.lblMsg.Text = "發票更新成功";
            }
            else
            {
                manager.CreateReceipt(model);
                this.lblMsg.Text = "發票新增成功";
            }
        }