Ejemplo n.º 1
0
 public static void SaveGroupPhrase(GroupPhrase gp)
 {
     using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
     {
         cnn.Execute("Insert into GroupPhrases (GroupPhraseTitle)", gp);
     }
 }
Ejemplo n.º 2
0
        public PhraseOption GetDefaultOption(GroupPhrase gp, Phrase p)
        {
            string sql = $"Select * from PhraseOptions po inner join RelGroupPhrasesPhrases rgpp on po.PhraseOptionID = rgpp.RelGPPDefaultOptionID where rgpp.RelGPPGroupPhraseID = {gp.GroupPhraseID} and rgpp.RelGPPPhraseID = @PhraseID limit 1;";

            using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SqlLiteDataAccess.SQLiteDBLocation))
            {
                var output = cnn.QueryFirst <PhraseOption>(sql, p);
                return(output);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get a groupphrase object from unique title or ID.
 /// </summary>
 /// <param name="strTitle"></param>
 /// <returns>A GroupPhrase object</returns>
 public static GroupPhrase GetGroupPhrase(int?GroupPhraseID = null)
 {
     if (GroupPhraseID != null)
     {
         string sql = "SELECT * FROM GroupPhrases WHERE GroupPhraseID = @GroupPhraseID;";
         using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
         {
             //to get an ilist cnn.Query<GroupPhrase>("SELECT * FROM GroupPhrases");
             GroupPhrase output = cnn.QuerySingleOrDefault <GroupPhrase>(sql, new { GroupPhraseID });
             return(output);
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a groupphrase object to database
        /// </summary>
        /// <param name="gp">a groupphrase object</param>
        /// <returns>True if successfull</returns>
        public static bool AddGroupPhrase(GroupPhrase gp)
        {
            if (gp != null)
            {
                string sql = "INSERT INTO GroupPhrases (" +
                             "GroupPhraseTitle," +
                             "GroupPhraseOSAdult," +
                             "GroupPhraseCSAdult," +
                             "GroupPhraseOSChild," +
                             "GroupPhraseCSChild," +
                             "GroupPhraseSubsectionID," +
                             "GroupPhraseConnectionType," +
                             "GroupPhraseSideType," +
                             "GroupPhraseComment" +
                             ") VALUES (" +
                             "@GroupPhraseTitle," +
                             "@GroupPhraseOSAdult," +
                             "@GroupPhraseCSAdult," +
                             "@GroupPhraseOSChild," +
                             "@GroupPhraseCSChild," +
                             "@GroupPhraseSubsectionID," +
                             "@GroupPhraseConnectionType," +
                             "@GroupPhraseSideType," +
                             "@GroupPhraseComment)";

                using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
                {
                    try
                    {
                        var affectedRows = cnn.Execute(sql, gp);
                    }
                    catch (Exception e)
                    {
                        if (e.Message.Contains("UNIQUE constraint failed: GroupPhrases.GroupPhraseTitle"))
                        {
                            MessageBox.Show("Cannot add new GroupPhrase because the title is not unique!");
                            return(false);
                        }
                        MessageBox.Show($"Cannot update due to error: ${e.Message}");
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Update a groupphrase object
        /// </summary>
        /// <param name="strTitle"></param>
        /// <returns>True if successfull</returns>
        public static bool UpdateGroupPhrase(GroupPhrase gp)
        {
            if (gp != null)
            {
                string sql = "UPDATE GroupPhrases SET " +
                             "GroupPhraseTitle = @GroupPhraseTitle, " +
                             "GroupPhraseOSAdult = @GroupPhraseOSAdult, " +
                             "GroupPhraseCSAdult= @GroupPhraseCSAdult," +
                             "GroupPhraseOSChild= @GroupPhraseOSChild," +
                             "GroupPhraseCSChild= @GroupPhraseCSChild," +
                             "GroupPhraseSubsectionID= @GroupPhraseSubsectionID," +
                             "GroupPhraseConnectionType= @GroupPhraseConnectionType," +
                             "GroupPhraseSideType= @GroupPhraseSideType," +
                             "GroupPhraseComment= @GroupPhraseComment" +
                             " WHERE GroupPhraseID = @GroupPhraseID;";

                using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
                {
                    var affectedRows = cnn.Execute(sql, gp);
                }
                return(true);
            }
            return(false);
        }