//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; } }
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); }
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 { } }
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); }
public void unMarkWord(VN_EN_Word w) { if (obj_VN_EN.unMark(w.VNKey) == false) { MessageBox.Show("Failed unmarking"); } else { return; } }
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); }
public void updateWord(string key, VN_EN_Word w) { obj_VN_EN.updateWord(key, w); }
public void addWord(VN_EN_Word w) { obj_VN_EN.addWord(w); }
public void autoSave(VN_EN_Word w) { saveIntoHistory(w); writeHistory(); }
private void saveIntoHistory(VN_EN_Word w) { history.push(w); }