public static void SearchSalesMan() { int SalesManCode; JMS_Entities searchedSalesMan; try { Console.Write("Enter code for search : "); SalesManCode = Convert.ToInt32(Console.ReadLine()); //Checking if all validations by calling the customerBiz class to use it's function AND using are true AND using NAMED ARGUMENTS searchedSalesMan = JMS_BAL.SearchSalesMan(SalesManCode: SalesManCode); if (searchedSalesMan != null) { Console.WriteLine("SalesMan : " + searchedSalesMan.SalesManCode); Console.WriteLine("Guest Name : " + searchedSalesMan.SalesManName); Console.WriteLine("SalesManRegion: " + searchedSalesMan.Region2); } else { throw new JMS_Exceptions("SalesMan not found!"); } } //Catching User defined exception catch (JMS_Exceptions p) { Console.WriteLine(p.Message); } //Catching System exception catch (SystemException e) { Console.WriteLine(e.Message); } }
public static void DisplaySalesMan() { //Creating List object to store n number of inputs from the user List <JMS_Entities> SMS = new List <JMS_Entities>(); try { SMS = JMS_BAL.ReturnSalesManInformation1(); if (SMS.Count > 0) { Console.WriteLine("*******************All SalesMan Detail****************"); Console.WriteLine("SalesManCode - SalesManName - SalesManRegion "); Console.WriteLine("--------------------------------------------------------"); foreach (JMS_Entities p in SMS) { Console.WriteLine(p.SalesManCode + "\t\t\t" + p.SalesManName + "\t\t\t" + p.Region2); } } else { throw new JMS_Exceptions("There are no records!"); } } //Catching User defined exception catch (JMS_Exceptions p) { Console.WriteLine(p.Message); } //Catching System exception catch (SystemException e) { Console.WriteLine(e.Message); } }
public static void DeleteSalesMan() { int SalesManCode; bool SalesManDeleted; try { //User Inputs Console.Write("Enter the SalesManCode to be deleted : "); SalesManCode = Convert.ToInt32(Console.ReadLine()); //Calling the customerBL class to use it's function AND using NAMED ARGUMENTS SalesManDeleted = JMS_BAL.DeleteSalesMan(SalesManCode); if (SalesManDeleted == true) { Console.WriteLine("SalesMan Deleted Successfully!"); } else { throw new JMS_Exceptions("SalesMan not deleted!"); } } //Catching User defined exception catch (JMS_Exceptions p) { Console.WriteLine(p.Message); } //Catching System exception catch (SystemException e) { Console.WriteLine(e.Message); } }
//Method to Add a Customer and calling the validation methods from the CustomerBal class public static void AddSalesMan() { try { //Creating object of Customer class to access the values being stored through the properties JMS_Entities newSalesMan = new JMS_Entities(); //User Inputs //Console.Write("Enter SalesManCode ID : "); //newSalesMan.SalesManCode = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter SalesManName : "); newSalesMan.SalesManName = Console.ReadLine(); Console.Write(" Enter the Region: (1- East, 2- West, 3- North, 4-south) "); newSalesMan.Region2 = (Region)Enum.Parse(typeof(Region), Console.ReadLine()); Console.Write("Enter TargetSet (0% - 100%): "); newSalesMan.TargetSet = float.Parse(Console.ReadLine()); Console.Write("Enter Actualtarget 0% - 100% : "); newSalesMan.ActualSales = float.Parse(Console.ReadLine()); //Checking if all validations by calling the CustomerBL class to use it's function AND using are true AND using NAMED ARGUMENTS bool SalesManAdded = JMS_BAL.AddSalesMan(newSalesMan); if (SalesManAdded == true) { Console.WriteLine("SalesMan Added Successfully!"); } else { throw new JMS_Exceptions("SalesMan not added! Please try again following the validations mentioned!"); } JMS_BAL.SerializeData(); } //Catching user defined exception catch (JMS_Exceptions p) { Console.WriteLine(p.Message); } //Catching System exception catch (SystemException e) { Console.WriteLine(e.Message); } }
//Method to Update a Customer and calling the validation methods from the CustomerBiz class public static void UpdateSalesMan() { JMS_Entities SalesManToBeUpdated = new JMS_Entities(); bool SalesManUpdated; try { //User inputs Console.Write("Enter SalesManCode for which you would like to update the record : "); SalesManToBeUpdated.SalesManCode = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter SalesManName to be updated : "); SalesManToBeUpdated.SalesManName = Console.ReadLine(); Console.Write("Enter SalesMan Region to be updated : "); SalesManToBeUpdated.Region2 = (Region)Enum.Parse(typeof(Region), Console.ReadLine()); //Checking if all validations by calling the customerBL class to use it's function AND using are true AND using NAMED ARGUMENTS SalesManUpdated = JMS_BAL.UpdateSalesMan(SalesManToBeUpdated); //Checking if validations are true or not if (SalesManUpdated == true) { Console.WriteLine("SalesMan Updated Successfully!"); } else { throw new JMS_Exceptions("SalesMan not updated!"); } } //Catching User defined exception catch (JMS_Exceptions p) { Console.WriteLine(p.Message); } //Catching System exception catch (SystemException e) { Console.WriteLine(e.Message); } }