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 KTV前台
{
public partial class 包場模式 : Form
{
public 包場模式()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection("server=.;database=ktv;integrated security=true;");
private void 選擇包間_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("請輸入房間號!", "提示");
}
else
{
conn.Open();
if (comboBox3.Text == "上午場(8:00---12:00)")
{
SqlCommand a = new SqlCommand("Select * from 房間信息 where 房間ID='"+textBox1.Text +"'",conn);
a.ExecuteNonQuery();
SqlCommand com = new SqlCommand("insert into 房間信息(模式,小時數,總價) values('" + comboBox3.Text + "','4','300') ", conn);
com.ExecuteNonQuery();
MessageBox.Show("添加成功", "提示");
}
else if (comboBox3.Text == "下午場(12:30---5:30)")
{
SqlCommand com = new SqlCommand("insert into 房間信息(模式,小時數,總價)values('" + comboBox3.Text + "','5','400')", conn);
com.ExecuteNonQuery();
MessageBox.Show("添加成功", "提示");
}
else if (comboBox3.Text == "黃金場(7:00---12:00)")
{
SqlCommand com = new SqlCommand("insert into 房間信息(房間ID,模式,小時數,總價) values('" + textBox1.Text + "','" + comboBox3.Text + "','5','1000')", conn);
com.ExecuteNonQuery();
MessageBox.Show("添加成功", "提示");
}
else if (comboBox3.Text == "午夜場(12:30--5:00)")
{
SqlCommand com = new SqlCommand("insert into 房間信息(房間ID,模式,小時數,總價) values('" + textBox1.Text + "','" + comboBox3.Text + "','5','300')", conn);
com.ExecuteNonQuery();
MessageBox.Show("添加成功", "提示");
}
conn.Close();
}
}
}
}
檢查數據庫中有沒有模式這一列。它的類型和你用的類型是否相符。