|
 |
|
C# ถ้าใส่วันกับเวลาในวันจองแล้วชนกันให้ขึ้ย Alert ไม่สามารถจองทับได้ |
|
 |
|
|
 |
 |
|
รบกวนหน่อยครับพอดีทำระบบเกี่ยวกับการจองถ้าผมต้องการให้ไม่สามารถจองได้ถ้าช่วงวันเวลาตรงกันผมต้องใส่ โค้ดอะไรเพิ่มเติ่มตรงไหนอ่ะครับ
Create User
if (txtPassword.Text.Length < 7)
{
lblStatus.Text = "กรุณากรอกรหัสผ่านให้ครบ 7 ตัวอักษร";
lblStatus.ForeColor = System.Drawing.Color.Red;
}
else
{
int intNumRows = 0;
String strSQL;
strSQL = "SELECT COUNT(*) FROM Organizer WHERE username = '" + txtUsername.Text + "'" ;
intNumRows = Convert.ToInt32(clsDB.QueryExecuteScalar(strSQL));
if (intNumRows > 0)
{
lblStatus.Text = "มี username ซ้ำในฐานข้อมูล";
lblStatus.ForeColor = System.Drawing.Color.Red;
}
else
{
try
{
DataTable dt = new DataTable();
DateTime dts = Convert.ToDateTime(txtStartDate.Text);
DateTime dte = Convert.ToDateTime(txtEndDate.Text);
ADMange AD = new ADMange(this.AD_Host, this.AD_Base, this.AD_Port, this.AD_UserObjectClass, this.AD_authenticationWith, this.AD_Username, this.AD_Password);
if (AD.createUserAccount(txtUsername.Text, txtPassword.Text, dte.ToString("yyyy-MM-dd"), txtOrganizer.Text, "", "", "", "", "ou=Organizer,"))
{
AD.setAccountExpire(txtUsername.Text, Convert.ToDateTime(txtEndDate.Text));
strSQL = "INSERT INTO Organizer(username,password,orgname,eventname,start_date,end_date,start_time,end_time,flag,picture)" +
"VALUES" +
"('" + txtUsername.Text + "','" + txtPassword.Text + "','" + txtOrganizer.Text + "','' " +
" ,'" + dts.ToString("yyyy-MM-dd") + "','" + dte.ToString("yyyy-MM-dd") + "','"+ddlHourStart.SelectedItem+"','"+ddlHourStop.SelectedItem+"','enable','' )";
if (clsDB.QueryExecuteNonQuery(strSQL))
{
Response.Write("<Script language=javascript> alert('ระบบทำการจองให้คุณเรียบร้อยแล้วค่ะ')</Script>");
}
}
else
{
lblStatus.Text = "มี User นี้ในระบบ AD แล้ว";
lblStatus.ForeColor = System.Drawing.Color.Red;
}
txtUsername.Text = "";
txtOrganizer.Text = "";
txtStartDate.Text = "";
txtEndDate.Text = "";
ddlHourStart.Text = "";
ddlHourStop.Text = "";
}
catch (Exception ex)
{
lblStatus.Text = "";
lblStatus.ForeColor = System.Drawing.Color.Red;
}
}
}
Tag : .NET, Ms SQL Server 2008, VS 2010 (.NET 4.x)

|
|
 |
 |
 |
 |
Date :
2014-01-02 13:08:23 |
By :
offonepoint |
View :
880 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หลักการก็คือไป Select ข้อมูลใน Table ที่จัดเก็บการจองครับ ถ้ามี Record ก็แสดงว่าถูกจองไปแล้ว
|
 |
 |
 |
 |
Date :
2014-01-04 08:20:02 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|