//Method to GET WareHouse details by WareHouseId public void GetWareHouseByWareHouseID() { bool check = false; do { try { WriteLine(" You chose to get the details of Warehouse by WareHouseId"); //Created an object for Warehouse Business class and is stored in a reference variable WareHouseBusinessLogicLayer wbl = new WareHouseBusinessLogicLayer(); WriteLine("Enter Existing WareHouse ID"); WriteLine("The Warehouse Id should start with WHID and of length 6.It shouldn't contain special characters"); //Reads the WareHouseid string whID = ReadLine(); //Calls the GetWareHouseByWareHouseID of WareHouseBusinessLogic and is stored in Warehouse reference variable WareHouse ware = wbl.GetWareHouseByWareHouseID(whID); // Condition to check whether the WareHouseid exists or not if (ware != null) { check = true; WriteLine("=============== WareHouse Details============="); WriteLine("WareHouseID" + " " + "WareHouseName" + " " + "ManagerName"); WriteLine(ware.WareHouseId + " " + ware.WareHouseName + " " + ware.MangerName); } else { WriteLine("WareHouse doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); }
/// <summary> ///Method to UPDATE WareHouseName /// </summary> public void UpdateWareHouse() { //Created an object for Warehouse Business class and is stored in a reference variable WareHouseBusinessLogicLayer wbl = new WareHouseBusinessLogicLayer(); WriteLine("1. Update WareHouse Name"); WriteLine("2. Update Manager Name"); int Option; bool a; a = int.TryParse(ReadLine(), out Option); if (a == true) { switch (Option) { case 1: UpdateWareHouseName(); break; case 2: UpdateManagerName(); break; default: WriteLine("Enter correct option"); break; } } //Method to UPDATE ManagerName void UpdateWareHouseName() { bool check = false; do { try { WriteLine("You chose to Update the WareHouse Name"); WriteLine("Enter Existing WareHouse ID"); WriteLine("The Warehouse Id should start with WHID and of length 6.It shouldn't contain special characters"); //Reads the WareHouseid and is stored in a reference variable string whID = ReadLine(); //Condition to check whether the warehouse id exists or not WareHouse ware = wbl.GetWareHouseByWareHouseID(whID); if (ware != null) { check = true; WriteLine("Enter new name for WareHouse"); WriteLine("WareHouse Name shouldn'be null or empty.It shouldn't contain special characters also"); //Reads the WareHouseName and is stored in the object ware.WareHouseName = ReadLine(); //Calls the UpdateWareHouseName method of WareHouseBusinessLogic wbl.UpdateWareHouseName(ware); WriteLine("WareHouse Name Updated Sucessfully!!!"); } else { WriteLine("Warehouse id doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } void UpdateManagerName() { bool check = false; do { try { WriteLine("You chose to Update the Manager Name"); WriteLine("Enter Existing WareHouse ID"); WriteLine("The Warehouse Id should start with WHID and of length 6.It shouldn't contain special characters"); //Reads the WareHouseid and is stored in a reference variable string whID = ReadLine(); //Condition to check whether the warehouse id exists or not WareHouse ware = wbl.GetWareHouseByWareHouseID(whID); //Condition to check whether the warehouse id exists or not if (ware != null) { check = true; WriteLine("Enter new name for Manager"); WriteLine("Manager Name shouldn'be null or empty.It shouldn't any contain special characters "); //Reads the MangerName and is stored in the object ware.MangerName = ReadLine(); //Calls the UpdateManagerName method of WareHouseBusinessLogic wbl.UpdateManagerName(ware); WriteLine("Manager Name Updated Sucessfully!!!"); } else { WriteLine("Warehouse id doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } }
//Method to REMOVE WareHouses public void RemoveWareHouse() { // Created an object for WareHouseBusinessLogic class WareHouseBusinessLogicLayer wbl = new WareHouseBusinessLogicLayer(); WriteLine("select on which type you want to remove the WareHouse"); WriteLine("1.on WareHouseId"); WriteLine("2.on WareHouseName"); int Option; bool a; //TryParse returns a bool value a = int.TryParse(ReadLine(), out Option); if (a == true) { switch (Option) { case 1: RemoveWareHouseByID(); break; case 2: RemoveWareHouseByWareHouseName(); break; default: WriteLine("Please Choose enter correct Option"); break; } } else { WriteLine("Please Enter Correct Option"); } //Local Function to REMOVE WareHouse by WareHouseId void RemoveWareHouseByID() { bool check = false; do { WriteLine("You chose to Remove the WareHouse by WareHouseId"); WriteLine("Enter the WarehouseID to be Deleted"); WriteLine("The Warehouse Id should start with WHID and of length 6.It shouldn't contain special characters"); //Reads the WareHouseid and is stored in a reference variable string whID = ReadLine(); try { //Condition to check whether the warehouse id exists or not WareHouse ware = wbl.GetWareHouseByWareHouseID(whID); if (ware != null) { check = true; //Calls the RemoveWareHouseByWareHouseID method of WareHouseBusiness Logic wbl.RemoveWareHouseByWareHouseID(whID); WriteLine("Warehouse Removed Successfully!"); } else { WriteLine("Warehouse id doesn't exist.Please enter existing WareHius"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } //Method to REMOVE WareHouse by WareHouseName void RemoveWareHouseByWareHouseName() { bool check = false; do { try { WriteLine("You chose to Remove the WareHouse by WareHouse Name"); // created the object for Warehouse class WareHouse ware = new WareHouse(); Write("Enter the Warehouse Name:"); WriteLine("Warehouse Name should neither be null nor contain special characters"); //Reads the WareHouseName and is stored in a reference variable string warName = ReadLine(); //Condition to check whether the warehouse Name exists or not if (wbl.GetWareHouseByWareHouseID(ware.WareHouseName) == null) { check = true; //Calls the RemoveWareHouseByWareHouseName method of WareHouseBusiness Logic wbl.RemoveWareHouseByWareHouseName(warName); WriteLine("Warehouse Removed"); } else { WriteLine("Warehouse doesn't exist by this name"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } }