Пример #1
0
        static void Main(string[] args)
        {
            BLArticle.Init();

            while (true)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Gestion des stocks");
                Console.WriteLine("------------------");
                Console.WriteLine("1. Voir les articles");
                Console.WriteLine("2. Voir le stock");
                Console.WriteLine("3. Ajouter un article");
                Console.WriteLine("4. Mettre un article en stock");
                Console.WriteLine("5. Total stock");
                Console.WriteLine("6. Quitter");
                Console.WriteLine("Faîtes un choix (1 à 6)");

                Console.ForegroundColor = ConsoleColor.Yellow;
                switch (Saisir(1, 6))
                {
                case 1: ArticleAffiche(); break;

                case 2: StockAffiche(); break;

                case 3: ArticleAjout(); break;

                case 4: StockAjout(); break;

                case 5: StockTotal(); break;

                case 6: return;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="article"></param>
 /// <returns></returns>
 public String Add(Article article)
 {
     try
     {
         article.Id = Guid.NewGuid().ToString();
         int result = new BLArticle().Add(article);
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "新增成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "新增失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "新增失败,失败原因:" + ex.Message
         }));
     }
 }
Пример #3
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="article"></param>
 /// <returns></returns>
 public String Update(Article article)
 {
     try
     {
         int result = new BLArticle().Update(article);
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "修改成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "修改失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "修改失败,失败原因:" + ex.Message
         }));
     }
 }
Пример #4
0
        private static void ArticleAffiche()
        {
            var liste = BLArticle.GetArticles();

            for (int i = 0; i < liste.Count; i += 3)
            {
                Console.WriteLine("{0} {1}\t{2}", liste[i], liste[i + 1], liste[i + 2]);
            }
        }
Пример #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var articles = BLArticle.GetArticles();

            for (int i = 0; i < articles.Count; i += 3)
            {
                list1.Items.Add((string)articles[i + 1]);
            }
        }
Пример #6
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids">Id的集合,如1,2,3</param>
        /// <returns></returns>
        public String Delete(String ids)
        {
            int num = new BLArticle().Delete(ids);

            return(JsonConvert.JavaScriptSerializer(new ExtResult()
            {
                success = true, msg = "成功删除" + num + "条数据"
            }));
        }
Пример #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var liste = BLArticle.GetArticles();

            for (int i = 0; i < liste.Count; i += 3)
            {
                listBox1.Items.Add(liste[i + 1]);
            }
        }
Пример #8
0
        private static Guid SaisirArticle()
        {
            var liste = BLArticle.GetArticles(); var n = 1;

            for (int i = 0; i < liste.Count; i += 3)
            {
                Console.WriteLine("{0}. {1}", n, liste[i + 1]);
                n++;
            }
            n = Saisir(1, n - 1);
            return((Guid)liste[3 * (n - 1)]);
        }
Пример #9
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <returns></returns>
        public String SelectByPage(int limit, int start, String query)
        {
            String sqlWhere = String.Format(" and (Title like '%{0}%' or Content like '%{0}%')", query);

            if (!String.IsNullOrEmpty(Request["cateId"]))
            {
                sqlWhere += String.Format(" and cate_Id='{0}'", Request["cateId"]);
            }

            int            total;
            List <Article> articles = new BLArticle().Select(limit, start, null, out total, sqlWhere);

            return(JsonConvert.JavaScriptSerializer(new ExtGridRecord(articles, total)));
        }
Пример #10
0
        private static void StockAjout()
        {
            Console.Write("Article : ");
            Guid id = SaisirArticle();

            Console.Write("Quantité : ");
            int  qte = Saisir(1, int.MaxValue);
            bool ok  = BLArticle.InsertStock(id, qte);

            if (ok)
            {
                Console.WriteLine("Stock mis à jour");
            }
            else
            {
                Console.WriteLine("Ajoût non effectué");
            }
        }
Пример #11
0
        private static void ArticleAjout()
        {
            Console.Write("Nom de l'article : ");
            string nom = Saisir();

            Console.Write("Prix de l'article : ");
            decimal prix = Saisir(Langue.FR);
            bool    ok   = BLArticle.InsertArticle(nom, prix);

            if (ok)
            {
                Console.WriteLine("Article ajouté");
            }
            else
            {
                Console.WriteLine("Ajoût non effectué");
            }
        }
Пример #12
0
 public String Save(Article article)
 {
     if (string.IsNullOrEmpty(article.Id))
     {
         article.CreateBy   = article.UpdateBy = CurrentUser.Id;
         article.CreateTime = article.UpdateTime = DateTime.Now;
         return(Add(article));
     }
     else
     {
         Article index = new BLArticle().Select(article.Id);
         index.Title      = article.Title;
         index.Content    = article.Content;
         index.UpdateBy   = CurrentUser.Id;
         index.UpdateTime = DateTime.Now;
         return(Update(index));
     }
 }
Пример #13
0
        private static void StockTotal()
        {
            int n = BLArticle.GetStockTotal();

            Console.WriteLine("{0} article{1} dans le stock", n, n > 1 ? "s": "");
        }
Пример #14
0
 public MainWindow()
 {
     InitializeComponent();
     BLArticle.Init();
     ListArticle = new List <string>();
 }
Пример #15
0
        public String Select(String id)
        {
            Article article = new BLArticle().Select(id);

            return(JsonConvert.JavaScriptSerializer(article));
        }
Пример #16
0
 public Form1()
 {
     InitializeComponent();
     BLArticle.Init();
 }