• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

酒店住宿信息管理系统源码 sql(数据库)+c#(界面) 大作业

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

界面展示:

此程序为本人数据库大作业,施工时间2天,有些许不足,仅供交流学习。acm选手无项目开发经验,项目爷轻喷。

系统功能的基本要求: 客房各种信息,包括客房的类别、当前的状态、负责人等;客房信息的查询和修改,包括按房间号查询住宿情况、按客户信息查询房间状态等。以及退房、订房、换房等信息的修改。对查询、统计结果打印输出。

 

 

 数据库信息代码:

create table 房间信息表
(房间号 int primary key,
房间类别 varchar(10) ,
房间状态 smallint, 
房间负责人 varchar(10),
房间价格 int,
);

create table 员工信息表
(员工类别 varchar(10),
用户名 varchar(10) primary key,
密码 varchar(10),
);

create table 顾客信息表
(身份证号 char(18) primary key,
姓名 varchar(8)NOT NULL,
性别 char(2)NOT NULL CONSTRAINT P1 CHECK(性别 IN (\'\',\'\')),
年龄 int NOT NULL CONSTRAINT P2 CHECK(年龄>0),
手机号 char(11),
会员等级 varchar(10) ,
);

create table 订房记录表
(订单编号 int primary key,
房间号 int,
住客身份证号 char(18),
开始时间 char(18),
到期时间 char(18),
foreign key (住客身份证号) references 顾客信息表(身份证号),
foreign key (房间号) references 房间信息表(房间号) ,
);

drop table 顾客服务表
create table 顾客服务表
(
房间号 int,
服务类型 varchar(10),
负责人 varchar(10),
foreign key (房间号) references 房间信息表(房间号),
);

Create unique index 身份证信息 on 顾客信息表(身份证号);
Create unique index 订单信息 on 订房记录表(订单编号);
Create unique index 房间信息 on 房间信息表(房间号);

create view 空房查询 
(房间号,
房间类别,
房间价格
)
as select 房间号,房间类别,房间价格 from 房间信息表 where 房间状态=0

create view 顾客订房信息查询
(顾客姓名,
身份,
预定房间类别,
订单房间状态,
房间价格,
房间号,
订单编号
)
as select 姓名,会员等级,房间类别,房间状态,房间价格,订房记录表.房间号,订单编号 
from 订房记录表,房间信息表,顾客信息表 
where 订房记录表.房间号=房间信息表.房间号 and 顾客信息表.身份证号=订房记录表.住客身份证号

create view 房间列表
(
房间号,
房间类别,
房间状态,
房间价格
)
as select 房间号,房间类别,房间状态,房间价格
from 房间信息表


create view 负责人任务列表
(
负责人,
房间号,
任务
)
as select 负责人,房间号,服务类型
from 顾客服务表

/*(订单编号 int primary key,
房间号 int,
住客身份证号 char(18),
开始时间 char(18),
到期时间 char(18),
*/
/*drop trigger 订房操作触发器*/

create trigger 服务触发器 on 顾客服务表
for insert 
as begin 
declare @room int,@房间负责人 varchar(10)
select @room=房间号 from inserted
select @房间负责人=房间负责人 from 房间信息表 where 房间号=@room 
update 顾客服务表 set 负责人=@房间负责人 where 房间号=@room
select (\'申请成功\')
end

create trigger 订房操作触发器 on 订房记录表
for insert 
as begin 
declare @idnum varchar,@room int,@starttime char(18),@endtime char(18)
select @idnum=住客身份证号,@room=房间号,@starttime=开始时间,@endtime=到期时间 from inserted 
update 房间信息表 set 房间状态=1 where 房间号=@room
select (\'订房成功\')
end

create trigger 退房操作触发器 on 订房记录表
for delete 
as begin 
declare @idnum varchar,@room int,@starttime char(18),@endtime char(18)
select @idnum=住客身份证号,@room=房间号,@starttime=开始时间,@endtime=到期时间 from deleted
update 房间信息表 set 房间状态=0 where 房间号=@room
select(\'退房成功\')
end

insert into 顾客服务表 values(103,\'打扫房间\',NULL);
select * from 顾客服务表
select * from 房间信息表

 C#界面程序主窗口源码: (完整程序源码私信)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
namespace WpfApp2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        
        string SqlConnectionStatement = "server=localhost;database=QT+SQL酒店master;Trusted_Connection=SSPI";
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string username;
            string password;
            string lei = "";
            if (b1.IsChecked == true)
            {
                lei += "管理员";
            }
            else if (b2.IsChecked == true)
            {
                lei += "员工";
            }
            else
            {
                MessageBox.Show("请选择类型");
                return;
            }
            username = t1.Text;
            password = t2.Text;
            string sql = "select * from 员工信息表 where 员工类别=" + "\'" + lei + "\' and " + "用户名=" + "\'" + username + "\' and " + "密码=" + "\'" + password + "\'";
            //MessageBox.Show(sql);
            try                                                                
            {
                SqlCommand cmd = new SqlCommand(sql,conn);
                SqlDataReader res = cmd.ExecuteReader();//执行SQL语句,并返回一个结果集
                if(res.Read())
                {
                    MessageBox.Show("登录成功");
                }
                else
                {
                    MessageBox.Show("用户名或密码错误");
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("用户名或密码错误");
                return;
            }
            //MssageBox.Show(sql);

            /*NavigationWindow window = new NavigationWindow();
            window.Source = new Uri("Page1.xaml", UriKind.Relative);
            window.Show();*/
            Window2 isw = new Window2();
            isw.Show();
            this.Close();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Window1 isw = new Window1(); 
            isw.Show(); 
        }

        private void 用户名_TextChanged(object sender, TextChangedEventArgs e)
        {

        }

        private void 用户名_Copy_TextChanged(object sender, TextChangedEventArgs e)
        {

        }
        /*string sql = "select * from 顾客信息表";
        SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
        DataTable dt = new DataTable();
        myda.Fill(dt);
        da1.ItemsSource = dt.DefaultView;*/
    }
}

 

 C#界面程序窗口一源码: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
namespace WpfApp2
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    /// 
    public partial class Window1 : Window
         
    {
        public Window1()
        {
            InitializeComponent();
        }
        string SqlConnectionStatement = "server=localhost;database=QT+SQL酒店master;Trusted_Connection=SSPI";
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string username;
            string password;
            string lei = "";
            if (b1.IsChecked == true)
            {
                lei += "管理员";
            }
            else if (b2.IsChecked == true)
            {
                lei += "员工";
            }
            else
            {
                MessageBox.Show("请选择类型");
                return;
            }
            username = t1.Text;
            password = t2.Text;
            if (t2.Text != t3.Text)
            {
                MessageBox.Show("两次密码不一致");
                return;
            }
           // string sqls = "insert into 员工信息表 values(\'管理员\',\'lihao\',\'123456\')";
            string sql = "insert into 员工信息表 values(\'" + lei + "\',\'" + username + "\',\'"+password+"\')";
         //   MessageBox.Show(sqls);
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            SqlCommand sqlman = new SqlCommand(sql, conn);
            sqlman.ExecuteNonQuery();
            MessageBox.Show("注册成功");
            this.Close();
        }
        /*string sql = "select * from 顾客信息表";
        SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
        DataTable dt = new DataTable();
        myda.Fill(dt);
        da1.ItemsSource = dt.DefaultView;*/
    }
}

 

 C#界面程序窗口二源码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
namespace WpfApp2
{
    /// <summary>
    /// Window2.xaml 的交互逻辑
    /// </summary>
    public partial class Window2 : Window
    {
        public Window2()
        {
            InitializeComponent();
        }
        string SqlConnectionStatement = "server=localhost;database=QT+SQL酒店master;Trusted_Connection=SSPI";
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string sql = "select * from 空房查询";
            SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            myda.Fill(dt);
            da1.ItemsSource = dt.DefaultView;
        }

        private void b2_Click(object sender, RoutedEventArgs e)
        {
            Window4 isw = new Window4();
            isw.Show();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Window3 isw = new Window3();
            isw.Show();
        }

        private void b4_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string sql = "select * from 顾客订房信息查询";
            SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            myda.Fill(dt);
            da1.ItemsSource = dt.DefaultView;
        }

        private void da1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void b3_Click(object sender, RoutedEventArgs e)
        {
            Window5 isw = new Window5();
            isw.Show();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string sql = "select * from 房间列表";
            SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            myda.Fill(dt);
            da1.ItemsSource = dt.DefaultView;
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string sql = "select * from 顾客信息表";
            SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            myda.Fill(dt);
            da1.ItemsSource = dt.DefaultView;
        }

        private void nb2_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string sql = "select * from 负责人任务列表";
            SqlDataAdapter myda = new SqlDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            myda.Fill(dt);
            da1.ItemsSource = dt.DefaultView;
        }

        private void nb1_Click(object sender, RoutedEventArgs e)
        {
            Window6 isw = new Window6();
            isw.Show();
        }

        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            Window7 isw = new Window7();
            isw.Show();
        }
    }
}

 

 C#界面程序窗口三源码: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
