示例#1
0
        public override void UpdateExample(TransliterationExample example, string word)
        {
            Refresh();
            SqlCommand cmd = new SqlCommand(
                string.Format("UPDATE TransExamples SET Word=N'{0}', Transliteration=N'{1}', Disabled='{2}' " +
                              "WHERE LangId1='{3}' AND LangId2='{4}' AND Word=N'{5}'",
                              Normalize(example.Source), Normalize(example.Destination), example.Disabled,
                              this.srcLanguage.Code, this.dstLanguage.Code, Normalize(word)),
                connection);

            if (cmd.ExecuteNonQuery() != 1)
            {
                throw new Exception("SQL UPDATE did not affect 1 row");
            }
        }
示例#2
0
        public override void CreateExample(TransliterationExample example)
        {
            Refresh();
            SqlCommand cmd = new SqlCommand(
                "INSERT INTO TransExamples (LangId1, LangId2, Word, Transliteration, Disabled) " +
                string.Format("VALUES ('{0}', '{1}', N'{2}', N'{3}', '{4}')",
                              this.srcLanguage.Code, this.dstLanguage.Code,
                              Normalize(example.Source),
                              Normalize(example.Destination ?? string.Empty),
                              example.Disabled),
                connection);

            if (cmd.ExecuteNonQuery() != 1)
            {
                throw new Exception("SQL INSERT did not affect 1 column");
            }
        }
示例#3
0
        public override List <TransliterationExample> ListExamples(bool enabledOnly = false)
        {
            Refresh();
            SqlCommand cmd = new SqlCommand("SELECT * FROM TransExamples WHERE LangId1='"
                                            + srcLanguage.Code + "' AND LangId2='" + dstLanguage.Code + "'" +
                                            (enabledOnly ? " AND Disabled='FALSE'" : string.Empty),
                                            connection);
            SqlDataReader reader = cmd.ExecuteReader();

            List <TransliterationExample> list = new List <TransliterationExample>();

            while (reader.Read())
            {
                TransliterationExample rule = new TransliterationExample()
                {
                    Source      = reader.GetString(2),
                    Destination = reader.GetString(3),
                    Disabled    = reader.GetBoolean(4)
                };
                list.Add(rule);
            }
            reader.Close();
            return(list);
        }
示例#4
0
 public override void UpdateExample(TransliterationExample example, string word)
 {
     throw new NotImplementedException();
 }
示例#5
0
 public override void CreateExample(TransliterationExample example)
 {
     throw new NotImplementedException();
 }
示例#6
0
 public abstract void UpdateExample(TransliterationExample example, string word);
示例#7
0
 public abstract void CreateExample(TransliterationExample example);