コード例 #1
0
 private bool Equals(LotterySaleManagmentTicket obj)
 {
     return(obj.SystemID == SystemID &&
            obj.ProductNormalPrice == ProductNormalPrice &&
            obj.Original.SystemId == Original.SystemId &&
            obj.StartDate.Equals(StartDate) &&
            obj.EndDate.Equals(EndDate) &&
            obj.TotalMoneyPayed.Equals(TotalMoneyPayed) &&
            obj.IsActive == IsActive);
 }
コード例 #2
0
        private void ValidateLottery(StockListItem stockList)
        {
            if (stockList.PurchaseWay != PurchaseEnum.Lottery)
            {
                return;
            }
            LotterySaleManagmentTicket lottery = DataLayerInstance.GetLotteryByProductID(stockList.Product.SystemId);

            lottery.InformCancel(syncher);
            DataLayerInstance.EditLotteryInDatabase(lottery);
        }
コード例 #3
0
ファイル: RemoveProductSlave.cs プロジェクト: maorRoz/Sadna
        private void HandleIfLottery(StockListItem stockListItem)
        {
            if (stockListItem.PurchaseWay != PurchaseEnum.Lottery)
            {
                return;
            }
            LotterySaleManagmentTicket lotteryManagment = DataLayerInstance.GetLotteryByProductID(stockListItem.Product.SystemId);

            lotteryManagment.InformCancel(syncher);
            DataLayerInstance.RemoveLottery(lotteryManagment);
        }
コード例 #4
0
ファイル: StockSyncher.cs プロジェクト: maorRoz/Sadna
        public void UpdateLottery(string storeName, string productName, double moenyPayed, string UserName, IOrderSyncher syncher, int cheatCode)
        {
            LotterySaleManagmentTicket lotto = DataLayer.GetLotteryByProductNameAndStore(storeName, productName);

            if (!lotto.updateLottery(moenyPayed, DataLayer.GetUserIDFromUserName(UserName)))
            {
                return;
            }
            syncher.CloseLottery(lotto.Original.Name, lotto.storeName, lotto.getWinnerID(cheatCode));
            UpdateQuantityAfterPurchase(storeName, productName, 1);
            MarketYard.Instance.GetPublisher().NotifyLotteryFinish(lotto.SystemID, storeName, productName);
        }
コード例 #5
0
        public void AddLottery(LotterySaleManagmentTicket lotteryManagment)
        {
            object[] lotteryVals = lotteryManagment.GetLotteryManagmentValuesArray();
            foreach (object val in lotteryVals)
            {
                dbConnection.CheckInput(val.ToString());
            }

            dbConnection.InsertTable("LotteryTable",
                                     "SystemID, ProductSystemID, ProductNormalPrice, TotalMoneyPayed, storeName ,StartDate,EndDate,IsActive ",
                                     new [] { "@idParam", "@prodIdParam", "@prodPriceParam", "@totalPriceParam", "@storeParam", "@startDateParam", "@endDataParam", "@activeParam" }
                                     , lotteryVals);
        }
コード例 #6
0
        public LotterySaleManagmentTicket GetLotteryByProductID(string productid)
        {
            dbConnection.CheckInput(productid);
            Product product = GetProductID(productid);
            LotterySaleManagmentTicket lotteryManagement = null;

            using (var dbReader =
                       dbConnection.SelectFromTableWithCondition("LotteryTable", "*", "ProductSystemID = '" + productid + "'"))
            {
                while (dbReader.Read())
                {
                    lotteryManagement = new LotterySaleManagmentTicket(dbReader.GetString(0), dbReader.GetString(4), product,
                                                                       dbReader.GetDateTime(5), dbReader.GetDateTime(6));
                    lotteryManagement.TotalMoneyPayed = dbReader.GetDouble(3);

                    lotteryManagement.IsActive = (bool.Parse(dbReader.GetString(7)));
                }
            }

            return(lotteryManagement);
        }
コード例 #7
0
        private string GetProductStockInformation(string productID, bool showAll)
        {
            StockListItem stockListItem = storeLogic.GetStockListItembyProductID(productID);

            if (stockListItem == null)
            {
                MarketLog.Log("storeCenter", "product not exists");
                throw new StoreException(StoreEnum.ProductNotFound, "product " + productID + " does not exist in Stock");
            }
            if (stockListItem.PurchaseWay == PurchaseEnum.Lottery && !showAll)
            {
                LotterySaleManagmentTicket managmentTicket =
                    storeLogic.GetLotteryByProductID((productID));
                StockListItem sli = storeLogic.GetStockListItembyProductID(productID);
                if ((managmentTicket.EndDate < MarketYard.MarketDate) ||
                    (managmentTicket.StartDate > MarketYard.MarketDate) ||
                    ((managmentTicket.TotalMoneyPayed == managmentTicket.ProductNormalPrice) && sli.Quantity == 0))
                {
                    return("");
                }
            }
            Discount totalDiscount  = stockListItem.CalcTotalDiscount(_storeName);
            string   discountString = " Discount: {";
            string   product        = stockListItem.Product.ToString();

            if (totalDiscount != null)
            {
                discountString += totalDiscount;
            }
            else
            {
                discountString += "null";
            }
            discountString += "}";
            string purchaseWay = " Purchase Way: " + EnumStringConverter.PrintEnum(stockListItem.PurchaseWay);
            string quanitity   = " Quantity: " + stockListItem.Quantity;
            string result      = product + discountString + purchaseWay + quanitity;

            return(result);
        }
