Пример #1
0
        public static bool UpdateRelationInfo(RelationData relation, string selectSource, string selectTarget)
        {
            string updateCommand = GetUpdateCommand(relation, selectSource, selectTarget);

            using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath))
            {
                conn.Open();
                string sq0 = "PRAGMA foreign_keys = 'on';";
                using (SQLiteCommand cmd = new SQLiteCommand(sq0, conn))
                {
                    cmd.ExecuteNonQuery();
                }
                using (SQLiteCommand cmd = new SQLiteCommand(updateCommand, conn))
                {
                    cmd.ExecuteNonQuery();
                }
                conn.Close();
            }
            if (relation.HasErrors)
            {
                relation.Tables[RelationData.RELATION_TABLE].GetErrors()[0].ClearErrors();
                return(false);
            }
            else
            {
                relation.AcceptChanges();
                return(true);
            }
        }
Пример #2
0
 public static bool UpdateRelationCommentInfo(RelationData relation)
 {
     using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath))
     {
         conn.Open();
         for (int i = 0; i < relation.Tables[RelationData.RELATION_TABLE].Rows.Count; i++)
         {
             DataRow data          = relation.Tables[RelationData.RELATION_TABLE].Rows[i];
             string  updateCommand = GetUpdateCommentCommand(data);
             using (SQLiteCommand cmd = new SQLiteCommand(updateCommand, conn))
             {
                 cmd.ExecuteNonQuery();
             }
         }
         conn.Close();
     }
     if (relation.HasErrors)
     {
         relation.Tables[RelationData.RELATION_TABLE].GetErrors()[0].ClearErrors();
         return(false);
     }
     else
     {
         relation.AcceptChanges();
         return(true);
     }
 }
Пример #3
0
        }//不同的等级的关系虚拟表Dataset

        public static bool InsertRelationInfo(RelationData relation)
        {
            DataRow data  = relation.Tables[RelationData.RELATION_TABLE].Rows[0];
            bool    check = CheckDuplication(data);

            if (!check)
            {
                return(false);
            }
            string insertCommand = GetInsertCommand(relation);

            using (SQLiteConnection conn = new SQLiteConnection(globalParameters.dbPath))
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(insertCommand, conn))
                {
                    cmd.ExecuteNonQuery();
                }
                conn.Close();
            }
            if (relation.HasErrors)
            {
                relation.Tables[RelationData.RELATION_TABLE].GetErrors()[0].ClearErrors();
                return(false);
            }
            else
            {
                relation.AcceptChanges();
                return(true);
            }
        }