Beispiel #1
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            if (true)
            {
                MessageBox.Show("Testing Mode Enabled");
                Testing ateTesting = new Testing();
                ateTesting.Show();
            }
            if (!Security.V1.ActivationCheck.__IsRegisteredVersion)
            {
                if (Security.V1.ActivationCheck.__IsTrialValid == false)
                {
                    MessageBox.Show(MsgTxt.YouShouldActivateNowTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            bool isadmin;

            if (UsrTxtBox.Text.Trim() != "" && PassTxtBox.Text.Trim() != "")
            {
                UsrTxtBox.BackColor  = UsrBGColor;
                PassTxtBox.BackColor = PassBGColor;
                DataRow dr = UsersMgmt.SelectUserByUserNameandPassword(UsrTxtBox.Text, PassTxtBox.Text);
                if (dr != null)
                {
                    if (IsFirstLogin || SharedVariables.IsStartup)
                    {
                        if (Convert.ToInt32(dr["IsAdmin"]) == 1)
                        {
                            PrivilegesManager.IsCurrentUserAdmin  = true;
                            SharedVariables.user_logged_name      = dr["UserName"].ToString();
                            SharedVariables.user_logged_name_name = dr["Name"].ToString();
                            isadmin = true;
                        }
                        else
                        {
                            PrivilegesManager.IsCurrentUserAdmin  = false;
                            SharedVariables.user_logged_name      = dr["UserName"].ToString();
                            SharedVariables.user_logged_name_name = dr["Name"].ToString();
                            isadmin = false;
                        }
                        PrivilegesManager.FillTemplate(Convert.ToInt32(dr["ID"]));
                        PrivilegesManager.IsTempActive  = false;
                        PrivilegesManager.IsAdminActive = isadmin;
                        SharedVariables.is_user_logged  = true;
                        if (SharedVariables.IsStartup)
                        {
                            Main2 aMain = new Main2();
                            aMain.Show();
                            //this.Close();
                        }
                    }    // END OF FIRST LOGIN
                    else //NOT FIRST LOGIN
                    {
                        if (Convert.ToInt32(dr["IsAdmin"]) == 1)
                        {
                            PrivilegesManager.IsTempUserAdmin     = true;
                            SharedVariables.temp_logged_name      = dr["UserName"].ToString();
                            SharedVariables.temp_logged_name_name = dr["Name"].ToString();
                        }
                        else
                        {
                            PrivilegesManager.IsTempUserAdmin     = false;
                            SharedVariables.temp_logged_name      = dr["UserName"].ToString();
                            SharedVariables.temp_logged_name_name = dr["Name"].ToString();
                        }
                        PrivilegesManager.FillTemplate(Convert.ToInt32(dr["ID"]), true);
                        PrivilegesManager.IsTempActive = true;
                    }

                    if (SharedVariables.IsStartup)
                    {
                        SharedVariables.IsStartup = false;
                        this.UsrTxtBox.Focus();
                        this.UsrTxtBox.Clear();
                        this.PassTxtBox.Clear();
                        this.Hide();
                    }
                    else //TEMP LOGIN SCREEN LAUNCHED INSIDE THE PROGRAM
                    {
                        this.Close();
                    }
                }
                else
                {
                    Thread.Sleep(1000);
                    MessageBox.Show(MsgTxt.UsrNameTxt + " " + MsgTxt.OrTxt + " " + MsgTxt.PasswordTxt + " " + MsgTxt.IncorrectTxt, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            else
            {
                string Messagetxt = MsgTxt.PleaseAddAllRequiredFields + "\n";
                if (UsrTxtBox.Text.Trim() == "")
                {
                    Messagetxt += "1)" + MsgTxt.UsrNameTxt + "\n";
                    UsrTxtBox.Focus();
                    UsrTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                }
                if (PassTxtBox.Text.Trim() == "")
                {
                    Messagetxt += "2)" + MsgTxt.PasswordTxt;
                    PassTxtBox.Focus();
                    if (UsrTxtBox.Text.Trim() == "")
                    {
                        UsrTxtBox.Focus();
                    }
                    PassTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                }
                MessageBox.Show(Messagetxt, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Testing aTest = new Testing();

            aTest.Show();
        }