Beispiel #1
0
        private void btnAddInitialize(Entities.Stock stock)
        {
            try
            {
                foreach (DataRow row in this.CurrentData.Rows)
                {
                    if (row["Name"].ToString() == stock.Name)
                    {
                        // This means that the name is already in portfolio.
                        btnAdd.IsEnabled        = false;
                        lblAlreadyAdded.Content = "Already added in Portfolio.";
                        break;
                    }
                }


                // If it has the default value then don't have content
                if (lblAlreadyAdded.Content.ToString() == this.DefaultLblAlreadyAddedContent)
                {
                    lblAlreadyAdded.Content = String.Empty;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "error");
            }
        }
Beispiel #2
0
        public wpfShowStock(Entities.Stock stock, DataTable currentData)
        {
            InitializeComponent();

            // Update current portfolio data
            this.CurrentData = currentData;

            // Update displayed stock
            this.UpdateCurrentDisplayedStock(stock);
        }
Beispiel #3
0
        private void UpdateCurrentDisplayedStock(Entities.Stock stock)
        {
            // Pass data to attribute:
            this.CurrentDisplayedStock.Name           = stock.Name;
            this.CurrentDisplayedStock.Var_day        = stock.Var_day;
            this.CurrentDisplayedStock.Var_dayPorcent = stock.Var_dayPorcent;
            this.CurrentDisplayedStock.Opening        = stock.Opening;
            this.CurrentDisplayedStock.Max            = stock.Max;
            this.CurrentDisplayedStock.Min            = stock.Min;
            this.CurrentDisplayedStock.Last           = stock.Last;
            this.CurrentDisplayedStock.Time           = stock.Time;



            this.UpdateWPF();
        }
        public async Task HandleAsync(CreateStockForProduct command)
        {
            var stock = new Entities.Stock
            {
                ProductId = command.ProductId,
                Quantity  = command.Quantity
            };

            context.Stocks.Add(stock);

            await context.SaveChangesAsync();

            var @event = new StockForProductCreated
            {
                Id        = stock.Id,
                ProductId = stock.ProductId,
                Quantity  = stock.Quantity
            };

            await bus.PublishAsync(@event, "price");
        }
Beispiel #5
0
        public void AfterTransferResultReturns(Boolean Success, Guid pOrderNumber, String pMsg)
        {//continue delivery and emailing after received bank's transfer message
            using (TransactionScope lScope = new TransactionScope())
            {
                using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
                {
                    Entities.Order pOrder = lContainer.Orders.Include("Delivery").Include("OrderItems.Media").Include("Customer")
                                            .Where((pOrder1) => pOrder1.OrderNumber == pOrderNumber).FirstOrDefault();
                    foreach (Entities.OrderItem oi in pOrder.OrderItems)
                    {
                        Entities.Media media = oi.Media;
                        Entities.Stock stock = lContainer.Stocks.Where((p) => p.Media.Id == media.Id).FirstOrDefault();
                        media.Stocks = stock;
                    }
                    if (Success)
                    {
                        pOrder.UpdateStockLevels();
                        PlaceDeliveryForOrder(pOrder);
                        lContainer.Orders.ApplyChanges(pOrder);
                        lContainer.SaveChanges();
                    }
                    else
                    {
                        Common.Model.SendEmailMessage emailMessage = new Common.Model.SendEmailMessage()
                        {
                            Topic       = "Email",
                            Message     = pMsg + " Order number: " + pOrderNumber + ".",
                            ToAddresses = pOrder.Customer.Email,
                            Date        = new DateTime()
                        };

                        PublisherServiceClient lClient = new PublisherServiceClient();
                        lClient.Publish(emailMessage);
                    }
                    lScope.Complete();
                }
            }
        }
