コード例 #1
0
        private async Task confirmOpr(CashTransfer cashtrans)
        {
            cashtrans.isConfirm = 1;
            int s = await cashModel.Save(cashtrans);

            if (!s.Equals(0))
            {
                await fillDataGrid();

                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopConfirm"), animation: ToasterAnimation.FadeIn);
            }
        }
コード例 #2
0
        private async Task recordCash(Invoice invoice)
        {
            User  user       = new User();
            float newBalance = 0;

            user = await user.getUserById((int)cb_user.SelectedValue);

            CashTransfer cashTrasnfer = new CashTransfer();

            cashTrasnfer.posId        = MainWindow.posID;
            cashTrasnfer.userId       = (int)cb_user.SelectedValue;
            cashTrasnfer.invId        = invoice.invoiceId;
            cashTrasnfer.createUserId = invoice.createUserId;
            cashTrasnfer.processType  = "balance";
            cashTrasnfer.side         = "u"; // user
            cashTrasnfer.transType    = "d"; //deposit
            cashTrasnfer.transNum     = await cashTrasnfer.generateCashNumber("du");

            if (user.balanceType == 0)
            {
                if (invoice.totalNet <= (decimal)user.balance)
                {
                    invoice.paid     = invoice.totalNet;
                    invoice.deserved = 0;
                    newBalance       = user.balance - (float)invoice.totalNet;
                    user.balance     = newBalance;
                }
                else
                {
                    invoice.paid     = (decimal)user.balance;
                    invoice.deserved = invoice.totalNet - (decimal)user.balance;
                    newBalance       = (float)invoice.totalNet - user.balance;
                    user.balance     = newBalance;
                    user.balanceType = 1;
                }

                cashTrasnfer.cash = invoice.paid;

                await invoice.saveInvoice(invoice);

                await cashTrasnfer.Save(cashTrasnfer); //add cash transfer

                await user.save(user);
            }
            else if (user.balanceType == 1)
            {
                newBalance   = user.balance + (float)invoice.totalNet;
                user.balance = newBalance;
                await user.save(user);
            }
        }
コード例 #3
0
        private async Task transfer()
        {
            //add cash transfer
            CashTransfer cash1 = new CashTransfer();

            cash1.transType = "p";//pull
            cash1.transNum  = await cash1.generateCashNumber(cash1.transType + "p");

            cash1.cash         = MainWindow.posLogIn.balance;
            cash1.createUserId = MainWindow.userID.Value;
            cash1.posIdCreator = MainWindow.posID.Value;
            cash1.isConfirm    = 1;
            cash1.side         = "p";//pos
            cash1.posId        = Convert.ToInt32(MainWindow.posID.Value);

            int s1 = await cash1.Save(cash1);

            if (!s1.Equals(0))
            {
                //second operation
                CashTransfer cash2 = new CashTransfer();

                cash2.transType = "d";//deposite
                cash2.transNum  = await cash2.generateCashNumber(cash2.transType + "p");

                cash2.cash              = MainWindow.posLogIn.balance;
                cash2.createUserId      = MainWindow.userID.Value;
                cash2.posIdCreator      = MainWindow.posID.Value;
                cash2.isConfirm         = 0;
                cash2.side              = "p"; //pos
                cash2.posId             = Convert.ToInt32(cb_pos.SelectedValue);
                cash2.cashTransIdSource = s1;  //id from first operation

                int s2 = await cash2.Save(cash2);

                if (s2 > 0)
                {
                    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);
                }
                else
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                }
            }
        }