Craft management dotnet ict
1.0 Introduction
1.1 Purpose of this document
Craft Management is used to insert shipping details to database, get shipping details by shipping id from database and calculate the shipping charges of products based on the weight, distance and priority. They get shipping details initially and calculate the shipping charges based on the logic.
Craft Management current focus is to automate the below mentioned requirements.
1. Insert the Shipping Details.
2. Display the shipping details on the shipping id from the database.
3. Calculate shipping charges based on weight, distance and priority.
1.2 Definitions & Acronyms
Definition / Acronym Description
Req Requirement
1.3 Project Overview
This project captures the various concepts, techniques and skills learnt and helps to put them into practice using C# with ADO.NET. Admittedly, this would be at a scaled-down level since the purpose is to let the associate experience the various concepts learned in C# as an individual. The individual associate is expected to create a console-based application within the specified time.
1.4 Scope
The scope of the system is explained through its following modules
1. Insert the Shipping Details.
2. Display the shipping details on the shipping id from the database.
3. Calculate shipping charges based on weight, distance and priority.
1.5 Target Audience Learner Level
1.6 Software Requirement
1.6.1 Software Requirements
# Item Specification/Version
1. C# 6
2. ADO.NET 4.5
3 ORACLE SERVER 18C
Note: All the required hardware and software will be provided in the Tekstac platform.
2.0 Functional Requirements
2.1 Functional Requirements
Req. # 1
Req. Name Get the shipping details from the user. Insert the
details to the database.
Req. Description The shipping details are entered through the Main
method. Assign the values to the ShippingDetails
object. Insert the details to the Shipping table in the
database.
Actors/
Users Admin
Comments The admin is responsible for inserting the data.
Req. # 2
Req. Name Get the shipping id from the user and display all the
details of that shipping id.
Req.
Description The shipping id is entered through main method. Pass the value to the method.
Actors/
Users Admin
Comments The admin is responsible for fetching the details
from the database.
Req. # 3
Req. Name Calculate shipping charges based on weight, distance and priority.
Req.
Description The user enter the weight, distance and priority. It
will calculate the total charges.
Actors/
Users User
Comments The user is responsible for calculating the shipping
charges.
2.2 Use case Diagram
2.3 System Architecture Diagram
2.4 Sample Input/Output
1. Add shipping details
2. Get shipping details by shipping id 3.Calculate shipping charges
4.Exit
Enter your choice
1
Enter shipping id
7
Enter start location
Lucknow
Enter end location
Bangalore Enter distance 6000
Enter start date
2021-01-12
Enter delivery date
2021-01-16
Enter priority
Medium
Details Added Successfully 1.Add shipping details
2. Get shipping details by shipping id 3.Calculate shipping charges
4.Exit
Enter your choice
2
Enter shipping id
7
ShippingId StartLocation EndLocation Distance StartDate DeliveryDate Priority
7 Lucknow Bangalore 6000 2021-01-12 2021-01-16 Medium
1. Add shipping details
2. Get shipping details by shipping id
3.Calculate shipping charges
4.Exit
Enter your choice
3
Enter weight
120
Enter distance
250
Enter priority
High
Shipping charges: 1200
3.0 Design Specification
3.1 Data Design
Table Structure:
Table name: Shipping
Column Name Data type
ShippingId NUMBER(Primary Key)
StartLocation VARCHAR2(100)
EndLocation VARCHAR2(100)
Distance NUMBER
StartDate Date
DeliveryDate Date
Priority VARCHAR2(100)
Design Constraints:
• Use ORACLE SERVER database to store the data. The database name is “Shipping”. This is already created for you in Tekstac.
• The table name and the column names should be the same as specified in the table structure.
• Connection string is given in DBConnection.cs, Should use the 'connStr' static variable for DB connections, which is also provided as part of code skeleton. THIS IS GIVEN ONLY FOR YOUR REFERENCE. You need NOT change this.
Sample Data is Already inserted in the Shipping table.
ShippingId StartLocation EndLocation Distance StartDate DeliveryDate Priority
1 Delhi Chennai 5000 2021-01-30 2021-02-02 High
2 Lucknow Bangalore 6000 2021-01-12 2021-01-16 Medium
3 Bangalore Kolkata 5500 2021-02-15 2021-02-20 High
4 Chennai Mumbai 1500 2021-02-19 2021-02-25 High
5 Punjab Haryana 200 2021-02-19 2021-02-20 Low
Note: The code skeleton will be available in the Tekstac platform
3.2 Component Details for identified Use Cases
3.2.1 Get data and insert into the database. In the ‘Main’ get the following values,
3.2.2 Get Shipping Id and Retrieve Details from database.
The User enters the Shipping id then it should get details of the Shipping product that matches the shipping id and return shipping details as an object
Example: If shipping Id is 1 then it shouldretrieve,
ShippingId StartLocation EndLocation Distance StartDate DeliveryDate Priority
1 Delhi Chennai 5000 2021-01-30 2021-02-02 High
3.2.3 Calculate Shipping Charges
The User enters the weight, distance and priority and the method should calculate the shipping charges and return it.
Weight Distance Charges
Weight <=50 Distance <=100
Distance >100and
Distance
<=350
Distance >350 200
400
700
Weight > 50 and Weight
<=100 Distance <=100
Distance >100and
Distance
<=350
Distance >350 300
600
1050
Weight > 100 and
Weight
<=500 Distance <=100
Distance >100and
Distance
<=350
Distance >350 500
1000
1750
Weight > 500 Distance <=100
Distance >100and
Distance
<=350
Distance >350 600
1200
2100
If Priority is High then add 20% to the charges
If Priority is Medium then add 10% to the charges
If Priority is Low there is no extra charges
Example: Weight = 50,Distance = 100 and Priority
= MediumShipping Charges = 200 + 10% extra charges Shipping Charges = 220
Example: Weight = 500,Distance = 1000 and Priority = Low
Shipping Charges = 1750 + No extra charges Shipping Charges = 1750
time.
3.3 Component Specification
Class Name : ShippingDetails(model class) Responsibility:
This model object holds the state of the Shipping detail at all point-in-
Type(Class)
Properties
ShippingDetails int ShippingId String StartLocation String EndLocation
int Distance
DateTime StartDate
DateTime DeliveryDate
String Priority
Note: Keep all the properties ‘public’.
Class Name : ShippingUtility (utility class)
3.3.1 InsertShippingDetails Method
Type(Class) Method Responsibilities
ShippingUtility public void InsertShippingDetails
(ShippingDetails shippingdetailsobj) This method should accept the ShippingDetails object and execute an Oracle query to insert the details into the database.
While writing the insert query, use TO_DATE to insert the date.
Example :
TO_DATE('2021-01-30','yyyy-mm-dd') – the date should be in this format
3.3.2 GetShippingDetailsByShippingId Method
Type(Class) Method Responsibilities
ShippingUtility public ShippingDetails GetShippingDetailsByShipp ingId(int shippingId) This method should get the shipping details of the shipping id passed as an argument that is in the database. Then return the details as ShippingDetails object.
3.3.3 CalculateShippingCharges Method
Type(Class) Method Responsibilities
ShippingUtility public double CalculateShippingCharges
(int weight,int distance,String priority) This method is used to calculate the shipping charges based on the weight, distance and priority.
Class Name : DBHandler (DAO class)
3.0.1 GetConnection Method
Responsibility:
This method should connect to the database by reading the database details from the
DBConnection.cs file and it should return the connection object.
Type(Class) Method Resources
DBHandler public OracleConnection GetConnection() DBConnection.cs file contains the database connection details.
3.1 General Design Constraints
1. The properties/method/class name should be correctly specified as given in the document.
2. Keep all the classes, methods and properties as ‘public’
3. Do not change the DBConnection.cs file.
4. Do not change the namespace name.
4.0 Submission
4.1 Code submission instructions
1. Do not change the code skeleton given as your code will be auto evaluated.
2. You can validate your solution against sample test cases during the assessment duration.
3. Your last submitted solution will be considered for detailed evaluation.
4. Make sure to submit the solution before the time limit. After the assessment duration you will not be allowed to submit the solution.
5.0 Change Log
Changes Made
V1.0.0 Initial baseline created on <dd-Mon-yy> by <Name of Author>
Vx.y.z <Please refer the configuration control tool / change item status form if the details of changes are maintained separately. If not, the template given below needs to be followed>
Section No. Changed By Effective Date Changes Effected
6.0 Evaluation Areas
S.No Description
1. Declaration of properties in the class ShippingDetails
2. Declaration of methods in the class DBHandler and ShippingUtility
3. Implementation to create a valid database connection object
4. Implementation to insert Shipping details to database
5. Implementation to retrieve a specific shippingdetails from database
6. Calculate the shipping charges based on the given business rules.
Solution:
Program.cs
Using System;
using System.Collections.Generic; using Oracle.ManagedDataAccess.Client; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ADO_Net_App1 //DO NOT change the namespace name { public class Program //DO NOT change the class name { public static void Main(string[] args) //DO NOT change the 'Main' method signature { //Implement code here bool flag = true; while(flag) { int option; Console.WriteLine("1.Add shipping details"); Console.WriteLine("2.Get shipping details by shipping id"); Console.WriteLine("3.Calculate shipping charges"); Console.WriteLine("4.Exit"); option = Convert.ToInt32(Console.ReadLine()); if(option == 1){ Console.WriteLine("Enter shipping id"); int id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter start location"); string slocation = Console.ReadLine(); Console.WriteLine("Enter end location"); string elocation = Console.ReadLine(); Console.WriteLine("Enter distance"); int distance = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter start date"); DateTime sdate = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", null); Console.WriteLine("Enter end date"); DateTime ddate = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", null); Console.WriteLine("Enter priority"); string priority = Console.ReadLine(); ShippingDetails obj = new ShippingDetails(id,slocation,elocation,distance,sdate,ddate,priority); ShippingUtility suObj = new ShippingUtility(); suObj.InsertShippingDetails(obj); } else if(option == 2){ ShippingUtility suObj = new ShippingUtility(); ShippingDetails obj = new ShippingDetails(); Console.WriteLine("Enter shipping id"); int id = Convert.ToInt32(Console.ReadLine()); obj = suObj.GetShippingDetailsByShippingId(id); Console.WriteLine("ShippingId\tStartLocation\tEndLocation\tDistance\tStartDate\tDeliveryDate\tPriority"); Console.WriteLine(obj.ShippingId+"\t"+obj.StartLocation+"\t"+obj.EndLocation+"\t"+obj.Distance+"\t"+obj.StartDate+"\t"+obj.DeliveryDate+"\t"+obj.Priority); } else if(option == 3){ Console.WriteLine("Enter weight"); int weight = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter distance"); int distance = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter priority"); string priority = Console.ReadLine(); ShippingUtility suObj = new ShippingUtility(); double charges = suObj.CalculateShippingCharges(weight, distance, priority); Console.WriteLine("Shipping charges : "+charges); }else{ flag = false; } } } } } --------------------------------------------------------------------------------- DBHandler.cs ................................................................... using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Oracle.ManagedDataAccess.Client; using System.Configuration;namespace ADO_Net_App1 //DO NOT change the namespace name { public class DBHandler //DO NOT change the class name { //Implement the methods as per the description public DBHandler() { } public OracleConnection GetConnection() { OracleConnection con = null; String Connection = DBConnection.connStr; con = new OracleConnection(Connection); return con; } } } --------------------------------------------------------------------------------- shipping utility --------------------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Oracle.ManagedDataAccess.Client; namespace ADO_Net_App1//DO NOT change the namespace name { public class ShippingUtility //DO NOT change the class name { //Implement code here public OracleConnection sqlcon { get; set; } public void InsertShippingDetails(ShippingDetails shippingdetailsobj) { sqlcon.Open(); string query = "Insert into shipping(ShippingId,StartLocation,EndLocation,Distance,StartDate,DeliveryDate,Priority) values(@id,@slocation,@elocation,@distance,@sdate,@ddate,@priority)"; OracleCommand cmd = new OracleCommand(query,sqlcon); cmd.Parameters.Add("@id",shippingdetailsobj.ShippingId); cmd.Parameters.Add("@slocation",shippingdetailsobj.StartLocation); cmd.Parameters.Add("@elocation",shippingdetailsobj.EndLocation); cmd.Parameters.Add("@distance",shippingdetailsobj.Distance); cmd.Parameters.Add("@sdate",shippingdetailsobj.StartDate); cmd.Parameters.Add("@ddate",shippingdetailsobj.DeliveryDate); cmd.Parameters.Add("@priority",shippingdetailsobj.Priority); int i = cmd.ExecuteNonQuery(); if(i>0){ Console.WriteLine("Details Added Successfully"); } sqlcon.Close(); } public ShippingDetails GetShippingDetailsByShippingId(int shippingId) { ShippingDetails obj = new ShippingDetails(); sqlcon.Open(); string query = "Select * from Shipping where ShippingId = "+shippingId+";"; OracleCommand cmd = new OracleCommand(query,sqlcon); OracleDataReader reader = cmd.ExecuteReader(); while(reader.Read()) { obj.ShippingId = (int)reader[0]; obj.StartLocation = reader[1].ToString(); obj.EndLocation = reader[2].ToString(); obj.Distance = (int)reader[3]; obj.StartDate = Convert.ToDateTime(reader[4].ToString()); obj.DeliveryDate = Convert.ToDateTime(reader[5].ToString()); obj.Priority = reader[6].ToString(); } sqlcon.Close(); return obj; } public double CalculateShippingCharges(int weight, int distance, string priority) { double charges = 0; double percentage = 0; if(priority.Equals("high")) percentage = 0.2; else if(priority.Equals("medium")) percentage = 0.1; else percentage = 0; if(weight <= 50){ if(distance <= 100){ charges = 200 + 200*percentage; }else if(distance > 100 && distance <= 350){ charges = 400 + 400*percentage; }else{ charges = 700 + 700*percentage; } } else if(weight > 50 && weight <= 100){ if(distance <= 100){ charges = 300 + 300*percentage; }else if(distance > 100 && distance <= 350){ charges = 600 + 600*percentage; }else{ charges = 1050 + 1050*percentage; } } else if(weight > 100 && weight <= 500){ if(distance <= 100){ charges = 500 + 500*percentage; }else if(distance > 100 && distance <= 350){ charges = 1000 + 1000*percentage; }else{ charges = 1750 + 1750*percentage; } } else{ if(distance <= 100){ charges = 600 + 600*percentage; }else if(distance > 100 && distance <= 350){ charges = 1200 + 1200*percentage; }else{ charges = 2100 + 2100*percentage; } } return charges; } } } ----------------------------------------------------------------------------------------- ShippingDetails.cs ................................ using System; using System.Collections.Generic; using Oracle.ManagedDataAccess.Client; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ADO_Net_App1//DO NOT change the namespace name { public class ShippingDetails //DO NOT change the class name { //Implement code here public int ShippingId { get; set; } public string StartLocation { get; set; } public string EndLocation { get; set; } public int Distance { get; set; } public DateTime StartDate { get; set; } public DateTime DeliveryDate { get; set; } public string Priority { get; set; } public ShippingDetails(){} public ShippingDetails(int id, string sLocation, string eLocation, int distance, DateTime sdate, DateTime ddate, string priority) { this.ShippingId = id; this.StartLocation = sLocation; this.EndLocation = eLocation; this.Distance = distance; this.StartDate = sdate; this.DeliveryDate = ddate; this.Priority = priority; } } } ......................................... DBConnection.cs //This is for your reference. DO NOT make any changes. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ADO_Net_App1 { public class DBConnection { public static String connStr = "User Id=admin;Password=admin;Data Source=localhost:1521/XE;"; } }
Comments
Post a Comment