Esempio n. 1
0
 public static CroatianPDV getInstance()
 {
     if (instance == null)
     {
         instance = new CroatianPDV();
     }
     return(instance);
 }
Esempio n. 2
0
        public void defineNewArticle()
        {
            Console.WriteLine("Enter article name");
            string name = Console.ReadLine();

            if (name == null || name.Length == 0)
            {
                Console.WriteLine("Article name is mandatory");
            }

            Console.WriteLine("Enter article price");
            string price = Console.ReadLine();

            if (price == null || price.Length == 0)
            {
                Console.WriteLine("Article price is mandatory");
            }

            Console.WriteLine("Choose pdv type:");
            Console.WriteLine("1 - Croatian PDV");

            int pdvType = Int32.Parse(Console.ReadLine());
            PDV pdv     = null;

            if (pdvType == CroatianPDV.getInstance().getId())
            {
                pdv = CroatianPDV.getInstance();
            }
            else
            {
                Console.WriteLine("PDV type does not exists");
            }
            Console.WriteLine("Enter article type");
            Console.WriteLine("1 - Article per item");
            Console.WriteLine("2 - Article per kg");
            int articleType = Int32.Parse(Console.ReadLine());

            if (articleType == 1)
            {
                ArticlePerItem articlePerItem = new ArticlePerItem(Util.getGlobalIdCounter(), name, float.Parse(price), pdv);
                articlePerItem.save();
                Console.WriteLine("Article created:");
                articlePerItem.print();
            }
            else if (articleType == 2)
            {
                ArticlePerKg articlePerKg = new ArticlePerKg(Util.getGlobalIdCounter(), name, float.Parse(price), pdv);
                articlePerKg.save();
                Console.WriteLine("Article created:");
                articlePerKg.print();
            }
            else
            {
                Console.WriteLine("PDV type does not exists");
            }
        }
Esempio n. 3
0
        protected override PDV Create(Type objectType, JObject jsonObject)
        {
            int typeName = Int32.Parse((jsonObject["type"]).ToString());

            switch (typeName)
            {
            case 1:
                return(CroatianPDV.getInstance());

            default:
                return(null);
            }
        }
Esempio n. 4
0
        private static void initArticles()
        {
            ArticlePerItem auto   = new ArticlePerItem(200, "Auto", 1250, CroatianPDV.getInstance());
            ArticlePerItem bicikl = new ArticlePerItem(201, "Bicikl", 100, CroatianPDV.getInstance());
            ArticlePerItem stol   = new ArticlePerItem(202, "Stol", 300, CroatianPDV.getInstance());
            ArticlePerItem cvijet = new ArticlePerItem(203, "Cvijet", 30, CroatianPDV.getInstance());

            ArticlePerKg limun    = new ArticlePerKg(100, "Limun", 10, CroatianPDV.getInstance());
            ArticlePerKg lubenica = new ArticlePerKg(101, "Lubenica", 5, CroatianPDV.getInstance());
            ArticlePerKg jabuka   = new ArticlePerKg(102, "Jabuka", 3, CroatianPDV.getInstance());

            List <Article> articles = new List <Article>();

            articles.Add(auto);
            articles.Add(bicikl);
            articles.Add(stol);
            articles.Add(cvijet);
            articles.Add(limun);
            articles.Add(lubenica);
            articles.Add(jabuka);
            Util.saveArticles(articles);
        }