实现模拟考试的答案

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 客房信息
{
    public partial class Form2 : Form
    {
        DataSet ds = new DataSet();
        SqlDataAdapter adapter = new SqlDataAdapter();
        string str = "Data Source=.;Initial Catalog=HotelDB;Integrated Security=True";
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            cha();
        }
       
        public void show()
        {
            string sql = @"SELECT 
      [Number],[Beds] ,[Price],[Remark]
FROM [HotelDB].[dbo].[Room]";
            SqlConnection conn = new SqlConnection(str);
            try
            {
                if (ds.Tables["room"] != null)
                {
                    ds.Tables["room"].Clear();
                }

                conn.Open();
                //SqlCommand comm = new SqlCommand(sql,conn);
                adapter = new SqlDataAdapter(sql, conn);
                adapter.Fill(ds, "room");
                this.dataGridView1.DataSource = ds.Tables["room"];
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
            finally
            {

            }
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            show();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public void cha()
        {
            string sql = @"SELECT 
       [Number] 
      ,[Beds] 
      ,[Price] 
      ,[Remark] 
  FROM [HotelDB].[dbo].[Room]";
            SqlConnection conn = new SqlConnection(str);

            if (!this.textBox2.Text.Equals(""))
            {
                sql += " where Number=" + this.textBox2.Text;
            }
            adapter = new SqlDataAdapter(sql, conn);
            try
            {
                if (ds.Tables["room"] != null)
                {
                    ds.Tables["room"].Clear();
                }

                adapter.Fill(ds, "room");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
            this.dataGridView1.DataSource = ds.Tables["room"];
        }
        public void show2() 
        {
            this.kefang.Text = this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
            this.chuang.Text = this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
            this.jiage.Text = this.dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
            this.beizhu.Text = this.dataGridView1.SelectedRows[0].Cells[3].Value.ToString();

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            show2();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            shanchu();
        }
        public void shanchu() 
        {
            SqlConnection conn = new SqlConnection(str);
            DialogResult rest = MessageBox.Show("确定要删除吗?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
            if (rest==DialogResult.OK)
            {
                if (dataGridView1.SelectedRows.Count>0)
                {
                    try
                    {
                        string nuber=this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                        conn.Open();
                        string sql = string.Format("delete from  room  where Number='{0}'",nuber);
                        SqlCommand comm = new SqlCommand(sql,conn);
                        int i = comm.ExecuteNonQuery();
                        if (i==1)
                        {
                            MessageBox.Show("删除成功!");
                        }
                    }
                    catch (Exception ex)
                    {

                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 JavaScript 编写的打砖块游戏(附源代码)   项目:JavaScript 打砖块游戏(附源代码) 打砖块游戏是使用 HTML5、CSS 和 JavaScript 开发的简单项目。这款游戏是关于借助弹跳球和滑动平面来打破障碍。您可以玩游戏,直到能够打破所有砖块而不会将球掉到地上。玩家必须使用箭头键移动滑动平面。 游戏制作 该项目仅包含 HTML、CSS 和 JavaScript。谈到这款游戏的功能,用户必须移动滑动平面以使球反弹回来以打破砖块。球必须接触砖块才能将其打破,并且不应掉落到地上。这款游戏的 PC 控制也很简单。您只需使用左、右、上、下键根据要求移动滑动平面即可。如果玩家能够在 3 次生命中清除所有砖块,则获胜。 该游戏包含大量的 javascript 以确保游戏正常运行。 如何运行该项目? 要运行此游戏,您不需要任何类型的本地服务器,但需要浏览器。我们建议您使用现代浏览器,如 Google Chrome 和 Mozilla Firefox, 以获得更好、更优化的游戏体验。要玩游戏,首先,单击 index.html 文件在浏览器中打开游戏。 演示: 该项目为国外大神项目,可以作为毕业设计的项目,也可以作为大作业项目,不用担心代码重复,设计重复等,如果需要对项目进行修改,需要具备一定基础知识。 注意:如果装有360等杀毒软件,可能会出现误报的情况,源码本身并无病毒,使用源码时可以关闭360,或者添加信任。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值