示例#1
0
 public void NoDiscount()
 {
     stock = new StockListItem(10, prod, null, PurchaseEnum.Immediate, "BLA");
     handler.Setup(x => x.GetProductFromStore("X", "NEWPROD")).Returns(stock);
     slave.EditDiscount("NEWPROD", null, false, null, null, "25", true);
     Assert.AreEqual((int)DiscountStatus.DiscountNotFound, slave.answer.Status);
 }
示例#2
0
 public void DiscountBadAmmount3()
 {
     discount = new Discount(DiscountTypeEnum.Visible, DateTime.Parse("03/05/2020"), DateTime.Parse("30/06/2020"), 50, false);
     stock    = new StockListItem(10, prod, discount, PurchaseEnum.Immediate, "BLA");
     handler.Setup(x => x.GetProductFromStore("X", "NEWPROD")).Returns(stock);
     slave.EditDiscount("NEWPROD", null, false, null, null, "shit", false);
     Assert.AreEqual((int)DiscountStatus.InvalidDiscountAmount, slave.answer.Status);
 }
示例#3
0
        public void GetStockListItembyProductID()
        {
            Discount      discount = handler.GetDiscount("D1");
            Product       product  = handler.GetProductID("P1");
            StockListItem expected = new StockListItem(5, product, discount, PurchaseEnum.Immediate, "S1");
            StockListItem find     = handler.GetStockListItembyProductID("P1");

            Assert.AreEqual(expected, find);
        }
示例#4
0
        public void AddProductSuccess()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");
            MarketAnswer           ans         = liorSession.AddNewProduct("item", 1, "des", 4);

            ProductToDelete = handler.GetProductFromStore("X", "item");
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
示例#5
0
        public void BuildStore()
        {
            MarketDB.Instance.InsertByForce();
            handler = StoreDL.Instance;
            Product P = new Product("P10000", "name", 100, "ds");

            ProductToDelete = new StockListItem(1, P, null, PurchaseEnum.Lottery, "S7");
            LotteryToDelete = new LotterySaleManagmentTicket("L100", "T", P, DateTime.Parse("31/12/2019"), DateTime.Parse("31/12/2020"));
            handler.AddStockListItemToDataBase(ProductToDelete);
            handler.AddLottery(LotteryToDelete);
            tickets = new LinkedList <LotteryTicket>();
        }
示例#6
0
        public void AddStockListItemToDataBase()
        {
            Discount      discount = new Discount("D105", DiscountTypeEnum.Hidden, DateTime.Parse("01/01/2018"), DateTime.Parse("31/12/2018"), 50, true);
            Product       product  = new Product("P110", "BOX", 100, "this is a plastic box");
            StockListItem expected = new StockListItem(10, product, discount, PurchaseEnum.Immediate, "S1");
            StockListItem find     = handler.GetStockListItembyProductID("P110");

            Assert.IsNull(find);
            handler.AddStockListItemToDataBase(expected);
            find = handler.GetStockListItembyProductID("P110");
            Assert.AreEqual(expected, find);
        }
示例#7
0
        public void AddDiscountsuccessfully()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            liorSession.AddNewProduct("item", 1, "des", 4);
            MarketAnswer ans = liorSession.AddDiscountToProduct("item", DateTime.Parse("01/01/2019"), DateTime.Parse("20/01/2019"), 10, "HIDDEN", true);

            ProductToDelete = handler.GetProductFromStore("X", "item");
            Assert.IsNotNull(ProductToDelete.Discount);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
示例#8
0
        public void AddQuanitiySuccess()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            liorSession.AddNewProduct("new", 5, "MOMO", 5);
            ProductToDelete = handler.GetProductFromStore(liorSession._storeName, "new");
            MarketAnswer  ans  = liorSession.AddQuanitityToProduct("new", 10);
            StockListItem find = handler.GetProductFromStore(liorSession._storeName, "new");

            Assert.AreEqual(find.Quantity, 15);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
示例#9
0
 public void UpdateStockAfterPurchaseTest()
 {
     try
     {
         orderServiceSession.LoginBuyer("Vadim Chernov", "123");
         orderServiceSession.GiveDetails("Vadim Chernov", "Mivtza Kilshon", "12345667");
         orderServiceSession.BuyItemFromImmediate(product1, store1, 3, 6, null);
         StockListItem itemToCheck = storeServiceSession.GetProductFromStore(store1, product1);
         Assert.AreEqual(17, itemToCheck.Quantity);
     }
     catch (MarketException)
     {
         Assert.Fail();
     }
 }
