コード例 #1
0
 /// <summary>
 /// Removes selected title row from gridview.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (gvContents.Rows.Count > 0)
     {
         DialogResult result = BetterDialog.ShowDialog("Remove Record?",
                                                       "Record will be deleted permanently.  Are you sure?",
                                                       string.Format("{0}\nSeason {1}\nStart {2}\nEnd {3}",
                                                                     gvContents.SelectedCells[0].Value, gvContents.SelectedCells[1].Value,
                                                                     gvContents.SelectedCells[2].Value, gvContents.SelectedCells[3].Value),
                                                       "Yes", "No", Image_IO.getImage(gvContents.SelectedCells[0].Value.ToString()),
                                                       BetterDialog.ImageStyle.Image);
         if (result == DialogResult.OK)
         {
             if (gvContents.Rows[gvContents.SelectedCells[0].RowIndex].Cells[4].ToString() != "null")
             {
                 DB_Handle.UpdateTable(string.Format(
                                           @"DELETE FROM CONTENTS WHERE
                     content_id = '{0}'",
                                           gvContents.Rows[gvContents.SelectedCells[0].RowIndex].Cells[4].Value));
             }
             gvContents.Rows.Remove(gvContents.Rows[gvContents.SelectedCells[0].RowIndex]);
             loadPage();
             DButton.SelBtn.DButton_Click(null, null);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Prompt to delete selected row:
        /// Yes - Deletes title and image then refreshes gridview.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dlg = BetterDialog.ShowDialog("Delete Title?", "Are you sure you want to delete this title?",
                                                       gvTitles.SelectedCells[0].Value.ToString(), "Yes", "No",
                                                       Image_IO.getImage(gvTitles.SelectedCells[0].Value.ToString()), BetterDialog.ImageStyle.Image);

            if (dlg == DialogResult.OK)
            {
                int row = gvTitles.SelectedCells[0].RowIndex;
                DB_Handle.UpdateTable(string.Format(
                                          @"DELETE FROM TITLES WHERE title_id={0}",
                                          "\"" + gvTitles.SelectedCells[0].Value.ToString() + "\""));
                Image_IO.delete_Image(gvTitles.SelectedCells[0].Value.ToString());

                if (gvTitles.Rows.Count > 0 && row > 0)
                {
                    savedRow = row - 1;
                    gvTitles[0, row].Selected = true;
                }
                else
                {
                    savedRow = 0;
                }
                if (txtSearch.Text.Length != 0)
                {
                    txtSearch_TextChanged(null, null);
                }
                load_infoPane();

                gvTitles.Focus();
            }
        }