基本信息
源码名称:C# 酒店管理系统源码(含数据库以及PPT)winform
源码大小:5.91M
文件格式:.zip
开发语言:C#
更新时间:2018-07-04
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

一个winform做的酒店管理系统,附加数据库后 ,可直接运行该实例

实现了 酒店预订/入住/宾客登记/换房/退房 等功能

管理员登陆账号:admin 密码:123









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;
using System.Text.RegularExpressions;

namespace HotelManager
{
    public partial class FrmHotelVip : Form
    {
        public FrmHotelVip()
        {
            InitializeComponent();
        }
        int i = 1;
        string str1 = "^\\d{11}$";
        private void FrmHotelVip_Load(object sender, EventArgs e)
        {
            this.cbSex.Text = "男";
            this.cbCard.Text = "白金会员";
            this.cbyeshu.Text = "1";
            
            
            //将数据库中的列名在dataGridView中用文字写出来
            SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
            con.Open();


            //分页 显示第一页的信息



            DataSet ds = new DataSet();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "page";
            cmd.Parameters.Add("@current", SqlDbType.Int).Value = i;
            cmd.Parameters.Add("@rowcount", SqlDbType.Int).Value = 3;
            cmd.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = "Vip";
            cmd.Parameters.Add("@columname", SqlDbType.NVarChar, 20).Value = "V_ID";
            SqlParameter p = new SqlParameter();
            p.ParameterName = "@totalpage";
            p.Direction = ParameterDirection.Output;
            p.SqlDbType = SqlDbType.Int;
            cmd.Parameters.Add(p);
            cmd.Connection = con;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;

            da.Fill(ds, "Vip");

            dataGridView1.Columns.Add("V_ID", "编号");
            dataGridView1.Columns[0].DataPropertyName = "V_ID";
            dataGridView1.Columns.Add("V_name", "姓名");
            dataGridView1.Columns[1].DataPropertyName = "V_name";
            dataGridView1.Columns.Add("V_sex", "性别");
            dataGridView1.Columns[2].DataPropertyName = "V_sex";
            dataGridView1.Columns.Add("V_phone", "电话号码");
            dataGridView1.Columns[3].DataPropertyName = "V_phone";
            dataGridView1.Columns.Add("V_cardid", "身份证号码");
            dataGridView1.Columns[4].DataPropertyName = "V_cardid";
            dataGridView1.Columns.Add("V_card", "Vip类型");
            dataGridView1.Columns[5].DataPropertyName = "V_card";
            
            dataGridView1.Columns.Add("V_notes", "备注");
            dataGridView1.Columns[6].DataPropertyName = "V_notes";

            dataGridView1.DataSource = ds.Tables[0];
            int j = 1;
            while (j <= int.Parse(p.Value.ToString()))
            {
                this.cbyeshu.Items.Add(j);
                j  ;
            }

            this.cbyeshu.Text = i.ToString();
            this.lbgong.Text = p.SqlValue.ToString();

            string sr = "select max(V_ID) from Vip";
            SqlCommand cmd1 = new SqlCommand(sr,con);
            int id = int.Parse(cmd1.ExecuteScalar().ToString());
            tbId.Text = Convert.ToString(id   1);

        }
        public void yanz()
        {
            Regex rg = new Regex("\\W");

            if (!rg.IsMatch(tbName.Text.ToString()))
            {
                MessageBox.Show("不能为空");
                return;
            }
            

        }
        //添加按钮
        private void bt_Add_Click_1(object sender, EventArgs e)
        {
            
            if (this.tbName.Text != "")
            {
                if (this.tbPhone.Text != "")
                {
                    try
                    {
                        if (this.tbCardid.Text != "")
                        {
                            if (this.cbCard.Text != "")
                            {
                               
                                    if (!Regex.IsMatch(tbPhone.Text, str1))
                                    {
                                        MessageBox.Show("电话号码应该输入11位数字");
                                    }
                                    SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                                    con.Open();
                                    string str = string.Format("insert into Vip values(@name,@sex,@phone,@cardid,@card,@notes)");
                                    SqlCommand com = new SqlCommand(str, con);

                                    com.Parameters.Add("@name", SqlDbType.NVarChar, 20).Value = this.tbName.Text.Trim();
                                    com.Parameters.Add("@sex", SqlDbType.NChar, 2).Value = this.cbSex.SelectedItem.ToString();
                                    com.Parameters.Add("@phone", SqlDbType.NChar, 11).Value = this.tbPhone.Text.Trim();
                                    com.Parameters.Add("@cardid", SqlDbType.NVarChar, 18).Value = this.tbCardid.Text.Trim();
                                    com.Parameters.Add("@card", SqlDbType.NVarChar, 20).Value = this.cbCard.Text.Trim();
                                  
                                    com.Parameters.Add("@notes", SqlDbType.NVarChar, 100).Value = this.tbNotes.Text.Trim();

                                    int row = com.ExecuteNonQuery();
                                    if (row > 0)
                                    {
                                        this.tbId.Text = "";
                                        this.tbName.Text = "";
                                        this.cbSex.Text = "";
                                        this.tbPhone.Text = "";
                                        this.tbCardid.Text = "";
                                        this.cbCard.Text = "";
                                       
                                        this.tbNotes.Text = "";
                                        MessageBox.Show("恭喜,增加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                        FrmHotelVip_Load(sender, e);
                                    }

                                
                            }
                            else
                            {
                                MessageBox.Show("类型不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                this.cbCard.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("身份证号不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            this.tbCardid.Focus();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("输入有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        this.tbPhone.Text = "";
                        this.tbCardid.Text = "";
                    }

                }
                else
                {
                    MessageBox.Show("电话号码不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.tbPhone.Focus();
                }

            }
            else
            {
                MessageBox.Show("名字不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.tbName.Focus();
            }
           
            this.dataGridView1.Columns.Clear();
            FrmHotelVip_Load(sender, e);
            

        }
        //删除按钮
        private void bt_Delete_Click_1(object sender, EventArgs e)
        {
            if (this.tbId.Text == "")
            {
                MessageBox.Show("你没有选中,请选择!!");
                return;
            }
            else
            {
                DialogResult dia = MessageBox.Show("删除信息!!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                if (dia == DialogResult.Yes)
                {

                    SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                    con.Open();
                    
                    string sql = "delete from Vip where V_ID=@ID";
                    SqlCommand cmd = new SqlCommand(sql, con);
                    cmd.Parameters.Add("@ID", SqlDbType.Int).Value = int.Parse(this.tbId.Text);
                    int row = cmd.ExecuteNonQuery();
                    if (row > 0)
                    {
                        MessageBox.Show("删除成功!!!");

                        this.tbId.Text = "";
                        this.tbName.Text = "";
                        this.cbSex.Text = "";
                        this.tbPhone.Text = "";
                        this.tbCardid.Text = "";
                        this.cbCard.Text = "";
                       
                        this.tbNotes.Text = "";
                        MessageBox.Show("你已经删除了一个会员!!!");

                        
                        this.dataGridView1.Columns.Clear();
                        FrmHotelVip_Load(sender, e);

                        
                    }
                    else
                    {
                        MessageBox.Show("删除失败!!");
                        return;
                    }
                   
                }
                
            }
            
        }
        //修改按钮
        private void bt_Update_Click_1(object sender, EventArgs e)
        {

            if (this.tbName.Text != "")
            {

                if (this.tbPhone.Text != "")
                {
                    try
                    {
                        if (this.tbCardid.Text != "")
                        {
                            if (this.cbCard.Text != "")
                            {

                                if (!Regex.IsMatch(tbPhone.Text, str1))
                                {
                                    MessageBox.Show("电话号码应该输入11位数字");
                                }
                                SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                                con.Open();
                                string sql = "update Vip set V_name=@name ,V_sex=@sex,V_phone=@phone,V_cardid=@cardid,V_card=@card,V_notes=@notes where V_ID=@ID ";
                                SqlCommand com = new SqlCommand(sql, con);
                                com.Parameters.Add("@name", SqlDbType.NVarChar, 20).Value = this.tbName.Text.Trim();
                                com.Parameters.Add("@sex", SqlDbType.NChar, 2).Value = this.cbSex.Text.ToString();
                                com.Parameters.Add("@phone", SqlDbType.NChar, 11).Value = this.tbPhone.Text.Trim();
                                com.Parameters.Add("@cardid", SqlDbType.NVarChar, 18).Value = this.tbCardid.Text.Trim();
                                com.Parameters.Add("@card", SqlDbType.NVarChar, 20).Value = this.cbCard.Text.Trim();
                               
                                com.Parameters.Add("@notes", SqlDbType.NVarChar, 100).Value = this.tbNotes.Text.Trim();
                                com.Parameters.Add("@ID", SqlDbType.Int).Value = int.Parse(this.tbId.Text);

                                int row = com.ExecuteNonQuery();
                                if (row > 0)
                                {
                                    MessageBox.Show("修改成功!!!");

                                }



                            }
                            else
                            {
                                MessageBox.Show("类型不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                this.cbCard.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("身份证号不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            this.tbCardid.Focus();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("输入有误,请检查后重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    }
                }
                else
                {
                    MessageBox.Show("电话号码不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.tbPhone.Focus();
                }

            }
            else
            {
                MessageBox.Show("名字不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.tbName.Focus();
            }



            this.dataGridView1.Columns.Clear();
            FrmHotelVip_Load(sender, e);


        }
        //退出按钮
        private void button10_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }
        //dataGridView1控件的单击事件
        private void dataGridView1_Click_1(object sender, EventArgs e)
        {

            SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
            con.Open();
            StringBuilder str = new StringBuilder();
            str.Append("select * from Vip ");

            SqlDataAdapter da = new SqlDataAdapter(str.ToString(), con);
            DataSet ds = new DataSet();
            da.Fill(ds, "Vip");
            //dataGridView1.DataSource = ds.Tables[0];
            
            DataGridViewRow stRow = dataGridView1.SelectedRows[0];
            this.tbId.Text = stRow.Cells[0].Value.ToString();
            this.tbName.Text = stRow.Cells[1].Value.ToString();
            this.cbSex.Text = stRow.Cells[2].Value.ToString();
            this.tbPhone.Text = stRow.Cells[3].Value.ToString();
            this.tbCardid.Text = stRow.Cells[4].Value.ToString();
            this.cbCard.Text = stRow.Cells[5].Value.ToString();
            
            this.tbNotes.Text = stRow.Cells[6].Value.ToString();
        }
        //查询按钮
        private void bt_Select_Click_1(object sender, EventArgs e)
        {
            if (tbmingzi.Text == "")
            {
                MessageBox.Show("不能为空!!!");
            }
            else
            {
                SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                con.Open();
                string str = string.Format("select * from Vip where V_name like '{0}%'", this.tbmingzi.Text.Trim().ToString());

                SqlDataAdapter sda = new SqlDataAdapter(str, con);
                DataSet ds = new DataSet();
                sda.Fill(ds, "Vip");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    dataGridView1.DataSource = ds.Tables[0];
                }
                else
                {
                    MessageBox.Show("没有此人,请查证后再查询!!");
                }
                this.tbId.Text = "";
                this.tbName.Text = "";
              
                this.tbPhone.Text = "";
                this.tbCardid.Text = "";
                
               
                this.tbNotes.Text = "";
               
                
            }

        }
        //首页按钮
        private void bt_One_Click_1(object sender, EventArgs e)
        {
            int r = 1;
            if (this.cbyeshu.Text == r.ToString())
            {
                MessageBox.Show("这就是第一页!!");
            }
            else
            {
                this.dataGridView1.Columns.Clear();
                SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                con.Open();
                DataSet ds3 = new DataSet();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "page";
                cmd.Parameters.Add("@current", SqlDbType.Int).Value = 1;
                cmd.Parameters.Add("@rowcount", SqlDbType.Int).Value = 3;
                cmd.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = "Vip";
                cmd.Parameters.Add("@columname", SqlDbType.NVarChar, 20).Value = "V_ID";
                SqlParameter p = new SqlParameter();
                p.ParameterName = "@totalpage";
                p.Direction = ParameterDirection.Output;
                p.SqlDbType = SqlDbType.Int;
                cmd.Parameters.Add(p);
                cmd.Connection = con;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                da.Fill(ds3, "Vip");

                dataGridView1.Columns.Add("V_ID", "编号");
                dataGridView1.Columns[0].DataPropertyName = "V_ID";
                dataGridView1.Columns.Add("V_name", "姓名");
                dataGridView1.Columns[1].DataPropertyName = "V_name";
                dataGridView1.Columns.Add("V_sex", "性别");
                dataGridView1.Columns[2].DataPropertyName = "V_sex";
                dataGridView1.Columns.Add("V_phone", "电话号码");
                dataGridView1.Columns[3].DataPropertyName = "V_phone";
                dataGridView1.Columns.Add("V_cardid", "身份证号码");
                dataGridView1.Columns[4].DataPropertyName = "V_cardid";
                dataGridView1.Columns.Add("V_card", "Vip类型");
                dataGridView1.Columns[5].DataPropertyName = "V_card";
               
                dataGridView1.Columns.Add("V_notes", "备注");
                dataGridView1.Columns[6].DataPropertyName = "V_notes";

                dataGridView1.DataSource = ds3.Tables["Vip"];

                int q = 1;
                this.cbyeshu.Text = q.ToString();
                i = int.Parse(this.cbyeshu.Text);
            }

        }
        //上一页按钮
        private void bt_Shang_Click_1(object sender, EventArgs e)
        {
            if (i != 1)
            {
                i--;
            
                dataGridView1.Columns.Clear();
                SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                con.Open();
                DataSet ds2 = new DataSet();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "page";
                cmd.Parameters.Add("@current", SqlDbType.Int).Value = i;
                cmd.Parameters.Add("@rowcount", SqlDbType.Int).Value = 3;
                cmd.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = "Vip";
                cmd.Parameters.Add("@columname", SqlDbType.NVarChar, 20).Value = "V_ID";
                SqlParameter p = new SqlParameter();
                p.ParameterName = "@totalpage";
                p.Direction = ParameterDirection.Output;
                p.SqlDbType = SqlDbType.Int;
                cmd.Parameters.Add(p);
                cmd.Connection = con;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                da.Fill(ds2, "Vip");

                dataGridView1.Columns.Add("V_ID", "编号");
                dataGridView1.Columns[0].DataPropertyName = "V_ID";
                dataGridView1.Columns.Add("V_name", "姓名");
                dataGridView1.Columns[1].DataPropertyName = "V_name";
                dataGridView1.Columns.Add("V_sex", "性别");
                dataGridView1.Columns[2].DataPropertyName = "V_sex";
                dataGridView1.Columns.Add("V_phone", "电话号码");
                dataGridView1.Columns[3].DataPropertyName = "V_phone";
                dataGridView1.Columns.Add("V_cardid", "身份证号码");
                dataGridView1.Columns[4].DataPropertyName = "V_cardid";
                dataGridView1.Columns.Add("V_card", "Vip类型");
                dataGridView1.Columns[5].DataPropertyName = "V_card";
              
                dataGridView1.Columns.Add("V_notes", "备注");
                dataGridView1.Columns[6].DataPropertyName = "V_notes";

                dataGridView1.DataSource = ds2.Tables["Vip"];


                this.cbyeshu.Text = i.ToString();
            }
            else 
            {
                MessageBox.Show("已经是第一页了!!");
                return;
            }

        }
        //下一页按钮
        private void bt_Xia_Click_1(object sender, EventArgs e)
        {

            if (int.Parse(this.cbyeshu.Text) != int.Parse(this.lbgong.Text))
            {
                i  ;
                dataGridView1.Columns.Clear();
                SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                con.Open();
                DataSet ds1 = new DataSet();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "page";
                cmd.Parameters.Add("@current", SqlDbType.Int).Value = i;
                cmd.Parameters.Add("@rowcount", SqlDbType.Int).Value = 3;
                cmd.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = "Vip";
                cmd.Parameters.Add("@columname", SqlDbType.NVarChar, 20).Value = "V_ID";
                SqlParameter p = new SqlParameter();
                p.ParameterName = "@totalpage";
                p.Direction = ParameterDirection.Output;
                p.SqlDbType = SqlDbType.Int;
                cmd.Parameters.Add(p);
                cmd.Connection = con;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                da.Fill(ds1, "Vip");

                dataGridView1.Columns.Add("V_ID", "编号");
                dataGridView1.Columns[0].DataPropertyName = "V_ID";
                dataGridView1.Columns.Add("V_name", "姓名");
                dataGridView1.Columns[1].DataPropertyName = "V_name";
                dataGridView1.Columns.Add("V_sex", "性别");
                dataGridView1.Columns[2].DataPropertyName = "V_sex";
                dataGridView1.Columns.Add("V_phone", "电话号码");
                dataGridView1.Columns[3].DataPropertyName = "V_phone";
                dataGridView1.Columns.Add("V_cardid", "身份证号码");
                dataGridView1.Columns[4].DataPropertyName = "V_cardid";
                dataGridView1.Columns.Add("V_card", "Vip类型");
                dataGridView1.Columns[5].DataPropertyName = "V_card";
              
                dataGridView1.Columns.Add("V_notes", "备注");
                dataGridView1.Columns[6].DataPropertyName = "V_notes";

                dataGridView1.DataSource = ds1.Tables["Vip"];



                this.cbyeshu.Text = i.ToString();


            }
            else 
            {
                MessageBox.Show("这已经是最后一页了!!");
                return;
            }
        }
        //尾页按钮
        private void bt_Wei_Click_1(object sender, EventArgs e)
        {
            if (this.cbyeshu.Text == this.lbgong.Text)
            {
                MessageBox.Show("这就是最后一页!!");

            }
            else
            {
                this.dataGridView1.Columns.Clear();
                SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
                con.Open();
                DataSet ds3 = new DataSet();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "page";
                cmd.Parameters.Add("@current", SqlDbType.Int).Value = this.lbgong.Text;
                cmd.Parameters.Add("@rowcount", SqlDbType.Int).Value = 3;
                cmd.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = "Vip";
                cmd.Parameters.Add("@columname", SqlDbType.NVarChar, 20).Value = "V_ID";
                SqlParameter p = new SqlParameter();
                p.ParameterName = "@totalpage";
                p.Direction = ParameterDirection.Output;
                p.SqlDbType = SqlDbType.Int;
                cmd.Parameters.Add(p);
                cmd.Connection = con;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                da.Fill(ds3, "Vip");

                dataGridView1.Columns.Add("V_ID", "编号");
                dataGridView1.Columns[0].DataPropertyName = "V_ID";
                dataGridView1.Columns.Add("V_name", "姓名");
                dataGridView1.Columns[1].DataPropertyName = "V_name";
                dataGridView1.Columns.Add("V_sex", "性别");
                dataGridView1.Columns[2].DataPropertyName = "V_sex";
                dataGridView1.Columns.Add("V_phone", "电话号码");
                dataGridView1.Columns[3].DataPropertyName = "V_phone";
                dataGridView1.Columns.Add("V_cardid", "身份证号码");
                dataGridView1.Columns[4].DataPropertyName = "V_cardid";
                dataGridView1.Columns.Add("V_card", "Vip类型");
                dataGridView1.Columns[5].DataPropertyName = "V_card";
               
                dataGridView1.Columns.Add("V_notes", "备注");
                dataGridView1.Columns[6].DataPropertyName = "V_notes";

                dataGridView1.DataSource = ds3.Tables["Vip"];


                this.cbyeshu.Text = p.Value.ToString();
                i = int.Parse(this.cbyeshu.Text);

            }
        }
        //cbyeshu控件的SelectionChangeCommitted_1事件
        private void cbyeshu_SelectionChangeCommitted_1(object sender, EventArgs e)
        {
            this.dataGridView1.Columns.Clear();
            int r = int.Parse(cbyeshu.SelectedItem.ToString());
            SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
            con.Open();
            DataSet ds3 = new DataSet();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "page";
            cmd.Parameters.Add("@current", SqlDbType.Int).Value = r;
            cmd.Parameters.Add("@rowcount", SqlDbType.Int).Value = 3;
            cmd.Parameters.Add("@tablename", SqlDbType.NVarChar, 20).Value = "Vip";
            cmd.Parameters.Add("@columname", SqlDbType.NVarChar, 20).Value = "V_ID";
            SqlParameter p = new SqlParameter();
            p.ParameterName = "@totalpage";
            p.Direction = ParameterDirection.Output;
            p.SqlDbType = SqlDbType.Int;
            cmd.Parameters.Add(p);
            cmd.Connection = con;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;

            da.Fill(ds3, "Vip");

            dataGridView1.Columns.Add("V_ID", "编号");
            dataGridView1.Columns[0].DataPropertyName = "V_ID";
            dataGridView1.Columns.Add("V_name", "姓名");
            dataGridView1.Columns[1].DataPropertyName = "V_name";
            dataGridView1.Columns.Add("V_sex", "性别");
            dataGridView1.Columns[2].DataPropertyName = "V_sex";
            dataGridView1.Columns.Add("V_phone", "电话号码");
            dataGridView1.Columns[3].DataPropertyName = "V_phone";
            dataGridView1.Columns.Add("V_cardid", "身份证号码");
            dataGridView1.Columns[4].DataPropertyName = "V_cardid";
            dataGridView1.Columns.Add("V_card", "Vip类型");
            dataGridView1.Columns[5].DataPropertyName = "V_card";
           
            dataGridView1.Columns.Add("V_notes", "备注");
            dataGridView1.Columns[6].DataPropertyName = "V_notes";



            dataGridView1.DataSource = ds3.Tables["Vip"];
       
            try
            {
                r = 3 * (Convert.ToInt32(this.cbyeshu.Text.Trim()) - 1);
                i = Convert.ToInt32(this.cbyeshu.Text.Trim());
            }
            catch
            {
                cbyeshu.Focus();
            }
        
        }

       

        private void button1_Click(object sender, EventArgs e)
        {

            SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Hotel;Integrated Security=True");
            con.Open();

            this.tbId.Text = "";
            

            string sr = "select max(V_ID) from Vip";
            SqlCommand cmd1 = new SqlCommand(sr, con);
            int id = int.Parse(cmd1.ExecuteScalar().ToString());
            this.tbId.Text = Convert.ToString(id   1);


            this.tbName.Text = "";
            this.tbPhone.Text = "";
            this.tbCardid.Text = "";
            this.cbCard.Text = "";
       
            this.tbNotes.Text = "";
        }
    }
}