private void BtnClickQue(object sender, RoutedEventArgs e) { data.Clear(); data.Add(colHead); string sqlStr = "call showCAcc;"; MySqlCommand cmd = new MySqlCommand(sqlStr, con); MySqlDataReader reader = null; try { reader = cmd.ExecuteReader(); CAccListItem item = new CAccListItem(); while (reader.Read()) { item.SAccNum = reader.GetString(0); item.BName = reader.GetString(1); item.CID = reader.GetString(2); item.LVDate = reader.GetDateTime(3).ToLongDateString(); item.balance = reader.GetString(4); item.applyDate = reader.GetDateTime(5).ToLongDateString(); item.ODraft = reader.GetString(6); data.Add(new CAccListItem(item)); } TxtAlert.Text = "Query success!"; } catch (MySqlException ex) { TxtAlert.Text = "Fail to execute sql command!\nError message: "; TxtAlert.Text += ex.Message; } finally { reader.Close(); } }
public void Init(CAccListItem item) { SAccNum = item.SAccNum; BName = item.BName; CID = item.CID; LVDate = item.LVDate; balance = item.balance; applyDate = item.applyDate; ODraft = item.ODraft; }
public CAccListItem(CAccListItem item) { Init(item); }