示例#1
0
        private void HandlePrepaidWaterPackages(Invoice newInvoice, InvoiceLineItem lineItem)
        {
            if ((lineItem.ProductCode).Contains("WAT PKG"))
            {
                if (newInvoice.AccountID != null)
                {
                    // check if the account has an existing prepaid bottle account
                    // if not, create a new one
                    int           bottleTypeID = ExtractBottleTypeID(lineItem.ProductCode);
                    PrepaidBottle p            = PrepaidBottleManager.GetPrepaidBottle(_accountID, bottleTypeID);

                    if (p == null) //create a new one
                    {
                        p                   = new PrepaidBottle();
                        p.AccountID         = _accountID;
                        p.PrepaidBottleType = bottleTypeID;
                        p.CreatedBy         = User.Identity.Name.ToString();
                        p.TopUpBalance(ProductManager.GetTopUpQty(lineItem.ProductCode) * lineItem.Quantity);
                        p.PrepaidBottleID = PrepaidBottleManager.Save(p);
                    }
                    else
                    {
                        p.TopUpBalance(ProductManager.GetTopUpQty(lineItem.ProductCode));
                        p.ModifiedBy = User.Identity.Name.ToString();
                        PrepaidBottleManager.Save(p);
                    }

                    // save the prepaid bottle transaction
                    PrepaidBottleTransaction pBTransaction = new PrepaidBottleTransaction();
                    pBTransaction.PrepaidBottleID    = p.PrepaidBottleID;
                    pBTransaction.TransactionType    = "topUp";
                    pBTransaction.TopUpQty           = ProductManager.GetTopUpQty(lineItem.ProductCode) * lineItem.Quantity;
                    pBTransaction.LastUpdatedBalance = p.Balance;
                    pBTransaction.CreatedBy          = User.Identity.Name.ToString();
                    pBTransaction.TransactionID      = PrepaidBottleTransactionManager.Save(pBTransaction);
                }
            }
        }
示例#2
0
        protected void lnkDeductPrepaid_OnCommand(object sender, CommandEventArgs e)
        {
            //get the deduct qty from the formview
            int deductQty = Convert.ToInt32((fview_DeductPrepaidBottle.FindControl("txtDeductQty") as TextBox).Text);

            selectedPrepaidBottle.DeductBalance(deductQty);
            selectedPrepaidBottle.ModifiedBy   = User.Identity.Name.ToString();
            selectedPrepaidBottle.ModifiedDate = DateTime.Now.ToLocalTime();
            PrepaidBottleManager.Save(selectedPrepaidBottle);

            PrepaidBottleTransaction pTransaction = new PrepaidBottleTransaction();

            pTransaction.PrepaidBottleID     = selectedPrepaidBottle.PrepaidBottleID;
            pTransaction.LastUpdatedBalance  = selectedPrepaidBottle.Balance;
            pTransaction.DeductQty           = deductQty;
            pTransaction.TransactionType     = "deduct";
            pTransaction.CreatedBy           = User.Identity.Name.ToString();
            pTransaction.LastTransactionDate = DateTime.Now.ToLocalTime();
            PrepaidBottleTransactionManager.Save(pTransaction);

            //refresh the Prepaid Water Gridview
            DisplayPrepaidWater();
        }