📄 checkindbconn.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
/// <summary>
/// CheckInDB 的摘要说明
/// </summary>
public class CheckInDB
{
private detailDBconn StayDB;
private string errortext;
public CheckInDB()
{
StayDB= new detailDBconn();
}
/// <summary>
///
/// </summary>
public void Init()
{
StayDB.intConn();
if (StayDB.isOpen == false)
StayDB.openDB();
}
/// <summary>
///
/// </summary>
/// <param name="room"></param>
/// <param name="IDPerson"></param>
/// <param name="endTime"></param>
/// <param name="deposit"></param>
public void InsertStayInfo(int room,int IDPerson,DateTime endTime,float deposit)
{
int id = getStayInfoID();
DateTime currentTime = getStartTime();
if (id <0)
{
errortext = "can not get stayInfoID";
}
StringBuilder sqlcommand = new StringBuilder();
sqlcommand.Append(
"insert into stayinfo(ID,room,IDPerson,startTime,endTime,IsIn,deposit) values (");
//插入记录的顾客ID
sqlcommand.Append("'" + id.ToString() + "'");
sqlcommand.Append(",'" + room + "',");
sqlcommand.Append("'" + IDPerson + "',");
sqlcommand.Append("'" + currentTime + "',");
sqlcommand.Append("'" + endTime + "',");
sqlcommand.Append("'" + 1 + "',");
sqlcommand.Append("'" + deposit + "')");
StayDB.insertCommand = sqlcommand.ToString();
try
{
StayDB.executeCommand();
}
catch
{
errortext = StayDB.errorMessage;
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public ArrayList SelectRoom(string type, string startTime,string endTime)
{
HotelRoomInfo aRoom;
ArrayList resultSet = new ArrayList();
try
{
StayDB.selectDataSetCommand = "select * from HotelInfo where roomType ="+"'"+type+"'";
DataSet ds = StayDB.getSelectDataSet();
string[] parmInfos ={ "@roomNO", "@theStartTime", "@theEndTime" };
object[] hotelInfo;
object[] parms = new object[3];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
hotelInfo = ds.Tables[0].Rows[i].ItemArray;
aRoom = new HotelRoomInfo();
aRoom.roomNO = int.Parse(hotelInfo[0].ToString());
aRoom.roomtype = hotelInfo[2].ToString();
aRoom.roomPrice = System.Decimal.ToInt32((decimal)hotelInfo[1]);
int retvalue = 0;
parms.SetValue(aRoom.roomNO.ToString(), 0);
parms.SetValue(startTime, 1);
parms.SetValue(endTime, 2);
StayDB.CallStoredProcedure("IsAvailable", parmInfos, parms, ref retvalue);
if (retvalue != 0)
{
resultSet.Add(aRoom);
}
}
}
catch (Exception e)
{
errortext = e.Message;
}
return resultSet;
}
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="identityNo"></param>
/// <param name="telephoneNo"></param>
public void InsertCustomer(string name, string identityNo,string telephoneNo)
{
int id = getCustomerID(); //插入记录的顾客ID
if (id <= 0)
{
errortext = "can not get record";
}
StringBuilder sqlcommand = new StringBuilder();
sqlcommand.Append("insert into clientinfo(ID,ClientName,identityNo,telephoneNo) values (");
sqlcommand.Append("'" + id.ToString() + "'");
sqlcommand.Append(",'" + name + "',");
sqlcommand.Append("'" + identityNo + "',");
sqlcommand.Append("'" + telephoneNo + "')");
StayDB.insertCommand = sqlcommand.ToString();
try
{
StayDB.executeCommand();
}
catch
{
errortext = StayDB.errorMessage;
}
/* int id = getCustomerID();
SqlCommand cmd = StayDB.dbconnection.CreateCommand();
cmd.CommandText = "insert into ClientInfo(ID,ClientName,identityNo,telephoneNo) values (";
cmd.CommandText += "'" + id.ToString() + "'";
cmd.CommandText += ",'" + name + "',";
cmd.CommandText += "'" + identityNo + "',";
cmd.CommandText += "'" + telephoneNo + "')";
cmd.ExecuteNonQuery();*/
}
public int InquireCustomer(string identityNo)
{
int retID = 0;
string[] parmInfo ={"@identityNo"};
string[] parm ={ identityNo };
StayDB.CallStoredProcedure("InquireCustomer", parmInfo, parm, ref retID);
return retID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public int getCustomerID()
{
int retID=0;
string[] parmInfo ={ };
string[] parm ={ };
StayDB.CallStoredProcedure("getCustomerID", parmInfo, parm, ref retID);
return retID;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public int getStayInfoID()
{
int retID = 0;
string[] parmInfo ={ };
string[] parm ={ };
StayDB.CallStoredProcedure("getStayInfoID", parmInfo, parm, ref retID);
return retID;
}
public void submitForm(string name,string identity,
string telphone,int room, int dayGap,float deposit)
{
int ID=InquireCustomer(identity);
if (ID <= 0)
{
InsertCustomer(name, identity, telphone);
}
ID = InquireCustomer(identity);
InsertStayInfo(room, ID, getEndTime(dayGap), deposit);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public DateTime getStartTime()
{
return DateTime.Now;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public DateTime getEndTime(int dayGap)
{
DateTime endtime = new DateTime();
endtime = getStartTime().AddDays(dayGap);
endtime.AddHours(0 - getStartTime().Hour);
endtime.AddMinutes(0 - getStartTime().Minute);
endtime.AddSeconds(0 - getStartTime().Second);
return endtime;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -