Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using MaterialSkin;
  12. using MaterialSkin.Controls;
  13. using SQLite;
  14.  
  15. namespace Auto
  16. {
  17. public partial class Form2 : MaterialForm
  18. {
  19. public SQLiteConnection connection;
  20.  
  21. public Form2()
  22. {
  23. InitializeComponent();
  24. var materialSkinManager = MaterialSkinManager.Instance;
  25. materialSkinManager.AddFormToManage(this);
  26. materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT;
  27. // Configure color schema
  28. materialSkinManager.ColorScheme = new ColorScheme(
  29. Primary.Blue400, Primary.Blue500,
  30. Primary.Blue500, Accent.LightBlue200,
  31. TextShade.WHITE
  32. );
  33. }
  34.  
  35. private void initialize()
  36. {
  37.  
  38. string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
  39. path = path + @"\AutoBase";
  40. if (!Directory.Exists(path))
  41. {
  42. DirectoryInfo di = Directory.CreateDirectory(path);
  43. }
  44. string db_path = Path.Combine(path, "clients.db3");
  45. connection = new SQLiteConnection(db_path);
  46. }
  47.  
  48. private void Form2_Load(object sender, EventArgs e)
  49. {
  50.  
  51. }
  52.  
  53. private void materialFlatButton1_Click(object sender, EventArgs e)
  54. {
  55. initialize();
  56. using (connection)
  57. {
  58. var table = connection.Table<Helpers.Clients>();
  59. var newClient = new Helpers.Clients();
  60. newClient.name = materialSingleLineTextField1.Text;
  61. newClient.phone = materialSingleLineTextField2.Text;
  62. connection.Insert(newClient);
  63. }
  64. this.DialogResult = DialogResult.OK;
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement