Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text == String.Empty || textBox2.Text == String.Empty)
                {
                    SpeechSynthesizer s = new SpeechSynthesizer();
                    s.Speak(label9.Text);

                    MessageBox.Show("Please Enter Data!", "Message");
                }
                else
                {
                    var loginResult = DataAccessLayer.GetRecords("SELECT * FROM UserAccount where username = '******'and [Password]='" + textBox2.Text + "'");

                    if (loginResult.Rows.Count == 0)
                    {
                        SpeechSynthesizer s = new SpeechSynthesizer();
                        s.Speak(label4.Text);

                        MessageBox.Show("Invalid Credentials!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                    else
                    {
                        GlobalVariable.LoggedInUser = loginResult;


                        StringBuilder qry = new StringBuilder();
                        qry.AppendLine("INSERT INTO UserLogs ");
                        qry.AppendLine("(");
                        qry.AppendLine("UserId,");
                        qry.AppendLine("Activity,");
                        qry.AppendLine("LogDate");
                        qry.AppendLine(") VALUES (");
                        qry.AppendLine("'" + loginResult.Rows[0].Field <int>("ID").ToString() + "',");
                        qry.AppendLine("'" + Class1.Activity.LOGIN.ToString() + "',");
                        qry.AppendLine("'" + DateTime.Now.ToString("MMM-dd-yyyy hh:mm:ss tt") + "'");
                        qry.AppendLine(")");
                        DataAccessLayer.ExecuteNonQuery(qry.ToString());
                        SpeechSynthesizer sp = new SpeechSynthesizer();
                        sp.Speak(label3.Text);
                        sp.Speak(label7.Text);

                        MessageBox.Show("Log-in Successful!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        this.Hide();
                        load loading = new load();
                        loading.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed due to " + ex.Message, "Message");
            }
        }
Exemplo n.º 2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (txtbox_retype.Text == txtbox_Pass.Text)
            {
                if (txtbox_name.Text == String.Empty || textbox_lastname.Text == String.Empty || txtbox_Pass.Text == String.Empty || txtbox_User.Text == String.Empty)
                {
                    SpeechSynthesizer sp = new SpeechSynthesizer();
                    sp.Speak(label10.Text);
                    MessageBox.Show("Please Enter Data!", "Message");
                }
                else
                {
                    var existingUser = DataAccessLayer.GetRecords("SELECT * FROM UserAccount where username = '******'");
                    if (existingUser.Rows.Count > 0)
                    {
                        MessageBox.Show("Username Already Exist!", "Message");
                        return;
                    }


                    StringBuilder qry = new StringBuilder();
                    qry.AppendLine("INSERT INTO UserAccount ");
                    qry.AppendLine("(");
                    qry.AppendLine("username,");
                    qry.AppendLine("[password],");
                    qry.AppendLine("fname,");
                    qry.AppendLine("mi,");
                    qry.AppendLine("lname");
                    qry.AppendLine(") VALUES (");
                    qry.AppendLine("'" + txtbox_User.Text.Trim() + "',");
                    qry.AppendLine("'" + txtbox_Pass.Text.Trim() + "',");
                    qry.AppendLine("'" + txtbox_name.Text.Trim() + "',");
                    qry.AppendLine("'" + txtbox_mi.Text.Trim() + "',");
                    qry.AppendLine("'" + textbox_lastname.Text.Trim() + "'");
                    qry.AppendLine(")");

                    DataAccessLayer.ExecuteNonQuery(qry.ToString());
                    SpeechSynthesizer sp = new SpeechSynthesizer();
                    sp.Speak(label9.Text);
                    MessageBox.Show("Account Successfully Created!", "Message");
                    this.Close();
                    Form1 f1 = new Form1();
                    f1.Show();
                }
            }
        }
Exemplo n.º 3
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtuser.Text == String.Empty || txtpass.Text == String.Empty)
                {
                    SpeechSynthesizer s = new SpeechSynthesizer();
                    s.Speak(label18.Text);
                    MessageBox.Show("Please Enter Data!", "Message");
                }
                else
                {
                    var loginResult = DataAccessLayer.GetRecords("SELECT * FROM UserAccount where Username = '******'and [Pass]='" + txtpass.Text + "'");

                    if (loginResult.Rows.Count == 0)
                    {
                        SpeechSynthesizer s = new SpeechSynthesizer();
                        s.Speak(label17.Text);
                        MessageBox.Show("Invalid Credentials!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                    else
                    {
                        SpeechSynthesizer s = new SpeechSynthesizer();


                        GlobalVariable.LoggedInUser = loginResult;


                        StringBuilder qry = new StringBuilder();
                        qry.AppendLine("INSERT INTO UserLogs ");
                        qry.AppendLine("(");
                        qry.AppendLine("UserId,");
                        qry.AppendLine("Activity,");
                        qry.AppendLine("LogDate");
                        qry.AppendLine(") VALUES (");
                        qry.AppendLine("'" + loginResult.Rows[0].Field <int>("ID").ToString() + "',");
                        qry.AppendLine("'" + Class1.Activity.LOGIN.ToString() + "',");
                        qry.AppendLine("'" + DateTime.Now.ToString("MMM-dd-yyyy hh:mm:ss tt") + "'");
                        qry.AppendLine(")");
                        DataAccessLayer.ExecuteNonQuery(qry.ToString());

                        SpeechSynthesizer sa = new SpeechSynthesizer();
                        sa.Speak(label16.Text);
                        MessageBox.Show("Log-in Successful!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        /* this.Hide();
                         * load loading = new load();
                         * loading.Show();*/
                        p.Visible             = false;
                        label11.Visible       = false;
                        pictureBox2.Visible   = false;
                        pictureBox3.Visible   = false;
                        panel1.Visible        = false;
                        panel2.Visible        = false;
                        txtpass.Visible       = false;
                        txtuser.Visible       = false;
                        btnlogin.Visible      = false;
                        btncancel.Visible     = false;
                        panel3.Visible        = false;
                        btn_del.Visible       = true;
                        label13.Visible       = true;
                        label10.Visible       = false;
                        btn_admin.Visible     = false;
                        btn_editgrade.Visible = false;
                        label14.Visible       = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed due to " + ex.Message, "Message");
            }
        }