Пример #1
0
        public Form_Login()
        {
            InitializeComponent();
            string currPass = HashPass.ReadFromReg(cmbBx_User.SelectedIndex + 1);

            if (currPass == "" || txtBx_Pass.Text == "")
            {
            }
            else if (HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text))
            {
                string hashedNewPass = HashPass.HashPassword(txtBx_Pass.Text);
                HashPass.WriteToReg(hashedNewPass, cmbBx_User.SelectedIndex + 1);
                MessageBox.Show("Password changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             //if (MessageBox.Show("Application will close after importing the license\nClick OK to continue", "Application will close!", MessageBoxButtons.OK, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
             //{
             string fileName = openFileDialog1.FileName;
             string name     = openFileDialog1.SafeFileNames[0].Remove(openFileDialog1.SafeFileNames[0].Length - 4, 4);
             HashPass.WriteToReg(name);
             string winPath     = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
             string newFileName = Path.Combine(winPath, "clc.clc");
             if (File.Exists(newFileName))
             {
                 File.Delete(newFileName);
             }
             File.Move(fileName, newFileName);
             if (HashPass.LicType == "p")
             {
                 foreach (Process p in System.Diagnostics.Process.GetProcessesByName("ProcessInfo"))
                 {
                     try
                     {
                         p.Kill();
                         p.WaitForExit();     // possibly with a timeout
                     }
                     catch (Win32Exception winException)
                     {
                         // process was terminating or can't be terminated - deal with it
                     }
                     catch (InvalidOperationException invalidException)
                     {
                         // process has already exited - might be able to let this one go
                     }
                 }
             }
             HashPass.CheckLicense();
             MessageBox.Show("License imported!");
             this.Close();
         }
         //}
         catch
         {
             MessageBox.Show("License import error!");
         }
     }
 }
Пример #3
0
        private void button_Ok_Click(object sender, EventArgs e)
        {
            SetStartup();
            if (tabControl1.SelectedIndex == 1)
            {
                if (cmbBx_User.Text.Contains("Select"))
                {
                    MessageBox.Show("Please select user", "No User Selected!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbBx_User.SelectAll();
                    return;
                }
                if (maskedTextBox_NewPass.Text != maskedTextBox_ConfirmPass.Text && Form1.isInServiceMode == true)
                {
                    MessageBox.Show("Your new password doesn't match with confirm password!", "Match error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox_ConfirmPass.SelectAll();
                    return;
                }

                int selectedIndex = 0;
                if (cmbBx_User.Text.ToLower() == "service")
                {
                    selectedIndex = 2;
                }
                else if (cmbBx_User.Text.ToLower() == "clinical")
                {
                    selectedIndex = 1;
                }
                string currPass = HashPass.ReadFromReg(selectedIndex);
                if (currPass == "" || HashPass.VerifyHashedPassword(currPass, maskedTextBox_CurrPass.Text))
                {
                    string hashedNewPass = HashPass.HashPassword(maskedTextBox_NewPass.Text);
                    HashPass.WriteToReg(hashedNewPass, selectedIndex);
                    MessageBox.Show("Password changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Entered password is incorrect!", "Wrong Password!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox_CurrPass.SelectAll();
                    return;
                }
            }

            string portName = comboBox_Ports.Text;

            if (comboBox_Ports.Text == "" || comboBox_Ports.Text == "No Serial Port!")
            {
                portName = "Null";
            }
            string baudrate          = comboBox_Baudrate.Text;
            string databits          = comboBox_DataBits.Text;
            string parity            = comboBox_Parity.Text;
            string clinicalTerminals = "0";

            if (checkBox_clinicalTerminals.Checked)
            {
                clinicalTerminals = "1";
            }

            string filename = "Settings.json";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            HashPass.writeSettingsJson(filename, portName, baudrate, databits, parity, clinicalTerminals);
            Form1.portName              = portName;
            Form1.curr_baudRate         = comboBox_Baudrate.Text;
            Form1.DataBits              = databits;
            Form1.Parity                = parity;
            Form1.showClinicalTerminals = clinicalTerminals;
            this.DialogResult           = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }