-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgramOop.cs
120 lines (112 loc) · 3.82 KB
/
ProgramOop.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Collections.Generic;
namespace ManajemenKasirMccRanur
{
public class ProgramOop
{
private static string[] listMenu = new string[3] { "Input Produk", "Jual Produk", "Exit" };
public static Display print = new Display(60, "left", "space");
static void Main(string[] args)
{
bool state = true;
do
{
state = ShowMenu("EASY SHOP CHASIER APP");
} while (state);
}
private static bool ShowMenu(string title)
{
bool state = true;
int index = 0;
String decodeStringMenu = "";
print.Header(title);
print.Content($" MENU: ");
foreach (String i in listMenu)
{
index++;
decodeStringMenu += $" ({index}) {i}|";
print.Content($" [{index}.] {i}");
}
print.Content($"|Pres Key 1 -{index} to select Menu | press Q for Exit Sessions");
print.Box("");
state = SelectMenu("Select Number Menu :");
print.Footer("");
return state;
}
/*
ThreadStaticAttribute is funtions for select menu options its was show front of
you can select with numbering format
*/
public static bool SelectMenu(string v)
{
bool rentry = false;
int limite = 0;
String i = "";
do
{
try
{
Console.Write(v);
String options = Console.ReadLine();
if (options.ToLower() == "q")
{
print.Content("Process was stoped");
return false;
}
else
{
switch (Convert.ToInt32(options))
{
case 1:
i = listMenu[0];
limite = AskingLimitInput($"Entry {i} Range : ");
new ProgramInput(0,limite);
break;
case 2:
i = listMenu[1];
limite = AskingLimitInput($"Entry {i} Range : ");
new ProgramInput(1, limite);
break;
default:
return false;
break;
}
}
rentry = false;
}
catch (Exception e)
{
Console.WriteLine("\t\t ! ~Erros Messages " + e.Message);
rentry = true;
}
} while (rentry);
return true;
}
private static int AskingLimitInput(String v)
{
bool rentry = false;
int limit = 0;
do
{
try
{
Console.Write(v);
limit = Convert.ToInt32(Console.ReadLine());
if (limit < 1) {
rentry = true;
Console.WriteLine($"\t\t ! range it's more then {limit} ");
}
else {
rentry = false;
}
}
catch (FormatException e)
{
Console.WriteLine("\t\t ! ~Erros Messages " + e.Message);
rentry = true;
}
} while (rentry);
return limit;
}
}
}