Example #1
0
        private void livKanji_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            Database db = new Database();

            if (e.Item.Tag != null)
            {
                Kanji kanji = e.Item.Tag as Kanji;
                if (kanji.IsStudied != e.Item.Checked)
                {
                    kanji.IsStudied = e.Item.Checked;
                    db.UpdateKanji(kanji);
                }
            }
        }
Example #2
0
        private void SetUnStudied()
        {
            Database db = new Database();

            foreach (ListViewItem lvi in livKanji.SelectedItems)
            {
                if (lvi.Tag != null && lvi.Tag is Kanji)
                {
                    Kanji kanji = lvi.Tag as Kanji;
                    kanji.IsStudied = true;
                    if (db.UpdateKanji(kanji) >= 1)
                    {
                        lvi.Checked = false;
                    }
                }
            }
        }
Example #3
0
 private void FillKanjiIntoTextBox(Kanji kanji)
 {
     if (kanji != null)
     {
         this.tbxKanji.Text        = kanji.StrKanji;
         this.tbxAmOn.Text         = kanji.StrAmon;
         this.tbxAmKun.Text        = kanji.StrAmkun;
         this.tbxKanjiMeaning.Text = kanji.StrMeaning;
     }
     else
     {
         this.tbxKanji.Text        = string.Empty;
         this.tbxAmOn.Text         = string.Empty;
         this.tbxAmKun.Text        = string.Empty;
         this.tbxKanjiMeaning.Text = string.Empty;
     }
 }
 private void setKanjiForShow(Kanji kanji)
 {
     if (null == kanji)
     {
         lbKanji.Text          = string.Empty;
         lbMeaning.Text        = string.Empty;
         lbOnyomi.Text         = string.Empty;
         lbKunyomi.Text        = string.Empty;
         picShowKanjiImg.Image = null;
         return;
     }
     lbKanji.Text   = kanji.StrKanji;
     lbMeaning.Text = kanji.StrMeaning;
     lbOnyomi.Text  = kanji.StrAmon;
     lbKunyomi.Text = kanji.StrAmkun;
     SetImageForKanji(kanji);
 }
        private void SetImageForKanji(Kanji kanji)
        {
            if (null == kanji)
            {
                picShowKanjiImg.Image = null;
                return;
            }
            if (null == kanji.StrKanji)
            {
                picShowKanjiImg.ImageLocation = string.Empty;
                return;
            }

            int    codeInt  = Convert.ToInt32(kanji.StrKanji[0]);
            string codeHexa = ToHex(codeInt);

            picShowKanjiImg.ImageLocation = string.Format(@"Kanji\{0}.gif", codeHexa);
        }
Example #6
0
 public int DeleteKanji(Kanji kanji)
 {
     lock (this)
     {
         try
         {
             OleDbConnection cn = new OleDbConnection(ConnectionString);
             cn.Open();
             OleDbCommand cmd = new OleDbCommand("DeleteKanji", cn);
             cmd.Parameters.Add(new OleDbParameter("@Id", kanji.Id));
             cmd.CommandType = CommandType.StoredProcedure;
             int ret = cmd.ExecuteNonQuery();
             cn.Close();
             return(ret);
         }
         catch
         {
             return(0);
         }
     }
 }
Example #7
0
        private void btnKanjiDeleleAll_Click(object sender, EventArgs e)
        {
            if (livKanji.SelectedItems.Count == 0)
            {
                MessageBox.Show("Hãy chọn ít nhất một từ.", "JWord", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Database db = new Database();

            foreach (ListViewItem lvi in livKanji.SelectedItems)
            {
                if (lvi.Tag != null && lvi.Tag is Kanji)
                {
                    Kanji kanji = lvi.Tag as Kanji;
                    if (db.DeleteKanji(kanji) >= 1)
                    {
                        livKanji.Items.Remove(lvi);
                    }
                }
            }
        }
Example #8
0
 private void btnClearText_Click(object sender, EventArgs e)
 {
     this.SelectKanji = null;
 }
Example #9
0
        public List <Kanji> GetKanjiData(GetDataType type)
        {
            lock (this)
            {
                List <Kanji>    arr = new List <Kanji>();
                OleDbConnection cn  = new OleDbConnection(ConnectionString);
                cn.Open();

                OleDbCommand cmd;
                if (type == GetDataType.All)
                {
                    cmd = new OleDbCommand("SELECT * FROM KANJI ", cn);
                }
                else if (type == GetDataType.Studied)
                {
                    cmd = new OleDbCommand("SELECT * FROM KANJI WHERE Hide = true", cn);
                }
                else
                {
                    cmd = new OleDbCommand("SELECT * FROM KANJI WHERE Hide = false", cn);
                }

                OleDbDataAdapter da = new OleDbDataAdapter(cmd);

                DataTable dt = new DataTable();
                int       i  = da.Fill(dt);
                if (i == 0)
                {
                    cn.Close();
                    return(arr);
                }

                foreach (DataRow dr in dt.Rows)
                {
                    Kanji k = new Kanji();

                    try
                    {
                        k.Id         = (int)dr["Id"];
                        k.StrKanji   = dr["Kanji"] as string;
                        k.StrAmon    = dr["Amon"] as string;
                        k.StrAmkun   = dr["Amkun"] as string;
                        k.StrMeaning = dr["Meaning"] as string;
                        k.StrSample  = dr["Sample"] as string;
                        k.IsStudied  = (bool)dr["Hide"];
                    }
                    catch
                    {
                        continue;
                    }

                    if (null != k.StrKanji && !string.IsNullOrEmpty(k.StrKanji.Trim()) &&
                        null != k.StrMeaning && !string.IsNullOrEmpty(k.StrMeaning.Trim()))
                    {
                        k.StrAmon   = null == k.StrAmon ? string.Empty : k.StrAmon;
                        k.StrAmkun  = null == k.StrAmkun ? string.Empty : k.StrAmkun;
                        k.StrSample = null == k.StrSample ? string.Empty : k.StrSample;
                        arr.Add(k);
                    }
                }
                cn.Close();
                return(arr);
            }
        }