001.
<?php
002.
session_start();
003.
if
(
$_SESSION
[
'UserID'
] ==
""
)
004.
{
005.
echo
"Please Login!"
;
006.
exit
();
007.
}
008.
?>
009.
<html>
010.
<head>
011.
<title>DhawathSystems Data</title>
012.
<meta http-equiv=
"content-type"
content=
"text/html; charset=tis-620"
/>
013.
</head>
014.
<body>
015.
016.
<center>
017.
<?
018.
include
(
"inc/connect.php"
);
019.
020.
if
(
$_POST
[
"hdnCmd"
] ==
"Add"
)
021.
{
022.
$strSQL
=
"INSERT INTO customer "
;
023.
$strSQL
.=
"(CustomerID,Name,Email,pc,License_win,License_off) "
;
024.
025.
$strSQL
.=
"VALUES "
;
026.
$strSQL
.=
"('"
.
$_POST
[
"txtAddCustomerID"
].
"','"
.
$_POST
[
"txtAddName"
].
"','"
.
$_POST
[
"txtAddEmail"
].
"' ,'"
.
$_POST
[
"txtpc"
].
"' "
;
027.
028.
$strSQL
.=
",'"
.
$_POST
[
"txtAddBudget"
].
"','"
.
$_POST
[
"txtAddUsed"
].
"') "
;
029.
$objQuery
= mysql_query(
$strSQL
);
030.
if
(!
$objQuery
)
031.
{
032.
echo
"Error Save ["
.mysql_error().
"]"
;
033.
}
034.
035.
036.
}
037.
038.
039.
if
(
$_POST
[
"hdnCmd"
] ==
"Update"
)
040.
{
041.
$strSQL
=
"UPDATE customer SET "
;
042.
$strSQL
.=
"CustomerID = '"
.
$_POST
[
"txtEditCustomerID"
].
"' "
;
043.
$strSQL
.=
",Name = '"
.
$_POST
[
"txtEditName"
].
"' "
;
044.
$strSQL
.=
",Email = '"
.
$_POST
[
"txtEditEmail"
].
"' "
;
045.
$strSQL
.=
",pc = '"
.
$_POST
[
"txtpc"
].
"' "
;
046.
$strSQL
.=
",License_win = '"
.
$_POST
[
"txtEditBudget"
].
"' "
;
047.
$strSQL
.=
",License_off = '"
.
$_POST
[
"txtEditUsed"
].
"' "
;
048.
$strSQL
.=
"WHERE CustomerID = '"
.
$_POST
[
"hdnEditCustomerID"
].
"' "
;
049.
$objQuery
= mysql_query(
$strSQL
);
050.
if
(!
$objQuery
)
051.
{
052.
echo
"Error Update ["
.mysql_error().
"]"
;
053.
}
054.
055.
056.
}
057.
058.
059.
if
(
$_GET
[
"Action"
] ==
"Del"
)
060.
{
061.
$strSQL
=
"DELETE FROM customer "
;
062.
$strSQL
.=
"WHERE CustomerID = '"
.
$_GET
[
"CusID"
].
"' "
;
063.
$objQuery
= mysql_query(
$strSQL
);
064.
if
(!
$objQuery
)
065.
{
066.
echo
"Error Delete ["
.mysql_error().
"]"
;
067.
}
068.
069.
070.
}
071.
072.
$strSQL
=
"SELECT * FROM customer"
;
073.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
074.
?>
075.
<font color=red size=3><b>ระบบบริหารจัดการรายละเอียด ผู้ใช้ แผนก ทรัพยากรมนุษย์และธุรการ</b></font>
076.
<form name=
"frmMain"
method=
"post"
action=
"<?=$_SERVER["
PHP_SELF
"];?>"
>
077.
<input type=
"hidden"
name=
"hdnCmd"
value=
""
>
078.
<table width=
"760"
border=
"1"
>
079.
<tr>
080.
<th width=
"36"
> <div align=
"center"
>ลำดับ</div></th>
081.
<th width=
"120"
> <div align=
"center"
>ชื่อ - นามสกุล</div></th>
082.
<th width=
"120"
> <div align=
"center"
>E-mail </div></th>
083.
<th width=
"135"
> <div align=
"center"
>ประเภทคอมพิวเตอร์ </div></th>
084.
<th width=
"38"
> <div align=
"center"
>License Windows </div></th>
085.
<th width=
"30"
> <div align=
"center"
>License Office </div></th>
086.
087.
</tr>
088.
<?php
089.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
090.
{
091.
?>
092.
093.
094.
<?
095.
if
(
$objResult
[
"CustomerID"
] ==
$_GET
[
"CusID"
]
and
$_GET
[
"Action"
] ==
"Edit"
)
096.
{
097.
?>
098.
099.
100.
101.
<tr>
102.
<td><div align=
"center"
>
103.
<input type=
"text"
name=
"txtEditCustomerID"
size=
"5"
value=
"<?=$objResult["
CustomerID
"];?>"
>
104.
<input type=
"hidden"
name=
"hdnEditCustomerID"
size=
"5"
value=
"<?=$objResult["
CustomerID
"];?>"
>
105.
</div></td>
106.
<td><input type=
"text"
name=
"txtEditName"
size=
"20"
value=
"<?=$objResult["
Name
"];?>"
></td>
107.
<td><input type=
"text"
name=
"txtEditEmail"
size=
"20"
value=
"<?=$objResult["
Email
"];?>"
></td>
108.
<td><input name=
"txtpc"
type=
"radio"
value=
"computer desktop"
>Computer Desktop<br>
109.
<input name=
"txtpc"
type=
"radio"
value=
"notebook"
>Notebook<br></td>
110.
<td align=
"right"
><input type=
"text"
name=
"txtEditBudget"
value=
"<?=$objResult["
License_win
"];?>"
></td>
111.
<td align=
"right"
><input type=
"text"
name=
"txtEditUsed"
value=
"<?=$objResult["
License_off
"];?>"
></td>
112.
<td colspan=
"2"
align=
"right"
><div align=
"center"
>
113.
<input name=
"btnAdd"
type=
"button"
id=
"btnUpdate"
value=
"Update"
OnClick=
"frmMain.hdnCmd.value='Update';frmMain.submit();"
>
114.
<input name=
"btnAdd"
type=
"button"
id=
"btnCancel"
value=
"Cancel"
OnClick=
"window.location='<?=$_SERVER["
PHP_SELF
"];?>';"
>
115.
</div></td>
116.
</tr>
117.
118.
119.
120.
<?
121.
}
122.
else
123.
{
124.
?>
125.
126.
127.
128.
<tr>
129.
<td><div align=
"center"
><?=
$objResult
[
"CustomerID"
];?></div></td>
130.
<td><?=
$objResult
[
"Name"
];?></td>
131.
<td><?=
$objResult
[
"Email"
];?></td>
132.
<td><?=
$objResult
[
"pc"
];?></td>
133.
<td align=
"right"
><?=
$objResult
[
"License_win"
];?></td>
134.
<td align=
"right"
><?=
$objResult
[
"License_off"
];?></td>
135.
<td align=
"center"
><a href=
"<?=$_SERVER["
PHP_SELF
"];?>?Action=Edit&CusID=<?=$objResult["
CustomerID
"];?>"
>Edit</a></td>
136.
<td align=
"center"
><a href=
"JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["
PHP_SELF
"];?>?Action=Del&CusID=<?=$objResult["
CustomerID
"];?>';}"
>
Delete
</a></td>
137.
</tr>
138.
<?
139.
}
140.
?>
141.
<?
142.
}
143.
?>
144.
<tr>
145.
<td><div align=
"center"
></div></td>
146.
<td><input type=
"text"
name=
"txtAddName"
size=
"20"
></td>
147.
<td><input type=
"text"
name=
"txtAddEmail"
size=
"20"
></td>
148.
<td><input name=
"txtpc"
type=
"radio"
value=
"computer desktop"
>Computer Desktop<br>
149.
<input name=
"txtpc"
type=
"radio"
value=
"notebook"
>Notebook<br></td>
150.
<td align=
"right"
><input type=
"text"
name=
"txtAddBudget"
></td>
151.
<td align=
"right"
><input type=
"text"
name=
"txtAddUsed"
></td>
152.
<td colspan=
"2"
align=
"right"
><div align=
"center"
>
153.
<input name=
"btnAdd"
type=
"button"
id=
"btnAdd"
value=
"Add"
OnClick=
"frmMain.hdnCmd.value='Add';frmMain.submit();"
>
154.
</div></td>
155.
</tr>
156.
</table>
157.
</form>
158.
<br>
159.
Total <?php
echo
$Num_Rows
;?> Record : <?php
echo
$Num_Pages
;?> Page :
160.
<?php
161.
if
(
$Prev_Page
)
162.
{
163.
echo
" <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "
;
164.
}
165.
166.
for
(
$i
=1;
$i
<=
$Num_Pages
;
$i
++){
167.
if
(
$i
!=
$Page
)
168.
{
169.
echo
"[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"
;
170.
}
171.
else
172.
{
173.
echo
"<b> $i </b>"
;
174.
}
175.
}
176.
if
(
$Page
!=
$Num_Pages
)
177.
{
178.
echo
" <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "
;
179.
}
180.
mysql_close(
$objConnect
);
181.
?>
182.
<?
183.
184.
?>
185.
</center>
186.
</body>
187.
</html>