private void button1_Click(object sender, EventArgs e) { if (dateTimePicker1.Value.ToString() == "" || cbTime.Text == "" || cbHairstyle.Text == "" || cbBarber.Text == "") { MessageBox.Show("Missing Data"); } else { try { Con.Open(); string query = "insert into BookingTbl values('" + CustIdCb.Text + "','" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + cbTime.Text + "','" + CustNamelbl.Text + "','" + cbHairstyle.Text + "','" + cbBarber.Text + "' )"; SqlCommand cmd = new SqlCommand(query, Con); cmd.ExecuteNonQuery(); MessageBox.Show("Customer Successfully Added"); ViewBooking vb = new ViewBooking(); vb.Show(); this.Hide(); Con.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } } }
private void button2_Click_1(object sender, System.EventArgs e) { ViewBooking vb = new ViewBooking(); vb.Show(); this.Hide(); }