Ejemplo n.º 1
0
        private void savebutton_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            if (CB.Checked)
            {
                if (datasourcetxt.Text == "")
                {
                    dserrorLabel.Visible = true;
                }
                else
                {
                    dserrorLabel.Visible = false;
                }
                if (databasetxt.Text == "")
                {
                    dberrorLabel.Visible = true;
                }
                else
                {
                    dberrorLabel.Visible = false;
                }
                if (dserrorLabel.Visible || dberrorLabel.Visible)
                {
                    MessageBox.Show("Fields with * are mandatory!");
                }
                else
                {
                    sb.Append("Data Source" + datasourcetxt.Text + ";Initial catalog= " + databasetxt + ";Security = true; MultipleActiveResultSets=ture");
                    File.WriteAllText(MainClass.path + "\\connect", sb.ToString());
                    DialogResult dr = MessageBox.Show("Setting Save Successfully,", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (dr == DialogResult.OK)
                    {
                        Login log = new Login();
                        MainClass.showWindow(log, this, MDI.ActiveForm);
                    }
                }
            }
            else
            {
                if (datasourcetxt.Text == "")
                {
                    dserrorLabel.Visible = true;
                }
                else
                {
                    dserrorLabel.Visible = false;
                }
                if (databasetxt.Text == "")
                {
                    dberrorLabel.Visible = true;
                }
                else
                {
                    dberrorLabel.Visible = false;
                }
                if (usernametxt.Text == "")
                {
                    unerrorLabel.Visible = true;
                }
                else
                {
                    unerrorLabel.Visible = false;
                }
                if (passtxt.Text == "")
                {
                    pwerrorLabel.Visible = true;
                }
                else
                {
                    pwerrorLabel.Visible = false;
                }
                if (dserrorLabel.Visible || dberrorLabel.Visible)
                {
                    MessageBox.Show("Fields with * are mandatory!");
                }
                else
                {
                    sb.Append("Data Source" + datasourcetxt.Text + ";Initial catalog= " + databasetxt + ";User ID =" + usernametxt.Text + "Password="******"MultipleActiveResultSets=ture");
                    File.WriteAllText(MainClass.path + "\\connect", sb.ToString());
                    DialogResult dr = MessageBox.Show("Setting Save Successfully,", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (dr == DialogResult.OK)
                    {
                        Login log = new Login();
                        MainClass.showWindow(log, this, MDI.ActiveForm);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void backBtn_Click(object sender, EventArgs e)
        {
            HomeScreen hs = new HomeScreen();

            MainClass.showWindow(hs, this, MDI.ActiveForm);
        }