private void refreshListBox() { try { resultLists.Items.Clear(); resultLists.Items.AddRange(Shohin.getAll().ToArray()); } catch (Exception ex) { textboxError.Text = string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace); } finally { textBoxSQL.Text = Shohin.excutedSql; } }
//追加ボンタン private void button2_Click(object sender, EventArgs e) { // 追加処理 try { Shohin.excutedSql = ""; Shohin newItem = new Shohin(inputProCode.Text, inputProName.Text, int.Parse(inputProPrice.Text)); newItem.insert(); textboxError.Text = ""; } catch (Exception ex) { textboxError.Text = ex.Message; } finally { textBoxSQL.Text = Shohin.excutedSql; } refreshListBox(); }
// 検索ボタン private void button1_Click(object sender, EventArgs e) { resultLists.Items.Clear(); try { Shohin.excutedSql = ""; resultLists.Items.AddRange( Shohin.extractByCondition( inputProCode.Text, inputProName.Text, int.Parse(inputProPrice.Text != ""?inputProPrice.Text:"0") ).ToArray() ); textboxError.Text = ""; } catch (Exception ex) { textboxError.Text = ex.Message; } finally { textBoxSQL.Text = Shohin.excutedSql; } }