Presentaion, Views, CLI
This commit is contained in:
BIN
Luminous Sales.pptx
Normal file
BIN
Luminous Sales.pptx
Normal file
Binary file not shown.
@@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Display
|
|
||||||
{
|
|
||||||
class InputHandler
|
|
||||||
{
|
|
||||||
public void CommandLineInterface()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Select action");
|
|
||||||
string input = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.Write("> ");
|
|
||||||
input = Console.ReadLine();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
}
|
|
||||||
switch (input)
|
|
||||||
{
|
|
||||||
case "sales": break;
|
|
||||||
case "usermanagment": break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void Sales()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.Write("> ");
|
|
||||||
string input = Console.ReadLine();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -15,10 +15,25 @@ namespace Display
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var uc = new UserController();
|
var uc = new UserController();
|
||||||
User currentUser = uc.ValidatePassword("admin123");
|
Console.Write("Enter password: ");
|
||||||
|
User currentUser = uc.ValidatePassword(Console.ReadLine());
|
||||||
uc = new UserController(currentUser);
|
uc = new UserController(currentUser);
|
||||||
var cv = new CashierView(currentUser);
|
var view = new BaseView(currentUser);
|
||||||
cv.SaleHandle();
|
switch (currentUser.RoleId)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
view = new CashierView(currentUser);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
view = new ManagerView(currentUser);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
view = new AdminView(currentUser);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
view.ActionHandle();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Display.Sales
|
|
||||||
{
|
|
||||||
class Deal
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Display.Sales
|
|
||||||
{
|
|
||||||
class Stock
|
|
||||||
{
|
|
||||||
//public void
|
|
||||||
}
|
|
||||||
}
|
|
@@ -17,7 +17,96 @@ namespace Display.Views
|
|||||||
public override void ShowAvaliableCommands()
|
public override void ShowAvaliableCommands()
|
||||||
{
|
{
|
||||||
base.ShowAvaliableCommands();
|
base.ShowAvaliableCommands();
|
||||||
Console.WriteLine("3. User Managment");
|
Console.WriteLine("4. User Managment");
|
||||||
|
}
|
||||||
|
public override void ActionHandle()
|
||||||
|
{
|
||||||
|
ShowAvaliableCommands();
|
||||||
|
Console.Write("> ");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int input = int.Parse(Console.ReadLine());
|
||||||
|
if (input == 0)
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
else if (input == 1)
|
||||||
|
{
|
||||||
|
SaleHandle();
|
||||||
|
}
|
||||||
|
else if (input == 2)
|
||||||
|
{
|
||||||
|
ManageHandle();
|
||||||
|
}
|
||||||
|
else if (input == 3)
|
||||||
|
{
|
||||||
|
AdminHandle();
|
||||||
|
}
|
||||||
|
else Console.WriteLine("Invalid operation");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void AdminHandle()
|
||||||
|
{
|
||||||
|
bool running = true;
|
||||||
|
while (running)
|
||||||
|
{
|
||||||
|
Console.WriteLine("1. GetAll");
|
||||||
|
Console.WriteLine("2. Get");
|
||||||
|
Console.WriteLine("3. GetByApproximateName");
|
||||||
|
Console.WriteLine("4. RegisterItem");
|
||||||
|
Console.WriteLine("5. UpdateRole");
|
||||||
|
Console.WriteLine("6. UpdateName");
|
||||||
|
Console.WriteLine("7. UpdatePassword");
|
||||||
|
Console.WriteLine("8. Delete");
|
||||||
|
Console.WriteLine("9. Exit");
|
||||||
|
Console.Write("Your choice: ");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int choice = int.Parse(Console.ReadLine());
|
||||||
|
switch (choice)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
GetAllUsers();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Get();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
GetByApproximateName();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
RegisterItem();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
UpdateRole();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
UpdateName();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
UpdatePassword();
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
Delete();
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
running = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Invalid Option!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void GetAllUsers()
|
public void GetAllUsers()
|
||||||
{
|
{
|
||||||
|
@@ -18,18 +18,40 @@ namespace Display.Views
|
|||||||
}
|
}
|
||||||
public virtual void ShowAvaliableCommands()
|
public virtual void ShowAvaliableCommands()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("0. Exit");
|
||||||
Console.WriteLine("1. Sales");
|
Console.WriteLine("1. Sales");
|
||||||
}
|
}
|
||||||
|
public virtual void ActionHandle()
|
||||||
|
{
|
||||||
|
ShowAvaliableCommands();
|
||||||
|
Console.Write("> ");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int input = int.Parse(Console.ReadLine());
|
||||||
|
if (input == 0)
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
else if (input == 1)
|
||||||
|
{
|
||||||
|
SaleHandle();
|
||||||
|
}
|
||||||
|
else Console.WriteLine("Invalid operation");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void SaleHandle()
|
public void SaleHandle()
|
||||||
{
|
{
|
||||||
Deal deal = new Deal();
|
bool running = true;
|
||||||
Product product = new Product();
|
while (running)
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("1. Search");
|
Console.WriteLine("1. Search");
|
||||||
Console.WriteLine("2. Sale");
|
Console.WriteLine("2. Sale");
|
||||||
Console.WriteLine("3. Exit");
|
Console.WriteLine("3. Exit");
|
||||||
Console.Write("Your Choice: ");
|
Console.Write("Your choice: ");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int choice = int.Parse(Console.ReadLine());
|
int choice = int.Parse(Console.ReadLine());
|
||||||
@@ -42,7 +64,7 @@ namespace Display.Views
|
|||||||
SaleItem();
|
SaleItem();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
Environment.Exit(0);
|
running = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Invalid Option!");
|
Console.WriteLine("Invalid Option!");
|
||||||
|
@@ -20,6 +20,79 @@ namespace Display.Views
|
|||||||
base.ShowAvaliableCommands();
|
base.ShowAvaliableCommands();
|
||||||
Console.WriteLine("2. Stock");
|
Console.WriteLine("2. Stock");
|
||||||
}
|
}
|
||||||
|
public override void ActionHandle()
|
||||||
|
{
|
||||||
|
ShowAvaliableCommands();
|
||||||
|
Console.Write("> ");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int input = int.Parse(Console.ReadLine());
|
||||||
|
if (input == 0)
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
else if (input == 1)
|
||||||
|
{
|
||||||
|
SaleHandle();
|
||||||
|
}
|
||||||
|
else if (input == 2)
|
||||||
|
{
|
||||||
|
ManageHandle();
|
||||||
|
}
|
||||||
|
else Console.WriteLine("Invalid operation");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void ManageHandle()
|
||||||
|
{
|
||||||
|
bool running = true;
|
||||||
|
while (running)
|
||||||
|
{
|
||||||
|
Console.WriteLine("1. GetAll");
|
||||||
|
Console.WriteLine("2. Get");
|
||||||
|
Console.WriteLine("3. GetByTime");
|
||||||
|
Console.WriteLine("4. Add");
|
||||||
|
Console.WriteLine("5. Delete");
|
||||||
|
Console.WriteLine("6. Exit");
|
||||||
|
Console.Write("Your choice: ");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int choice = int.Parse(Console.ReadLine());
|
||||||
|
switch (choice)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
GetAll();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Get();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
GetByTime();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Add();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
Delete();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
running = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("Invalid Option!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public void GetAll()
|
public void GetAll()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -39,13 +112,13 @@ namespace Display.Views
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Get(int id)
|
public void Get()
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Enter stock id...");
|
Console.Write("Enter stock id: ");
|
||||||
id = int.Parse(Console.ReadLine());
|
int id = int.Parse(Console.ReadLine());
|
||||||
stockctrl.Get(id);
|
stockctrl.Get(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -74,16 +147,24 @@ namespace Display.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(int productId, double amount)
|
public void Add()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Adding stock by product id...");
|
Console.WriteLine("Adding stock by product id...");
|
||||||
Console.WriteLine("Enter product id: ");
|
Console.Write("Enter product ID or name: ");
|
||||||
productId = int.Parse(Console.ReadLine());
|
string product = Console.ReadLine();
|
||||||
Console.WriteLine("Enter stock amount:");
|
Console.Write("Enter stock amount:");
|
||||||
amount = double.Parse(Console.ReadLine());
|
double amount = double.Parse(Console.ReadLine());
|
||||||
stockctrl.Add(productId, amount);
|
bool result = int.TryParse(product, out int productId);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
stockctrl.Add(productId, amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stockctrl.Add(product, amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -92,30 +173,13 @@ namespace Display.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(string productName, double amount)
|
public void Delete()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Adding stock by product name...");
|
Console.WriteLine("Deleting stock...");
|
||||||
Console.WriteLine("Enter product name: ");
|
Console.Write("Enter deal id: ");
|
||||||
productName = Console.ReadLine();
|
int id = int.Parse(Console.ReadLine());
|
||||||
amount = double.Parse(Console.ReadLine());
|
|
||||||
stockctrl.Add(productName, amount);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Delete(int id)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.WriteLine("Deleting stock");
|
|
||||||
Console.WriteLine("Enter deal id: ");
|
|
||||||
id = int.Parse(Console.ReadLine());
|
|
||||||
dealctrl.Delete(id);
|
dealctrl.Delete(id);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
Reference in New Issue
Block a user