Esempio n. 1
0
        private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                int cnt = 0;

                foreach (Form frm in Application.OpenForms)
                {
                    if (!frm.Name.Equals("MainFR") && !frm.Name.Equals("LoginFR") && !frm.Name.Equals("StartForm"))
                    {
                        cnt++;
                    }
                }

                if (cnt == 0)
                {
                    linkLabel4.Enabled = true;
                }
                else
                {
                    linkLabel4.Enabled = false;
                    return;
                }

                logOutClicked = true;
                new LogWriter(System.Environment.NewLine + "- " + DateTime.Now.ToString("dd.MM.yy. HH:mm - ") + "LogOut clicked" + System.Environment.NewLine);
                Hide();
                LoginForm fr = new LoginForm();
                fr.ShowDialog();

                if (loginCNt == 1)
                {
                    MainFR MF = new MainFR();
                    MF.ShowDialog();
                    Close();
                    return;
                }
                if (loginCNt == 3 && !fr.isLoged)
                {
                    MessageBox.Show("To many attempts, I will close now!");
                    Application.Exit();
                }
                else if (!fr.isLoged)
                {
                    MessageBox.Show("Wrong login data, please check again, attempts left: " + (3 - loginCNt));
                    loginCNt++;
                }

                if (fr.isLoged)
                {
                    if (!CheckIDs())
                    {
                        foreach (Control ctr in this.Controls)
                        {
                            if (ctr is LinkLabel)
                            {
                                ((LinkLabel)ctr).Enabled = false;
                            }
                        }
                        linkLabel16.Enabled = true;
                        linkLabel9.Enabled  = true;
                    }
                    MainFR MF = new MainFR();
                    MF.ShowDialog();
                    Close();
                }
                else
                {
                    Show();
                }
            }
            catch (Exception e1)
            {
                new LogWriter(e1);
            }
        }
Esempio n. 2
0
        private void OkBT_Click_1(object sender, EventArgs e)
        {
            label1.Visible = true;
            this.Refresh();

            QueryCommands qc  = new QueryCommands();
            List <String> arr = new List <string>();

            if ((this.UsernameBX.Text.Equals("") || this.PasswordBX.Text.Equals("")) && Properties.Settings.Default.AutoLogin == false)
            {
                MessageBox.Show("Please enter both, username and password!");
                label1.Visible = false;
                this.Refresh();
            }
            else
            {
                try
                {
                    if (Properties.Settings.Default.AutoLogin == false)
                    {
                        Properties.Settings.Default.Username = this.UsernameBX.Text;
                        Properties.Settings.Default.Password = this.PasswordBX.Text;
                    }

                    arr = qc.SetWorkingDBUser(Properties.Settings.Default.Username, Properties.Settings.Default.Password);
                    //arr = qc.Qcommands(this.UsernameBX.Text, this.PasswordBX.Text, arr, "DBUser");

                    if (!arr.Any())
                    {
                        if (loginCNt == 3)
                        {
                            MessageBox.Show("To many attempts, I will close now!");
                            Application.Exit();
                        }
                        else
                        {
                            MessageBox.Show("Wrong login data, please check again, attempts left: " + (3 - loginCNt));
                            loginCNt++;
                            this.UsernameBX.ResetText();
                            this.PasswordBX.ResetText();
                            this.UsernameBX.Focus();
                        }
                    }
                    else
                    {
                        if (this.checkBox1.Checked)
                        {
                            if (Properties.Settings.Default.AutoLogin == false)
                            {
                                Properties.Settings.Default.Remember = true;
                                Properties.Settings.Default.Username = this.UsernameBX.Text;
                                Properties.Settings.Default.Password = this.PasswordBX.Text;
                            }

                            Properties.Settings.Default.AutoLogin = checkBox2.Checked ? true : false;

                            //Properties.Settings.Default.DefaultLogoName = "DefaultLogoPOT";

                            try
                            {
                                if (rbHrv.Checked)
                                {
                                    Properties.Settings.Default.LanguageStt = "hrv";
                                    Thread.CurrentThread.CurrentUICulture   = CultureInfo.GetCultureInfo("hr-HR");
                                }
                                else if (rbEng.Checked)
                                {
                                    Properties.Settings.Default.LanguageStt = "eng";
                                    Thread.CurrentThread.CurrentUICulture   = CultureInfo.GetCultureInfo("en-US");
                                }
                            }
                            catch (Exception e1)
                            {
                                new LogWriter(e1);
                                Properties.Settings.Default.LanguageStt = "other";
                                Properties.Settings.Default.Save();
                            }

                            if (Properties.Settings.Default.AutoLogin == false)
                            {
                                Properties.Settings.Default.Save();
                            }
                        }

                        loginCNt = 1;
                        Hide();
                        Form MF = new MainFR();
                        MF.ShowDialog();
                        Close();
                    }
                }
                catch (Exception e1)
                {
                    new LogWriter(e1);
                    MessageBox.Show(e1.Message);
                }
                finally
                {
                    label1.Visible = false;
                    this.Refresh();

                    if (!arr.Any())
                    {
                        if (loginCNt == 3)
                        {
                            MessageBox.Show("To many attempts, I will close now!");
                            Application.Exit();
                        }
                        else
                        {
                            MessageBox.Show("Wrong login data, please check again, attempts left: " + (3 - loginCNt));
                            loginCNt++;
                            this.UsernameBX.ResetText();
                            this.PasswordBX.ResetText();
                            this.UsernameBX.Focus();
                        }
                    }
                }
            }
        }