Exemplo n.º 1
0
        private void BT_AdminAdd_Click(object sender, EventArgs e)
        {
            var p = new Person();

            // Creating an instance of Person.cs to use its functions and strings
            p.UserName = TB_AdminUsername.Text;
            p.PassWord = TB_AdminPassword.Text;
            // Declaring the textbox values to Person.cs strings

            w.Insert(p);
            // Using the Insert function in Person.cs through here
        }
Exemplo n.º 2
0
        //void ClearTBoxes(DependencyObject dObject)
        //{
        //    TextBox tb = dObject as TextBox;
        //    if (tb != null)
        //        tb.Text = null;

        //    foreach (DependencyObject obj in dObject.GetChildObjects())
        //        ClearTextBoxes(obj);
        //}


        private void BT_RegisterRegister_Click(object sender, EventArgs e)
        {
            //OleDbConnection connection;

            //connection =
            //    new OleDbConnection(
            //        @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=A:\Users\Atul Anand Sinha\Documents\Visual Studio 2013\Projects\Database\Database.accdb;Persist Security Info=False");

            using (
                var connection =
                    new OleDbConnection(
                        @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=A:\Users\Atul Anand Sinha\Documents\Visual Studio 2013\Projects\Database\Database.accdb;Persist Security Info=False")
                )
            // Using the connection string and address:
            {
                if (!empId())
                // If the function empId() returns false then
                {
                    // Do nothing
                }
                else
                {
                    if (textBox1.Text != "" && textBox2.Text == textBox3.Text)
                    // If username textbox is not null and the password textboxes match then
                    {
                        var p = new Person();
                        // Create a new instance from Person.cs class library
                        p.UserName = textBox1.Text;
                        p.PassWord = textBox3.Text;
                        // Assign username and password textbox values to Person.cs strings
                        w.Insert(p);
                        // Run the Insert function in Worker.cs
                        MessageBox.Show("You are registered!");
                        // Show success message!
                    }
                    else
                    {
                        MessageBox.Show("Values in textboxes must be same!", "Error!", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        // Show error message
                    }
                }
            }
        }