private void btnEntryBLC_Click(object sender, EventArgs e) { int i = 0; List<AccountRec> lst = new List<AccountRec>(); AccountRec wkRec = new AccountRec(); // 列数は新規の行も含んでいるので-1する for (i = 0; i < dgvBalance.Rows.Count - 1; i++) { // id : uint16 wkRec.id = Int16.Parse((string)dgvBalance.Rows[i].Cells["blc_id"].Value); // eot : byte if (null != dgvBalance.Rows[i].Cells["blc_eot"].Value) { wkRec.eot = sbyte.Parse((string)dgvBalance.Rows[i].Cells["blc_eot"].Value); } else { wkRec.eot = 0; } // type : byte wkRec.type = sbyte.Parse((string)dgvBalance.Rows[i].Cells["blc_type"].Value); // init : int32 wkRec.initval = Int32.Parse((string)dgvBalance.Rows[i].Cells["blc_initval"].Value); // name : string wkRec.name = (string)dgvBalance.Rows[i].Cells["blc_name"].Value; lst.Add(wkRec); } KBDatabase kdb = new KBDatabase(); kdb.setAccountRec(lst); MessageBox.Show("口座を登録しました。"); }
public List<AccountRec> getAccountRec() { SQLiteCommand command; SQLiteDataReader reader; List<AccountRec> lst; string szCmd = "select * from T_BALANCE order by id"; AccountRec wkRec = new AccountRec(); lst = new List<AccountRec>(); opendb(); command = new SQLiteCommand(szCmd, hConn); reader = command.ExecuteReader(); while (reader.Read()) { // id : uint16 wkRec.id = reader.GetInt16(0); // eot : int8 wkRec.eot = (sbyte)reader.GetByte(1); // type : int8 wkRec.type = (sbyte)reader.GetByte(2); // init : int32 wkRec.initval = reader.GetInt32(3); // name : string wkRec.name = reader.GetString(4); lst.Add(wkRec); } closedb(); return lst; }