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

📄 checkoutform.cs

📁 一个很好的宾馆管理系统 VC++和SQL做的
💻 CS
📖 第 1 页 / 共 2 页
字号:
            旅客姓名ComboBox_SelectedIndexChanged(null, null);
        }

        private void 打印Button_Click(object sender, EventArgs e)
        {
            if (this.旅客姓名ComboBox.Text.Length < 1||this.费用总额TextBox.Text=="0" )
            {
                return;
            }
            if (MessageBox.Show("当您为旅客打印结帐单后,您必须保存该项操作,是否继续?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            this.printPreviewDialog1.Document = this.printDocument1;
            this.printPreviewDialog1.ShowDialog();
            this.结帐金额TextBox.Enabled = false;
        }

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            double MyAmount = this.My费用总额 - Convert.ToDouble(this.预收押金TextBox.Text);
            string MyAmountInfo="实收金额:"+MyAmount.ToString();
            if (MyAmount < 0)
            {
                MyAmountInfo = "实补金额:" + MyAmount.ToString().Remove(0,1);
            }
            //打印旅客结帐单
            e.Graphics.DrawString(this.MyCompany + "旅客结帐单", new Font("宋体", 20), Brushes.Black, 220, 80);
            e.Graphics.DrawString("结帐编号:" + this.My结帐编号, new Font("宋体", 12), Brushes.Black, 100, 150);
            e.Graphics.DrawString("操作员:" + this.MyOperator, new Font("宋体", 12), Brushes.Black, 600, 150);

            e.Graphics.DrawLine(new Pen(Color.Black, (float)3.00), 100, 185, 720, 185);

            e.Graphics.DrawString("房号:" + this.酒店房号ComboBox.Text, new Font("宋体", 12), Brushes.Black, 110, 195);
            e.Graphics.DrawString("姓名:" + this.旅客姓名ComboBox.Text, new Font("宋体", 12), Brushes.Black, 300, 195);
            e.Graphics.DrawString("入住编号:" + this.My入住编号, new Font("宋体", 12), Brushes.Black, 500, 195);
           
            e.Graphics.DrawLine(new Pen(Color.Black), 100, 215, 720, 215);
            e.Graphics.DrawString("         序号          费用类别           金额", new Font("宋体", 12), Brushes.Black, 110, 220);
            e.Graphics.DrawLine(new Pen(Color.Black), 100, 240, 720, 240);
            e.Graphics.DrawString("           1     店内消费               " + this.My店内消费.ToString(), new Font("宋体", 12), Brushes.Black, 110, 245);
            e.Graphics.DrawString("           2     住宿费                " + this.My住宿费.ToString(), new Font("宋体", 12), Brushes.Black, 110, 265);
            e.Graphics.DrawString("           3     电话费                " + this.My电话费.ToString(), new Font("宋体", 12), Brushes.Black, 110, 285);
            e.Graphics.DrawString("           4     用餐费                " + this.My用餐费.ToString(), new Font("宋体", 12), Brushes.Black, 110, 305);
            e.Graphics.DrawLine(new Pen(Color.Black), 100, 325, 720, 325);
            e.Graphics.DrawString("                                     费用金额合计:" + this.My费用总额.ToString(), new Font("宋体", 12), Brushes.Black, 110, 330);
            
            e.Graphics.DrawLine(new Pen(Color.Black), 100, 350, 720, 350);
            e.Graphics.DrawString("入住日期:" + this.My入住日期.ToLongDateString()+"                 结帐日期:"+this.My结帐日期.ToLongDateString(), new Font("宋体", 12), Brushes.Black, 110, 355);
            e.Graphics.DrawLine(new Pen(Color.Black), 100, 375, 720, 375);
            e.Graphics.DrawString("预收押金:" + this.预收押金TextBox.Text + "                           " + MyAmountInfo, new Font("宋体", 12), Brushes.Black, 110, 380);         

            e.Graphics.DrawLine(new Pen(Color.Black, (float)3.00), 100, 400, 720, 400);
            DateTime MyDate = DateTime.Now;
            e.Graphics.DrawString("打印日期:" + MyDate.ToLongDateString() + MyDate.ToLongTimeString(), new Font("宋体", 12), Brushes.Black, 450, 405);
            e.Graphics.DrawString("温馨提示:为了维护您及他人的合法权益,请不要带未经登记的人员进出您的房间。", new Font("宋体", 12), Brushes.Black, 100, 425);
            e.Graphics.DrawString("警察提示:请保管好您的物品,重要物品请寄存于酒店寄存处,免费寄存!", new Font("宋体", 12), Brushes.Black, 100, 445);
            e.Graphics.DrawString("谢谢合作!", new Font("宋体", 20), Brushes.Black, 550, 465);
        }

        private void 保存Button_Click(object sender, EventArgs e)
        {
            String MySQLConnectionString = global::MyHotel.Properties.Settings.Default.MyHotelConnectionString;
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            string MySQL = "Select Count(*) From 客房结帐单 Where 入住编号='" + this.My入住编号 + "'";
            SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
            int MyCount = (int)MyCommand.ExecuteScalar();
            if (MyCount > 0)
            {
                if (MyConnection.State == ConnectionState.Open)
                {
                    MyConnection.Close();
                }
                return;
            }

            //自动计算自编号            
            MyCommand.CommandText = "Select max(自编号) 最大编号 From 客房结帐单";
            object MyResult = MyCommand.ExecuteScalar();
            Int64 MyID = 1;
            if (MyResult != System.DBNull.Value)
            {
                String MyMaxID = MyResult.ToString().Trim();
                MyMaxID = MyMaxID.Substring(2, MyMaxID.Length - 2);
                MyID = Convert.ToInt64(MyMaxID) + 1;
            }
            int MyLength = MyID.ToString().Length;
            string MyNewID = "";
            switch (MyLength)
            {
                case 1:
                    MyNewID = "JZ0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "JZ000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "JZ00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "JZ0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "JZ000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "JZ00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "JZ0" + MyID.ToString();
                    break;
            }
            String My自编号= MyNewID;

            MySQL = "INSERT INTO [客房结帐单] ([自编号],[入住编号],[结帐编号], [房号], [客人姓名], [入住日期], [结帐日期], [店内消费], [住宿费], [电话费], [用餐费], [预收押金], [结帐金额], [操作人员],[说明]) VALUES (@自编号,@入住编号,@结帐编号, @房号, @客人姓名, @入住日期, @结帐日期, @店内消费, @住宿费, @电话费, @用餐费, @预收押金, @结帐金额, @操作人员,@说明)";
            MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            MyCommand = MyConnection.CreateCommand();
            MyCommand.CommandText = MySQL;
            MyCommand.Parameters.Add(new SqlParameter("@自编号", SqlDbType.VarChar));
            MyCommand.Parameters.Add(new SqlParameter("@入住编号", SqlDbType.VarChar));
            MyCommand.Parameters.Add(new SqlParameter("@结帐编号", SqlDbType.VarChar));
            MyCommand.Parameters.Add(new SqlParameter("@房号", SqlDbType.VarChar));
            MyCommand.Parameters.Add(new SqlParameter("@客人姓名", SqlDbType.VarChar));
            MyCommand.Parameters.Add(new SqlParameter("@入住日期", SqlDbType.DateTime));
            MyCommand.Parameters.Add(new SqlParameter("@结帐日期", SqlDbType.DateTime));
            MyCommand.Parameters.Add(new SqlParameter("@店内消费", SqlDbType.Float));
            MyCommand.Parameters.Add(new SqlParameter("@住宿费", SqlDbType.Float));
            MyCommand.Parameters.Add(new SqlParameter("@电话费", SqlDbType.Float));
            MyCommand.Parameters.Add(new SqlParameter("@用餐费", SqlDbType.Float));
            MyCommand.Parameters.Add(new SqlParameter("@预收押金", SqlDbType.Float));
            MyCommand.Parameters.Add(new SqlParameter("@结帐金额", SqlDbType.Float));            
            MyCommand.Parameters.Add(new SqlParameter("@操作人员", SqlDbType.VarChar));
            MyCommand.Parameters.Add(new SqlParameter("@说明", SqlDbType.VarChar));

            MyCommand.Parameters["@自编号"].Value = My自编号;
            MyCommand.Parameters["@入住编号"].Value = this.My入住编号;
            MyCommand.Parameters["@结帐编号"].Value = this.My结帐编号;
            MyCommand.Parameters["@房号"].Value = this.酒店房号ComboBox.Text;
            MyCommand.Parameters["@客人姓名"].Value = this.旅客姓名ComboBox.Text;
            MyCommand.Parameters["@入住日期"].Value = this.My入住日期;
            MyCommand.Parameters["@结帐日期"].Value = this.My结帐日期;
            MyCommand.Parameters["@店内消费"].Value = this.My店内消费;
            MyCommand.Parameters["@住宿费"].Value = this.My住宿费;
            MyCommand.Parameters["@电话费"].Value = this.My电话费;
            MyCommand.Parameters["@用餐费"].Value = this.My用餐费 ;
            MyCommand.Parameters["@预收押金"].Value = this.My预收押金;
            MyCommand.Parameters["@结帐金额"].Value = this.My结帐金额;
            MyCommand.Parameters["@操作人员"].Value = this.MyOperator;
            MyCommand.Parameters["@说明"].Value = this.说明TextBox.Text;
            MyCommand.ExecuteNonQuery();
            MySQL = "Update 酒店房间 Set 已入住人数=已入住人数-" + this.My住宿人数.ToString() + " WHERE 房号='" + this.酒店房号ComboBox.Text + "'";
            MyCommand.CommandText = MySQL;
            MyCommand.ExecuteNonQuery();
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
            旅客姓名ComboBox_SelectedIndexChanged(null, null);
        }
    }
}

⌨️ 快捷键说明

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