Пример #1
2
        public void EditQuestion(string[] str, Game g)
        {
            SqlConnection connect = new SqlConnection();
            SqlCommand cmd = null;
            SqlTransaction trans = null;
            try
            {
                connect.ConnectionString = @"Initial Catalog=Millionaire;Data Source=(local);Integrated Security=SSPI";
                connect.Open();
                trans = connect.BeginTransaction();
                cmd = connect.CreateCommand();

                cmd.Connection = connect;
                cmd.Transaction = trans;

                cmd.CommandText = "update Millionaire_table set question='" + str[0] + "', answer1='" + str[1] + "', answer2='" + str[2] + "', answer3='" + str[3] + "', answer4='" + str[4] + "' where question='" + str[5] +"'";
                cmd.ExecuteNonQuery();

                trans.Commit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                trans.Rollback();
            }
            finally
            {
                cmd.Dispose();
                connect.Close();
            }
        }
Пример #2
0
        public void RemoveQuestion(string question, Game g)
        {
            SqlConnection connect = new SqlConnection();
            SqlCommand cmd = null;
            SqlTransaction trans = null;
            try
            {
                connect.ConnectionString = @"Initial Catalog=Millionaire;Data Source=(local);Integrated Security=SSPI";
                connect.Open();
                trans = connect.BeginTransaction();
                cmd = connect.CreateCommand();

                cmd.Connection = connect;
                cmd.Transaction = trans;

                cmd.CommandText = "delete from Millionaire_table where question = '" + question +"'";
                cmd.ExecuteNonQuery();

                trans.Commit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                trans.Rollback();
            }
            finally
            {
                cmd.Dispose();
                connect.Close();
            }
        }
Пример #3
0
 public void RemoveQuestion(string question, Game g)
 {
     using (StreamWriter sw = new StreamWriter("..\\..\\Resources\\question.txt", false, Encoding.Default))
     {
         for (int n = 0; n < g.Count_Question; n++)
         {
             g.Current_Question = n;
             sw.WriteLine(g.Question);
             sw.WriteLine(g.Answer_A);
             sw.WriteLine(g.Answer_B);
             sw.WriteLine(g.Answer_C);
             sw.WriteLine(g.Answer_D);
         }
     }
 }