Esempio n. 1
0
        // Buttons
        private void save()
        {
#if DEMO
            new DemoVersionOnly("Modifying song data").ShowDialog();
#else
            // update row
            currentRow.Number = Convert.ToInt32(txtNumber.Text);
            currentRow.Title  = txtTitle.Text;
            currentRow.Chorus = txtChorus.Text;
            currentRow.Image  = currentImage.ImageId;

            // save changes
            if (currentRow.RowState == DataRowState.Detached)
            {
                Program.SongsDS.Songs.AddSongsRow(currentRow);
            }

            Data.Songs.AddUpdateSong(currentRow);
            currentRow.AcceptChanges();

            #region Save datatable changes
            Data.Songs.UpdateSongCopyright(currentRow.AutoNumber, txtCopyright.Text);
            using (FBirdTask t = new FBirdTask())
            {
                DataTable changes = dt.GetChanges();
                if (changes != null)
                {
                    t.CommandText = "DELETE FROM [SongVerses] WHERE [AutoNumber] = @AutoNumber";
                    t.Parameters.Add("@AutoNumber", FbDbType.Integer);
                    t.Parameters["@AutoNumber"].Value = currentRow.AutoNumber;
                    t.ExecuteNonQuery();

                    t.CommandText =
                        "INSERT INTO [SongVerses] ([AutoNumber], [IsChorus], [Verse], [OrderNum]) " +
                        "VALUES (@AutoNumber, @IsChorus, @Verse, @OrderNum)";
                    t.Parameters.Add("@IsChorus", FbDbType.SmallInt);
                    t.Parameters.Add("@Verse", FbDbType.VarChar, 0);
                    t.Parameters.Add("@OrderNum", FbDbType.Integer);

                    int i = 0;
                    foreach (DataRow r in dt.Rows)
                    {
                        if (r.RowState == DataRowState.Deleted)
                        {
                            continue;
                        }

                        t.Parameters["@OrderNum"].Value = i.ToString();
                        t.Parameters["@IsChorus"].Value = (bool)r["IsChorus"] == true ? 1 : 0;
                        t.Parameters["@Verse"].Value    = r["Verse"];
                        t.ExecuteNonQuery();
                        i++;
                    }
                }
            }
            #endregion
#endif
        }
Esempio n. 2
0
        /// <summary></summary>
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

            // update row
            currentRow.Number = Convert.ToInt32(txtNumber.Text);
            currentRow.Title  = txtTitle.Text;
            currentRow.Chorus = txtChorus.Text;

            // save changes
            if (currentRow.RowState == DataRowState.Detached)
            {
                Presenter.DefaultDS.Songs.AddSongsRow(currentRow);
            }

            currentRow.AcceptChanges();

            // save datatable changes
            using (FBirdTask t = new FBirdTask())
            {
                DataTable changes = dt.GetChanges();
                if (changes != null)
                {
                    t.CommandText = "DELETE FROM \"SongVerses\" WHERE \"AutoNumber\" = @AutoNumber";
                    t.Parameters.Add("@AutoNumber", FbDbType.Integer);
                    t.Parameters["@AutoNumber"].Value = currentRow.AutoNumber;
                    t.ExecuteNonQuery();

                    t.CommandText =
                        "INSERT INTO \"SongVerses\" (\"AutoNumber\", \"IsChorus\", \"Verse\", \"OrderNum\") " +
                        "VALUES (@AutoNumber, @IsChorus, @Verse, @OrderNum)";
                    t.Parameters.Add("@IsChorus", FbDbType.SmallInt);
                    t.Parameters.Add("@Verse", FbDbType.VarChar, 2048);
                    t.Parameters.Add("@OrderNum", FbDbType.Integer);

                    int i = 0;
                    foreach (DataRow r in dt.Rows)
                    {
                        t.Parameters["@OrderNum"].Value = i.ToString();
                        t.Parameters["@IsChorus"].Value = (bool)r["IsChorus"] == true ? 1 : 0;
                        t.Parameters["@Verse"].Value    = r["Verse"];
                        t.ExecuteNonQuery();
                        i++;
                    }
                }
            }
            this.Close();
        }
