Nazariy qism:
Mabil aloqa kompaniyalarida mijozlarga xizmat ko’rsatish qudagi turlardan iborat
1.Tariflar bilan ishlash, qulay tariflarni tanlash, tariflar qo’shish va tariflarni o’chirish
mumkin.
2. Internet paketlarini tanlash va ularga o’zgartirishlar kiritish.
100
3.Administrator bo’limini yaratish(1 - rasm).
1-rasm. Form oynasi
16 – Tajriba ishida biz administrator bo’limini shakillantiramiz.
Administrator bo’limida quidagi imkoniyatlar mavjud.
1.Tariflar bo’limida operator xuquqlarini shakillantirish.
2.Internet paketlar bo’limida operator xuquqlarini shakillantirish.
3.Administrator bo’limidagi login va parolni o’zgartirish.
Administrator bo’limi quidagi ko’rinishda bo’ladi.
Administrator bo’limida sozlash tugmasi mavjud.
Sozlash tugmasida login va parolni o’zgartirish uchun yangi form yaratiladi.
101
Bu formda fayllar bilan ishlash bajariladi.
Faylni yaratish va unga dastlabki login va parolni joylashtirish.
Fayldan o’qish kodi:
String ^ a , ^ b;
string X , Y ;
ifstream in("parol.txt");
in >> X >> Y;
a = textBox1 -> Text;
b = textBox2 -> Text;
x = gcnew String (X.c_str());
y = gcnew String (Y.c_str());
Faylga yozish kodi:
ofstream out("parol.txt");
string s = msclr::interop::marshal_as(a);
string ss = msclr::interop::marshal_as(b);
out << s << "\n" << ss;
out.close();
this -> Hide();
Sozlash formi ilovasi qudagicha;
#include
"stdafx.h"
102
#include
"iostream"
#include
"fstream"
#include
"stdio.h"
#include
"string"
#include
"msclr\marshal_cppstd.h"
;
using
namespace
std;
using
namespace
msclr::interop;
#pragma
endregion
int
k ;
String
^ p , ^ l,^ x,^y;
private
: System::
Void
button1_Click(System::
Object
^
sender
, System::
EventArgs
^
e
)
{
String
^ a , ^ b;
string
X , Y ;
ifstream
in(
"parol.txt"
);
in >> X >> Y;
a = textBox1 -> Text;
b = textBox2 -> Text;
x =
gcnew
String
(X.c_str());
y =
gcnew
String
(Y.c_str());
if
(k == 0)
{
if
(a == x && b == y)
{
label1->Text =
"Yangi login va parolni kiritig "
;
textBox1->Text =
""
;
textBox2->Text=
""
;
k ++;
}
else
{
103
MessageBox
::Show(
"login yoki parol xato kiritildi"
);
}
}
else
if
(k == 1)
{
if
(a !=
""
&& b !=
""
)
{
l = a;
p = b;
label1->Text=
"login va parolni qaytadan kiriting"
;
textBox1->Text=
""
;
textBox2->Text=
""
;
k ++;
}
else
{
MessageBox
::Show(
"Iltimos jadvalni to'ldiring"
);
}
}
else
if
(k == 2)
{
if
(a == l && b == p)
{
MessageBox
::Show(
"Login va Parol yangilandi !"
);
ofstream
out(
"parol.txt"
);
string
s = msclr::interop::marshal_as<
string
>(a);
string
ss = msclr::interop::marshal_as<
string
>(b);
out << s <<
"\n"
<< ss;
out.close();
this
-> Hide();
}
104
else
{
MessageBox
::Show(
"Login yoki parol xato kiritildi !"
);
}
}
}
private
: System::
Void
Sozlash_Load(System::
Object
^
sender
, System::
EventArgs
^
e
)
{
k = 0;
p =
""
, l =
""
;
}
Tajriba ishi №17
Mavzu: Mini loyihalar yaratish: dastur tuzish
Ishni bajarishdan maqsad: Visual Studio 2012 muhitida C++ dasturlash tilida
mobil aloqa kompaniyalari mijozlariga hizmat ko’rsatish dasturini yaratish .
Nazariy qism:
Mabil aloqa kompaniyalarida mijozlarga xizmat ko’rsatish qudagi turlardan iborat
1.Tariflar bilan ishlash , qulay tariflarni tanlash , tariflar qo’shish va tariflarni
o’chirsh mumkin.
2. Internet paketlarini tanlash va ularga o’zgartirishlar kiritish.
3.Administrator bo’limini yaratish.
17 – Tajriba ishida biz tariflar bo’limini shakillantiramiz.
Tariflar bo’limi operator va mijozlarga xizmat qiladi.
Dastlab form mihozlar uchun xizmat qiladi . Agar login va parol kiritilsa bu
form operatorlar uchun xizmat qiladi.
Mijozlarning imkoniyatlari bir muncha cheklangan bo’ladi, faqat o’zlariga
maqul tarifni tanlab biladilar.
105
1 – rasm. Tariflar oynasi.
Login va parol kiritilsa unda formda saqlash va yuklash tugmalari hosil bo’ladi 2
- rasm.
2 – rasm. Tariflar oynasi (Administrator uchun).
Saqlash tugmasida bajarilgan amallarni saqlash mumkin.
Yuklash tugmasida yangi tarif qo’shishi mumkin.
O’zgarishlar internet to’plamlari bo’limida ham amalga oshadi
Bu bo’limda o’zingizga maqul tarifni tanlab bila olasiz(3-rasm).
106
(3-rasm)
Operatorlar uchun ajratilgan bo’limdagi yuklash tugmachasi mavjud, bu tugmachada
tarif yuklash mumkin(4-rasm).
4-rasm
Bu bo’limda tarif nomi va uning elementlarini kiritishingiz mumkin.
//Tariflar bo’limi ilovasi
#include
"stdafx.h"
#include
"math.h"
#include
"Add.h"
int
fun(
string
x
)
{
int
n =
x
.size();
107
for
(
int
i = 0; i < n ; i ++)
{
if
(
x
[i] <
'0'
||
x
[i] >
'9'
)
return
0;
}
return
1;
}
#pragma
endregion
private
: System::
Void
Tarif_Load(System::
Object
^
sender
,
System::
EventArgs
^
e
) {
oleDbDataAdapter1 -> Fill(dataSet1);
if
(a == 1)
button2->Visible =
true
, button3 -> Visible =
true
;
}
private
: System::
Void
label1_Click(System::
Object
^
sender
, System::
EventArgs
^
e
)
{
}
private
: System::
Void
button1_Click(System::
Object
^
sender
, System::
EventArgs
^
e
)
{
if
(daqiqa -> Text !=
""
&& sms -> Text !=
""
&& mb -> Text !=
""
){
string
s1 = msclr::interop::marshal_as<
string
>(daqiqa->Text),
s2 = msclr::interop::marshal_as<
string
>(sms ->Text),
s3 = msclr::interop::marshal_as<
string
>(mb->Text);
if
(fun(s1) && fun(s2) && fun(s3)){
rich -> Text =
""
;
int
n = W -> Rows -> Count;
int
m = W -> Columns -> Count;
108
__int64
a , b , c ;
a =
Convert
::ToInt64(daqiqa -> Text);
b =
Convert
::ToInt64(sms -> Text);
c =
Convert
::ToInt64(mb -> Text);
String
^ s;
double
x , y , z , d , mn = 1e18 , g;
for
(
int
i = 0; i < n - 1 ; i++){
rich -> Text +=
Convert
::ToString(W -> Rows[i] -> Cells[0] -> Value) +
" = "
;
x =
(
Convert
::ToInt64(W -> Rows[i] -> Cells[2] -> Value) +
Convert
::ToInt64(W -> Rows[i] -> Cells[3] -> Value)) / 2. *
max
(0 ,a - 30 *
Convert
::ToInt64(W -> Rows[i] -> Cells[5] -> Value));
y =
(
Convert
::ToInt64(W -> Rows[i] -> Cells[6] -> Value) +
Convert
::ToInt64(W -> Rows[i] -> Cells[7] -> Value)) / 2. *
max
(0 ,b -30 *
Convert
::ToInt64(W -> Rows[i] -> Cells[9] -> Value) );
//Add bo’limi kodi
#include
"stdafx.h"
#include
"string"
#include
"iostream"
#include
"stdlib.h"
#include
"msclr\marshal_cppstd.h"
;
using
namespace
std;
using
namespace
msclr::interop;
int
fun(
string
x
)
{
int
n =
x
.size();
for
(
int
i = 0; i < n ; i ++)
{
if
(
x
[i] <
'0'
||
x
[i] >
'9'
)
return
0;
109
}
return
1;
}
#pragma
endregion
private
: System::
Void
Add_Load(System::
Object
^
sender
,
System::
EventArgs
^
e
) {
oleDbDataAdapter1 -> Fill(dataSet1);
}
private
: System::
Void
button1_Click(System::
Object
^
sender
, System::
EventArgs
^
e
)
{
oleDbConnection1 -> Open();
if
(a1 -> Text !=
""
&& a2->Text !=
""
&& a3->Text !=
""
&& a4-
>Text !=
""
&& a5->Text !=
""
&& a6->Text !=
""
&& a7->Text !=
""
&& a8->Text
!=
""
&& a9->Text !=
""
&& a10->Text !=
""
&& a11->Text !=
""
&& a12->Text !=
""
&& a13->Text !=
""
&& a14->Text !=
""
&& a15->Text !=
""
&& a16 -> Text !=
""
)
{
try
{
string
s1=msclr::interop::marshal_as<
string
>(a1->Text),
s2=msclr::interop::marshal_as<
string
>(a2->Text),
s3=msclr::interop::marshal_as<
string
>(a3->Text),
s4=msclr::interop::marshal_as<
string
>(a4->Text),
s5=msclr::interop::marshal_as<
string
>(a5->Text),
s6=msclr::interop::marshal_as<
string
>(a6->Text),
s7=msclr::interop::marshal_as<
string
>(a7->Text),
s8=msclr::interop::marshal_as<
string
>(a8->Text),
s9=msclr::interop::marshal_as<
string
>(a9->Text),
110
s10=msclr::interop::marshal_as<
string
>(a10->Text),
s11=msclr::interop::marshal_as<
string
>(a11->Text),
s12=msclr::interop::marshal_as<
string
>(a12->Text),
s13=msclr::interop::marshal_as<
string
>(a13->Text),
s14=msclr::interop::marshal_as<
string
>(a14->Text),
s15=msclr::interop::marshal_as<
string
>(a15->Text);
if
(fun(s2) && fun(s3) && fun(s4) && fun(s5) && fun(s6) && fun(s7) && fun(s8)
&& fun(s9) && fun(s10) && fun(s11) && fun(s12) && fun(s13) && fun(s14) &&
fun(s15))
{
dataSet1 -> Tables[
"Tarif"
] -> Rows -> Add(a1->Text , a2->Text , a3->Text , a4-
>Text , a5->Text , a6->Text , a7->Text,a8->Text,a9->Text,a10->Text,a11->Text,a12-
>Text,a13->Text,a15->Text,a16->Text);
oleDbDataAdapter1 -> Update(dataSet1 -> Tables[
"Tarif"
]);
this
-> Hide();
MessageBox
::Show(
"Tarif Qo'shildi"
);
}
else
MessageBox
::Show(
"Jadvalni to'ldirishda hatolik bor"
);
}
catch
(
OleDbException
^ oleException)
{
MessageBox
::Show(oleException -> Message ,
"Error"
,
MessageBoxButtons
::
OK
,
MessageBoxIcon
::
Error
);
}
}
else
MessageBox
::Show(
"Hamma katakni to'ldiring!"
);
oleDbConnection1 -> Close();
}
z =
Convert
::ToInt64(W -> Rows[i] -> Cells[13] -> Value) *
max
(0 ,c - 30
*
Convert
::ToInt64(W -> Rows[i] -> Cells[14] -> Value));
111
d =
Convert
::ToInt64(W -> Rows[i] -> Cells[1] -> Value) * 30;
g = (x + y + z + d) / 100 ;
rich -> Text +=
Convert
::ToString(g) +
" $ \n"
;
if
(g < mn )
{
mn = g;
s =
Convert
::ToString(W -> Rows[i] -> Cells[0] -> Value);
}
}
MessageBox
::Show( s ,
"Qulay tarif"
);
}
else
MessageBox
::Show(
"jadvalni to'ldirishda hatolik bor"
);
}
else
MessageBox
::Show(
"Iltimos jadvali to'ldiring "
);
}
private
: System::
Void
button2_Click(System::
Object
^
sender
, System::
EventArgs
^
e
)
{
Add
^ A =
gcnew
Add
;
A -> Show();
}
private
: System::
Void
bindingNavigator1_RefreshItems(System::
Object
^
sender
,
System::
EventArgs
^
e
) {
}
private
: System::
Void
bindingNavigator1_RefreshItems_1(System::
Object
^
sender
,
System::
EventArgs
^
e
) {
}
private
: System::
Void
button2_Click_1(System::
Object
^
sender
, System::
EventArgs
^
e
) {
112
this
->Hide();
Add
^ F =
gcnew
Add
;
F -> Show();
}
private
: System::
Void
button3_Click_1(System::
Object
^
sender
, System::
EventArgs
^
e
) {
oleDbDataAdapter1 -> Update(dataSet1 -> Tables[
"Tarif"
]);
MessageBox
::Show(
"Saqlandi"
);
}
Do'stlaringiz bilan baham: |