예제 #1
0
        public bool SellProductBL(SellBO objSellBO)
        {
            SellDA objSellDA = new SellDA();
            int    ProductID = objSellDA.GetProductID(objSellBO.ProductName);

            TypeDA objTypeDA    = new TypeDA();
            int    OldTypeCount = objTypeDA.GetOldTypeCount(objSellBO.TypeName, ProductID);

            Constants.RemainingProduct = OldTypeCount;
            if (OldTypeCount < objSellBO.ProductCount)
            {
                return(false);
            }
            int NewTypeCount = OldTypeCount - objSellBO.ProductCount;

            objTypeDA.DecreaseFromStock(objSellBO.TypeName, ProductID, NewTypeCount);

            decimal Price = objSellDA.GetPriceOfProduct(objSellBO, ProductID);

            objSellBO.ProductPrice = Price * objSellBO.ProductCount;
            objSellDA.SellProductDA(objSellBO);

            decimal oldLoan = objSellDA.GetOldLoan(objSellBO);
            decimal newLoan = oldLoan + objSellBO.ProductPrice;

            objSellDA.AddLoanDA(objSellBO, newLoan);

            return(true);
        }
예제 #2
0
        public bool PayLoanDA(SellBO objSellBO, decimal payment)
        {
            SellDA     objSellDA     = new SellDA();
            CostumerDA objCostumerDA = new CostumerDA();
            decimal    oldLoan       = objSellDA.GetOldLoan(objSellBO);
            decimal    newLoan       = 0;

            if (oldLoan < payment)
            {
                return(false);
            }
            else
            {
                newLoan = oldLoan - payment;
                objCostumerDA.PayLoanDA(objSellBO, newLoan);
                return(true);
            }
        }