|
|
|
ช่วยหน่อยครับ คือผมต้องการจับเวลานะคับ โดยการเริ่มก็กดปุ่ม start จะเซฟเวลาปัจจุบัน |
|
|
|
|
|
|
|
คือผมต้องการจับเวลานะคับ โดยการเริ่มก็กดปุ่ม start จะเซฟเวลาปัจจุบัน ณ ขณะนั้น หลังจากเสร็จแล้ว ก็กดปุ่ม stop ก็จะเซฟเวลาปัจจุบัน ต้องแก้ไขโค๊ดตรงไหนมั่งครับ
โค๊ด
<HTML>
<HEAD>
<TITLE> AddAllEmpn</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-620">
<link href="bossStyle.css" rel="stylesheet" type="text/css" />
</HEAD>
<!--#include file="module.asp"-->
<%tmpactionmode = trim(request("actionmode"))
tmpmode = trim(request("mode")) %>
<BODY bgcolor="#F0FFFF">
<form name="form1" method="post" action="addempnallbb.asp">
<%
Set conn = server.createobject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1 ; User ID=itdev ; Password=egathr ;Persist Security Info=True;Initial Catalog=service;Data Source=HR-DEVELOP"
Set Rs = Server.CreateObject("ADODB.Recordset")
response.write "<input type='Hidden' name='mode' value='"&tmpmode&"'>"
response.write "<input type='Hidden' name='PONo' value='"&trim(request("PONo"))&"'>"
response.write "<input type='Hidden' name='UserName' value='"&trim(request("UserName"))&"'>"
response.write "<input type='Hidden' name='TimeStart' value='"&trim(request("TimeStart"))&"'>"
response.write "<input type='Hidden' name='TimeStop' value='"&trim(request("TimeStop"))&"'>"
response.write "<input type='Hidden' name='TimeTotal' value='"&trim(request("TimeTotal"))&"'>"
if tmpactionmode="บันทึก" or tmpactionmode="ตกลง" then
if trim(request("PONo"))="" then tmpPONo="-" else tmpPONo=trim(request("PONo")) end if
if trim(request("UserName"))="" then tmpUserName="-" else tmpUserName=trim(request("UserName")) end if
if trim(request("TimeStart"))="" then tmpTimeStart="-" else tmpTimeStart=trim(request("TimeStart")) end if
if trim(request("TimeStop"))="" then tmpTimeStop="-" else tmpTimeStop=trim(request("TimeStop")) end if
if trim(request("TimeTotal"))="" then tmpTimeTotal="-" else tmpTimeTotal=trim(request("TimeTotal")) end if
if tmpactionmode="บันทึกthen
sqlupd= "INSERT INTO dbo.TimeCheck VALUES ('"&trim(request("PONo"))&"','"&tmpUserName&"','"&tmpTimeStart&"','"&tmpTimeStop&"','"&tmpTimeTotal&"')"
conn.Execute (sqlupd)%>
<script LANGUAGE="JavaScript">
alert("บันทึกข้อมูลเรียบร้อยแล้ว");
window.opener.location.reload();
window.close();
</script>
<%elseif tmpactionmode="ตกลง" then
sqlupd= "update dbo.TimeCheck Set UserName = '"&tmpUserName&"',TimeStart='"&tmpTimeStart&"',TimeStop='"&tmpTimeStop&"',TimeTotal='"&tmpTimeTotal&"' Where PONo = '"&trim(request("PONo"))&"' "
conn.Execute (sqlupd)%>
<script LANGUAGE="JavaScript">
alert("แก้ไขข้อมุลเรียบร้อยแล้ว");
window.opener.location.reload();
window.close();
</script>
<%end if%>
<%elseif tmpactionmode="ยืนยัน" then
sqldel=" delete from dbo.TimeCheck where UserName='"&trim(request("UserName"))&"' "
conn.Execute (sqldel)%>
<script LANGUAGE="JavaScript">
alert("ลบข้อมูลเรียบร้อยแล้ว");
window.opener.location.reload();
window.close();
</script>
<%end if %>
<%if tmpmode="add" then
tmpHead="บันทึกข้อมูล"
elseif tmpmode="edit" then
tmpHead="แก้ไขข้อมูล"
elseif tmpmode="del" then
tmpHead="ลบข้อมูล"
end if
if tmpmode<>"add" then
strSQL=" select * from dbo.TimeCheck where PONo = '"&trim(request("PONo"))&"' "
Rs.Open strSQL, conn, 1,3
if not Rs.eof then
if trim(request("UserName")) <> "" then strUserName = trim(request("UserName")) else strUserName=trim(Rs("UserName")) end if
if trim(request("TimeStart")) <> "" then strTimeStart = trim(request("TimeStart")) else strTimeStart=trim(Rs("TimeStart")) end if
if trim(request("TimeStop")) <> "" then strTimeStop= trim(request("TimeStop")) else strTimeStop=trim(Rs("TimeStop")) end if
if trim(request("TimeTotal")) <> "" then strTimeTotal = trim(request("TimeTotal")) else strTimeTotal=trim(Rs("TimeTotal")) end if
end if
else
strUserName=trim(request("UserName"))
strTimeStart=trim(request("TimeStart"))
strTimeStop=trim(request("TimeStop"))
strTimeTotal=trim(request("TimeTotal"))
end if
%>
<table width="60%" border="1" cellspacing="0" cellpadding="1" align="center" bgcolor="#FFCCFF">
<tr bgcolor="">
<td height="30" align="center" valign="middle"><b><%=tmpHead%></b></td>
</tr>
</table><br>
<table width="70%" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="">
<tr>
<td width="40%" align="right" height="35">เลขที่ PO : </td>
<td ><%=trim(request("PONo"))%></td>
</tr>
<tr>
<td align="right" height="35">ชื่อผู้ใช้งาน : </td>
<td><input name="UserName" type="text" value="<%=session("usr_name")%>" size="20" maxlength="100"></td>
</tr>
<tr>
<td align="right" height="35">เวลาที่เริ่มการค้นหา: </td>
<td><input name="TimeStart" type="text" value="<%response.write Time ()%>" size="20" maxlength="100"></td>
</tr>
<tr>
<td align="right" height="35">เวลาที่หยุดการค้นหา: </td>
<td><input name="TimeStop" type="text" value="<%=strTimeStop%>" size="20" maxlength="100"></td>
</tr>
<tr>
<td align="right" height="35">เวลาที่ใช้ในการค้นหาทั้งหมด: </td>
<td><input name="TimeTotal" type="text" value="<%=strTimeTotal%>" size="20" maxlength="100"></td>
</tr>
</table>
<p align="center">
<%if tmpmode="add" then%>
<input type="submit" name="actionmode" value=" บันทึก " >
<%elseif tmpmode="edit" then%>
<input type="submit" name="actionmode" value=" ตกลง " >
<%elseif tmpmode="del" then%>
<input type="submit" name="actionmode" value=" ยืนยัน ">
<%end if%>
</p>
</form>
</BODY>
</HTML>
Tag : - - - -
|
|
|
|
|
|
Date :
2010-01-21 15:57:27 |
By :
punkkydear |
View :
1499 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (ASP)
<HTML>
<HEAD>
<TITLE> AddAllEmpn</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=windows-620">
<link href="bossStyle.css" rel="stylesheet" type="text/css" />
</HEAD>
<!--#include file="module.asp"-->
<%tmpactionmode = trim(request("actionmode"))
tmpmode = trim(request("mode")) %>
<BODY bgcolor="#F0FFFF">
<form name="form1" method="post" action="addempnallbb.asp">
<%
[font=Verdana] Dim dt_start As DateTime
Dim dt_stop As DateTime
Dim tsp As TimeSpan
'เริ่มจับเวลาตอน connect open
dt_start = DateTime.Now[/font]
Set conn = server.createobject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1 ; User ID=itdev ; Password=egathr ;Persist Security Info=True;Initial Catalog=service;Data Source=HR-DEVELOP"
Set Rs = Server.CreateObject("ADODB.Recordset")
response.write "<input type='Hidden' name='mode' value='"&tmpmode&"'>"
response.write "<input type='Hidden' name='PONo' value='"&trim(request("PONo"))&"'>"
response.write "<input type='Hidden' name='UserName' value='"&trim(request("UserName"))&"'>"
response.write "<input type='Hidden' name='TimeStart' value='"&trim(request("TimeStart"))&"'>"
response.write "<input type='Hidden' name='TimeStop' value='"&trim(request("TimeStop"))&"'>"
response.write "<input type='Hidden' name='TimeTotal' value='"&trim(request("TimeTotal"))&"'>"
if tmpactionmode="บันทึก" or tmpactionmode="ตกลง" then
if trim(request("PONo"))="" then tmpPONo="-" else tmpPONo=trim(request("PONo")) end if
if trim(request("UserName"))="" then tmpUserName="-" else tmpUserName=trim(request("UserName")) end if
if trim(request("TimeStart"))="" then tmpTimeStart="-" else tmpTimeStart=trim(request("TimeStart")) end if
if trim(request("TimeStop"))="" then tmpTimeStop="-" else tmpTimeStop=trim(request("TimeStop")) end if
if trim(request("TimeTotal"))="" then tmpTimeTotal="-" else tmpTimeTotal=trim(request("TimeTotal")) end if
if tmpactionmode="บันทึกthen
sqlupd= "INSERT INTO dbo.TimeCheck VALUES ('"&trim(request("PONo"))&"','"&tmpUserName&"','"&tmpTimeStart&"','"&tmpTimeStop&"','"&tmpTimeTotal&"')"
conn.Execute (sqlupd)
[font=Verdana] 'จับเวลาตอน connection execute เสร็จ ปกติจะเอา return value มาตรวจสอบก่อนก็ดีครับ
dt_stop = DateTime.Now
tsp = dtt_stop - dt_start
'โชว์ว่าใช้เวลาไปเท่าไหร่เป็น seconds ไม่ต้องกดปุ่มหยุดแล้ว
alert(tsp.Seconds.ToString)[/font]
%>
<script LANGUAGE="JavaScript">
alert("บันทึกข้อมูลเรียบร้อยแล้ว");
window.opener.location.reload();
window.close();
</script>
<%elseif tmpactionmode="ตกลง" then
sqlupd= "update dbo.TimeCheck Set UserName = '"&tmpUserName&"',TimeStart='"&tmpTimeStart&"',TimeStop='"&tmpTimeStop&"',TimeTotal='"&tmpTimeTotal&"' Where PONo = '"&trim(request("PONo"))&"' "
conn.Execute (sqlupd)%>
<script LANGUAGE="JavaScript">
alert("แก้ไขข้อมุลเรียบร้อยแล้ว");
window.opener.location.reload();
window.close();
</script>
<%end if%>
<%elseif tmpactionmode="ยืนยัน" then
sqldel=" delete from dbo.TimeCheck where UserName='"&trim(request("UserName"))&"' "
conn.Execute (sqldel)%>
<script LANGUAGE="JavaScript">
alert("ลบข้อมูลเรียบร้อยแล้ว");
window.opener.location.reload();
window.close();
</script>
<%end if %>
<%if tmpmode="add" then
tmpHead="บันทึกข้อมูล"
elseif tmpmode="edit" then
tmpHead="แก้ไขข้อมูล"
elseif tmpmode="del" then
tmpHead="ลบข้อมูล"
end if
if tmpmode<>"add" then
strSQL=" select * from dbo.TimeCheck where PONo = '"&trim(request("PONo"))&"' "
Rs.Open strSQL, conn, 1,3
if not Rs.eof then
if trim(request("UserName")) <> "" then strUserName = trim(request("UserName")) else strUserName=trim(Rs("UserName")) end if
if trim(request("TimeStart")) <> "" then strTimeStart = trim(request("TimeStart")) else strTimeStart=trim(Rs("TimeStart")) end if
if trim(request("TimeStop")) <> "" then strTimeStop= trim(request("TimeStop")) else strTimeStop=trim(Rs("TimeStop")) end if
if trim(request("TimeTotal")) <> "" then strTimeTotal = trim(request("TimeTotal")) else strTimeTotal=trim(Rs("TimeTotal")) end if
end if
else
strUserName=trim(request("UserName"))
strTimeStart=trim(request("TimeStart"))
strTimeStop=trim(request("TimeStop"))
strTimeTotal=trim(request("TimeTotal"))
end if
%>
<table width="60%" border="1" cellspacing="0" cellpadding="1" align="center" bgcolor="#FFCCFF">
<tr bgcolor="">
<td height="30" align="center" valign="middle"><b><%=tmpHead%></b></td>
</tr>
</table><br>
<table width="70%" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="">
<tr>
<td width="40%" align="right" height="35">เลขที่ PO : </td>
<td ><%=trim(request("PONo"))%></td>
</tr>
<tr>
<td align="right" height="35">ชื่อผู้ใช้งาน : </td>
<td><input name="UserName" type="text" value="<%=session("usr_name")%>" size="20" maxlength="100"></td>
</tr>
<tr>
<td align="right" height="35">เวลาที่เริ่มการค้นหา: </td>
<td><input name="TimeStart" type="text" value="<%response.write Time ()%>" size="20" maxlength="100"></td>
</tr>
<tr>
<td align="right" height="35">เวลาที่หยุดการค้นหา: </td>
<td><input name="TimeStop" type="text" value="<%=strTimeStop%>" size="20" maxlength="100"></td>
</tr>
<tr>
<td align="right" height="35">เวลาที่ใช้ในการค้นหาทั้งหมด: </td>
<td><input name="TimeTotal" type="text" value="<%=strTimeTotal%>" size="20" maxlength="100"></td>
</tr>
</table>
<p align="center">
<%if tmpmode="add" then%>
<input type="submit" name="actionmode" value=" บันทึก " >
<%elseif tmpmode="edit" then%>
<input type="submit" name="actionmode" value=" ตกลง " >
<%elseif tmpmode="del" then%>
<input type="submit" name="actionmode" value=" ยืนยัน ">
<%end if%>
</p>
</form>
</BODY>
</HTML>
|
|
|
|
|
Date :
2010-01-26 11:56:43 |
By :
numenoy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากคับ
|
|
|
|
|
Date :
2010-01-26 13:58:59 |
By :
punkkydear |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|