-
Notifications
You must be signed in to change notification settings - Fork 2
/
SettingsForm.cs
62 lines (57 loc) · 2.14 KB
/
SettingsForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
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 CredentialManagement;
namespace AZI_SWCustomProperties
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
txtOdooUrl.Text = Properties.UserSettings.Default.OdooUrl;
txtOdooDb.Text = Properties.UserSettings.Default.OdooDb;
txtSwKey.Text = Properties.AppSettings.Default.SwLicenseKey;
txtAreaFactor.Text = Properties.AppSettings.Default.AreaFactor.ToString();
var cm = new Credential { Target = Properties.AppSettings.Default.OdooCredentialTarget };
if (cm.Load())
{
txtOdooUser.Text = cm.Username;
txtOdooPass.Text = cm.Password;
}
}
private void BtnSubmit_Click(object sender, EventArgs e)
{
Properties.UserSettings.Default.OdooDb = txtOdooDb.Text;
Properties.UserSettings.Default.OdooUrl = txtOdooUrl.Text;
Properties.AppSettings.Default.SwLicenseKey = txtSwKey.Text;
Decimal areaFactor;
if (!Decimal.TryParse(txtAreaFactor.Text, out areaFactor))
{
MessageBox.Show("Area Factor must be a decimal number");
return;
}
Properties.AppSettings.Default.AreaFactor = areaFactor;
Properties.UserSettings.Default.Save();
Properties.AppSettings.Default.Save();
var cm = new Credential { Target = Properties.AppSettings.Default.OdooCredentialTarget };
if (cm.Load())
cm.Delete();
Credential cred = new Credential
{
Target = Properties.AppSettings.Default.OdooCredentialTarget,
Username = txtOdooUser.Text,
Password = txtOdooPass.Text,
PersistanceType = PersistanceType.LocalComputer
};
cred.Save();
Close();
}
}
}