Beispiel #6
0
        public void UpdateUI(Entities.Data database)
        {
            List <string> listData = database.ListData;

            Entities.Stock stock = new Entities.Stock();
            int            i     = 0;

            // Go through names in portfolio.. (this goes in ORDER!!)
            foreach (var name in database.ListNames)
            {
                // If name is the same as the current name displayed, it needs updating.
                if (this.lblName.Content.ToString().ToUpper() == name.ToUpper())
                {
                    // We can enter the listData because names and data is correlated
                    // pos[n] in listNames = pos[n] in listData
                    stock.AddData(database.ListData[i], Config.Configuration.dataSourceCurrent);
                    this.UpdateCurrentDisplayedStock(stock);
                }

                // Update counter.
                i++;
            }
        }
 public void SellStock(Entities.Stock pStock, int pQuantity)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
        private void btnFindStock_Click(object sender, RoutedEventArgs e)
        {
            /* DOCSTRING
             *
             * btnFindStock_Click: private MainWindow -> void (Raised by Event Click)
             * parameters:
             *      - sender, e
             * returns:
             *      - void
             * exceptions:
             *      - Exceptions are handled by the exception handler.
             * objective/operatory:
             *      -    The objective of the function is to find a desired stock in the
             *           market, as long as the information to retreive this data is
             *           available in the program's database. The function must also
             *           manage what WPF should be created to display the found data
             *           depending on the information found.
             *
             *           The operatory consists in creating a Data instance and calling
             *           the Find method. If any information was found it wil be in a
             *           property called ListData in the database instance.
             *           It then adds into a list of stocks: the current data retreived
             *           and manages this information to show different WPF depending
             *           on how many stocks were found.
             *
             *           //TODO:
             *               In the property CurrentData the current Portfolio is stored,
             *               thus when calling find we should check if the data is in the
             *               portfolio before looking it up in the website because the data
             *               in the portfolio is already to be used in the CurrentData
             *               property (a DataTable) whilst the website information must be
             *               retreived in real-time.
             */


            // Code to find a stock (ANY) in the market.
            string stockStr = txbStock.Text.ToString();

            System.Windows.MessageBox.Show(stockStr);

            List <Entities.Stock> listStocks = new List <Entities.Stock>();

            Entities.Data database = new Entities.Data();

            // Try to find stock in web.
            try
            {
                // Stock data will be stored in a property in the database instance created.
                database.Find(stockStr, Config.Configuration.findMethodSimilar, true);

                if (database.ListData.Any())
                {
                    // There may be multiple "similar" stocks (e.g PAMP ADR, PAMP BCBA or substring of n strings
                    // e.g PAMP can be PAMPA ENERGIA or PETROLERA PAMPA).
                    for (int i = 0; i < database.ListData.Count; i++)
                    {
                        listStocks.Add(new Entities.Stock());
                        listStocks[i].AddData(database.ListData[i], Configuration.dataSourceCurrent);
                    }

                    if (listStocks.Count == 1)
                    {
                        // One stock found.
                        wpfShowStock wpfStock = new wpfShowStock(listStocks[0], this.CurrentData);
                        wpfStock.CurrentData = this.CurrentData;
                        wpfStock.Show();
                    }
                    else
                    {
                        // Multiple stocks found
                        System.Windows.MessageBox.Show("Please be more precise.", "Information", MessageBoxButton.OK, MessageBoxImage.Asterisk);

                        // TODO: Intermediate WPF to choose one of the found stocks and then open a wpfShowStock.
                    }
                }
                else
                {
                    // Either stock was found in the web (thus listData count is 0) or there is no data to show.
                    if (database.StockFoundInPortfolio.Rows.Count > 0)
                    {
                        // Load stock found as dataTable in a stock instance.
                        Entities.Stock stock = new Entities.Stock();
                        stock.AddData(database.StockFoundInPortfolio);

                        // Show stock
                        wpfShowStock wpfStock = new wpfShowStock(stock, this.CurrentData);
                        wpfStock.CurrentData = this.CurrentData;
                        wpfStock.Show();
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("No information was found", "Information", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                }
            }

            catch (Exception Ex)
            {
                System.Windows.MessageBox.Show(Ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }