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 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"); }