Exemple #1
0
 /// <summary>
 /// Swap two disc slots in a location.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void swapMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (selDisc != string.Empty)
         {
             DB_Handle.UpdateTable(string.Format(
                                       @"INSERT OR REPLACE INTO DISCS 
                 VALUES ('{0}','{1}','{2}','{3}');",
                                       selDisc, Page, Slot, Location_ID));
         }
         if (Disc != string.Empty)
         {
             DB_Handle.UpdateTable(string.Format(
                                       @"INSERT OR REPLACE INTO DISCS 
                 VALUES ('{0}','{1}','{2}','{3}');",
                                       Disc, selPage, selSlot, Location_ID));
         }
         Caller.loadPage();
         OnClick(null);
     }
     catch (Exception ex)
     {
         BetterDialog.ShowDialog("Disc Move", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
     }
 }
Exemple #2
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);
         }
     }
 }
Exemple #3
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();
            }
        }
Exemple #4
0
        /// <summary>
        /// Prompt to delete record.
        /// Deletes disc and all content records on disc.
        /// </summary>
        /// <remarks>
        /// no foreign_key support in sqlite version so
        /// records are manually deleted from each table.
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dlg = BetterDialog.ShowDialog("Delete Disc",
                                                       "Disc will be deleted permanently. Are you Sure?",
                                                       Location_ID + Disc, "Yes", "No", Image, BetterDialog.ImageStyle.Image);

            if (dlg == DialogResult.OK)
            {
                try
                {
                    DB_Handle.UpdateTable(string.Format(
                                              @"DELETE FROM DISCS WHERE disc_id='{0}' and location_id='{1}'",
                                              Disc, Location_ID));

                    DataTable dt = DB_Handle.GetDataTable(string.Format(
                                                              @"SELECT content_id from disc_contents WHERE disc_id='{0}' and location_id='{1}'",
                                                              Disc, Location_ID));

                    for (int i = 0; i <= dt.Rows.Count - 1; i++)
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"DELETE FROM CONTENTS WHERE content_id='{0}'", dt.Rows[i][0]));
                    }

                    DB_Handle.UpdateTable(string.Format(
                                              @"DELETE FROM DISC_CONTENTS WHERE disc_id='{0}' and location_id='{1}'",
                                              Disc, Location_ID));
                }
                catch (Exception ex)
                {
                    BetterDialog.ShowDialog("Disc Delete", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
                finally
                {
                    DButton.SelBtn.PerformClick();
                    Caller.loadPage();
                    OnClick(null);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Attempts to save selected disc and each of its content rows.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveClick(object sender, EventArgs e)
        {
            bool rollbackpos = false;

            if (txtDisc.Text.Length < 1)
            {
                Error_Handle.TipError("Disc required\n", toolTip, txtDisc);
            }
            else if (txtPage.Text.Length < 1)
            {
                Error_Handle.TipError("Page required\n", toolTip, txtPage);
            }
            else if (txtSlot.Text.Length < 1)
            {
                Error_Handle.TipError("Slot required\n", toolTip, txtSlot);
            }
            else if (ddLocation.Text.Length < 1)
            {
                Error_Handle.TipError("Location required\n", toolTip, ddLocation);
            }
            else if (gvContents.Rows.Count < 1)
            {
                Error_Handle.TipError("Content required\n", toolTip, gvContents);
            }
            else
            {
                try
                {
                    DB_Handle.UpdateTable(string.Format(
                                              @"INSERT OR REPLACE INTO DISCS 
                        VALUES ('{0}','{1}','{2}','{3}');",
                                              txtDisc.Text, txtPage.Text, txtSlot.Text, ddLocation.Text));

                    if (isNewRecord)
                    {
                        rollbackpos = true;
                    }
                    DB_Handle.OpenConnection();
                    for (int i = 0; i <= gvContents.Rows.Count - 1; i++)
                    {
                        DB_Handle.ScalarUpdate(string.Format(
                                                   @"INSERT OR REPLACE INTO CONTENTS 
                            (content_id, title_id, season, rangeStart, rangeEnd)
                            VALUES ({0},{1},'{2}','{3}','{4}');",
                                                   gvContents.Rows[i].Cells[4].Value,
                                                   "\"" + gvContents.Rows[i].Cells[0].Value + "\"",
                                                   gvContents.Rows[i].Cells[1].Value,
                                                   gvContents.Rows[i].Cells[2].Value,
                                                   gvContents.Rows[i].Cells[3].Value));


                        DB_Handle.ScalarUpdate(string.Format(
                                                   @"INSERT OR REPLACE INTO DISC_CONTENTS
                            (content_id, disc_id, location_id)
                            VALUES (last_insert_rowid(),'{0}','{1}');",
                                                   txtDisc.Text,
                                                   ddLocation.Text));
                    }
                    BetterDialog.ShowDialog("Disc Save", "Success", "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
                catch (Exception ex)
                {
                    if (rollbackpos)
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"DELETE FROM DISCS WHERE
                            disc_id = '{0}' AND location_id = '{1}'",
                                                  txtDisc.Text, ddLocation.Text));
                    }
                    BetterDialog.ShowDialog("Disc Save", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
                }
                finally
                {
                    DB_Handle.CloseConnection();
                    DButton.SelBtn.DButton_Click(null, null);
                    loadPage();
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Attempts to update title and information.
        /// Validates information.
        /// Renames image if exists.
        /// </summary>
        /// <remarks>'Insert into' for new records only.</remarks>
        /// <returns>Pass or fail coniditon.</returns>
        public bool saveData()
        {
            bool status = false;

            try
            {
                if (txtTitle.Text.Trim().Length == 0)
                {
                    Error_Handle.TipError("Title required\n", toolTip, txtTitle);
                }
                else if (isnewrecord && SearchExistingTitles())
                {
                    Error_Handle.TipError("Title already exists\n", toolTip, txtTitle);
                }
                else if (ddCategory.Text.Length == 0)
                {
                    Error_Handle.TipError("Category required\n", toolTip, ddCategory);
                }
                else if (ddStatus.Text.Length < 1)
                {
                    Error_Handle.TipError("Status required\n", toolTip, ddStatus);
                }
                else if (ddLanguage.Text.Length < 1)
                {
                    Error_Handle.TipError("Language required\n", toolTip, ddLanguage);
                }
                else if (txtYear.Text.Length != 4)
                {
                    Error_Handle.TipError("Year required\n", toolTip, txtYear);
                }
                else if (txtEpisode.Text.Length < 1)
                {
                    Error_Handle.TipError("Episode required\n", toolTip, txtEpisode);
                }
                else
                {
                    if (isnewrecord)
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"INSERT INTO TITLES VALUES ({0},'{1}','{2}','{3}','{4}','{5}');",
                                                  "\"" + txtTitle.Text.Trim() + "\"", txtEpisode.Text.Replace(" ", ""), ddCategory.Text,
                                                  txtYear.Text, ddStatus.Text, ddLanguage.Text, currentTitle));
                    }
                    else
                    {
                        DB_Handle.UpdateTable(string.Format(
                                                  @"UPDATE TITLES SET
                            title_id={0}, 
                            episodes='{1}', 
                            category='{2}', 
                            year='{3}', 
                            status='{4}', 
                            language='{5}'
                            WHERE title_id={6};",
                                                  "\"" + txtTitle.Text.Trim() + "\"", txtEpisode.Text.Replace(" ", ""), ddCategory.Text,
                                                  txtYear.Text, ddStatus.Text, ddLanguage.Text, "\"" + currentTitle + "\""));

                        DB_Handle.UpdateTable(string.Format(
                                                  @"UPDATE CONTENTS SET
                            title_id={0}
                            WHERE title_id={1};",
                                                  "\"" + txtTitle.Text.Trim() + "\"", "\"" + currentTitle + "\""));
                        Image_IO.rename_Image(currentTitle, txtTitle.Text.Trim());
                    }

                    BetterDialog.ShowDialog("Saved", "Success", string.Empty, string.Empty, "OK", null, BetterDialog.ImageStyle.Icon);
                    status = true;
                    populateDropDownTitles();
                }
            }
            catch (Exception ex)
            {
                Error_Handle.TipError(ex.Message, toolTip, imgError);
            }
            return(status);
        }