private async void testbutton_Click(object sender, RoutedEventArgs e) { string s = await RakutenSearchAPI.JAN_Search(Jancode_Box.Text); TestBox.AcceptsReturn = true; TestBox.Text = s; Candidate_Set(s); }
private async void exec() { string s = await RakutenSearchAPI.JAN_Search(Jancode_Box.Text); TestBox.AcceptsReturn = true; TestBox.Text = s; Candidate_Set(s); }
private async void DataGrid_CurrentCellChanged(object sender, EventArgs e) { DataGrid dg = (DataGrid)sender; if (dg.SelectedItem == null) { return; } Item item = dg.SelectedItem as Item; last_jan = item._janCode; try { string s = await RakutenSearchAPI.JAN_Search(item._janCode); Candidate_Set(s); } catch { //dg.SelectedItem = null; } }
private async void JANCODE_TEXT_KeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { JANCODE_TEXT.IsReadOnly = true; if (!CheckFunction.JANCODE_Integrity_Check(JANCODE_TEXT.Text)) { JANCODE_TEXT.IsReadOnly = false; CheckFunction.Message_Show("Error", "JANコードが正しくありません"); JANCODE_TEXT.Text = ""; return; } try { string s = await RakutenSearchAPI.JAN_Search(JANCODE_TEXT.Text); Candidate_Set(s); } catch { JANCODE_TEXT.Text = ""; return; } finally{ } // 謎ポイント // 初回、if (Items.First(x => x._janCode == last_jan)._janCode == JANCODE_TEXT.Text)でマッチするレコードがなかった場合例外発生、2回目以降は例外は発生せずelseに飛ぶ // 応急措置として同じコードを書いています // いろいろおかしい try { // リスト上に存在する場合 if (Items.First(x => x._janCode == JANCODE_TEXT.Text)._janCode == JANCODE_TEXT.Text) { last_jan = JANCODE_TEXT.Text; Items.First(x => x._janCode == JANCODE_TEXT.Text)._num += 1; } else { DatabaseAccess db = new DatabaseAccess(); if (db.Search_Item(JANCODE_TEXT.Text)) { // DB既登録の場合 Item item = db.Get_Item(JANCODE_TEXT.Text); item._num = 1; last_jan = JANCODE_TEXT.Text; Items.Add(item); } else { // DB未登録の場合 Item item = new Item(JANCODE_TEXT.Text, "", 0, 0, 1); last_jan = JANCODE_TEXT.Text; Items.Add(item); } } }catch { DatabaseAccess db = new DatabaseAccess(); if (db.Search_Item(JANCODE_TEXT.Text)) { // DB既登録の場合 Item item = db.Get_Item(JANCODE_TEXT.Text); item._num = 1; last_jan = JANCODE_TEXT.Text; Items.Add(item); } else { // DB未登録の場合 Item item = new Item(JANCODE_TEXT.Text, "", 0, 0, 1); last_jan = JANCODE_TEXT.Text; Items.Add(item); } } //DatabaseAccess db = new DatabaseAccess(); //db.Insert_Item(item); // 処理完了後 JANCODE_TEXT.Text = ""; JANCODE_TEXT.IsReadOnly = false; } }