示例#10
0
        public void EditDiscountStartDateSuccessfully()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            var product = handler.GetProductFromStore("X", "BOX");

            product.Discount.startDate = DateTime.Parse("06/06/2018");
            MarketAnswer  ans  = liorSession.EditDiscount("BOX", null, false, "06/06/2018", null, null, false);
            StockListItem find = handler.GetProductFromStore("X", "BOX");

            Assert.AreEqual(find.Discount.startDate, product.Discount.startDate);
            Assert.AreEqual((int)DiscountStatus.Success, ans.Status);
        }
示例#11
0
 public void BuildStore()
 {
     marketDbMocker = new Mock <IMarketBackUpDB>();
     MarketException.SetDB(marketDbMocker.Object);
     MarketLog.SetDB(marketDbMocker.Object);
     handler     = new Mock <IStoreDL>();
     userService = new Mock <IUserSeller>();
     prod        = new Product("NEWPROD", 150, "desc");
     discount    = new Discount(DiscountTypeEnum.Visible, DateTime.Parse("03/05/2020"), DateTime.Parse("30/06/2020"), 50, true);
     stock       = new StockListItem(10, prod, discount, PurchaseEnum.Immediate, "BLA");
     handler.Setup(x => x.GetStorebyName("X")).Returns(new Store("X", ""));
     handler.Setup(x => x.GetProductByNameFromStore("X", "NEWPROD")).Returns(prod);
     handler.Setup(x => x.IsStoreExistAndActive("X")).Returns(true);
     handler.Setup(x => x.GetProductFromStore("X", "NEWPROD")).Returns(stock);
     slave = new EditDiscountSlave("X", userService.Object, handler.Object);
 }
示例#12
0
        public void EditDiscountDiscountTypeSuccessfully()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            liorSession.AddNewProduct("BOX", 150, "desc", 3);
            liorSession.AddDiscountToProduct("BOX", DateTime.Parse("03/05/2020"), DateTime.Parse("30/06/2020"), 50, "VISIBLE", false);
            var product = handler.GetProductFromStore("X", "BOX");

            product.Discount.discountType = DiscountTypeEnum.Hidden;
            MarketAnswer  ans  = liorSession.EditDiscount("BOX", "shit", true, null, null, null, false);
            StockListItem find = handler.GetProductFromStore("X", "BOX");

            Assert.AreEqual((int)find.Discount.discountType, (int)product.Discount.discountType);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
        public void ChangeToImmediateSuccessLottery()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");
            Product P = new Product("P1345678", "OBJ", 9, "des");

            ProductToDelete = new StockListItem(4, P, null, PurchaseEnum.Lottery, "S1");
            lotteryToDelete = new LotterySaleManagmentTicket("L1000", "X", P, DateTime.Parse("31/12/2018"), DateTime.Parse("31/12/2020"));
            handler.AddStockListItemToDataBase(ProductToDelete);
            handler.AddLottery(lotteryToDelete);
            MarketAnswer  ans  = liorSession.ChangeProductPurchaseWayToImmediate("OBJ");
            StockListItem find = handler.GetProductFromStore("X", "OBJ");

            Assert.AreEqual((int)PurchaseEnum.Immediate, (int)find.PurchaseWay);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
示例#14
0
        public void BuildStore()
        {
            marketDbMocker = new Mock <IMarketBackUpDB>();
            MarketException.SetDB(marketDbMocker.Object);
            MarketLog.SetDB(marketDbMocker.Object);
            handler     = new Mock <IStoreDL>();
            userService = new Mock <IUserSeller>();
            slave       = new ChangeProductPurchaseWayToLotterySlave("X", userService.Object, handler.Object);
            MarketYard.SetDateTime(new DateTime(2018, 4, 14));
            prod = new Product("item", 1, "des");
            Discount discount = new Discount(DiscountTypeEnum.Visible, DateTime.Parse("03/05/2020"), DateTime.Parse("30/06/2020"), 50, false);

            stock = new StockListItem(10, prod, discount, PurchaseEnum.Immediate, "BLA");
            handler.Setup(x => x.GetStorebyName("X")).Returns(new Store("X", ""));
            handler.Setup(x => x.GetProductByNameFromStore("X", "item")).Returns(prod);
            handler.Setup(x => x.IsStoreExistAndActive("X")).Returns(true);
            handler.Setup(x => x.GetProductFromStore("X", "item")).Returns(stock);
        }
 public void BuyItemTestEverything()
 {
     try
     {
         storeServiceSession.LoginShoper(user, pass);
         Assert.AreEqual(8, ((UserService)userServiceSession).MarketUser.SystemID);
         storeServiceSession.AddProductToCart(store, product, 3);
         CartItem expected = ((UserService)userServiceSession).MarketUser.Cart.SearchInCart(store, product, 11);
         Assert.AreEqual(3, expected.Quantity);
         orderServiceSession.LoginBuyer(user, pass);
         orderServiceSession.BuyItemFromImmediate(product, store, 3, 11, null);
         userServiceSession3.SignIn(user, pass);
         Assert.IsNull(((UserService)userServiceSession3).MarketUser.Cart.SearchInCart(store, product, 11));
         StockListItem itemToCheck = StoreDL.Instance.GetProductFromStore(store, product);
         Assert.AreEqual(33, itemToCheck.Quantity);
     }
     catch (MarketException)
     {
         Assert.Fail();
     }
 }
