Ejemplo n.º 1
0
 /// <summary>
 /// This function delete elements of the ShoppingCard.xml file.
 /// </summary>
 /// <param name="shoppingCard">This parameter is a object of ShoppingCard class.</param>
 /// <returns> This function does not return a value </returns>
 public static void Delete(ShoppingCard shoppingCard)
 {
     try
     {
         XDocument xDoc = XDocument.Load(@"data/ShoppingCard.xml");
         XElement  shoppingCardRootElement = xDoc.Root;
         foreach (XElement Card in shoppingCardRootElement.Elements())
         {
             if (shoppingCard.CustomerID.ToString() == Card.FirstAttribute.Value)
             {
                 Card.Element("PaymentAmount").Value = "0";
                 Card.Element("PaymentType").Value   = "cash";
                 Card.Element("ItemToPurchaseList").Remove();
                 XElement item = new XElement("ItemToPurchaseList");
                 Card.Add(item);
                 xDoc.Save(@"data/ShoppingCard.xml");
                 return;
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        private void addDishToCard()
        {
            DishModel tmp = SelectedDish;

            dishesNames.Add(tmp.Name);
            Card.Add(tmp);
        }
Ejemplo n.º 3
0
 private void listBox1_DoubleClick(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem is Product product)
     {
         card.Add(product);
         listBox2.Items.Add(product);
     }
 }
Ejemplo n.º 4
0
        public void CardTest()
        {
            //arrange
            Customer customer = new Customer()
            {
                CustomerId = 1,
                Name       = "testUser"
            };

            Product product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            Product product2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200,
                Count     = 20
            };
            Card card = new Card(customer);

            List <Product> expectedResult = new List <Product>()
            {
                product1, product1, product2
            };

            //act
            card.Add(product1);
            card.Add(product1);
            card.Add(product2);
            var carResult = card.GetAll();

            //assert
            Assert.AreEqual(expectedResult.Count, carResult.Count);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                Assert.AreEqual(expectedResult[i], carResult[i]);
            }
        }
Ejemplo n.º 5
0
        protected void LinkButton_Add_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton  btn = sender as LinkButton;
                GridViewRow gvr = btn.NamingContainer as GridViewRow;
                MahsolatID = int.Parse(GridView_Card.DataKeys[gvr.RowIndex].Value.ToString());


                Card.Add(MahsolatID, Session);

                Card.Show(GridView_Card, Session);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 6
0
 public void AddCard(ItemDB input_card)
 {
     if (Equip.CardSlot == 0)
     {
         return;
     }
     if (Card.Count < Equip.CardSlot)
     {
         Card.Add(input_card);
     }
     else
     {
         if (LastCardSetSlot - 1 <= Equip.CardSlot)
         {
             LastCardSetSlot = 0;
         }
         Card[LastCardSetSlot] = input_card;
     }
 }
Ejemplo n.º 7
0
            public void AddCard(int input_card)
            {
                ItemDB item = MainWindow._roo_db.Equip_db[(int)EnumBaseTable_Kor.EQUIP_TYPE_TO_DB_ENUM[EquipType]][Equip];

                if (item.CardSlot == 0)
                {
                    return;
                }
                if (Card.Count < item.CardSlot)
                {
                    Card.Add(input_card);
                }
                else
                {
                    if (LastCardSetSlot - 1 <= item.CardSlot)
                    {
                        LastCardSetSlot = 0;
                    }
                    Card[LastCardSetSlot] = input_card;
                }
            }
Ejemplo n.º 8
0
        private void AcceptButton_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < CardsDataGridView.RowCount; i++)
            {
                string serialNum  = CardsDataGridView["serial_num", i].Value.ToString();
                string shortName  = CardsDataGridView["short_name", i].Value.ToString();
                long   statusId   = Convert.ToInt64(CardsDataGridView["status_id", i].Value);
                long   locationId = Convert.ToInt64(CardsDataGridView["location_id", i].Value);

                if (!Card.Find(serialNum, shortName, out long cardId)) // Если карты нет в БД.
                {
                    if (!Card.Add(serialNum, shortName, locationId, statusId, out cardId))
                    {
                        MessageBox.Show("Возникла ошибка при добавлении карты в БД!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            MessageBox.Show("Карты успешно добавлены!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);

            MainForm.SubMenuProcessing(MainForm.AllCardsBtn, MainForm.CardsBtn, MainForm.CardsP);
            Functions.OpenChildForm(new AllCards(), MainForm.ContP);
        }
Ejemplo n.º 9
0
        public void CashDeskTest()
        {
            //arrange
            Customer customer1 = new Customer()
            {
                Name       = "Tester1",
                CustomerId = 1,
            };

            Customer customer2 = new Customer()
            {
                Name       = "Tester2",
                CustomerId = 2,
            };

            Seller seller = new Seller()
            {
                Name     = "SellerTest",
                SellerId = 1
            };

            var product1 = new Product()
            {
                ProductId = 1,
                Name      = "pr1",
                Price     = 100,
                Count     = 10
            };
            var product2 = new Product()
            {
                ProductId = 2,
                Name      = "pr2",
                Price     = 200,
                Count     = 20
            };

            var card1 = new Card(customer1);

            card1.Add(product1);
            card1.Add(product1);
            card1.Add(product2);
            var card2 = new Card(customer2);

            card2.Add(product1);
            card2.Add(product2);
            card2.Add(product2);
            var chashDesk = new  CashDesk(1, seller);

            chashDesk.MaxQueueLenght = 10;

            chashDesk.Enqueue(card1);
            chashDesk.Enqueue(card2);

            var card1Result = 400;
            var card2Result = 500;

            //act
            var card1ActualResult = chashDesk.Dequeue();
            var card2ActualResult = chashDesk.Dequeue();

            //assert
            Assert.AreEqual(card1Result, card1ActualResult);
            Assert.AreEqual(card2Result, card2ActualResult);
            Assert.AreEqual(7, product1.Count);
            Assert.AreEqual(17, product2.Count);
        }
Ejemplo n.º 10
0
    public void OnPointerClick(PointerEventData eventData)
    {
        print(myCard.cardName);
        print(clickEffect);
        switch (clickEffect)
        {
        case ClickEffect.nothing:
            if (eventData.button == PointerEventData.InputButton.Right)
            {
                UpgradePreview();
            }
            break;

        case ClickEffect.option:
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                myCard.Option();
            }
            break;

        case ClickEffect.trash:
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                myCard.UiTrash(zone);
            }
            if (eventData.button == PointerEventData.InputButton.Right)
            {
                UpgradePreview();
            }
            break;

        case ClickEffect.upgrade:
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                myCard.UiUpgrade(zone);
            }
            if (eventData.button == PointerEventData.InputButton.Right)
            {
                UpgradePreview();
            }
            break;

        case ClickEffect.unlock:
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                myCard.Unlock(zone);
            }
            if (eventData.button == PointerEventData.InputButton.Right)
            {
                UpgradePreview();
            }
            break;

        case ClickEffect.newFactory:
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                if (UiText != null)
                {
                    UiText.text = "Sold";
                }
                this.gameObject.SetActive(false);
                myCard.Add(zone);
            }
            if (eventData.button == PointerEventData.InputButton.Right)
            {
                UpgradePreview();
            }
            break;

        case ClickEffect.resorce:
            if (myCard.Master.CurrentBank.Transaction(Currency.coin, myCard.FactoryCost * -1))
            {
                UiText.text = "Sold";
                this.gameObject.SetActive(false);
                myCard.PlayEffect();
                myCard.Master.bankUi.UpdateUI();
            }
            break;

        case ClickEffect.shop:
            if (myCard.Master.CurrentBank.Transaction(Currency.coin, myCard.FactoryCost * -1))
            {
                UiText.text = "Sold";
                this.gameObject.SetActive(false);
                myCard.Add(zone);
                myCard.Master.bankUi.UpdateUI();
            }
            break;
        }
    }