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(); } }