Exemplo n.º 1
0
        private void SaveEntry_Click(object sender, EventArgs e)
        {
            TableTableAdapter   regionTableAdapter  = new TableTableAdapter();
            DataTableConnection dataTableConnection = new DataTableConnection();

            dataTableConnection.mainWindow = this;

            var dataTable = dataTableConnection.RefreshDataTable();

            if (uRLTextBox.Text.Trim() != "" && usernameTextBox.Text.Trim() != "" && passwordTextBox.Text.Trim() != "")
            {
                if (dataTable.Rows.Count == 0)
                {
                    regionTableAdapter.Insert(1, URLTextBox.Text, UsernameTextBox.Text, PasswordTextBox.Text);
                    URLTextBox.Text      = "";
                    UsernameTextBox.Text = "";
                    PasswordTextBox.Text = "";
                }
                else
                {
                    regionTableAdapter.Insert(Convert.ToInt32(dataTable.Rows[dataTable.Rows.Count - 1].ItemArray[0]) + 1, URLTextBox.Text, UsernameTextBox.Text, PasswordTextBox.Text);
                    URLTextBox.Text      = "";
                    UsernameTextBox.Text = "";
                    PasswordTextBox.Text = "";
                }
            }
            dataTableConnection.RefreshDataTable();
        }
Exemplo n.º 2
0
 public void DataGridViewRightClickActions(object sender, ToolStripItemClickedEventArgs e, DataTableConnection dt)
 {
     if (e.ClickedItem.Text == "Copy URL" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         mainWindow.passwordRecordGridView.CurrentCell = mainWindow.passwordRecordGridView.Rows[mainWindow.passwordRecordGridView.CurrentCell.RowIndex].Cells[1];
         columnToCopy = mainWindow.passwordRecordGridView.CurrentCell.ColumnIndex;
         Clipboard.SetDataObject(mainWindow.passwordRecordGridView.CurrentCell.Value.ToString().Trim(), false);
     }
     else if (e.ClickedItem.Text == "Copy Username" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         mainWindow.passwordRecordGridView.CurrentCell = mainWindow.passwordRecordGridView.Rows[mainWindow.passwordRecordGridView.CurrentCell.RowIndex].Cells[2];
         columnToCopy = mainWindow.passwordRecordGridView.CurrentCell.ColumnIndex;
         Clipboard.SetDataObject(mainWindow.passwordRecordGridView.CurrentCell.Value.ToString().Trim(), false);
     }
     else if (e.ClickedItem.Text == "Copy Password" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         mainWindow.passwordRecordGridView.CurrentCell = mainWindow.passwordRecordGridView.Rows[mainWindow.passwordRecordGridView.CurrentCell.RowIndex].Cells[3];
         columnToCopy = mainWindow.passwordRecordGridView.CurrentCell.ColumnIndex;
         Clipboard.SetDataObject(mainWindow.passwordRecordGridView.CurrentCell.Value.ToString().Trim(), false);
     }
     else if (e.ClickedItem.Text == "Delete Entry" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         TableTableAdapter regionTableAdapter = new TableTableAdapter();
         mainWindow.rightClickMenu.Visible = false;
         var confirmResult = MessageBox.Show("Are you sure to delete this entry ?", "Confirm Delete", MessageBoxButtons.YesNo);
         if (confirmResult == DialogResult.Yes)
         {
             regionTableAdapter.Delete(Convert.ToInt32(mainWindow.passwordRecordGridView.CurrentRow.Cells[0].Value),
                                       mainWindow.passwordRecordGridView.CurrentRow.Cells[1].Value.ToString(),
                                       mainWindow.passwordRecordGridView.CurrentRow.Cells[2].Value.ToString(),
                                       mainWindow.passwordRecordGridView.CurrentRow.Cells[3].Value.ToString());
             dt.RefreshDataTable();
         }
     }
 }
Exemplo n.º 3
0
 public void DataGridViewRightClickActions(object sender, ToolStripItemClickedEventArgs e, DataTableConnection dt)
 {
     if (e.ClickedItem.Text == "Copy URL" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         mainWindow.passwordRecordGridView.CurrentCell = mainWindow.passwordRecordGridView.Rows[mainWindow.passwordRecordGridView.CurrentCell.RowIndex].Cells[1];
         columnToCopy = mainWindow.passwordRecordGridView.CurrentCell.ColumnIndex;
         Clipboard.SetDataObject(mainWindow.passwordRecordGridView.CurrentCell.Value.ToString().Trim(), false);
     }
     else if (e.ClickedItem.Text == "Copy Username" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         mainWindow.passwordRecordGridView.CurrentCell = mainWindow.passwordRecordGridView.Rows[mainWindow.passwordRecordGridView.CurrentCell.RowIndex].Cells[2];
         columnToCopy = mainWindow.passwordRecordGridView.CurrentCell.ColumnIndex;
         Clipboard.SetDataObject(mainWindow.passwordRecordGridView.CurrentCell.Value.ToString().Trim(), false);
     }
     else if (e.ClickedItem.Text == "Copy Password" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         mainWindow.passwordRecordGridView.CurrentCell = mainWindow.passwordRecordGridView.Rows[mainWindow.passwordRecordGridView.CurrentCell.RowIndex].Cells[3];
         columnToCopy = mainWindow.passwordRecordGridView.CurrentCell.ColumnIndex;
         Clipboard.SetDataObject(mainWindow.passwordRecordGridView.CurrentCell.Value.ToString().Trim(), false);
     }
     else if (e.ClickedItem.Text == "Delete Entry" && mainWindow.passwordRecordGridView.CurrentCell.Value != null)
     {
         TableTableAdapter regionTableAdapter = new TableTableAdapter();
         //DataTableConnection dataTableConnection = new DataTableConnection();
         //var dataTable = dataTableConnection.RefreshDataTable();
         regionTableAdapter.Delete(Convert.ToInt32(mainWindow.passwordRecordGridView.CurrentRow.Cells[0].Value),
                                   mainWindow.passwordRecordGridView.CurrentRow.Cells[1].Value.ToString(),
                                   mainWindow.passwordRecordGridView.CurrentRow.Cells[2].Value.ToString(),
                                   mainWindow.passwordRecordGridView.CurrentRow.Cells[3].Value.ToString());
         dt.RefreshDataTable();
     }
 }