private void button2_Click(object sender, EventArgs e) { string locationName = textBox5.Text; string name = textBox6.Text; BookingDataSet.HotelsDataTable hotels = new BookingDataSet.HotelsDataTable(); BookingDataSetTableAdapters.HotelsTableAdapter ta = new BookingDataSetTableAdapters.HotelsTableAdapter(); SqlConnection sda = ta.Connection; SqlCommand comm = new SqlCommand("delete from Hotels where hotelLocation = '" + locationName + "' and name = '" + name + "'", sda); comm.Connection.Open(); comm.ExecuteNonQuery(); comm.Connection.Close(); }
private void button1_Click(object sender, EventArgs e) { string locationName = textBox1.Text; string name = textBox2.Text; int category = Convert.ToInt16(textBox3.Text); string pictUrl = textBox4.Text; BookingDataSet.HotelsDataTable hotels = new BookingDataSet.HotelsDataTable(); BookingDataSetTableAdapters.HotelsTableAdapter ta = new BookingDataSetTableAdapters.HotelsTableAdapter(); SqlConnection sda = ta.Connection; SqlCommand comm = new SqlCommand("insert into Hotels(hotelLocation,name,hotelCategory,pictUrl) values('" + locationName + "','" + name + "'," + category.ToString() + ",'" + pictUrl + "'" + ")", sda); comm.Connection.Open(); comm.ExecuteNonQuery(); comm.Connection.Close(); }
private void hotelsViewToolStripMenuItem_Click(object sender, EventArgs e) { groupBox3.Visible = false; groupBox1.Visible = false; groupBox2.Visible = true; dataGridView1.Visible = true; BookingDataSet.HotelsDataTable hotels = new BookingDataSet.HotelsDataTable(); BookingDataSetTableAdapters.HotelsTableAdapter ta = new BookingDataSetTableAdapters.HotelsTableAdapter(); SqlConnection sda = ta.Connection; SqlCommand comm = new SqlCommand("select * from Hotels", sda); comm.Connection.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(comm); da.Fill(dt); dataGridView1.DataSource = dt; // dataGridView1. comm.Connection.Close(); }