📄 discountdbconn.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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.Collections;
/// <summary>
/// GroupDBConn 的摘要说明
/// </summary>
public class GroupDBConn:DBConn
{
private string sql = null;
private SqlCommand comm = null;
private SqlDataReader reader = null;
public GroupDBConn()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public ArrayList getAllGroup()
{
sql = "SELECT * FROM [GroupInfo]";
ArrayList reList = new ArrayList();
this.Open();
comm = new SqlCommand(sql, conn);
reader = comm.ExecuteReader();
Group group = null;
while (reader.Read())
{
group = new Group();
group.ID = reader.GetInt32(0);
group.Name = reader.GetString(1);
group.Telphone = reader.GetString(2);
try
{
group.Address = reader.GetString(3);
}
catch
{
group.Address = "";
}
group.Contact = reader.GetString(4);
group.Discount = reader.GetDouble(5);
reList.Add(group);
}
this.Close();
return reList;
}
public void delGroup(int id)
{
sql = "DELETE FROM [GroupInfo] WHERE [ID] = " + id.ToString();
this.Open();
comm = new SqlCommand(sql, conn);
comm.ExecuteNonQuery();
this.Close();
}
public void updateGroup(Group group)
{
sql = "UPDATE [GroupInfo] SET [name] = '" + group.Name + "', [telephoneno] = '" + group.Telphone + "', [ADDRESS] = '" + group.Address + "', [LINKMAN] = '" + group.Contact + "', [discount] = " + group.Discount.ToString() + " WHERE [ID] = " + group.ID.ToString();
this.Open();
comm = new SqlCommand(sql, conn);
comm.ExecuteNonQuery();
this.Close();
}
public void insertGroup(Group group)
{
int id = 0;
sql = "SELECT MAX([ID]) FROM [GroupInfo]";
this.Open();
comm = new SqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
try
{
id = reader.GetInt32(0);
}
catch{
id = 0;
}
}
reader.Close();
id = id + 1;
sql = "INSERT INTO [GroupInfo](ID, NAME, TELEPHONENO, ADDRESS, LINKMAN, DISCOUNT) VALUES(" + id.ToString() + ", '" + group.Name + "', '" + group.Telphone + "', '" + group.Address + "', '" + group.Contact + "', " + group.Discount.ToString() + ")";
comm = new SqlCommand(sql, conn);
comm.ExecuteNonQuery();
this.Close();
}
}
public class SeasonDBConn : DBConn
{
private string sql = null;
private SqlCommand comm = null;
private SqlDataReader reader = null;
public ArrayList getAllRoomType()
{
ArrayList reList = new ArrayList();
sql = "SELECT [price], [roomType], COUNT([room]), [discount] FROM [HotelInfo] GROUP BY [price], [roomType], [discount]";
this.Open();
comm = new SqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
string[] room = { "", "", "", "" };
room[0] = reader.GetSqlMoney(0).ToString();
room[1] = reader.GetSqlString(1).ToString();
room[2] = reader.GetInt32(2).ToString();
room[3] = (reader.GetDouble(3) * 100.0).ToString();
reList.Add(room);
}
this.Close();
return reList;
}
public void updateRoomDiscount(string roomType, double discount)
{
sql = "UPDATE [HotelInfo] SET [discount] = " + discount.ToString() + " WHERE [roomType] = '" + roomType + "'";
this.Open();
comm = new SqlCommand(sql, conn);
comm.ExecuteNonQuery();
this.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -