public async Task <IActionResult> Edit(long id, [Bind("StewardAccountsId,EnteringDate,HouseNumber,CustomerName,ProductType,Product,Cost,Amount,Profit,Receivable,Received,IsFinish,EnteringStaff,FrontDesk,FrontDeskLeader,StewardLeader,RelationStaff,IsSteward,IsFinance,Branch,Note")] BrhStewardAccounts brhStewardAccounts)
        {
            if (id != brhStewardAccounts.StewardAccountsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (brhStewardAccounts.Receivable == brhStewardAccounts.Received)
                    {
                        brhStewardAccounts.IsFinish = true;
                    }

                    brhStewardAccounts.EnteringDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"));

                    _context.Update(brhStewardAccounts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BrhStewardAccountsExists(brhStewardAccounts.StewardAccountsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView("~/Areas/Branch/Views/BrhStewardAccount/Edit.cshtml", brhStewardAccounts));
        }
        public async Task <IActionResult> Create([Bind("StewardAccountsId,EnteringDate,HouseNumber,CustomerName,ProductType,Product,Cost,Amount,Profit,Receivable,Received,IsFinish,EnteringStaff,FrontDesk,FrontDeskLeader,StewardLeader,RelationStaff,IsSteward,IsFinance,Branch,Note,PayWay1,PayDate1,PayAmount1,PayWay2,PayDate2,PayAmount2,PayWay3,PayDate3,PayAmount3")] BrhStewardModel brhStewardModel)
        {
            if (ModelState.IsValid)
            {
                BrhStewardPaymentDetial bfp1 = new BrhStewardPaymentDetial();
                BrhStewardPaymentDetial bfp2 = new BrhStewardPaymentDetial();
                BrhStewardPaymentDetial bfp3 = new BrhStewardPaymentDetial();

                if (brhStewardModel.PayAmount1 != 0)
                {
                    bfp1.StewardAccountsId = brhStewardModel.StewardAccountsId;
                    bfp1.PayWay            = brhStewardModel.PayWay1;
                    bfp1.PayDate           = brhStewardModel.PayDate1;
                    bfp1.PayAmount         = brhStewardModel.PayAmount1;
                    _context.Add(bfp1);
                }
                else
                {
                    bfp1.PayAmount = 0;
                }

                if (brhStewardModel.PayAmount2 != 0)
                {
                    bfp2.StewardAccountsId = brhStewardModel.StewardAccountsId;
                    bfp2.PayWay            = brhStewardModel.PayWay2;
                    bfp2.PayDate           = brhStewardModel.PayDate2;
                    bfp2.PayAmount         = brhStewardModel.PayAmount2;
                    _context.Add(bfp2);
                }
                else
                {
                    bfp2.PayAmount = 0;
                }

                if (brhStewardModel.PayAmount3 != 0)
                {
                    bfp3.StewardAccountsId = brhStewardModel.StewardAccountsId;
                    bfp3.PayWay            = brhStewardModel.PayWay3;
                    bfp3.PayDate           = brhStewardModel.PayDate3;
                    bfp3.PayAmount         = brhStewardModel.PayAmount3;
                    _context.Add(bfp3);
                }
                else
                {
                    bfp3.PayAmount = 0;
                }

                BrhStewardAccounts brhStewardAccounts = new BrhStewardAccounts();
                brhStewardAccounts.Amount            = brhStewardModel.Amount;
                brhStewardAccounts.Branch            = brhStewardModel.Branch;
                brhStewardAccounts.Cost              = brhStewardModel.Cost;
                brhStewardAccounts.CustomerName      = brhStewardModel.CustomerName;
                brhStewardAccounts.EnteringStaff     = brhStewardModel.EnteringStaff;
                brhStewardAccounts.FrontDesk         = brhStewardModel.FrontDesk;
                brhStewardAccounts.FrontDeskLeader   = brhStewardModel.FrontDeskLeader;
                brhStewardAccounts.HouseNumber       = brhStewardModel.HouseNumber;
                brhStewardAccounts.Note              = brhStewardModel.Note;
                brhStewardAccounts.Product           = brhStewardModel.Product;
                brhStewardAccounts.ProductType       = brhStewardModel.ProductType;
                brhStewardAccounts.Profit            = brhStewardModel.Profit;
                brhStewardAccounts.Receivable        = brhStewardModel.Receivable;
                brhStewardAccounts.RelationStaff     = brhStewardModel.RelationStaff;
                brhStewardAccounts.StewardAccountsId = brhStewardModel.StewardAccountsId;
                brhStewardAccounts.StewardLeader     = brhStewardModel.StewardLeader;

                brhStewardAccounts.Received = bfp1.PayAmount + bfp2.PayAmount + bfp3.PayAmount;

                if (brhStewardAccounts.Receivable == brhStewardAccounts.Received)
                {
                    brhStewardAccounts.IsFinish = true;
                }

                brhStewardAccounts.EnteringDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"));

                _context.Add(brhStewardAccounts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView("~/Areas/Branch/Views/BrhStewardAccount/Create.cshtml", brhStewardModel));
        }