Esempio n. 3
0
        public static void SaveFontToDatabase(int id, PresenterFont font)
        {
            using (FBirdTask t = new FBirdTask())
            {
                // check is font saved
                t.CommandText = "SELECT COUNT(*) FROM [PPTFONT] WHERE [AUTONUMBER] = @AUTONUMBER";
                t.AddParameter("@AUTONUMBER", id);
                if ((int)t.ExecuteScalar() == 0)
                {
                    // insert
                    t.CommandText =
                        "INSERT INTO [PPTFONT] ([AUTONUMBER], [FONTNAME], [SIZEINPOINTS], [COLOR], [VERTICALALIGNMENT], [HORIZONTALALIGNMENT], [OUTLINE], [SHADOW], [OUTLINECOLOR], [SHADOWCOLOR], [ITALIC], [BOLD], [DOUBLESPACE]) " +
                        "VALUES (@AUTONUMBER, @FONTNAME, @SIZEINPOINTS, @COLOR, @VERTICALALIGNMENT, @HORIZONTALALIGNMENT, @OUTLINE, @SHADOW, @OUTLINECOLOR, @SHADOWCOLOR, @ITALIC, @BOLD, @DOUBLESPACE)";
                }
                else
                {
                    // update
                    t.CommandText =
                        "UPDATE [PPTFONT] SET " +
                        "[FONTNAME] = @FONTNAME, " +
                        "[SIZEINPOINTS] = @SIZEINPOINTS," +
                        "[COLOR] = @COLOR," +
                        "[VERTICALALIGNMENT] = @VERTICALALIGNMENT," +
                        "[HORIZONTALALIGNMENT] = @HORIZONTALALIGNMENT," +
                        "[OUTLINE] = @OUTLINE," +
                        "[SHADOW] = @SHADOW," +
                        "[ITALIC] = @ITALIC," +
                        "[BOLD] = @BOLD, " +
                        "[OUTLINECOLOR] = @OUTLINECOLOR, " +
                        "[SHADOWCOLOR] = @SHADOWCOLOR, " +
                        "[DOUBLESPACE] = @DOUBLESPACE " +
                        "WHERE [AUTONUMBER] = @AUTONUMBER";
                }

                // add parameters
                t.AddParameter("@FONTNAME", 512, font.FontName);
                t.AddParameter("@SIZEINPOINTS", font.SizeInPoints);
                t.AddParameter("@COLOR", font.Color.ToArgb());
                t.AddParameter("@VERTICALALIGNMENT", (int)font.VerticalAlignment);
                t.AddParameter("@HORIZONTALALIGNMENT", (int)font.HorizontalAlignment);
                t.AddParameter("@OUTLINE", font.Outline);
                t.AddParameter("@SHADOW", font.Shadow);
                t.AddParameter("@ITALIC", font.Italic);
                t.AddParameter("@BOLD", font.Bold);
                t.AddParameter("@OUTLINECOLOR", font.OutlineColor.ToArgb());
                t.AddParameter("@SHADOWCOLOR", font.ShadowColor.ToArgb());
                t.AddParameter("@DOUBLESPACE", font.DoubleSpace);

                // save to db
                t.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index;

            index = SndataGrid.CurrentCell.RowNumber;
            int rNumber = sRow.Number;


            using (FBirdTask t = new FBirdTask())
            {
                t.CommandText = "DELETE FROM [SongNotes] WHERE [Number] = @NNumber";
                t.AddParameter("@Number", rNumber);

                t.ExecuteNonQuery();
            }
            SNdataView.Delete(index);
        }
Esempio n. 5
0
        private void save()
        {
            int rNum = dt.Rows.Count;

            using (FBirdTask t = new FBirdTask())
            {
                t.CommandText = "INSERT INTO [SongNotes] ([Note],[IdSong]) " +
                                "VALUES (@Note, @IdSong)";
                t.Parameters.Add("@Note", FbDbType.VarChar);
                t.Parameters.Add("@IdSong", FbDbType.Integer);
                for (int i = rowCount; i < rNum; i++)
                {
                    t.Parameters["@Note"].Value   = sRow.Note;
                    t.Parameters["@IdSong"].Value = SNumber;
                    t.ExecuteNonQuery();
                }
            }
        }
Esempio n. 6
0
        private static void Application_ThreadExit(object sender, EventArgs e)
        {
            Program.exiting = true;

            if (!Program.Presenter.songsInitComplete)
            {
                try
                {
                    if (Program.Presenter.bwSongsInit.IsBusy)
                    {
                        Program.Presenter.bwSongsInit.CancelAsync();
                    }
                }
                catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); }
                return;
            }

            /*
             * Save all the unsaved data
             */
            using (FBirdTask t = new FBirdTask())
            {
                t.CommandText = "INSERT INTO [Songs] " +
                                "([AutoNumber], [Number], [Title], [Chorus], [Location], [DisplayDefault], [ImageId], [Overlay], [FontId], [Settings]) VALUES " +
                                "(@AutoNumber, @Number, @Title, @Chorus, @Location, @DisplayDefault, @ImageId, @Overlay, @FontId, @Settings)";
                t.Parameters.Add("@AutoNumber", FbDbType.Integer);
                t.Parameters.Add("@Number", FbDbType.Integer);
                t.Parameters.Add("@Title", FbDbType.VarChar, 0);
                t.Parameters.Add("@Chorus", FbDbType.VarChar, 0);
                t.Parameters.Add("@Location", FbDbType.VarChar, 0);
                t.Parameters.Add("@DisplayDefault", FbDbType.SmallInt);
                t.Parameters.Add("@ImageId", FbDbType.Integer);
                t.Parameters.Add("@Overlay", FbDbType.Integer);
                t.Parameters.Add("@FontId", FbDbType.Integer);
                t.Parameters.Add("@Settings", FbDbType.VarChar, 0);

                DataTable dt = Program.SongsDS.Songs.GetChanges(DataRowState.Added);
                if (dt != null)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        t.Parameters["@AutoNumber"].Value     = row["AutoNumber"];
                        t.Parameters["@Number"].Value         = row["Number"];
                        t.Parameters["@Title"].Value          = row["Title"];
                        t.Parameters["@Chorus"].Value         = row["Chorus"];
                        t.Parameters["@Location"].Value       = row["Location"];
                        t.Parameters["@DisplayDefault"].Value = (bool)row["DisplayDefault"] == true ? 1 : 0;
                        t.Parameters["@ImageId"].Value        = row["Image"];
                        t.Parameters["@Overlay"].Value        = row["Overlay"];
                        t.Parameters["@FontId"].Value         = row["FontId"];
                        t.Parameters["@Settings"].Value       = row["Settings"];

                        t.ExecuteNonQuery();
                    }
                }

                dt = Program.SongsDS.Songs.GetChanges(DataRowState.Modified);
                if (dt != null)
                {
                    t.CommandText = "UPDATE [Songs] SET " +
                                    "[Number] = @Number, " +
                                    "[Title] = @Title, " +
                                    "[Chorus] = @Chorus, " +
                                    "[Location] = @Location, " +
                                    "[DisplayDefault] = @DisplayDefault, " +
                                    "[ImageId] = @ImageId, " +
                                    "[Overlay] = @Overlay, " +
                                    "[FontId] = @FontId, " +
                                    "[Settings] = @Settings WHERE [AutoNumber] = @AutoNumber";

                    foreach (DataRow row in dt.Rows)
                    {
                        t.Parameters["@AutoNumber"].Value     = row["AutoNumber"];
                        t.Parameters["@Number"].Value         = row["Number"];
                        t.Parameters["@Title"].Value          = row["Title"];
                        t.Parameters["@Chorus"].Value         = row["Chorus"];
                        t.Parameters["@Location"].Value       = row["Location"];
                        t.Parameters["@DisplayDefault"].Value = (bool)row["DisplayDefault"] == true ? 1 : 0;
                        t.Parameters["@ImageId"].Value        = row["Image"];
                        t.Parameters["@Overlay"].Value        = row["Overlay"];
                        t.Parameters["@FontId"].Value         = row["FontId"];
                        t.Parameters["@Settings"].Value       = row["Settings"];

                        t.ExecuteNonQuery();
                    }
                }

                dt = Program.SongsDS.Songs.GetChanges(DataRowState.Deleted);
                if (dt != null)
                {
                    t.Parameters.Clear();
                    t.Parameters.Add("@AutoNumber", FbDbType.Integer);
                    t.CommandText = "DELETE FROM [Songs] WHERE [AutoNumber] = @AutoNumber";

                    foreach (DataRow row in dt.Rows)
                    {
                        t.Parameters["@AutoNumber"].Value = row["AutoNumber"];
                        t.ExecuteNonQuery();
                    }
                }
            }//*/
        }