Пример #1
0
        void ComboBox1SelectedIndexChanged(object sender, EventArgs e)
        {
            //take the new index of the combobox and look up the index of the local list.
            //use the local list value to search the database user IDs.
            //then repopulate the form.
            //access connections have already been set up and everything.
            //TODO:after quert, point editResult to the localResult for use when button2 is pressed

            string selectedIndex = "";
            string selectedName  = "";
            int    myIndex       = comboBox1.SelectedIndex;

            comboIndex = myIndex;
            dbResult localResult = new dbResult();

            selectedIndex = localIndex[myIndex];
            selectedName  = localName[myIndex];
            localResult.queryDatabase("WHERE ((MyNumber='" + selectedIndex + "')", ")", localResult, conn2);

            localResult.ClearIndex();
            localResult.ClearName();
            for (int i = 0; i < localIndex.Count; i++)
            {
                localResult.SetIndex(localIndex[i]);
                localResult.SetName(localName[i]);
            }
            //editResult = localResult;
            clearForm();
            populateForm(localResult, myIndex);
            //localResult = null;
        }
Пример #2
0
        void Button2Click(object sender, System.EventArgs e)
        {
            int      myIndex       = comboBox1.SelectedIndex;
            string   selectedIndex = "";
            string   selectedName  = "";
            dbResult localResult   = new dbResult();

            selectedIndex = localIndex[myIndex];
            selectedName  = localName[myIndex];
            localResult.queryDatabase("WHERE ((MyNumber='" + selectedIndex + "')", ")", localResult, conn2);

            localResult.ClearIndex();
            localResult.ClearName();
            for (int i = 0; i < localIndex.Count; i++)
            {
                localResult.SetIndex(localIndex[i]);
                localResult.SetName(localName[i]);
            }

            //delete the entry we're going to edit
            localResult.deleteFromDatabase(localIndex[myIndex], conn2);

            //set up the extraction form and show
            ExtractionForm editForm = new ExtractionForm(myDBPath, localResult);

            editForm.Show();
        }
Пример #3
0
        void FindButtonClick(object sender, System.EventArgs e)
        {
            //create the form to show results, create teh SQL string, run the command and then show results on form
            dbResult findResult    = new dbResult();
            string   queryCriteria = "";
            string   queryEnd      = "";

            if (!isConnected)
            {
                MessageBox.Show("Please connect to database prior to searching.");
            }
            else
            {
                //last name must be entered prior to search.  entering * is a wildcard, and entering nothing actually searches for a blank criteria
                if (lastName.Text != "")
                {
                    if (lastName.Text != "*")
                    {
                        queryEnd      = ")";
                        queryCriteria = "WHERE ((LastName='" + lastName.Text.ToString() + "')";
                        if (firstName.Text != "")
                        {
                            queryCriteria = queryCriteria + "AND " + "(FirstName='" + firstName.Text.ToString() + "')";
                        }
                        if (middleName.Text != "")
                        {
                            queryCriteria = queryCriteria + "AND " + "(middleName='" + middleName.Text.ToString() + "')";
                        }
                    }
                    findResult.queryDatabase(queryCriteria, queryEnd, findResult, conn);

                    //set up the form and show
                    dbForm findForm = new dbForm(findResult, dataBasePath);
                    findForm.Show();
                }
            }
        }