SHARE
TWEET

Untitled

a guest Jun 12th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using NLSDAL.Entity;
  12. using NLSServices.Utilities;
  13.  
  14. namespace NAPS.Biometrics
  15. {
  16.     public partial class FrmSystemOptions : DevExpress.XtraEditors.XtraForm
  17.     {
  18.         public FrmSystemOptions()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void btnCancel_Click(object sender, EventArgs e)
  24.         {
  25.             this.Close();
  26.         }
  27.  
  28.         private void btnOk_Click(object sender, EventArgs e)
  29.         {
  30.             SaveSettings();
  31.         }
  32.  
  33.  
  34.         private void FrmSystemOptions_Load(object sender, EventArgs e)
  35.         {
  36.             LoadSettings();
  37.             using (NLSEntities dbContext = NLSEntities.CreateFromIni("config.ini"))
  38.             {
  39.                 // save Multi organizations settings
  40.                 Settings firstSetting = dbContext.Settings.FirstOrDefault();
  41.                 if (firstSetting != null)
  42.                 {
  43.                     chkMultiOrganizations.Checked =  firstSetting.MultiOrganization;
  44.  
  45.                 }
  46.  
  47.             }
  48.  
  49.         }
  50.  
  51.         private void navigationPane1_Click(object sender, EventArgs e)
  52.         {
  53.  
  54.         }
  55.  
  56.         public void SaveSettings()
  57.         {
  58.             SettingsManager settings = SettingsManager.GetInstance();
  59.  
  60.             settings[SettingsManager.NETLOGIA_URL] = txtNetlogiaURL.Text;
  61.             settings[SettingsManager.CLIENT_ID] = txtNetlogiaClientId.Text;
  62.             settings[SettingsManager.USER_DEVICE_ID] = txtNetlogiaDeviceId.Text;
  63.             settings[SettingsManager.CLIENT_SECRET] = txtNetlogiaClientSecret.Text;
  64.             settings[SettingsManager.NETPORTAL_INSTANCE_ID] = txtNetportalInstanceId.Text;
  65.             settings[SettingsManager.NETPORTAL_INSTANCE_NAME] = txtNetportalInstance.Text;
  66.             settings[SettingsManager.NETPORTAL_SYNC_INTERVAL] = txtNetportalSyncInterval.Text;
  67.             settings[SettingsManager.NETLOGIA_SAVE_PUNCHES] = chkNetlogiaSavePunches.Checked ? "1" : "0";
  68.             settings[SettingsManager.NETLOGIA_SAVE_PUNCHES] = chkNetportalSavePunches.Checked ? "1" : "0";
  69.  
  70.             settings[SettingsManager.ERP_PRIMAVERA_V9] = chkPrimavera9.Checked ? "1" : "0";
  71.             settings[SettingsManager.ERP_PRIMAVERA_V10] = chkPrimavera10.Checked ? "1" : "0";
  72.  
  73.             settings.Save();
  74.  
  75.             using (NLSEntities dbContext = NLSEntities.CreateFromIni("config.ini"))
  76.             {
  77.                 // save Multi organizations settings
  78.                 Settings firstSetting = dbContext.Settings.FirstOrDefault();
  79.                 if (firstSetting != null)
  80.                 {
  81.                     if (chkMultiOrganizations.Checked)
  82.                     {
  83.                         firstSetting.MultiOrganization = true;
  84.                     }
  85.                     else
  86.                     {
  87.                         firstSetting.MultiOrganization = false;
  88.                     }
  89.  
  90.                     dbContext.SaveChanges();
  91.  
  92.                     MessageBox.Show("Settings saved successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
  93.                 }
  94.  
  95.             }
  96.  
  97.  
  98.         }
  99.  
  100.  
  101.         public void LoadSettings()
  102.         {
  103.  
  104.             SettingsManager settings = SettingsManager.GetInstance();
  105.  
  106.             txtNetlogiaURL.Text = settings[SettingsManager.NETLOGIA_URL];
  107.             txtNetlogiaClientId.Text = settings[SettingsManager.CLIENT_ID];
  108.             txtNetlogiaDeviceId.Text = settings[SettingsManager.USER_DEVICE_ID];
  109.             txtNetlogiaClientSecret.Text = settings[SettingsManager.CLIENT_SECRET];
  110.             txtNetportalInstanceId.Text = settings[SettingsManager.NETPORTAL_INSTANCE_ID];
  111.             txtNetportalInstance.Text = settings[SettingsManager.NETPORTAL_INSTANCE_NAME];
  112.             txtNetportalSyncInterval.Text = settings[SettingsManager.NETPORTAL_SYNC_INTERVAL];
  113.  
  114.             chkNetlogiaSavePunches.Checked = settings[SettingsManager.NETLOGIA_SAVE_PUNCHES] == "1";
  115.             chkNetportalSavePunches.Checked = settings[SettingsManager.NETLOGIA_SAVE_PUNCHES] == "1";
  116.  
  117.             chkPrimavera9.Checked = settings[SettingsManager.ERP_PRIMAVERA_V9] == "1";
  118.             chkPrimavera10.Checked = settings[SettingsManager.ERP_PRIMAVERA_V10] == "1";
  119.  
  120.         }
  121.  
  122.  
  123.     }
  124. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top