Ejemplo n.º 1
0
        private void btnAddToEntry_Click(object sender, EventArgs e)
        {
            /*************************************************************************************************
            *                                                                                               *
            *                    btnAddToEntry_Click: Add a Word or Expression to the Entry                 *
            *                    ==========================================================                 *
            *                                                                                               *
            *  Add a single row of data (excluding the keyword).  The entry will be added to the end of the *
            *    data in the grid.                                                                          *
            *                                                                                               *
            *************************************************************************************************/
            int       currRow = 0;
            EditEntry entryForm;

            entryForm = new EditEntry(dgvMain.Rows[0].Cells[0].Value.ToString(), "", "", "", true, false);
            if (entryForm.ShowDialog() == DialogResult.OK)
            {
                currRow = dgvMain.RowCount - 1;
                if (currRow == 0)
                {
                    return;
                }
                dgvMain.RowCount++;
                dgvMain.Rows[currRow].Cells[0].Value = "";
                dgvMain.Rows[currRow].Cells[1].Value = entryForm.SourceEntry;
                dgvMain.Rows[currRow].Cells[2].Value = entryForm.EnglishEntry;
                dgvMain.Rows[currRow].Cells[3].Value = entryForm.ExampleEntry;
            }
            entryForm.Dispose();
        }
Ejemplo n.º 2
0
        private void btnNewEntry_Click(object sender, EventArgs e)
        {
            /*************************************************************************************************
            *                                                                                               *
            *                                btnNewEntry_Click: Start a New Entry                           *
            *                                ====================================                           *
            *                                                                                               *
            *  Uses btnStore_Click to store the data, then btnClear_Click to return state to starting       *
            *    point.                                                                                     *
            *                                                                                               *
            *************************************************************************************************/
            EditEntry entryForm;

            btnStore_Click(sender, e);
            btnClear_Click(sender, e);
            entryForm = new EditEntry("", "", "", "", true, true);
            if (entryForm.ShowDialog() == DialogResult.OK)
            {
                dgvMain.RowCount++;
                dgvMain.Rows[0].Cells[0].Value = entryForm.KeyWord;
                dgvMain.Rows[0].Cells[1].Value = entryForm.SourceEntry;
                dgvMain.Rows[0].Cells[2].Value = entryForm.EnglishEntry;
                dgvMain.Rows[0].Cells[3].Value = entryForm.ExampleEntry;
            }
            entryForm.Dispose();
        }
Ejemplo n.º 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            /*************************************************************************************************
            *                                                                                               *
            *                         btnEdit_Click: Modify the currently Selected row                      *
            *                         ================================================                      *
            *                                                                                               *
            *************************************************************************************************/
            int              idx, currRow = 0;
            String           keyWordText, sourceText, engText, egText;
            EditEntry        entryForm;
            DataGridViewCell dataGridViewCell;

            dataGridViewCell = dgvMain.Rows[0].Cells[0];
            if (dataGridViewCell.Value == null)
            {
                return;
            }
            keyWordText = dataGridViewCell.Value.ToString();
            if (keyWordText.Length == 0)
            {
                return;
            }
            for (idx = 0; idx < dgvMain.RowCount; idx++)
            {
                if (dgvMain.Rows[idx].Selected)
                {
                    currRow = idx;
                    break;
                }
            }
            dataGridViewCell = dgvMain.Rows[currRow].Cells[1];
            if (dataGridViewCell.Value == null)
            {
                sourceText = "";
            }
            else
            {
                sourceText = dataGridViewCell.Value.ToString();
            }
            dataGridViewCell = dgvMain.Rows[currRow].Cells[2];
            if (dataGridViewCell.Value == null)
            {
                engText = "";
            }
            else
            {
                engText = dataGridViewCell.Value.ToString();
            }
            dataGridViewCell = dgvMain.Rows[currRow].Cells[3];
            if (dataGridViewCell.Value == null)
            {
                egText = "";
            }
            else
            {
                egText = dataGridViewCell.Value.ToString();
            }
            entryForm = new EditEntry(keyWordText, sourceText, engText, egText, false, false);
            if (entryForm.ShowDialog() == DialogResult.OK)
            {
                dgvMain.Rows[currRow].Cells[1].Value = entryForm.SourceEntry;
                dgvMain.Rows[currRow].Cells[2].Value = entryForm.EnglishEntry;
                dgvMain.Rows[currRow].Cells[3].Value = entryForm.ExampleEntry;
            }
            entryForm.Dispose();
        }