private void Detour_Click(object sender, EventArgs e) { TidInfo.Name = delete_text.Text; comm = con.CreateCommand(); comm.CommandText = "DELETE FROM `project`.`buy_tour` WHERE t_id ='" + TidInfo.Name + "'and u_id = '" + UserInfo.Name + "'"; try { int rowsAffected = comm.ExecuteNonQuery(); MessageBox.Show("Tour Removed!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } Acc oldform = (Acc)Application.OpenForms["Acc"]; oldform.Close(); this.Close(); Acc fm = new Acc(UserInfo.Name); fm.Show(); con.Close(); }
private void addtour_Click(object sender, EventArgs e) { comm = con.CreateCommand(); comm.CommandText = "INSERT INTO project.buy_tour (`t_id`, `u_id`) " + "VALUES " + "(@tid,@uid)"; comm.Parameters.AddWithValue("@tid", TidInfo.Name); comm.Parameters.AddWithValue("@uid", UserInfo.Name); try { int rowsAffected = comm.ExecuteNonQuery(); MessageBox.Show("Tour Added!"); Alltour newform = (Alltour)Application.OpenForms["Alltour"]; newform.Close(); Acc oldform = (Acc)Application.OpenForms["Acc"]; oldform.Close(); this.Close(); Acc fm = new Acc(UserInfo.Name); fm.Show(); con.Close(); } catch { MessageBox.Show("Tour already in your plan!"); } }