Example #1
0
        //autosave, is for history
        public void saveWord(VN_EN_Word w, DateTime t)
        {
            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                using (SqlCommand cmd = new SqlCommand(saveWordCommand, conn))
                {
                    cmd.Parameters.Add("@Time", SqlDbType.SmallDateTime).Value    = t;
                    cmd.Parameters.Add("@VNKey", SqlDbType.NVarChar).Value        = w.VNKey;
                    cmd.Parameters.Add("@VNSuggestion", SqlDbType.NVarChar).Value = w.VNSuggestion;
                    cmd.Parameters.Add("@WordType", SqlDbType.NVarChar).Value     = w.WordType;
                    cmd.Parameters.Add("@ENMeans", SqlDbType.NText).Value         = w.Means;
                    cmd.Parameters.Add("@Example", SqlDbType.NText).Value         = w.Example;

                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                conn.Close();
                throw e;
            }
        }
Example #2
0
        public bool bookMark(VN_EN_Word w)
        {
            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                using (SqlCommand cmd = new SqlCommand(bookMarkCommand, conn))
                {
                    cmd.Parameters.Add("@VNKey", SqlDbType.NVarChar).Value        = w.VNKey;
                    cmd.Parameters.Add("@VNSuggestion", SqlDbType.NVarChar).Value = w.VNSuggestion;
                    cmd.Parameters.Add("@WordType", SqlDbType.NVarChar).Value     = w.WordType;
                    cmd.Parameters.Add("@ENMeans", SqlDbType.NText).Value         = w.Means;
                    cmd.Parameters.Add("@Example", SqlDbType.NText).Value         = w.Example;

                    cmd.ExecuteNonQuery();
                    return(true);
                }
            }
            catch (Exception)
            {
                conn.Close();
            }
            return(false);
        }
Example #3
0
        public void updateWord(string key, VN_EN_Word w)
        {
            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                using (SqlCommand cmd = new SqlCommand(addWordCommand, conn))
                {
                    cmd.Parameters.Add("VNKey", SqlDbType.NVarChar).Value         = w.VNKey;
                    cmd.Parameters.Add("@VNSuggestion", SqlDbType.NVarChar).Value = w.VNSuggestion;
                    cmd.Parameters.Add("@WordType", SqlDbType.NVarChar).Value     = w.WordType;
                    cmd.Parameters.Add("@ENMeans", SqlDbType.NText).Value         = w.Means;
                    cmd.Parameters.Add("@Example", SqlDbType.NText).Value         = w.Example;
                    cmd.Parameters.Add("@key", SqlDbType.NVarChar).Value          = key;

                    cmd.ExecuteNonQuery();
                }
            }
            catch
            {
            }
        }
Example #4
0
        public VN_EN_Word getWord(string key)
        {
            VN_EN_Word w = null;

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                using (SqlCommand cmd = new SqlCommand(getVnWordCommand, conn))
                {
                    cmd.Parameters.Add("@VNKey", SqlDbType.NVarChar).Value = HexadecimalEncoding.ToHexString(key + " \r");

                    SqlDataReader sdr = cmd.ExecuteReader();

                    if (sdr.Read())
                    {
                        w = new VN_EN_Word();

                        w.VNKey        = HexadecimalEncoding.FromHexString(sdr["VNKey"].ToString());
                        w.VNSuggestion = sdr["VNSuggestion"].ToString();
                        w.WordType     = sdr["WordType"].ToString();
                        w.Means        = sdr["ENMeans"].ToString();
                        w.Example      = sdr["Example"].ToString();
                    }
                    else
                    {
                        sdr.Close();
                    }

                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("@VNKey", SqlDbType.NVarChar).Value = HexadecimalEncoding.ToHexString(key + "\r");
                    sdr = cmd.ExecuteReader();

                    if (sdr.Read())
                    {
                        w = new VN_EN_Word();

                        w.VNKey        = HexadecimalEncoding.FromHexString(sdr["VNKey"].ToString());
                        w.VNSuggestion = sdr["VNSuggestion"].ToString();
                        w.WordType     = sdr["WordType"].ToString();
                        w.Means        = sdr["ENMeans"].ToString();
                        w.Example      = sdr["Example"].ToString();
                    }
                    sdr.Close();
                }
            }
            catch (Exception e)
            {
                conn.Close();
                throw e;
            }

            return(w);
        }
Example #5
0
 public void unMarkWord(VN_EN_Word w)
 {
     if (obj_VN_EN.unMark(w.VNKey) == false)
     {
         MessageBox.Show("Failed unmarking");
     }
     else
     {
         return;
     }
 }
Example #6
0
 public void bookMarkWord(VN_EN_Word w)
 {
     if (obj_VN_EN.bookMark(w) == false)
     {
         MessageBox.Show("Failed bookmarking");
     }
     else
     {
         return;
     }
 }
 public void autoSave(VN_EN_Word w)
 {
     obj_His_DAO.autoSave(w);
 }
Example #8
0
 public void updateWord(string key, VN_EN_Word w)
 {
     obj_VN_EN.updateWord(key, w);
 }
Example #9
0
 public void addWord(VN_EN_Word w)
 {
     obj_VN_EN.addWord(w);
 }
Example #10
0
        public void autoSave(VN_EN_Word w)
        {
            saveIntoHistory(w);

            writeHistory();
        }
Example #11
0
 private void saveIntoHistory(VN_EN_Word w)
 {
     history.push(w);
 }