⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 roomstatusform.cs

📁 一个很好的宾馆管理系统 VC++和SQL做的
💻 CS
字号:
//文件名:RoomStatusForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace MyHotel
{
    public partial class RoomStatusForm : Form
    {
        public RoomStatusForm()
        {
            InitializeComponent();
        }

        private void RoomStatusForm_Load(object sender, EventArgs e)
        {
            //获取酒店客房入住信息
            String MySQLConnectionString = global::MyHotel.Properties.Settings.Default.MyHotelConnectionString;
            string MySQL = "Select 房号,已入住人数,楼层,单价,类别,可容纳人数,说明 From 酒店房间 ";
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            DataTable MyRoomTable = new DataTable();
            SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
            MyAdapter.Fill(MyRoomTable);
            this.酒店客房入住图DataGridView.DataSource = MyRoomTable;
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }

        private void 酒店客房入住图DataGridView_SelectionChanged(object sender, EventArgs e)
        {
            string My房号 = this.酒店客房入住图DataGridView.CurrentRow.Cells[0].Value.ToString();
            //获取选择的酒店客房入住旅客信息
            String MySQLConnectionString = global::MyHotel.Properties.Settings.Default.MyHotelConnectionString;
            string MySQL = "Select 入住编号,客人姓名,住宿人数,联系电话,客人性别,房号,折扣价格,预收押金,入住日期,离开日期,证件名称,证件号码,证件地址,操作人员,说明 From 客房入住单 Where 房号='" + My房号 + "' AND 入住编号 NOT IN (Select 入住编号 From 客房结帐单)";
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            DataTable MyRoomTable = new DataTable();
            SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
            MyAdapter.Fill(MyRoomTable);
            this.酒店客房旅客信息DataGridView.DataSource = MyRoomTable;
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }

        private void 酒店客房入住图DataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == this.酒店客房旅客信息DataGridView.Columns[1].Index)
            {
                try
                {
                    if (((int)e.Value) > 0)
                    {
                        e.CellStyle.BackColor = Color.Red;
                        e.CellStyle.SelectionBackColor = Color.Black;
                        e.CellStyle.SelectionForeColor = Color.Yellow;
                        e.CellStyle.ForeColor = Color.White;
                    }
                }
                catch
                {
                }
            }    

       }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -