|
|
|
สอบถาม Code เก็บสถิติการเข้าดูหน้าเว็บของแต่ละ User ว่าเข้าดูกี่ครั้ง |
|
|
|
|
|
|
|
หลักการ็คงจะไปสร้าง Log ไว้ครับ แล้วก็ Update ว่าเข้ากี่ครั้งครับ เช่น
Code (SQL)
UPDATE table_log SET VIEW = VIEW + 1 WHERE username = 'abc';
|
|
|
|
|
Date :
2014-03-26 17:36:50 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Security;
using System.Data;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void btnOK_Click(object sender, EventArgs e)
{
if (CheckAuthenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
{
FormsAuthentication.RedirectFromLoginPage("UserLog", false);
}
else
{
ClearList();
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
ClearList();
}
#region Method
private void ClearList()
{
txtUsername.Text = "";
txtPassword.Text = "";
SetFocusCtrl(txtUsername);
}
private void SetFocusCtrl(System.Web.UI.Control ctrl)
{
string script = "<SCRIPT language=\"javascript\">" + "document.getElementById('" + ctrl.ID + "').focus() </SCRIPT>";
ClientScript.RegisterStartupScript(this.GetType(), "focus", script.Trim());
}
private bool CheckAuthenticate(string Username, string Password)
{
string querystr = "select * from emp where ltrim(rtrim(Username))='" + Username.Trim() + "' and ltrim(rtrim(Password)) ='" + Password.Trim() + "'";
vdoClassUtil cUtil = new vdoClassUtil();
DataTable dtUser = cUtil.GetDatatable(querystr);
if (dtAgent.Rows.Count == 1)
{
return true;
}
else
{
return false;
}
}
#endregion
}
|
|
|
|
|
Date :
2014-03-27 09:46:06 |
By :
plasara51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วจะทำการ UPDATE การเข้าดูที่หน้า page นี้ได้เลยไหมค่ะ
|
|
|
|
|
Date :
2014-03-27 09:47:33 |
By :
plasara51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะ insert
tb.login
loginid
usename
login_dtm
เข้าไป โค้ดต้องเขียนแบบไหนค่ะ
ลองเขียนแล้ว แต่รันไม่ขึ้นนะคะ
Code (C#)
private bool CheckAuthenticate(string Username, string Password)
{
string querystr = "select * from video_emp where ltrim(rtrim(Username))='" + Username.Trim() + "' and ltrim(rtrim(Password)) ='" + Password.Trim() + "'";
vdoClassUtil cUtil = new vdoClassUtil();
DataTable dtAgent = cUtil.GetDatatable(querystr);
if (dtAgent.Rows.Count == 1)
{
string strToday = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString();
string strSQLLog = "INSERT INTO video_login (";
strSQLLog += "\r" + " Username, Status_dtm ";
strSQLLog += "\r" + ") VALUES (";
strSQLLog += "\r '" + txtUsername.Text.Trim().ToLower() + "', getdate())";
cUtil.RunQuery(strSQLLog);
}
else
{
return false;
}
|
|
|
|
|
Date :
2014-03-28 11:41:28 |
By :
plasara51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|