/// <summary> /// Method to GET WareHouseAddress details by WareHouseId /// </summary> public void GetAddressByWareHouseID() { bool check = false; do { try { WriteLine("You chose to Get the Address details byWareHouseId"); //Created an object for WarehouseAddress Business class and is stored in a reference variable WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); WriteLine("Enter the 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 warehouseid = ReadLine(); //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer WareHouseAddress add = wabl.GetAddressByWareHouseID(warehouseid); //Condition to check whether the address id exists or not if (add != null) { check = true; WriteLine("WareHouseID" + " " + "AddressID" + " " + "Door Number" + " " + "LocationName" + " " + "State" + " " + "Pincode"); WriteLine(add.WareHouseId + " " + add.AddressId + " " + add.DoorNumber + " " + add.LocationName + " " + add.State + " " + add.Pincode); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); }
/// <summary> /// Method to check whether AddressId exists or not /// </summary> /// <param name="id"></param> /// <returns></returns> public bool CheckAddressId(string id) { WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); bool result = wabl.CheckAddressId(id); // Condition to check whether AddressId exists or not if (result == true) { WriteLine("Address Exists"); return(result); } return(result); }
/// <summary> /// Method to GET the address details /// </summary> public void GetAddresses() { WriteLine("You chose to Get all the Addresses"); //Created an object for WareHouseAddressBusinessLogicLayer and is stored in the reference variable WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); //Calls the GetAddresses method of WareHouseAddressBusinessLogicLayer List <WareHouseAddress> addressList = wabl.GetAddresses(); WriteLine("=============== WareHouse Details============="); WriteLine("WareHouseID" + " " + "AddressID" + " " + "Door Number" + " " + "LocationName" + " " + "State" + " " + "Pincode"); WriteLine("-----------------------------------------------------------------------"); foreach (WareHouseAddress item in addressList) { WriteLine(item.WareHouseId + " " + item.AddressId + " " + item.DoorNumber + " " + item.LocationName + " " + item.State + " " + item.Pincode); } }
//Method to GET WareHouseAddress details by LocationName public void GetAddressByLocationName() { bool check = false; do { try { WriteLine("You chose to Get Address by Location Name"); WriteLine("Enter the locationName"); WriteLine("The Location Name should neither be null nor empty.It shouldn't contain any special characters"); //Reads the location name and is stored in a reference variable string locationName = ReadLine(); //Created an object for WarehouseAddress Business class and is stored in a reference variable WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer List <WareHouseAddress> addressList = wabl.GetAddressByLocationName(locationName); //Condition to check whether the address id exists or not if (addressList != null) { check = true; foreach (WareHouseAddress item in addressList) { WriteLine(item.WareHouseId + " " + item.AddressId + " " + item.DoorNumber + " " + item.LocationName + " " + item.State + " " + item.Pincode);// Displaying the products } } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); }
/// <summary> /// Method to REMOVE an address of the Warehouse /// </summary> public void RemoveWareHouseAddress() { WareHouseAddress w = new WareHouseAddress(); // creating the object for Warehouse class WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); // Creating thhe object for WareHouseBusinessLogic class WriteLine("select on which type you want to remove the WareHouse Address"); WriteLine("1.on WareHouseId"); WriteLine("2.on AddressId"); int Option; bool a; a = int.TryParse(ReadLine(), out Option); if (a == true) { switch (Option) { case 1: RemoveAddressByWareHouseID(); break; case 2: RemoveAddressByAddressID(); break; default: WriteLine("Please Choose enter correct Option"); break; } } else { WriteLine("Please Enter Correct Option"); } //Local function to REMOVE an address of the Warehouse by wareHouseID void RemoveAddressByWareHouseID() { bool check = false; do { WriteLine("You chose to Remove the Address by WareHouseId"); Write("Enter the WarehouseID of the Address 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 { WareHouseAddress addr = wabl.GetAddressByWareHouseID(whID); // Condition to check whether WarHouseId exists or not if (addr != null) { check = true; //Calls the RemoveAddressByWareHouseID method of WareHouseAddressBusinessLogicLayer wabl.RemoveAddressByWareHouseID(whID); WriteLine("Warehouse Removed"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } //Local function to REMOVE an address of the Warehouse by addressID void RemoveAddressByAddressID() { bool check = false; do { WriteLine("You chose to Remove the Address by AddressId"); Write("Enter the AddressId to be Deleted:"); WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters"); //Reads the entered AddressId string addressId = ReadLine(); try { WareHouseAddress addr = wabl.GetAddressByAddressID(addressId); // Condition to check whether AddressId exists or not if (addr != null) { check = true; //Calls the RemoveAddressByAddressID method of WareHouseAddressBusinessLogicLayer wabl.RemoveAddressByAddressID(addressId); WriteLine("Warehouse Removed"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } }
/// <summary> /// Method to UPDATE the details of WareHouse Address /// </summary> public void UpdateWareHouseAddress() { //Created an object for WareHouseAddress Business class and stored it in a reference variable WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); WriteLine("1. Update Door Number "); WriteLine("2. Update Location Name"); WriteLine("3. Update State"); WriteLine("4. Update Pincode"); int Option; bool a; a = int.TryParse(ReadLine(), out Option); if (a == true) { switch (Option) { case 1: UpdateDoorNumber(); break; case 2: UpdateLocationName(); break; case 3: UpdateState(); break; case 4: UpdatePincode(); break; default: WriteLine("Enter correct option"); break; } } //Local Function to UPDATE Door Number of WareHouse void UpdateDoorNumber() { bool check = false; do { try { WriteLine("You chose to Update the Door Number of a WareHouse Address"); WriteLine("Enter Existing Address ID"); WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters"); //Reads the AddressId and is stored in a reference variable string adId = ReadLine(); //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer WareHouseAddress wadd = wabl.GetAddressByAddressID(adId); //Condition to check whether AddressId is null or not if (wadd != null) { check = true; WriteLine("Enter the new Door Number for the WareHouse"); WriteLine("Door Number shouldn't be null or empty"); //Reads the DoorNumber and is stored in reference variable wadd.DoorNumber = ReadLine(); //Calls the UpdateDoorNumber method of WareHouseAddressBusiess Logic wabl.UpdateDoorNumber(wadd); WriteLine("Door Number Updated Sucessfully!!!"); } else { WriteLine("Address id doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } //Local Function to UPDATE the Location Name of WareHouse void UpdateLocationName() { bool check = false; do { try { WriteLine("You chose to Update the LocationName of a WareHouse Address"); WriteLine("Enter Existing Address ID"); WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters"); //Reads the AddressId and is stored in a reference variable string adId = ReadLine(); //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer WareHouseAddress wadd = wabl.GetAddressByAddressID(adId); //Condition to check whether AddressId is null or not if (wadd != null) { check = true; WriteLine("Enter the new Location Name for the WareHouse"); WriteLine("Location name shouldn't be null or empty and special characters are not allowed "); //Reads the LocationName and is stored in reference variable wadd.LocationName = ReadLine(); //Calls the UpdateLocationName method of WareHouseAddressBusiess Logic wabl.UpdateLocationName(wadd); WriteLine("Door Number Updated Sucessfully!!!"); } else { WriteLine("Address id doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } //Local Function to UPDATE the State of WareHouse void UpdateState() { bool check = false; do { try { WriteLine("You chose to Update the State of a WareHouse Address"); WriteLine("Enter Existing Address ID"); WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters"); //Reads the AddressId and is stored in a reference variable string adId = ReadLine(); //Calls the GetAddressByAddressID method of WareHouseAddressBusinessLogicLayer WareHouseAddress wadd = wabl.GetAddressByAddressID(adId); //Condition to check whether AddressId is null or not if (wadd != null) { check = true; WriteLine("Enter the new State for the WareHouse"); WriteLine("State shouldn't be null or empty and special characters are not allowed "); //Reads the State and is stored in an reference variable wadd.State = ReadLine(); //Calls the UpdateState method of WareHouseAddressBusinessLogicLayer wabl.UpdateState(wadd); WriteLine("Door Number Updated Sucessfully!!!"); } else { WriteLine("Address id doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } //Local Function to UPDATE the Pincode of WareHouse void UpdatePincode() { bool check = false; do { try { WriteLine("You chose to Update the Pincode of a WareHouse Address"); WriteLine("Enter Existing Address ID"); WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters"); //Reads the AddressId and is stored in a reference variable string adId = ReadLine(); //Calls the GetAddressByAddressID method of WareHouseAddressBusinessLogicLayer WareHouseAddress wadd = wabl.GetAddressByAddressID(adId); //Condition to check whether AddressId is null or not if (wadd != null) { check = true; WriteLine("Enter the new Pincode for the WareHouse"); WriteLine("Numeric values with length 6 are only allowed"); //Reads the Pincode and is stored in a reference variable wadd.Pincode = ReadLine(); //Calls the UpdatePincode method of WareHouseAddressBusinessLogicLayer wabl.UpdatePincode(wadd); WriteLine("Door Number Updated Sucessfully!!!"); } else { WriteLine("Address id doesn't exist"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); } }
/// <summary> ///Method to ADD Address details to the list /// </summary> public void AddAddress() { bool check = false; do { try { WriteLine("You chose to Add the Address to a WareHouse"); //Created an object for WareHouseAddress class and stored it in a reference variable WareHouseAddress address = new WareHouseAddress(); //Created an object for WareHouseAddress Business class and stored it in a reference variable WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); WriteLine("You chose to add address to the WareHouse"); WriteLine("Enter Existing WareHouseId"); 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 the WareHouseAddress object address.WareHouseId = ReadLine(); //Condition to check whether WareHouseid exists or not if (CheckWareHouseId(address.WareHouseId) == true) { //Condition to check whether Addressid exists or not if (CheckAddressId(address.AddressId) == false) { check = true; WriteLine("Enter Address id"); WriteLine("Addressid must be of length 6 and should contain only alphanumeric values"); //Reads the AddressId and is stored in the WareHouseAddress object address.AddressId = ReadLine(); WriteLine("Enter Door Number"); WriteLine("Door Number shouldn't be null or empty"); //Reads the DoorNumber and is stored in the WareHouseAddress object address.DoorNumber = ReadLine(); WriteLine("Enter Location Name"); WriteLine("Location Name shouldn't be null and should contain alphabets"); //Reads the LocationName and is stored in the WareHouseAddress object address.LocationName = ReadLine(); WriteLine("Enter State"); WriteLine("State shouldn't be null and should contain alphabets"); //Reads the State and is stored in the WareHouseAddress object address.State = ReadLine(); WriteLine("Enter the Pincode"); WriteLine("Pincode must be numeric and length should be exactly 6"); //Reads the Pincode and is stored in the WareHouseAddress object address.Pincode = ReadLine(); //Calls the AddAddress method of WareHouseAddressBusinessLogic wabl.AddAddress(address); WriteLine("Address added successfully"); } else { WriteLine("Address id exists already"); } } else { WriteLine("WareHouse id doesn't exist or is invalid"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); }