Ejemplo n.º 1
0
        private void login()
        {
            Boolean valid = false;

            HSForm = new HomeScreen(txtUsername.Text);
            myConn.Close();
            btnQuickLogin.Enabled = true;

            string loginReport = Properties.Settings.Default.loginReportPath;

            using (StreamWriter sw = File.AppendText(loginReport))
            {
                System.DateTime dt    = DateTime.Today;
                string          day   = dt.Day.ToString();
                string          month = dt.Month.ToString();
                string          year  = dt.Year.ToString();

                string fullString = txtUsername.Text + "," + day + "," + month + "," + year;
                sw.WriteLine(fullString);
            }


            using (StreamReader sw = new StreamReader(Properties.Settings.Default.quickLoginPath))
            {
                string line;
                while ((line = sw.ReadLine()) != null)
                {
                    string[] lineInfo = line.Split(',');
                    string   id       = lineInfo[0];
                    if (id.Equals(txtUsername.Text))
                    {
                        valid = true;
                        break;
                    }
                }
            }

            if (!valid)
            {
                quickLogin(txtUsername.Text);
            }

            lblPin.Visible        = false;
            btnSubmit.Visible     = false;
            txtPIN.Visible        = false;
            btnLogin.Visible      = true;
            txtUsername.Visible   = true;
            txtPassword.Text      = "";
            txtUsername.Text      = "";
            txtPIN.Text           = "";
            lblSuccess.Text       = "";
            txtCredentialBox.Text = "";
            txtPIN.Enabled        = false;
            btnSubmit.Enabled     = false;
            this.Hide();
            HSForm.ShowDialog();
            this.Show();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string UName = txtUsername.Text;
            string PWord = txtPassword.Text;

            myConn = new SqlConnection("Server=softwarecapproject.database.windows.net;Database=VideoStoreUsers;User ID = bcrumrin64; Password=S0ftT0pix!; Encrypt=True; TrustServerCertificate=False; Connection Timeout=30;");
            myConn.Open();
            myCmd = new SqlCommand("SELECT IDNumber, PassPhrase FROM UserTable WHERE IDNumber = @Uname AND PassPhrase = @Pass", myConn);
            myCmd.Parameters.AddWithValue("@Uname", UName);
            myCmd.Parameters.AddWithValue("@Pass", PWord);

            var test = myCmd.ExecuteScalar();

            if (test == null)
            {
                lblSuccess.Text = "Invalid Username/Password";
                myConn.Close();
            }
            else
            {
                Boolean valid = true;
                HSForm = new HomeScreen(txtUsername.Text);
                myConn.Close();

                string loginReport = "..\\Files\\LoginReport.txt";
                using (StreamWriter sw = File.AppendText(loginReport))
                {
                    System.DateTime dt    = DateTime.Today;
                    string          day   = dt.Day.ToString();
                    string          month = dt.Month.ToString();
                    string          year  = dt.Year.ToString();

                    string fullString = txtUsername.Text + "," + day + "," + month + "," + year;
                    sw.WriteLine(fullString);
                }

                txtPassword.Text = "";
                txtUsername.Text = "";
                this.Hide();
                HSForm.ShowDialog();
                this.Show();
            }
        }