private Kanji AssignKanjiDetails(Kanji kanji) { kanji.SetCharacter(txtKanji.Text); kanji.SetNumOfStrokes((int)numNumOfStroke.Value); List <string> temp_list = new List <string>(); foreach (var item in lbKunyomiList.Items) { temp_list.Add(item.ToString()); } kanji.SetKunyomi(temp_list); temp_list = new List <string>(); foreach (var item in lbOnyomiList.Items) { temp_list.Add(item.ToString()); } kanji.SetOnyomi(temp_list); temp_list = new List <string>(); foreach (var item in lbMeaningList.Items) { temp_list.Add(item.ToString()); } kanji.SetMeaning(temp_list); List <Structure> temp_structure = new List <Structure>(); if (chkADJACTIVE.Checked == true) { temp_structure.Add(Structure.ADJACTIVE); } if (chkADVERB.Checked == true) { temp_structure.Add(Structure.ADVERB); } if (chkNOUN.Checked == true) { temp_structure.Add(Structure.NOUN); } if (chkVERB.Checked == true) { temp_structure.Add(Structure.VERB); } kanji.SetStructure(temp_structure); return(kanji); }
private void btnAddUpdate_Click(object sender, EventArgs e) { if (EmptinessCheck()) { if (management_type == ManagementType.ADD) { Kanji added_kanji = new Kanji(); added_kanji = AssignKanjiDetails(added_kanji); user_pool.FindUser(user.GetMail()).AddKanji(added_kanji); // save DB_str = JsonConvert.SerializeObject(user_pool); File.WriteAllText(user_pool.path, DB_str); this.Close(); } else if (management_type == ManagementType.UPDATE_DELETE) { // do update Kanji updated_kanji = new Kanji(); updated_kanji = AssignKanjiDetails(updated_kanji); user_pool.FindUser(user.GetMail()).DeleteKanji(kanji); user_pool.FindUser(user.GetMail()).AddKanji(updated_kanji); // save DB_str = JsonConvert.SerializeObject(user_pool); File.WriteAllText(user_pool.path, DB_str); this.Close(); } } else { MessageBox.Show("Lack of info!"); } }