Exemplo n.º 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");
            }
        }
Exemplo n.º 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");
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 public override void UpdateExample(TransliterationExample example, string word)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public override void CreateExample(TransliterationExample example)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public abstract void UpdateExample(TransliterationExample example, string word);
Exemplo n.º 7
0
 public abstract void CreateExample(TransliterationExample example);