示例#16
0
        /// <summary>
        /// Performs a search on symbols close to the specified string
        /// </summary>
        /// <param name="symbol"></param>
        public void Search(string symbol)
        {
            DataAccessor.Search(symbol, (Dictionary <string, string> r) =>
            {
                this.BeginInvoke((Action <Dictionary <string, string> >)((Dictionary <string, string> results) =>
                {
                    this.SuspendLayout();
                    ClearSearchResults();
                    int yPos = 35;
                    foreach (var pair in results)
                    {
                        StockListItem item = new StockListItem(this, pair.Key, pair.Value);
                        item.Location      = new System.Drawing.Point(5, yPos);
                        Controls.Add(item);

                        yPos += 35;
                    }
                    this.ResumeLayout();
                }), new object[] { r });
            });
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DateTime MaxDate = new DateTime(2008, 1, 29);
            DateTime MinDate = new DateTime(2008, 1, 1);

            if (Calendar2.SelectedDate > MaxDate || Calendar2.SelectedDate < MinDate || Calendar1.SelectedDate < MinDate || Calendar1.SelectedDate > MaxDate)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Selected Date is not valid.Please select the date between 1st Jan 2008 and 29th Jan 2008!');", true);
            }
            else
            {
                ExcelEngine  excelEngine = new ExcelEngine();
                IApplication application = excelEngine.Excel;
                // A new workbook is created.[Equivalent to creating a new workbook in Microsoft Excel]
                // The number of default worksheets is the application setting in Microsoft Excel.
                myWorkbook = excelEngine.Excel.Workbooks.Add(XlsIOHelper.ResolveApplicationDataPath("Template.xls", Request));
                ListItem[] StockList;// = new ListItem();
                //  ArrayList[] StockList;
                int index = 0;
                foreach (ListItem lItem in CheckBoxList1.Items)
                {
                    if (lItem.Selected)
                    {
                        index++;
                    }
                }
                StockList = new ListItem[index];
                int stockItem = 0;
                foreach (ListItem lItem in CheckBoxList1.Items)
                {
                    if (lItem.Selected)
                    {
                        StockList[stockItem] = lItem;
                        stockItem++;
                    }
                }
                IChart chart = myWorkbook.Worksheets[1].Charts[0];
                chart.PrimaryCategoryAxis.NumberFormat     = "m/d/yyyy";
                chart.PrimaryValueAxis.NumberFormat        = "\"$\"#,##0.00";
                chart.SecondaryValueAxis.NumberFormat      = "\"$\"#,##0.00";
                chart.SecondaryValueAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_High;

                // Adding new worksheets in workbook's sheets collection
                for (int count = 1; count < StockList.Length; count++)
                {
                    myWorkbook.Worksheets.AddCopyAfter(myWorkbook.Worksheets[1], myWorkbook.Worksheets[0]);
                }

                // Adding hyperlinks to menu sheet
                IWorksheet menu_sheet  = myWorkbook.Worksheets[0];
                int        InsertIndex = DEF_FST_ROW_NUM_SC - 3;

                menu_sheet.HyperLinks.RemoveAt(0);
                menu_sheet.Range["G21"].Text = "";

                for (int count = 0; count < StockList.Length; count++)
                {
                    menu_sheet.InsertRow(InsertIndex, 2, ExcelInsertOptions.FormatAsBefore);
                    IHyperLink report_hyperlink = menu_sheet.HyperLinks.Add(menu_sheet.Range["G" + InsertIndex + ":I" + InsertIndex]);
                    report_hyperlink.Type          = ExcelHyperLinkType.Workbook;
                    report_hyperlink.Address       = StockList[count].Text + "!A1";
                    report_hyperlink.TextToDisplay = StockList[count].Text;

                    InsertIndex += 2;
                }

                // Creating Stock report
                int itemIndex = 1;

                foreach (Object StockListItem in StockList)
                {
                    CreateStockReport(StockListItem.ToString(), itemIndex);
                    FillAnalysisPortfolioSheet(StockListItem.ToString());
                    itemIndex += 1;
                }
                myWorkbook.Worksheets[0].Activate();
                //Saving the workbook to disk.


                if (rBtnXls.Checked == true)
                {
                    myWorkbook.Version = ExcelVersion.Excel97to2003;
                    myWorkbook.SaveAs(reportDirectory + "\\Sample.xls", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);
                }
                else
                {
                    myWorkbook.Version = ExcelVersion.Excel2016;
                    myWorkbook.SaveAs(reportDirectory + "\\Sample.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016);
                }
                //No exception will be thrown if there are unsaved workbooks.
                excelEngine.ThrowNotSavedOnDestroy = false;
                excelEngine.Dispose();
            }
        }
