public static void SearchByRefCommand() //_ SEARCHING Article. { Console.WriteLine("------------------------------"); Console.WriteLine("SEARCHING Article ------------"); Console.WriteLine("------------------------------"); int Ref = 0; //_ Article Reference. bool correct = false; //_ Reference Filling. do { //_ Entry Type Verification. Console.Write("Enter the Article Reference : _"); try { Ref = Int32.Parse(Console.ReadLine()); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); Article searchedArticle = null; //_ Searching for the Article. try { searchedArticle = ArticleDAL.SelectByRef(Ref); Console.WriteLine("Searching Done Successfully .."); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (searchedArticle != null) //_ null : Article Not Found. Show(searchedArticle); else Console.WriteLine("Article Not Found."); }
public static void AddCommand() //_ ADDING Article. { Console.WriteLine("------------------------------"); Console.WriteLine("ADDING Article ---------------"); Console.WriteLine("------------------------------"); Console.WriteLine("Enter Article Data : "); Article articleAdd = GetArticleFromUser(); //_ Instanciation of the Article filled by the user. try { ArticleDAL.Add(articleAdd); //_ Adding the Article. Console.WriteLine("Article Added Successfully .."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/*_ COMMANDES _*/ public static void PrintAllCommand() //_ PRINT All Articles. { Console.WriteLine("---------------------------------"); Console.WriteLine("Articles ------------------------"); Console.WriteLine("---------------------------------"); List<Article> printing = null; try //_ Articles Receiving. { printing = ArticleDAL.SelectAll(); Console.WriteLine("Mapping Done .."); } catch (Exception ex) { Console.WriteLine(ex.Message); } Show(printing); //_ Affichage. }
public static void DeleteCommand() //_ SUPRESSION d'un Article. { Console.WriteLine("------------------------------"); Console.WriteLine("DELETING Article -------------"); Console.WriteLine("------------------------------"); int Ref = 0; //_ Reference. //_ Reference Filling. bool correct = false; do { Console.Write("Enter the Article Reference : _"); try //_ Type Verification. { Ref = Int32.Parse(Console.ReadLine()); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); Article searchedArticle = null; //_ Searching. try { searchedArticle = ArticleDAL.SelectByRef(Ref); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (searchedArticle != null) { Show(searchedArticle); //_ Search Result Printing. //_ Deleting Confirmation. char choice = 'n'; correct = false; do //_ Type Verification. { Console.Write("\nDo you Confirm Deleting ? [(Y): Yes / (n): no] _"); try { choice = char.Parse(Console.ReadLine()); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); if (choice == 'Y') //_ Deleting Confirmed. { try { ArticleDAL.Delete(Ref); Console.WriteLine("Article Deleted Successfully .."); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else Console.WriteLine("No Article Deleting.."); } else Console.WriteLine("Article Not Found"); }
public static void ModificationCommand() //_ MODIFICATION of Article. { Console.WriteLine("------------------------------"); Console.WriteLine("MODIFICATION of Article ------"); Console.WriteLine("------------------------------"); int Ref = 0; //_ Article Reference. bool correct = false; //_ Reference Filling. do { //_ Type Verification. Console.Write("Enter the Article Reference : _"); try { Ref = Int32.Parse(Console.ReadLine()); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); Article searchedArticle = null; //_ Searching for the Article. try { searchedArticle = ArticleDAL.SelectByRef(Ref); Console.WriteLine("Recherche Effectuée .."); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (searchedArticle != null) //_ null : Article introuvable. { Show(searchedArticle); //_ Affichage de l'Article Trouvé. Console.WriteLine(); //_ Saisie des informations manquantes. Article updatedArticle = new Article(Ref, "", 0); Console.Write("--Designation : _"); //_ Designation Filling. updatedArticle.Designation = Console.ReadLine(); correct = false; //_ Price Filling. do { //_ Type Verification. Console.Write("--Prce : _"); try { updatedArticle.Price = float.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); Show(updatedArticle); //_ Modification Printing. Console.WriteLine(); correct = false; //_ Confirmation of the Modifications. char choice = 'n'; do //_ Type Verification. { Console.Write("\nDo you Confirm the modifications ? [(Y): Yes / (n): no] _"); try { choice = char.Parse(Console.ReadLine()); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); if (choice == 'Y') //_ Verification de la confirmation. { //_ Mise à jour. try { ArticleDAL.Update(Ref, updatedArticle); Console.WriteLine("Article Modified Successfully .."); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else Console.WriteLine("No Modification Added .."); } else Console.WriteLine("Article Not Found"); }
static void Main() { /*_ INFORMATIONS _*/ ArticleView.LinesJump(); ArticleView.DevelopperInfo(); Console.ReadLine(); /*_ DB_CONNECTION _*/ ArticleView.LinesJump(); string FichierBD = ArticleView.Setting(); try { ArticleDAL.ConnectTo(FichierBD); } catch (Exception ex) { Console.WriteLine(ex.Message); goto PROGRAM_END; } Console.ReadLine(); /*_ MAIN_PROGRAM _*/ int choix = -1; while (choix != 0) { ArticleView.LinesJump(); ArticleView.Menu(); /*_ DECISION_ENTRY _*/ bool correct = false; do { //_ Format Verification. Console.Write("Enter your choice : _"); try { choix = Int32.Parse(Console.ReadLine()); correct = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } while (correct == false); /*_ REDIRECTION _*/ switch (choix) { case 1: //_ PRINT. ArticleView.LinesJump(); ArticleView.PrintAllCommand(); Console.ReadLine(); break; case 2: //_ ADD. ArticleView.LinesJump(); ArticleView.AddCommand(); Console.ReadLine(); break; case 3: //_ SEARCH. ArticleView.LinesJump(); ArticleView.SearchByRefCommand(); Console.ReadLine(); break; case 4: //_ MODIFICATION. ArticleView.LinesJump(); ArticleView.ModificationCommand(); Console.ReadLine(); break; case 5: //_ DELETE. ArticleView.LinesJump(); ArticleView.DeleteCommand(); Console.ReadLine(); break; case 0: //_ QUIT. goto DISCONNECTION; default: //_ ERROR. Console.WriteLine("WRONG CHOICE"); Console.ReadLine(); break; } } /*_ DB_DISCONNECTION _*/ DISCONNECTION: ArticleView.LinesJump(); try { ArticleDAL.DisconnectFromDB(); } catch (Exception ex) { Console.WriteLine(ex.Message); goto PROGRAM_END; } /*_ QUIT _*/ Console.WriteLine("Thank you for visiting !"); ArticleView.DevelopperInfo(); PROGRAM_END :; }