Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: PassSaver.Interaction
- // Assembly: PassSaver, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: 63F4F655-5AF4-4653-8798-AD5E71C943D1
- // Assembly location: C:\Users\kiril\Desktop\Release\PassSaver.exe
- using System;
- using System.Collections.Generic;
- using System.Data.Common;
- using System.Data.SQLite;
- using System.IO;
- namespace PassSaver
- {
- internal class Interaction
- {
- private static SQLiteConnection connection;
- private static SQLiteCommand command;
- public User[] users;
- public void Connect(bool first)
- {
- Directory.GetCurrentDirectory();
- if (first)
- {
- SQLiteConnection.CreateFile("users.db");
- Interaction.connection = new SQLiteConnection(string.Format("Data Source={0}\\users.db", (object) Directory.GetCurrentDirectory()));
- Interaction.connection.Open();
- Interaction.command = new SQLiteCommand(Interaction.connection);
- Interaction.command.CommandText = "CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT,Username TEXT NOT NULL,Password TEXT NOT NULL,Description TEXT NULL);";
- Interaction.command.ExecuteNonQuery();
- }
- else
- {
- Interaction.connection = new SQLiteConnection(string.Format("Data Source={0}\\users.db", (object) Directory.GetCurrentDirectory()));
- Interaction.connection.Open();
- Interaction.command = new SQLiteCommand(Interaction.connection);
- this.UpdateListUsers();
- }
- }
- public void AddUser(string username, string password)
- {
- string str = "INSERT INTO users (Username, Password) VALUES ('" + username + "','" + password + "');";
- Interaction.command.CommandText = str;
- Interaction.command.ExecuteNonQuery();
- this.UpdateListUsers();
- }
- public void AddUser(string username, string password, string description)
- {
- string str = "INSERT INTO users (Username, Password, Description) VALUES ('" + username + "', '" + password + "', '" + description + "');";
- Interaction.command.CommandText = str;
- Interaction.command.ExecuteNonQuery();
- this.UpdateListUsers();
- }
- public void UpdateListUsers()
- {
- string str1 = "SELECT * FROM users;";
- Interaction.command.CommandText = str1;
- SQLiteDataReader sqLiteDataReader = Interaction.command.ExecuteReader();
- List<User> userList = new List<User>();
- userList.Clear();
- foreach (DbDataRecord dbDataRecord in (DbDataReader) sqLiteDataReader)
- {
- User user = new User();
- int int32 = Convert.ToInt32(dbDataRecord["id"].ToString());
- string str2 = dbDataRecord["Username"].ToString();
- string str3 = dbDataRecord["Password"].ToString();
- string str4 = dbDataRecord["Description"].ToString();
- user.id = int32;
- user.Username = str2;
- user.Password = str3;
- user.Description = str4;
- userList.Add(user);
- }
- Interaction.command.Reset();
- this.users = userList.ToArray();
- }
- public void RemoveUser(int id)
- {
- string str = string.Format("DELETE FROM users WHERE Username = {0}", (object) id);
- Interaction.command.CommandText = str;
- Interaction.command.ExecuteNonQuery();
- this.UpdateListUsers();
- }
- public void Disconnect()
- {
- Interaction.connection.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement