Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace Test_slagalica
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- string cs = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename= C:\Users\Pavle\Documents\Visual Studio 2015\Projects\Test slagalica\Test slagalica\Slagalica-DB.mdf;Integrated Security=True";
- string queryString = "SELECT * FROM table1 WHERE LEN(Reci) >=10 AND LEN(Reci) <=12 ORDER BY NEWID()";
- int i;
- Random random = new Random();
- string word;
- string promesana_rec;
- private void Form1_Load(object sender, EventArgs e)
- {
- Label[] label = new Label[] { label2, label3, label4, label5, label6, label7, label8, label9, label10, label11, label12, label13 };
- button1.Text = "Start";
- textBox1.Text = "";
- textBox2.Text = "";
- textBox1.Enabled = false;
- using (SqlConnection connection = new SqlConnection(cs))
- {
- SqlCommand mycommand = new SqlCommand(queryString, connection);
- try
- {
- connection.Open();
- string word = (string)mycommand.ExecuteScalar();
- promesana_rec = new string(word.OrderBy(r => random.Next()).ToArray());
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Label[] label = new Label[] { label2, label3, label4, label5, label6, label7, label8, label9, label10, label11, label12, label13 };
- timer1.Start();
- if (!button1.Enabled)
- return;
- if (button1.Text == "Start")
- {
- i = 0;
- timer1.Enabled = true;
- button1.Text = "Stop";
- button1.Enabled = true;
- }
- else
- {
- label[i].Text = Convert.ToString(promesana_rec[i]);
- i = i + 1;
- if (i == 12)
- {
- textBox1.Enabled = true;
- button1.Enabled = false;
- button1.Text = "Start";
- timer1.Enabled = false;
- textBox1.Focus();
- }
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- //char[] letters = "AБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ".ToCharArray();
- char[] letters = new char[30] { 'A', 'Б', 'В', 'Г', 'Д', 'Ђ', 'Е', 'Ж', 'З', 'И', 'Ј', 'К', 'Л', 'Љ', 'М', 'Н', 'Њ', 'О', 'П', 'Р', 'С', 'Т', 'Ћ', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Џ', 'Ш' };
- Label[] label = new Label[] { label2, label3, label4, label5, label6, label7, label8, label9, label10, label11, label12, label13 };
- string randomString = "";
- randomString += letters[random.Next(0, 30)].ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement