Example #1
0
        /// <summary>
        /// Public interface to load Edit Pane.
        /// </summary>
        public void load_editPane()
        {
            Control saveControl = lastControlEntered;

            contentPane.Disable();
            infoPane.Disable();
            gvTitles.Enabled = false;
            panel1.Enabled   = false;
            editPane.Clear_Fields();
            editPane.SetFilter(filterCategory);
            editPane.load_data(DB_Handle.GetDataTable(string.Format(
                                                          @"SELECT * FROM titles 
                WHERE title_id={0}",
                                                          "\"" + gvTitles.SelectedCells[0].Value.ToString() + "\"")));
            editPane.Enable();
            editPane.Focus();
            lastControlEntered = saveControl;
        }
Example #2
0
 /// <summary>
 /// Generates the next available disc_id from discs table.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnGenerate_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = DB_Handle.GetDataTable(string.Format(
                                                   @"select max(disc_id) from discs 
             where location_id = '{0}'", ddLocation.Text));
         if (dt.Rows[0][0] is DBNull)
         {
             txtDisc.Text = "001";
         }
         else
         {
             txtDisc.Text = (Convert.ToInt32(dt.Rows[0][0]) + 1).ToString("000");
         }
     }
     catch (Exception ex)
     {
         BetterDialog.ShowDialog("DiscID Generation", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
     }
 }
Example #3
0
 /// <summary>
 /// Load Info Pane with data for selected gridview title.
 /// or
 /// Load Disc Pane with data for selected gridview title.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void gvTitles_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (gvTitles.SelectedCells.Count > 0)
     {
         if (gvTitles.SelectedCells[0].Value != null)
         {
             savedRow      = gvTitles.SelectedCells[0].RowIndex;
             lblTitle.Text = gvTitles.SelectedCells[0].Value.ToString();
             if (infoPane.active)
             {
                 infoPane.load_data(DB_Handle.GetDataTable(string.Format(
                                                               @"SELECT * FROM titles WHERE title_id={0}",
                                                               "\"" + gvTitles.SelectedCells[0].Value.ToString() + "\"")));
             }
             else
             {
                 contentPane.load_data(gvTitles.SelectedCells[0].Value.ToString());
             }
         }
     }
 }
Example #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);
                }
            }
        }
Example #5
0
        public void load_data(string sel)
        {
            gvDisc.Rows.Clear();
            try
            {
                DataTable temp = DB_Handle.GetDataTable(string.Format(
                                                            @"Select 
                        disc_contents.location_id, 
                        disc_contents.disc_id, 
                        discs.page_number,
                        discs.slot_number, 
                        contents.season, 
                        contents.rangeStart,
                        contents.rangeEnd 
                    FROM contents 
                    INNER JOIN disc_contents ON contents.content_id = disc_contents.content_id
                    INNER JOIN discs ON discs.disc_id = disc_contents.disc_id 
                    WHERE contents.title_id={0} AND discs.location_id=disc_contents.location_id",
                                                            "\"" + sel + "\""));

                if (temp.Rows.Count > 0)
                {
                    for (int i = 0; i <= temp.Rows.Count - 1; i++)
                    {
                        for (int k = 0; k <= temp.Columns.Count - 1; k++)
                        {
                            Console.WriteLine(temp.Rows[i][k].ToString());
                        }
                        gvDisc.Rows.Add(temp.Rows[i][0],
                                        temp.Rows[i][1], temp.Rows[i][2], temp.Rows[i][3],
                                        temp.Rows[i][4], temp.Rows[i][5], temp.Rows[i][6]);
                    }
                }
            }
            catch (Exception ex)
            {
                BetterDialog.ShowDialog("DB Error", ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon);
            }
        }
Example #6
0
        /// <summary>
        /// Get contents of a disc_id and generate a merged image for it.
        /// </summary>
        /// <param name="discid"></param>
        /// <param name="locationid"></param>
        /// <param name="btn"></param>
        /// <returns></returns>
        public static Image generateDiscImage(string discid, string locationid, Control btn)
        {
            Image     img  = resize_Image(LFI.Properties.Resources.border, 245, 345);
            DataTable temp = DB_Handle.GetDataTable(string.Format(
                                                        @"SELECT * FROM contents JOIN disc_contents on contents.content_id =
                disc_contents.content_id WHERE disc_id='{0}' and location_id='{1}';",
                                                        discid, locationid));

            if (temp.Rows.Count > 0)
            {
                List <string> disc_titles = new List <string>();
                if (temp.Rows.Count > 0)
                {
                    for (int i = 0; i <= temp.Rows.Count - 1; i++)
                    {
                        disc_titles.Add(temp.Rows[i][1].ToString());
                    }
                }
                img = Image_IO.createMergedImage(disc_titles, btn);
            }
            return(img);
        }
Example #7
0
        /// <summary>
        /// Load dbutton information based on Location, Page, Slot.
        /// Set selection data if currently selected.
        /// </summary>
        /// <param name="page">page_number.</param>
        public void load(int page)
        {
            DataTable dt = DB_Handle.GetDataTable(string.Format(@"select * from discs
                where location_id='{0}' and page_number='{1}' and slot_number='{2}'",
                                                                Location_ID, page, Slot));

            if (dt.Rows.Count != 0)
            {
                setData(dt.Rows[0][0], dt.Rows[0][1]);
            }
            else
            {
                setData(string.Empty, page);
            }
            Image = Image_IO.generateDiscImage(Disc, Location_ID, this);
            if (selDisc != string.Empty)
            {
                if (selSlot == Slot && selPage == Page)
                {
                    SetClick();
                }
            }
        }
Example #8
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();
                }
            }
        }
Example #9
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);
        }