namespace WpfApp2
{
    /// <summary>
    /// Window3.xaml 的交互逻辑
    /// </summary>
    public partial class Window3 : Window
    {
        public Window3()
        {
            InitializeComponent();
        }
        string SqlConnectionStatement = "server=localhost;database=QT+SQL酒店master;Trusted_Connection=SSPI";
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string id;
            string name;
            string sex;
            string age;
            string phone;
            id = t1.Text;
            name = t2.Text;
            sex = t3.Text;
            age = t4.Text;
            phone = t5.Text;
            // string sqls = "insert into 员工信息表 values(\'管理员\',\'lihao\',\'123456\')";
            string sql = "insert into 顾客信息表 values(\'" + id + "\',\'" + name + "\',\'" + sex  + "\'," + age + ",\'"+phone+"\',"+"100"+")";
            //MessageBox.Show(sql);
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            SqlCommand sqlman = new SqlCommand(sql, conn);
            sqlman.ExecuteNonQuery();
            MessageBox.Show("注册成功");
            this.Close();
        }
    }
}

 

 C#界面程序窗口四源码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
namespace WpfApp2
{
    /// <summary>
    /// Window3.xaml 的交互逻辑
    /// </summary>
    public partial class Window4 : Window
    {
        public Window4()
        {
            InitializeComponent();
        }
        string SqlConnectionStatement = "server=localhost;database=QT+SQL酒店master;Trusted_Connection=SSPI";
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection conn = new SqlConnection(SqlConnectionStatement);
            conn.Open();
            string id;
            string starttime;
            string endtime;
            int biaohao;
            int room;
            id = t1.Text;
            starttime= t2.Text; 
            endtime= t3.Text;
            string sql = "select * from 顾客信息表 where 身份证号=" + "\'" + id  + "\'";
           // MessageBox.Show(sql);
            
           
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataReader res = cmd.ExecuteReader();//执行SQL语句,并返回一个结果集
                if (res.Read())
                {
                    Random rd = new Random();
                    biaohao = rd.Next();
                    string sqlss1 = "select * from 房间信息表 where 房间状态=0 and 房间类别=\'总统套房\'";
                    string sqlss2 = "select * from 房间信息表 where 房间状态=0 and 房间类别=\'垃圾房\'";
                  //  MessageBox.Show(sqlss1);
                  //  MessageBox.Show(sqlss2);
                    if (b1.IsChecked == true)
                    {
                        SqlCommand cmdd = new SqlCommand(sqlss1, conn);
                     
                       
                    
                    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#使用dll控件教程发布时间:2022-07-10
下一篇:
[C#]日志管理软件 WorkLog V1.10 - LeeWenjie发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap