Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- 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 MaterialSkin;
- using MaterialSkin.Controls;
- using SQLite;
- namespace Auto
- {
- public partial class Form1 : MaterialForm
- {
- public SQLiteConnection connection;
- public Form1()
- {
- InitializeComponent();
- var materialSkinManager = MaterialSkinManager.Instance;
- materialSkinManager.AddFormToManage(this);
- materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
- // Configure color schema
- materialSkinManager.ColorScheme = new ColorScheme(
- Primary.Blue400, Primary.Blue500,
- Primary.Blue500, Accent.LightBlue200,
- TextShade.WHITE
- );
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- initialize();
- using (connection)
- {
- connection.CreateTable<Helpers.Clients>();
- }
- UpdateListView();
- }
- private void materialFlatButton1_Click(object sender, EventArgs e)
- {
- using (Form2 form2 = new Form2())
- {
- if (form2.ShowDialog() == DialogResult.OK)
- {
- UpdateListView();
- }
- }
- }
- private void UpdateListView()
- {
- initialize();
- materialListView1.Items.Clear();
- var table = connection.Table<Helpers.Clients>();
- foreach (var client in table.Reverse())
- {
- ListViewItem item = new ListViewItem(client.id.ToString());
- item.SubItems.Add(client.name);
- item.SubItems.Add(client.phone);
- materialListView1.Items.Add(item);
- }
- }
- private void initialize()
- {
- string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
- path = path + @"\AutoBase";
- if (!Directory.Exists(path))
- {
- DirectoryInfo di = Directory.CreateDirectory(path);
- }
- string db_path = Path.Combine(path, "clients.db3");
- connection = new SQLiteConnection(db_path);
- }
- private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- initialize();
- using (connection)
- {
- for (int i = 0; i < materialListView1.SelectedItems.Count; i++)
- {
- Console.WriteLine(materialListView1.SelectedItems[i].Text);
- connection.Query<Helpers.Clients>("delete from Clients where id = " + materialListView1.SelectedItems[i].Text);
- }
- }
- UpdateListView();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement