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.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using MySql.Data.MySqlClient;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using System.Security.Policy;
- using MySqlX.XDevAPI.Common;
- namespace BillionRec
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public static string connectorString = "server = localhost;Database=billion2;User ID=root;Password=";
- static string loremIpsum2(string url)
- {
- var rand = new Random();
- string result = null;
- string[] words = File.ReadLines(url).ToArray();
- int leaght = 20;
- for (int j = 0; j <10; j++)
- {
- for (int k = 0; k < 2; k++)
- {
- for (int i = 0; i < leaght; i++)
- {
- result = string.Concat(result, words[rand.Next(words.Length)]);
- if (i < leaght)
- {
- result = string.Concat(result, "");
- }
- }
- }
- }
- return result;
- }
- static string loremIpsum(int vlenght)
- {
- var rand = new Random();
- string result = null;
- var words = new[] { "lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "sed", "diam", "nonummy", "nibh", "euismod", "tincidunt", "ut", "laoreet", "dolore", "magna", "aliquam", "erat" };
- for (int i = 0; i < vlenght; i++)
- {
- result = string.Concat(result, words[rand.Next(words.Length)]);
- if (i < vlenght)
- {
- result = string.Concat(result, " ");
- }
- }
- return result;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- textBox1.Text = loremIpsum(Convert.ToInt32(maskedTextBox1.Text));
- }
- private void maskedTextBox1_TextChanged(object sender, EventArgs e)
- {
- if (System.Text.RegularExpressions.Regex.IsMatch(maskedTextBox1.Text, "[^0-9]"))
- {
- MessageBox.Show("Please enter only numbers.");
- maskedTextBox1.Text = maskedTextBox1.Text.Remove(maskedTextBox1.Text.Length - 1);
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- MySqlConnection myConn = new MySqlConnection(connectorString);
- myConn.Open();
- for (int i = 0; i<1000000; i++)
- {
- textBox1.Text = loremIpsum(Convert.ToInt32(maskedTextBox1.Text));
- string query = $"INSERT INTO rec(rec_Name) VALUES('{textBox1.Text}')";
- MySqlCommand myCommand = new MySqlCommand(query, myConn);
- myCommand.ExecuteNonQuery();
- }
- MessageBox.Show("Finish");
- myConn.Close();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- MySqlConnection myConn = new MySqlConnection(connectorString);
- myConn.Open();
- string query = "truncate rec;";
- MySqlCommand myCommand = new MySqlCommand(query, myConn);
- myCommand.ExecuteNonQuery();
- myConn.Close();
- MessageBox.Show("Finish");
- string query2 = "SELECT * FROM rec";
- MySqlConnection MyConn = new MySqlConnection(connectorString);
- MySqlCommand MyComm = new MySqlCommand(query2, MyConn);
- MySqlDataAdapter MyAdap = new MySqlDataAdapter();
- MyAdap.SelectCommand = MyComm;
- DataTable dTable = new DataTable();
- MyAdap.Fill(dTable);
- dataGridView1.DataSource = dTable;
- }
- private void button3_Click(object sender, EventArgs e)
- {
- string query = "SELECT * FROM rec";
- MySqlConnection MyConn = new MySqlConnection(connectorString);
- MySqlCommand MyComm = new MySqlCommand(query, MyConn);
- MySqlDataAdapter MyAdap = new MySqlDataAdapter();
- MyAdap.SelectCommand = MyComm;
- DataTable dTable = new DataTable();
- MyAdap.Fill(dTable);
- dataGridView1.DataSource = dTable;
- MessageBox.Show("Finish");
- }
- private void button5_Click(object sender, EventArgs e)
- {
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.ShowDialog();
- string url = openFileDialog1.FileName;
- textBox2.Text = url;
- }
- private void button6_Click(object sender, EventArgs e)
- {
- string url = textBox2.Text;
- MySqlConnection myConn = new MySqlConnection(connectorString);
- myConn.Open();
- for (int i = 0; i < 1000000; i++)
- {
- textBox1.Text = loremIpsum(Convert.ToInt32(maskedTextBox1.Text));
- string Des = loremIpsum2(url);
- Des = MySqlHelper.EscapeString(Des);
- richTextBox1.Text = Des;
- string query = $"INSERT INTO rec(rec_Name,rec_Descript) VALUES ('{textBox1.Text}','{richTextBox1.Text}')";
- MySqlCommand myCommand = new MySqlCommand(query, myConn);
- myCommand.ExecuteNonQuery();
- }
- MessageBox.Show("Finish");
- myConn.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement