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; } } }
/// <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 })); } }
/// <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 })); } }
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]); } }
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]); } }
/// <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 + "条数据" })); }
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]); } }
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)]); }
/// <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))); }
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é"); } }
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é"); } }
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)); } }
private static void StockTotal() { int n = BLArticle.GetStockTotal(); Console.WriteLine("{0} article{1} dans le stock", n, n > 1 ? "s": ""); }
public MainWindow() { InitializeComponent(); BLArticle.Init(); ListArticle = new List <string>(); }
public String Select(String id) { Article article = new BLArticle().Select(id); return(JsonConvert.JavaScriptSerializer(article)); }
public Form1() { InitializeComponent(); BLArticle.Init(); }