public SysSettings(TrnIntegrationForm form)
        {
            InitializeComponent();
            trnInnosoftPOSIntegrationForm = form;

            getSettings();
        }
Exemple #2
0
        private void btnIntegrateFiles_Click(object sender, EventArgs e)
        {
            String settingsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Settings.json");

            String json;

            using (StreamReader trmRead = new StreamReader(settingsPath)) { json = trmRead.ReadToEnd(); }

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            Entities.SysSettings sysSettings = javaScriptSerializer.Deserialize <Entities.SysSettings>(json);

            Entities.SysSettings newSysSettings = new Entities.SysSettings()
            {
                ConnectionString         = sysSettings.ConnectionString,
                Domain                   = sysSettings.Domain,
                LogFileLocation          = sysSettings.LogFileLocation,
                FolderToMonitor          = sysSettings.FolderToMonitor,
                IsFolderMonitoringOnly   = true,
                FolderMonitoringUserCode = sysSettings.FolderMonitoringUserCode,
                FolderForSentFiles       = sysSettings.FolderForSentFiles,
                ManualSalesIntegration   = false
            };

            String newJson = new JavaScriptSerializer().Serialize(newSysSettings);

            File.WriteAllText(settingsPath, newJson);

            btnMainIntegrate.Enabled  = false;
            btnIntegrateFiles.Enabled = false;

            Forms.TrnIntegrationForm trnInnosoftPOSIntegrationForm = new Forms.TrnIntegrationForm();
            trnInnosoftPOSIntegrationForm.Show();

            Hide();
        }
        public void login()
        {
            try
            {
                btnLogin.Enabled  = false;
                btnCancel.Enabled = false;

                String username = txtUsername.Text;
                String password = txtPassword.Text;

                var user = from d in posdb.MstUsers
                           where d.UserName.Equals(username) &&
                           d.Password.Equals(password)
                           select d;

                if (user.Any())
                {
                    currentUser = user.FirstOrDefault().FullName;

                    String settingsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Settings.json");

                    String json;
                    using (StreamReader trmRead = new StreamReader(settingsPath)) { json = trmRead.ReadToEnd(); }

                    JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                    Entities.SysSettings sysSettings          = javaScriptSerializer.Deserialize <Entities.SysSettings>(json);

                    Entities.SysSettings newSysSettings = new Entities.SysSettings()
                    {
                        ConnectionString         = sysSettings.ConnectionString,
                        Domain                   = sysSettings.Domain,
                        LogFileLocation          = sysSettings.LogFileLocation,
                        FolderToMonitor          = sysSettings.FolderToMonitor,
                        IsFolderMonitoringOnly   = false,
                        FolderMonitoringUserCode = sysSettings.FolderMonitoringUserCode,
                        FolderForSentFiles       = sysSettings.FolderForSentFiles,
                        ManualSalesIntegration   = sysSettings.ManualSalesIntegration
                    };

                    String newJson = new JavaScriptSerializer().Serialize(newSysSettings);
                    File.WriteAllText(settingsPath, newJson);

                    TrnIntegrationForm trnInnosoftPOSIntegrationForm = new TrnIntegrationForm();
                    trnInnosoftPOSIntegrationForm.getLoginDetails(this);
                    trnInnosoftPOSIntegrationForm.Show();

                    Hide();
                }
                else
                {
                    MessageBox.Show("Incorrect Username or Password.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    btnLogin.Enabled  = true;
                    btnCancel.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                btnLogin.Enabled  = true;
                btnCancel.Enabled = true;
            }
        }