示例#1
0
        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();
        }
示例#2
0
        private void loginbutton_Click(object sender, EventArgs e)
        {
            i = 0;
            MySqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from user_account where u_id='" + usernametextbox.Text + "'and password='******'";
            cmd.ExecuteNonQuery();
            var name = usernametextbox.Text;

            comm             = con.CreateCommand();
            comm.CommandText = "Insert into project.login_his values @u_id";
            comm.Parameters.AddWithValue("@u_id", name);
            UserInfo.Name = usernametextbox.Text;
            DataTable        dt = new DataTable();
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);

            da.Fill(dt);
            i = Convert.ToInt32(dt.Rows.Count.ToString());

            if (i == 0)
            {
                MessageBox.Show("The username or password is incorrect. Try again!");
                usernametextbox.Clear();
                passwordtextbox.Clear();
                usernametextbox.Select();
            }
            else
            {
                string         data    = usernametextbox.Text;
                register_login newform = (register_login)Application.OpenForms["register_login"];
                newform.Close();
                this.Close();
                Acc fm = new Acc(data);
                fm.Show();
                con.Close();
            }
        }
示例#3
0
 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!");
     }
 }