コード例 #8
0
        public void EditLotteryInDatabase(LotterySaleManagmentTicket lotteryManagment)
        {
            string[] columnNames =
            {
                "SystemID",
                "ProductSystemID",
                "ProductNormalPrice",
                "TotalMoneyPayed",
                "storeName",
                "StartDate",
                "EndDate",
                "IsActive"
            };
            object[] lotteryVals = lotteryManagment.GetLotteryManagmentValuesArray();
            foreach (object val in lotteryVals)
            {
                dbConnection.CheckInput(val.ToString());
            }

            dbConnection.UpdateTable("LotteryTable", "SystemID = '" + lotteryManagment.SystemID + "'", columnNames,
                                     new[] { "@idParam", "@prodIdParam", "@prodPriceParam", "@totalPriceParam", "@storeParam", "@startDateParam", "@endDataParam", "@activeParam" }
                                     , lotteryVals);
        }
コード例 #9
0
ファイル: AddNewLotterySlave.cs プロジェクト: maorRoz/Sadna
 public StockListItem AddNewLottery(string name, double price, string description, DateTime startDate, DateTime endDate)
 {
     try
     {
         Store store = DataLayerInstance.GetStorebyName(_storeName);
         MarketLog.Log("StoreCenter", "trying to add product to store");
         checkIfStoreExistsAndActive();
         MarketLog.Log("StoreCenter", " check if has premmision to add products");
         _storeManager.CanManageProducts();
         MarketLog.Log("StoreCenter", " check if product name avlaiable in the store" + _storeName);
         CheckIfProductNameAvailable(name);
         MarketLog.Log("StoreCenter", "check that dates are OK");
         CheckIfDatesAreOK(startDate, endDate);
         Product       product       = new Product(name, price, description);
         StockListItem stockListItem = new StockListItem(1, product, null, PurchaseEnum.Lottery, store.SystemId);
         DataLayerInstance.AddStockListItemToDataBase(stockListItem);
         LotterySaleManagmentTicket lotterySaleManagmentTicket = new LotterySaleManagmentTicket(
             _storeName, stockListItem.Product, startDate, endDate);
         DataLayerInstance.AddLottery(lotterySaleManagmentTicket);
         MarketLog.Log("StoreCenter", "product added");
         answer = new StoreAnswer(StoreEnum.Success, "product added");
         return(stockListItem);
     }
     catch (StoreException exe)
     {
         answer = new StoreAnswer((StoreEnum)exe.Status, exe.GetErrorMessage());
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
     }
     return(null);
 }
コード例 #10
0
        public void ChangeProductPurchaseWayToLottery(string productName, DateTime startDate, DateTime endDate)
        {
            try
            {
                MarketLog.Log("StoreCenter", "check if store exists");
                checkIfStoreExistsAndActive();
                MarketLog.Log("StoreCenter", " check if has premmision to edit products");
                _storeManager.CanManageProducts();
                MarketLog.Log("StoreCenter", " has premmission");
                MarketLog.Log("StoreCenter", "check if product exists");
                checkifProductExists(DataLayerInstance.GetProductByNameFromStore(_storeName, productName));
                MarketLog.Log("StoreCenter", "product exists");
                StockListItem stockListItem = DataLayerInstance.GetProductFromStore(_storeName, productName);
                CheckIfAlreadyLottery(stockListItem);
                MarketLog.Log("StoreCenter", "check if dates are OK");
                CheckIfDatesAreOK(startDate, endDate);
                stockListItem.PurchaseWay = PurchaseEnum.Lottery;
                DataLayerInstance.EditStockInDatabase(stockListItem);
                LotterySaleManagmentTicket lotterySaleManagmentTicket = new LotterySaleManagmentTicket(
                    _storeName, stockListItem.Product, startDate, endDate);
                DataLayerInstance.AddLottery(lotterySaleManagmentTicket);

                answer = new StoreAnswer(ChangeToLotteryEnum.Success, "type changed");
            }
            catch (StoreException exe)
            {
                answer = new StoreAnswer((ChangeToLotteryEnum)exe.Status, exe.GetErrorMessage());
            }
            catch (DataException e)
            {
                answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
            }
            catch (MarketException)
            {
                answer = new StoreAnswer(StoreEnum.NoPermission, "you have no premmision to do that");
            }
        }
コード例 #11
0
 public void RemoveLottery(LotterySaleManagmentTicket lotteryManagment)
 {
     dbConnection.CheckInput(lotteryManagment.SystemID);
     dbConnection.DeleteFromTable("LotteryTable", "SystemID = '" + lotteryManagment.SystemID + "'");
 }