Esempio n. 1
0
 private void frmLogin_Load(object sender, EventArgs e)
 {
     if (!File.Exists("server.inf"))
     {
         frmServerConfigure frm = new frmServerConfigure();
         frm.FormClosed += (o, arg) =>
         {
             this.Enabled = true;
         };
         this.Enabled = false;
         frm.Show();
     }
 }
Esempio n. 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text != string.Empty && txtPass.Text != string.Empty)
            {
                try
                {
                    var sqlAgent = SQLAgent.GetInstance();

                    sqlAgent.Connect(File.ReadAllText("server.inf"));
                    if (!sqlAgent.AdminLogin(txtUser.Text, txtPass.Text))
                    {
                        MessageBox.Show("User name or password incorrect", "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.Hide();
                    frmFunctions functions = new frmFunctions();
                    functions.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error connecting server\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (ex is WebException)
                    {
                        frmServerConfigure frm = new frmServerConfigure();
                        this.Enabled    = false;
                        frm.FormClosed += (o, arg) =>
                        {
                            this.Enabled = true;
                        };
                        frm.Show();
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter both user name and password", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }