Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace encrypt
- {
- public partial class logs : Form
- {
- Thread th;
- SqlConnection sqlConnection;
- public logs()
- {
- InitializeComponent();
- }
- private async void logs_Load(object sender, EventArgs e)
- {
- string connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\webda\source\repos\encrypt\encrypt\EncryptDB.mdf;Integrated Security = True";
- sqlConnection = new SqlConnection(connectionString);
- await sqlConnection.OpenAsync();
- SqlDataReader sqlReader = null;
- SqlCommand command = new SqlCommand("SELECT * FROM [Encrypt_text]", sqlConnection);
- try
- {
- sqlReader = await command.ExecuteReaderAsync();
- while (await sqlReader.ReadAsync())
- {
- listBox1.Items.Add(Convert.ToString(sqlReader["id"]) + " " + Convert.ToString(sqlReader["time"]) + " " + Convert.ToString(sqlReader["encrypt_text"]));
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- if (sqlReader != null) sqlReader.Close();
- }
- SqlDataReader sqlReader_2 = null;
- SqlCommand command_2 = new SqlCommand("SELECT * FROM [Decrypt_text]", sqlConnection);
- try
- {
- sqlReader_2 = await command_2.ExecuteReaderAsync();
- while (await sqlReader_2.ReadAsync())
- {
- listBox2.Items.Add(Convert.ToString(sqlReader_2["id"]) + " " + Convert.ToString(sqlReader_2["time"]) + " " + Convert.ToString(sqlReader_2["decrypt_text"]));
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- if (sqlReader_2 != null) sqlReader_2.Close();
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- th = new Thread(encrypt);
- th.SetApartmentState(ApartmentState.STA);
- th.Start();
- }
- public void encrypt()
- {
- encrypt encrypt = new encrypt();
- encrypt.ShowDialog();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- th = new Thread(decrypt);
- th.SetApartmentState(ApartmentState.STA);
- th.Start();
- }
- public void decrypt()
- {
- decrypt decrypt = new decrypt();
- decrypt.ShowDialog();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- this.Close();
- th = new Thread(home);
- th.SetApartmentState(ApartmentState.STA);
- th.Start();
- }
- public void home()
- {
- main home = new main();
- home.ShowDialog();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement