Exemplo n.º 1
0
        private void savebtn_Click(object sender, EventArgs e)
        {
            if (iscb.Checked)
            {
                if (serverTxt.Text == "")
                {
                    serverErrorLabel.Visible = true;
                }
                else
                {
                    serverErrorLabel.Visible = false;
                }

                if (databaseTxt.Text == "")
                {
                    DbErrorLabel.Visible = true;
                }
                else
                {
                    DbErrorLabel.Visible = false;
                }


                if (serverErrorLabel.Visible || DbErrorLabel.Visible)
                {
                    MainClass.showMessage("Fields with * are mandatory.", "error");
                }
                else
                {
                    connection = "Data Source=" + serverTxt.Text +
                                 ";Initial Catalog=" + databaseTxt.Text +
                                 ";Integrated Security=true;MultipleActiveResultSets=true";
                    saveConnection();
                    DialogResult dr = MessageBox.Show("Settings saved succesfully.");
                    if (dr == DialogResult.OK)
                    {
                        LoginScreen ls = new LoginScreen();
                        MainClass.showWindow(ls, this, MDI.ActiveForm);
                    }
                }
            }
            else
            {
                if (serverTxt.Text == "")
                {
                    serverErrorLabel.Visible = true;
                }

                else
                {
                    serverErrorLabel.Visible = false;
                }



                if (databaseTxt.Text == "")
                {
                    DbErrorLabel.Visible = true;
                }
                else
                {
                    DbErrorLabel.Visible = false;
                }



                if (userTxt.Text == "")
                {
                    UserErrorLabel.Visible = true;
                }
                else
                {
                    UserErrorLabel.Visible = false;
                }


                if (passTxt.Text == "")
                {
                    PassErrorLabel.Visible = true;
                }
                else
                {
                    PassErrorLabel.Visible = false;
                }



                if (serverErrorLabel.Visible || DbErrorLabel.Visible || UserErrorLabel.Visible || PassErrorLabel.Visible)
                {
                    MainClass.showMessage("Fields with * are mandatory.", "error");
                }
                else
                {
                    connection = "Data Source=" + serverTxt.Text +
                                 ";Initial Catalog=" + databaseTxt.Text +
                                 ";User Id=" + userTxt.Text + ";Password="******";MultipleActiveResultSets=true";
                    saveConnection();
                    DialogResult dr = MessageBox.Show("Settings saved succesfully.");
                    if (dr == DialogResult.OK)
                    {
                        LoginScreen ls = new LoginScreen();
                        MainClass.showWindow(ls, this, MDI.ActiveForm);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void logoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoginScreen ls = new LoginScreen();

            MainClass.showWindow(ls, this);
        }