示例#18
0
        private void btnCreateReport_Click(object sender, EventArgs e)
        {
            #region Initialize Workbook
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;
            // A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            // The number of default worksheets is the application setting in MS Excel.
            myWorkbook = excelEngine.Excel.Workbooks.Add(dataDirectory.FullName + "Template.xls");

            //Set the Default version as Excel 97to2003
            if (this.rdbExcel97.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel97to2003;
                fileName           = "StockPortfolioOutput.xls";
            }
            //Set the Default version as Excel 2007
            else if (this.rdbExcek2007.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel2007;
                fileName           = "StockPortfolioOutput.xlsx";
            }
            //Set the Default version as Excel 2010
            else if (this.rdbExcel2010.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel2010;
                fileName           = "StockPortfolioOutput.xlsx";
            }
            //Set the Default version as Excel 2013
            else if (this.rdbExcel2013.Checked)
            {
                myWorkbook.Version = ExcelVersion.Excel2013;
                fileName           = "StockPortfolioOutput.xlsx";
            }

            IChart chart = myWorkbook.Worksheets[1].Charts[0];
            chart.PrimaryCategoryAxis.NumberFormat     = "m/d/yyyy";
            chart.PrimaryValueAxis.NumberFormat        = "\"$\"#,##0.00";
            chart.SecondaryValueAxis.NumberFormat      = "\"$\"#,##0.00";
            chart.SecondaryValueAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_High;

            // Adding new worksheets in workbook's sheets collection
            for (int count = 1; count < StockList.SelectedItems.Count; count++)
            {
                myWorkbook.Worksheets.AddCopyAfter(myWorkbook.Worksheets[1], myWorkbook.Worksheets[0]);
            }

            // Adding hyperlinks to menu sheet
            IWorksheet menu_sheet = myWorkbook.Worksheets[0];
            #endregion

            int InsertIndex = DEF_FST_ROW_NUM_SC - 3;

            menu_sheet.HyperLinks.RemoveAt(0);
            menu_sheet.Range["G21"].Text = "";

            #region Insert Hyperlinks for Stock items
            for (int count = 0; count < StockList.SelectedItems.Count; count++)
            {
                menu_sheet.InsertRow(InsertIndex, 2, ExcelInsertOptions.FormatAsBefore);
                IHyperLink report_hyperlink = menu_sheet.HyperLinks.Add(menu_sheet.Range["G" + InsertIndex + ":I" + InsertIndex]);
                report_hyperlink.Type          = ExcelHyperLinkType.Workbook;
                report_hyperlink.Address       = StockList.SelectedItems[count].ToString() + "!A1";
                report_hyperlink.TextToDisplay = StockList.SelectedItems[count].ToString();

                InsertIndex += 2;
            }
            #endregion

            #region Creating Stock report

            int itemIndex = 1;

            foreach (Object StockListItem in StockList.SelectedItems)
            {
                CreateStockReport(StockListItem.ToString(), itemIndex);
                FillAnalysisPortfolioSheet(StockListItem.ToString());
                itemIndex += 1;
            }
            #endregion

            #region Save the Workbook
            myWorkbook.Worksheets[0].Activate();
            // Saving the workbook to disk.
            myWorkbook.SaveAs(reportDirectory + "\\" + fileName);
            #endregion

            #region Dispose the Excel Engine
            // No exception will be thrown if there are unsaved workbooks. No use here since we are
            // saving the workbook.
            excelEngine.ThrowNotSavedOnDestroy = false;
            excelEngine.Dispose();
            #endregion

            #region View the Workbook
            //Message box confirmation to view the created spreadsheet.
            if (MessageBox.Show("Do you want to view the workbook?", "Workbook has been created",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                == DialogResult.Yes)
            {
                //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer]
                System.Diagnostics.Process.Start(reportDirectory + "\\" + fileName);
                //Exit
                this.Close();
            }
            else
            {
                // Exit
                this.Close();
            }
            #endregion
        }